Custom Actions

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
nagios_aws
Posts: 76
Joined: Wed May 18, 2016 3:34 am

Custom Actions

Post by nagios_aws »

Hello everyone,

here is my problem :

I want to be able to restart some services from Nagios Portal.
To restart a service, i will need a hostname and a port number, then pass those informations to a Linux CLI proprietary program on the Nagios Server.
this CLI program can be launched anywhere and send commands to the specified service on the remote server.

the fact is that those services are monitored using a custom plugin which got a port number in parameter.

I checked the "custom actions" documentation, but it's not enough for me because I can't retrieve the port number from the service, so I can't pass them to the CLI tool.

Do you have anything that can help me with this ?

Thank you
avandemore
Posts: 1597
Joined: Tue Sep 27, 2016 4:57 pm

Re: Custom Actions

Post by avandemore »

It almost sounds like you are wanting an event handler:

https://assets.nagios.com/downloads/nag ... ios-XI.pdf

Information like service ports are only available in certain contexts. The page is a listing of where macros can be used:

https://assets.nagios.com/downloads/nag ... olist.html
Previous Nagios employee
nagios_aws
Posts: 76
Joined: Wed May 18, 2016 3:34 am

Re: Custom Actions

Post by nagios_aws »

Hello,

thank you for your answer, but I don't want to do something when the service changes state, I want to be able to do it whenever I choose.

I thought about some dropdown menu generated from the Nagios database and from the services' configuration files, but I need the database implementation ...
avandemore
Posts: 1597
Joined: Tue Sep 27, 2016 4:57 pm

Re: Custom Actions

Post by avandemore »

Just to make sure we on the same page, this is component you are speaking of correct?

https://assets.nagios.com/downloads/nag ... ios-XI.pdf

You can use the available macro to pass in the service macro, then your executing script could be made robust enough to understand what it means.
Previous Nagios employee
nagios_aws
Posts: 76
Joined: Wed May 18, 2016 3:34 am

Re: Custom Actions

Post by nagios_aws »

Yes, this is the component, but I can't use it because there is no way to get the parameters set in $ARG1$
Each service as a specific port, and I can't redeclare it in "custom actions", I will need to create about 1000 customs actions ...

Do you say there is a way to get service parameters through other macro ?
nagios_aws
Posts: 76
Joined: Wed May 18, 2016 3:34 am

Re: Custom Actions

Post by nagios_aws »

I figured out a way to do my thing :

I will launch a script from the "custom actions" command, like this :

Code: Select all

/usr/local/nagios/libexec/test.pl "%servicename%" "%hostname%"
the %servicename% contains the port number needed, so I will be able to do what I want.

my problem is it seems that Perl is not launched, but Bash is, can you confirm ?

Also, is there a way to send check_nrpe command via Perl or bash, like this :

Code: Select all

/usr/local/nagios/libexec/check_nrpe -H HOSTNAME -t 30 -c service_command_restart -a 29030
Thank you
avandemore
Posts: 1597
Joined: Tue Sep 27, 2016 4:57 pm

Re: Custom Actions

Post by avandemore »

my problem is it seems that Perl is not launched, but Bash is, can you confirm ?
It will launch an executable depending on how you define it.
Also, is there a way to send check_nrpe command via Perl or bash, like this :
That question should be a separate thread, but the quick answer is you need to define a custom plugin in the NRPE listener. You can find documentation on that here:
https://assets.nagios.com/downloads/nag ... e/NRPE.pdf -- See the customizing your configuration section.
NRPE plugins can also be any type of executable.
Or here:
https://assets.nagios.com/downloads/nag ... ios-XI.pdf
Previous Nagios employee
Locked