Page 1 of 1

How to add a new service command in service page

Posted: Sat May 31, 2014 6:40 am
by zaheer.abdulla
Hi,

Is it possible to add a Service Command in the page where we see other service commands like Reschedule service check, acknowledge alarm etc.?

Thanks

Re: How to add a new service command in service page

Posted: Mon Jun 02, 2014 10:25 am
by tmcdonald
I'm a bit confused by what you mean. All configuration in Nagios Core is done via the config files, not the web interface. What page are you referring to? Are you actually using Nagios XI?

Re: How to add a new service command in service page

Posted: Mon Jun 02, 2014 1:27 pm
by zaheer.abdulla
Sorry for the bad explanation and confusion. I am using Nagios core.

In Nagios wepage, when we click on any service, eg. http service, the Service Information page opens. There we have Service State Information and Service Commands (eg. Disable Active Checks Of This Service, Re-schedule Next Service Check, etc.) in the page.

Is it possible to add a new service command there?

Re: How to add a new service command in service page

Posted: Mon Jun 02, 2014 2:58 pm
by slansing
You are talking about the check_command? As in check_nrpe!cpu_usage!30!50 etc? Or a new action button such as those you noted above? If you are asking about changing the check command you can do that by clicking Configure > Reconfigure.

Re: How to add a new service command in service page

Posted: Mon Jun 02, 2014 9:44 pm
by zaheer.abdulla
A new action button is that what I am looking for. By clicking it, need to trigger a perl script.

Re: How to add a new service command in service page

Posted: Mon Jun 02, 2014 9:54 pm
by eloyd
You would have to write the code and add it to the Nagios core source for the CGIs. Most likely you'd want to smack your code into the middle of <nagios src>/cgi/statuswml.c. This is not "hard" exactly, but likely to be way beyond the scope of this forum.

If you're looking for a "plug-in" type approach to adding an action button to this display, the answer is no. But I think it's a great idea for future core development to "plug-in-ify" this part of the UI if you want to tackle it :-)

Re: How to add a new service command in service page

Posted: Mon Jun 02, 2014 10:02 pm
by zaheer.abdulla
:) .

So, instead of creating new action, if I want modify already existing action, is this the file I need to modify? <nagios src>/cgi/statuswml.c.

Re: How to add a new service command in service page

Posted: Mon Jun 02, 2014 10:08 pm
by eloyd
If you want to "jerry rig" it to do something else on your server (aim it at a different CGI or a perl script or whatever) then you could hijack one of the existing actions, yes. But this is a "your mileage may vary" type thing since whatever you want to do will 100% break if you ever upgrade. Plus you would lose whatever functionality you hijack.

But basically, the answer to your question is "yes." :mrgreen:

Re: How to add a new service command in service page

Posted: Tue Jun 03, 2014 2:50 pm
by scottwilkerson
Thanks @eloyd

@zaheer.abdulla - Not sure if you are a long time user or just getting started, but I did want to mention that in the Commercial XI version of Nagios, this is a built-in feature, in Core, as eloyd has suggested you would have to roll-your-own.