First off thank you for reading my post! First time here, so any input is much appreciated!
I am working on an integration project where we are gathering planned outages from another system. Once that info is gathered and formatted we are then passing the scheduled outage info to nagios. We are in the midst of automating scheduled downtime in this way .
As such I am ready to start testing scheduled downtime in our nagios system using a script. I am completely new to nagios scripting and want to gather any/all ideas you may offer.
Currently I have written a test script based on things I have seen online thus far. what I have written is a test script using hardcoded values..
the script is currently not registering downtime for the test instance in our system. As such I want to ask if any of you know or see anything funny in the script ...its a simply 3 liner using hardcoded values for now, my main goal is to get the script working first and foremost, I can refine other things later..
Start Script Code
#!/bin/sh
NAGIOS_CMD="/usr/local/nagios/var/rw/nagios.cmd"
echo "SCHEDULE_HOST_DOWNTIME;FCFSPRE;2012-09-07 18:00:00;2012-09-07 22:00:00;1;0;7200;CMS Migration Team;CHG0030530" >>$NAGIOS_CMD
echo $NAGIOS_CMD "is the nagios control file"
End Script Code
My Questions:
1) I read that if the downtime is fixed then duration is ignored. As such, should I strip out the '7200' in the parameters being passed?
After I run my test script the control file still has a size of 0. It has an updated date/time stamp however other than this I am not sure
of a practical way of testing if the script worked ( other than the obvious which would be to use the web UI and see if the host has the downtime scheduled).
This is my first time testing in Nagios so I want to make sure my methodology is correct.
Again ANY input you have is much appreciated!
Testing Script to Schedule Downtime - Newbie needs help! =)
Re: Testing Script to Schedule Downtime - Newbie needs help!
Use this set of Docs for the command you need.
http://old.nagios.org/developerinfo/ext ... ndlist.php
http://old.nagios.org/developerinfo/ext ... and_id=122
Also, turn on in the nagios.cfg:
So you can watch the nagios.log and make sure the commands are getting through.
http://old.nagios.org/developerinfo/ext ... ndlist.php
http://old.nagios.org/developerinfo/ext ... and_id=122
Also, turn on in the nagios.cfg:
Code: Select all
log_external_commands=1Re: Testing Script to Schedule Downtime - Newbie needs help!
thank you so much for this information, i will check the cfg file to make sure the external commands are being logged.mguthrie wrote:Use this set of Docs for the command you need.
http://old.nagios.org/developerinfo/ext ... ndlist.php
http://old.nagios.org/developerinfo/ext ... and_id=122
Also, turn on in the nagios.cfg:
So you can watch the nagios.log and make sure the commands are getting through.Code: Select all
log_external_commands=1
once that is enabled where exactly would the aforementioned log be located?
thank you!
Re: Testing Script to Schedule Downtime - Newbie needs help!
On a source install, you can do a running tail with:
Code: Select all
tail -f /usr/local/nagios/var/nagios.logRe: Testing Script to Schedule Downtime - Newbie needs help!
mguthrie wrote:On a source install, you can do a running tail with:
Code: Select all
tail -f /usr/local/nagios/var/nagios.log
hey thank you! I have been on night shift. back to this project, will be testing shortly.
appreciate it!
i will follow up...
Re: Testing Script to Schedule Downtime - Newbie needs help!
Hello All,
Ive done a few things.
1) Verified that external commands are being logged
2) Updated my code to use SCHEDULE_HOST_SVC_DOWNTIME .
Ran the script and tailed the nagios.log .
Not a single entry for my target HOST even showed up in the log file, its as if nothing was even recognized by the nagios system.
So I wanted to ask if it matters in the code if I append to >> or create > when I issue commands to the nagios control file. I am not sure if using the > will completely wipe out what others have entered in the system, and that is what I fear. So I am using >> for the moment. I am not sure if this is an error or not?
Also, do I have to have special permissions on our linux box to even be able to issue commands to the nagios control file?
thanks again!!!
Really appreciate it,
here is the code FYI:
#!/bin/sh
NAGIOS_CMD="/usr/local/nagios/var/rw/nagios.cmd"
echo "SCHEDULE_HOST_SVC_DOWNTIME;FCFSPRE;2012-09-10 18:00:00;2012-09-10 22:00:00;1;0;7200;CMS Migration Team;CHG0030530" >>$NAGIOS_CMD
#echo $NAGIOS_CMD "is the nagios control file"
Ive done a few things.
1) Verified that external commands are being logged
2) Updated my code to use SCHEDULE_HOST_SVC_DOWNTIME .
Ran the script and tailed the nagios.log .
Not a single entry for my target HOST even showed up in the log file, its as if nothing was even recognized by the nagios system.
So I wanted to ask if it matters in the code if I append to >> or create > when I issue commands to the nagios control file. I am not sure if using the > will completely wipe out what others have entered in the system, and that is what I fear. So I am using >> for the moment. I am not sure if this is an error or not?
Also, do I have to have special permissions on our linux box to even be able to issue commands to the nagios control file?
thanks again!!!
Really appreciate it,
here is the code FYI:
#!/bin/sh
NAGIOS_CMD="/usr/local/nagios/var/rw/nagios.cmd"
echo "SCHEDULE_HOST_SVC_DOWNTIME;FCFSPRE;2012-09-10 18:00:00;2012-09-10 22:00:00;1;0;7200;CMS Migration Team;CHG0030530" >>$NAGIOS_CMD
#echo $NAGIOS_CMD "is the nagios control file"