Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
#!/bin/sh
# This is a sample shell script showing how you can submit the SCHEDULE_HOST_DOWNTIME command
# to Nagios. Adjust variables to fit your environment as necessary.
now=`date +%s`
commandfile='/usr/local/nagios/var/rw/nagios.cmd'
/bin/printf "[%lu] SCHEDULE_HOST_DOWNTIME;host1;1110741500;1110748700;0;0;7200;Some One;Some Downtime Comment\n" $now > $commandfile
#!/bin/sh
# This is a sample shell script showing how you can submit the SCHEDULE_HOST_DOWNTIME command
# to Nagios. Adjust variables to fit your environment as necessary.
now=`date +%s`
commandfile='/usr/local/nagios/var/rw/nagios.cmd'
/usr/bin/printf "[%lu] SCHEDULE_HOST_DOWNTIME;nagios.domain.com;1406678400;1406764800;0;0;0;Test User;Test Downtime Comment\n" $now > $commandfile
if [ $? -ne 1 ]; then
echo "Works....";
fi
It outputs "Works..." when it definitely does not. :\
Do you have:
A host "nagios.domain.com"
A user "Test User"
The issue with your current command provided everything else exists in your configs, is that duration is set to 0 and needs to be a valid positive number. The particular item is highlighted, note this value is in seconds.
SCHEDULE_HOST_DOWNTIME;nagios.domain.com;1406678400;1406764800;0;0;0;Test User;Test Downtime Comment
Also just so you are aware, the test to see if it works, is simply checking if printf passed or failed. Unless you put something obviously malicious in there, printf is not going to fail very often. That said, I do agree that it is not a good test at all.
Nagios-Plugins maintainer exclusively, unless you have other C language bugs with open-source nagios projects, then I am happy to help! Please pm or use other communication to alert me to issues as I no longer track the forum.