Is it possible to ack nagios alerts from the terminal on a remote workstation?

I have nagios alerts set up to come through jabber with an http link to ack.

Is is possible there is a script I can run from a terminal on a remote workstation that takes the hostname as a parameter and acks the alert?

./ack hostname

The benefit, while seemingly mundane, is threefold. First, take http load off nagios. Secondly, nagios http pages can take up to 10-20 seconds to load, so I want to save time there. Thirdly, avoiding slower use of mouse + web interface + firefox/other annoyingly slow browser.

Ideally, I would like a script bound to a keyboard shortcut that simply acks the most recent alert. Finally, I want to take the inputs from a joystick, buttons and whatnot, and connect one to a big red button bound to the script so I can just ack the most recent nagios alert by hitting the button lol. (It would be rad too if the button had a screen on the enclosure that showed the text of the alert getting acked lol)

Make fun of me all you want, but this is actually something that would be useful to me. If I can save five seconds per alert, and I get 200 alerts per day I need to ack, that's saving me 15 minutes a day. And isn't the whole point of the sysadmin to automate what can be automated?

Thanks!


Solution 1:

This is definitely possible, but keep in mind that you are diving into the innards of Nagios which have a steep learning curve. It should be an interesting and rewarding learning curve.

You can make use of the Nagios External Commands to allow external programs to insert commands into the Nagios command queue. There are many commands. Combine this with remote access and the possibilities from the command line and shell scripting, and the possibilities are quite large.

Here's one example: From a remote box, SSH into the Nagios host. The command ~/bin/ack will insert a command into the command_file queue. Nagios will then read the command_file, and execute your command. The command might look something like:

ssh nagios.example.org ~/bin/ack hostA

Another example: To disable all notifications on Nagios from a remote host, the command is something like:

ssh nagios.example.org "echo \"[\"date +%s\"] DISABLE_NOTIFICATIONS\" > /var/spool/nagios/cmd/nagios.cmd"

You could in theory do this with other daemons as well, make use of Netcat to listen on a port and pipe commands into a file, or even do this using Jabber, IRC, etc. I know one group who did this using xinitd listening on certain ports. Be very careful to consider the security implications of allowing unauthenticated remote access to your Nagios host.

Nagios has more information on external commands in the manual. See Nagios Core: External Commands

Here's an example for executing commands from Munin. They make use of NSCA

Solution 2:

If security is not your priority, some netcat + xinetd + script each side will do. If you want some security and/or you don't want to write it yourself, you may want to give NRCD or nscaweb a try. Or take a look at this script named nagios_commander