Page 1 of 1

checking for certain parameters in a command

Posted: Fri Sep 22, 2017 10:54 am
by DOkuwa
Hello
I have Nagios core running and I want to run a command on a remote host and the result of this command produces some info
and to alert Nagios if some of this information is missing with the message that this particular information is missing
it is probably a plugin

Re: checking for certain parameters in a command

Posted: Fri Sep 22, 2017 12:33 pm
by kyang
Hi @DOkuwa,

The best way to run a command on a remote host would be to download our NRPE agent.
https://support.nagios.com/kb/article.php?id=515

I don't know what check you want to run or what information you want Nagios to be alerted from.

Our Nagios plugins usually allow you to pass warning and critical thresholds, thus this output will be sent to Nagios and let you know if the check command on the remote host is OK, Warning, Critical

Let us know if this helps!

Re: checking for certain parameters in a command

Posted: Fri Sep 22, 2017 2:01 pm
by dwasswa
Hi @DOkuwa,

@kyang is right. However,can you please give an example of the kind of information you want nagios to check.

Re: checking for certain parameters in a command

Posted: Mon Sep 25, 2017 10:34 am
by DOkuwa
on a remote server I run this command as a root
brcontrol at the command prompt and get the following result below
if there is some missing information( all the information below is not complete) create a warning alarm describing what is missing , if the information is complete there is an alarm saying it is ok
please guide me .
and if the broker is not working at all create a critical alarm


Broker is located at: 10.241.10.41:426 Started: Nov 5 17:58:38 2015


Domain Host Name Port PID State Last Change Time
---------------------- --------------------------------------- ------ ------- ------- --------------------
INCHARGE-SA-PRES sam-pres-01 19500 2118 RUNNING Sep 20 15:05:15 2017
xxx-apm-01 apm-01 19510 29889 RUNNING Jun 17 23:00:28 2017
xxx-apm-02 apm-01 19514 30117 RUNNING Jun 17 22:59:58 2017
xxx-apm-03 apm-01 19512 30355 RUNNING Jun 17 23:00:27 2017
xxx-apm-04 apm-01 19511 30594 RUNNING Jun 17 23:00:06 2017
xxx-apm-05 apm-02 19510 37029 RUNNING Jun 17 22:41:18 2017
xxx-apm-06 apm-02 19515 36796 RUNNING Jun 17 22:41:13 2017

Re: checking for certain parameters in a command

Posted: Mon Sep 25, 2017 11:54 am
by scottwilkerson
You will likely need to write a nagios plugin which is a script that runs the command you want, parses the information returned from the command and then outputs that information and the appropriate exit code.
https://nagios-plugins.org/doc/guidelines.html


Then you would use the link @kyang gave above to call the script.

One thing to point out is that if the script needs to call somethis as root, you will need to ad a line like this with visudo

Code: Select all

Defaults:nagios !requiretty
nagios ALL=NOPASSWD: /usr/local/nagios/libexec/your-script-name.sh

Re: checking for certain parameters in a command

Posted: Tue Sep 26, 2017 4:19 am
by DOkuwa
Thanks @scottwilkerson
I am looking also on the internet for some examples to follow
Please point if you have seen one
Just a basic one

Re: checking for certain parameters in a command

Posted: Tue Sep 26, 2017 9:23 am
by scottwilkerson
DOkuwa wrote:Thanks @scottwilkerson
I am looking also on the internet for some examples to follow
Please point if you have seen one
Just a basic one
This is really going to depend on what the expected output is and what you want to alert on.

Re: checking for certain parameters in a command

Posted: Tue Sep 26, 2017 9:42 am
by DOkuwa
like I said
just to run the command and then parses the info and then create a notification or warning alert if any of the e.g any of the ports are missing and another critical notification/alert if the command does not run
Thanks

Re: checking for certain parameters in a command

Posted: Tue Sep 26, 2017 9:48 am
by scottwilkerson
DOkuwa wrote:like I said
just to run the command and then parses the info and then create a notification or warning alert if any of the e.g any of the ports are missing and another critical notification/alert if the command does not run
Thanks
Ok, then you would want to follow these guidelines in the programming language of your choice as long as it can run on your Nagios sevver.
https://nagios-plugins.org/doc/guidelines.html

Good luck on your first Nagios plugin!