Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Our routine maintenance requires services have to be brought down.

The problem is these services have Nagios checks and we either have to go to the web interface and disable the check or get the emails.

Is there a way from command line on a Windows and/or Linux guest to disable the Nagios check (or notifications) and enable it? Ideally this would happen on the machine we are performing the maintenance on, not the Nagios server itself.

I would like to disable notifications/checks pre-maintenance and re-enable them post maintenance.

share|improve this question

3 Answers 3

up vote 6 down vote accepted

Assuming that the guest can reach the web interface, the following command lines should work:

To disable notifications

curl -d "cmd_typ=23&cmd_mod=2&host=[THE HOST]&service=[THE SERVICE]&btnSubmit=Commit" "http://[[NAGIOS SERVER]/nagios/cgi-bin/cmd.cgi"

To enable notifications

curl -d "cmd_typ=22&cmd_mod=2&host=[THE HOST]&service=[THE SERVICE]&btnSubmit=Commit" "http://[[NAGIOS SERVER]/nagios/cgi-bin/cmd.cgi"

Depending on your setup, you may also need to use the --insecure or --user options of curl.

And IIRC, the cmd_type number is different for service and host groups -- look at what links are being used in your web browser.

share|improve this answer
    
Looks great. I'll give it a try before marking this question as answered. Thanks! –  andyhky Aug 26 '09 at 14:52
    
Those command work well for service/host notification enable/disable purpose. But could you please suggest how could I achieve scheduled host downtime by this kind of script? Because the downtime option takes more argument.Please suggest. –  unixbhaskar Jul 27 '11 at 9:58
1  
To schedule downtime, again, follow Matt's advice: "Look at what links are being used in your browser" — Look at the HTML form and just emulate that. For "downtime for host and all services" additional parameters are cmd_typ=86, cmd_mod=2, com_data=your comment, trigger=0, start_time=2012-01-02 22:33:00, end_time=2012......, fixed=1, hours=0, minutes=0 –  mogsie Aug 8 '12 at 6:58
    
The cmd_typ codes can be found here: docs.icinga.org/latest/en/cgiparams.html. Do not use the docs located at old.icinga.org (even though most of the posts will list those ones!) –  Steve Dec 11 at 18:37

Yo can Enable/Disable host notification with nagios.cmd command

e.g:

Disable all notification for my-host

now=`date +%s`
#Check first path nagios.cmd & printf 
commandfile='/var/lib/nagios3/rw/nagios.cmd'  

/usr/bin/printf "[%lu] DISABLE_HOST_NOTIFICATIONS;my-host\n" $now > $commandfile

Enable all notification for my-host

now=`date +%s`
#Check first path nagios.cmd & printf 
commandfile='/var/lib/nagios3/rw/nagios.cmd'  
/usr/bin/printf "[%lu] ENABLE_HOST_NOTIFICATIONS;my-host\n" $now > $commandfile

You can also check this url Nagios Notification command

share|improve this answer
    
The link is for the old docs, make sure to use docs.icinga.org/latest/en/cgiparams.html instead. –  Steve Dec 11 at 18:38

For such use, you may edit your nagios services file, and disable checks of all services on this host, like what you did in the web interface, and that require the modification of some options.
Let's take an example If you need to disable checks for DNS service in machine nibiru, disable the active/passive checks like the following.


define service{
    host_name               nibiru
    service_description     DNS
    ...
    active_checks_enabled   0  ; set value to 0
    passive_checks_enabled  0  ; set value to 0
    ...
}

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.