Nagios command line

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
reincarne
Posts: 146
Joined: Wed Jun 26, 2013 4:39 am

Nagios command line

Post 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.
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Nagios command line

Post 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
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.
reincarne
Posts: 146
Joined: Wed Jun 26, 2013 4:39 am

Re: Nagios command line

Post 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?
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Nagios command line

Post 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.
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.
reincarne
Posts: 146
Joined: Wed Jun 26, 2013 4:39 am

Re: Nagios command line

Post 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.
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Nagios command line

Post 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.
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.
reincarne
Posts: 146
Joined: Wed Jun 26, 2013 4:39 am

Re: Nagios command line

Post 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 :)
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Nagios command line

Post by tmcdonald »

Did this resolve everything for you?
Former Nagios employee
reincarne
Posts: 146
Joined: Wed Jun 26, 2013 4:39 am

Re: Nagios command line

Post 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>
reincarne
Posts: 146
Joined: Wed Jun 26, 2013 4:39 am

Re: Nagios command line

Post 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
Locked