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.

up vote 7 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.

  • 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!) – Ben Dec 11 '14 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

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
    ...
}

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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