checking for certain parameters in a command

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
DOkuwa
Posts: 114
Joined: Tue Aug 15, 2017 3:54 pm

checking for certain parameters in a command

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

Re: checking for certain parameters in a command

Post 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!
dwasswa

Re: checking for certain parameters in a command

Post by dwasswa »

Hi @DOkuwa,

@kyang is right. However,can you please give an example of the kind of information you want nagios to check.
DOkuwa
Posts: 114
Joined: Tue Aug 15, 2017 3:54 pm

Re: checking for certain parameters in a command

Post 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
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: checking for certain parameters in a command

Post 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
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
DOkuwa
Posts: 114
Joined: Tue Aug 15, 2017 3:54 pm

Re: checking for certain parameters in a command

Post 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
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: checking for certain parameters in a command

Post 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.
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
DOkuwa
Posts: 114
Joined: Tue Aug 15, 2017 3:54 pm

Re: checking for certain parameters in a command

Post 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
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: checking for certain parameters in a command

Post 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!
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
Locked