External Command question
Posted: Fri Mar 20, 2015 1:21 pm
So, I created a new downtime scheduling component based on XI's recurring downtime component. Everything works great, we're using it, except one thing, the creation date always says 12-31-1969.
In the examples online it is written like this:
Two questions about that...what on earth is the [%lu] doing? and it's printing all that to the command file as well as the $now variable, right? I'm only writing the stuff in the quotes, including the [%LU]. That includes a \n newline, so I'm having trouble understanding where the $now variable comes into play there.
In php I'm building a variable $cfg_str and then this code is used:
I need to add the $now(or whatever I name it) to the commandfile on the next line? Oh god...someone help me figure out what i have to do, not how to(I can do that).
Thanks!
In the examples online it is written like this:
Code: Select all
now=`date +%s`
commandfile='/usr/local/nagios/var/rw/nagios.cmd'
/bin/printf "[%lu] SCHEDULE_HOST_SVC_DOWNTIME;host1;1110741500;1110748700;0;0;7200;Some One;Some Downtime Comment\n" $now > $commandfileIn php I'm building a variable $cfg_str and then this code is used:
Code: Select all
$fh = fopen('/usr/local/nagios/var/rw/nagios.cmd', "a") or die(gettext("Error: Could not open downtime config file for writing."));
fwrite($fh, $cfg_str);
fclose($fh);
Thanks!