Can I add icon to services to manually issue commands?

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.
Locked
zicat
Posts: 5
Joined: Wed Nov 05, 2014 3:19 am

Can I add icon to services to manually issue commands?

Post by zicat »

Hello.
I recently used Nagios to monitor our production servers. I want to do the following, but can't find a solution.
I want to display an icon next to the service on the web interface, when the service becomes critical. So, when the operator get notified and logon to the web interface, he can choose to click the icon, to issue some command to the service, e.g. to restart it.
Any ideas? Thanks in advance.
slansing
Posts: 7698
Joined: Mon Apr 23, 2012 4:28 pm
Location: Travelling through time and space...

Re: Can I add icon to services to manually issue commands?

Post by slansing »

Yes, you could build this in, but it won't be necessarily easy. You would have to hook it into an SSH session extension for your browser, and allow them to log into the system. For what you are mentioning, users typically find event-handlers the best, and easiest solution:

http://nagios.sourceforge.net/docs/nagi ... dlers.html
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Can I add icon to services to manually issue commands?

Post by abrist »

You could use the action url to do this:
action_url: This directive is used to define an optional URL that can be used to provide more actions to be performed on the host. If you specify an URL, you will see a red "splat" icon in the CGIs (when you are viewing host information) that links to the URL you specify here. Any valid URL can be used. If you plan on using relative paths, the base path will the the same as what is used to access the CGIs (i.e. /cgi-bin/nagios/).
http://nagios.sourceforge.net/docs/3_0/ ... tions.html
Though you will need to create a cgi or web api to your script.
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
zicat
Posts: 5
Joined: Wed Nov 05, 2014 3:19 am

Re: Can I add icon to services to manually issue commands?

Post by zicat »

Event handler is an option. But it runs after the service becomes critical. I want to leave the operator chance to choose, if restarting the service is safe.
slansing wrote:Yes, you could build this in, but it won't be necessarily easy. You would have to hook it into an SSH session extension for your browser, and allow them to log into the system. For what you are mentioning, users typically find event-handlers the best, and easiest solution:

http://nagios.sourceforge.net/docs/nagi ... dlers.html
zicat
Posts: 5
Joined: Wed Nov 05, 2014 3:19 am

Re: Can I add icon to services to manually issue commands?

Post by zicat »

The first part of my problem is solved by action_url. Although it only applies to host, it is acceptable.
Now, how to issue a shell script command by clicking the icon on the web page? Do I have to write my own cgi?
abrist wrote:You could use the action url to do this:
action_url: This directive is used to define an optional URL that can be used to provide more actions to be performed on the host. If you specify an URL, you will see a red "splat" icon in the CGIs (when you are viewing host information) that links to the URL you specify here. Any valid URL can be used. If you plan on using relative paths, the base path will the the same as what is used to access the CGIs (i.e. /cgi-bin/nagios/).
http://nagios.sourceforge.net/docs/3_0/ ... tions.html
Though you will need to create a cgi or web api to your script.
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Can I add icon to services to manually issue commands?

Post by abrist »

zicat wrote: Do I have to write my own cgi?
Yes, or php script or something similar.
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
sreinhardt
-fno-stack-protector
Posts: 4366
Joined: Mon Nov 19, 2012 12:10 pm

Re: Can I add icon to services to manually issue commands?

Post by sreinhardt »

Essentially yes, although it most certainly does not need to be written in C. Really all you need is a script in a web accessible location, that can resolve your issue when called via apache. To start, I would suggest making ones that do not accept arguments, once you get it figured out, you can move on to accepting url or post variables for better scripts.
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.
Locked