Page 1 of 2

Nagios command line

Posted: Mon Nov 18, 2013 6:28 am
by reincarne
Hi,
I managed to find a command which is able to enable/disable the 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"

The problem is that during maintenance mode, I want to disable notifications for a specific hosts group or a specific host, is that possible?

In general, are there other commands that can help me with Nagios? I prefer to automate some processes in my company using scripts , and I will need some Nagios command lines.

Thanks.

Re: Nagios command line

Posted: Mon Nov 18, 2013 11:34 am
by abrist
If you schedule downtime, notifications should be suppressed during the downtime.
reincarne wrote:The problem is that during maintenance mode, I want to disable notifications for a specific hosts group or a specific host, is that possible?
You would have to create a script that parses the cgi status for the relevant hosts in the hostgroup, and then run the command on each one.
EDIT: *CGI Status

Re: Nagios command line

Posted: Thu Dec 05, 2013 2:53 am
by reincarne
abrist wrote:If you schedule downtime, notifications should be suppressed during the downtime.
reincarne wrote:The problem is that during maintenance mode, I want to disable notifications for a specific hosts group or a specific host, is that possible?
You would have to create a script that parses the gci status for the relevant hosts in the hostgroup, and then run the command on each one.

How can you parse the gci status for a specific host?

Re: Nagios command line

Posted: Thu Dec 05, 2013 4:09 pm
by abrist
Carefully. In all seriousness, this will require some scripting. Is there a reason why you do not want to use downtime to achieve this goal? When a host enters downtime, all notifications for the host and its services are suppressed until downtime ends.

Re: Nagios command line

Posted: Tue Dec 17, 2013 5:54 am
by reincarne
abrist wrote:Carefully. In all seriousness, this will require some scripting. Is there a reason why you do not want to use downtime to achieve this goal? When a host enters downtime, all notifications for the host and its services are suppressed until downtime ends.

I know, but I want to automate some stuff in my company.
For example, during some maintenance, I need to go and manually disable notification to 50 hosts for example. While I want it to be done using the command line above in my first post.
I'm sure that part of the command can contain somewhere the hostname and it can do the trick.

Re: Nagios command line

Posted: Tue Dec 17, 2013 10:53 am
by abrist
You could write to the command pipe to disable host notifications:
http://old.nagios.org/developerinfo/ext ... mand_id=16

Downtime can be scheduled to be recurring and can be applied to multiple hosts at once. I still suggest that you take a look as it was designed to be automated/scheduled.

Re: Nagios command line

Posted: Wed Jan 15, 2014 3:08 am
by reincarne
abrist wrote:You could write to the command pipe to disable host notifications:
http://old.nagios.org/developerinfo/ext ... mand_id=16

Downtime can be scheduled to be recurring and can be applied to multiple hosts at once. I still suggest that you take a look as it was designed to be automated/scheduled.

Thanks :)

Re: Nagios command line

Posted: Wed Jan 15, 2014 10:06 am
by tmcdonald
Did this resolve everything for you?

Re: Nagios command line

Posted: Wed Mar 05, 2014 2:45 am
by reincarne
I have a problem now.

If I try to run this command:
curl -d "'cmd_typ=23&cmd_mod=2&host=myhost&service=myservice&btnSubmit=Commit'" "http://XX.XX.XX.XX/nagios/cgi-bin/cmd.cgi" -u USER"

It works.
But, how to run same command to stop notifications for a service group or host group?
I says that I have no permissions even if I run it with an admin user.
The error attached below.

<P><DIV CLASS='errorMessage'>Sorry, but you are not authorized to commit the specified command.</DIV></P>
<P><DIV CLASS='errorDescription'>Read the section of the documentation that deals with authentication and authorization in the CGIs for more information.<BR><BR>
<A HREF='javascript:window.history.go(-2)'>Return from whence you came</A></DIV></P>

Re: Nagios command line

Posted: Wed Mar 05, 2014 3:41 am
by reincarne
Never mind, figured out bymyself.

curl -d "cmd_typ=29&cmd_mod=2&host=SERVER&btnSubmit=Commit" "http://XI/nagios/cgi-bin/cmd.cgi" -u "USER"

If you can, please provide me a list of all the CMD types. I didn't find it over the internet.
Thanks