Page 1 of 1

Nrpe custom plugin

Posted: Fri Mar 10, 2017 8:26 pm
by simonx
Hi All ,I have the following scenario:
Both Debian jessie
Monitoring server: 192.168.0.200
Client server: 192.168.0.100
Nagios and Nrpe works fine on both servers.Now , i want to monitor some values of iostat on the client server(.100), so i'm runnng the command
#iostat -xm 20 in  the background to a file(iostat.txt). Then i have the following on the client server.
#command[check_iostat.php]=tail -100 /usr/lib/nagios/plugins/iostat.txt | tac | grep Device -B2000 -m1 | tac
This gives the following is the output of the command when run on command line.
# tail -100 /usr/lib/nagios/plugins/iostat.txt | tac | grep Device -B2000 -m1 | tac
Device: rrqm/s wrqm/s r/s w/s rMB/s wMB/s avgrq-sz avgqu-sz await r_await w_await svctm %util
sdc 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
sdb 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
sda 0.00 0.50 0.00 0.70 0.00 0.00 13.71 0.01 8.29 0.00 8.29 8.29 0.58

i only want the values for r/s,w/s,rMB/s,wMB/s,%util on the monitoring server,
i'm pulling the above output.My question is, on the monitoring server , can i create a php script to filter the values i want and present them on Nagios ?

Thank you .

Re: Nrpe custom plugin

Posted: Mon Mar 13, 2017 11:43 am
by mcapra
simonx wrote:My question is, on the monitoring server , can i create a php script to filter the values i want and present them on Nagios ?
You certainly could, but I think it would be much better to have the plugin you are executing on the remote machine return the proper Nagios plugin outputs. Here's a link to the documentation for developing a Nagios plugin:
https://nagios-plugins.org/doc/guidelines.html

Re: Nrpe custom plugin

Posted: Mon Mar 13, 2017 5:27 pm
by simonx
Thanks.

I have managed to put together the script.

My last question is on how do i do generic configs on the nagios server to cater for about 20 hosts, i'm avoiding doing configs on commands.cfg and services for each of the 20 hosts.

Thanks once again.

Re: Nrpe custom plugin

Posted: Tue Mar 14, 2017 10:51 am
by mcapra
One way many users address large configuration sets is to group their hosts into a hostgroup. Then, if those hosts share common check (cpu, disk, memory, etc) you can assign those services to the hostgroup rather than individual hosts. Then, any hosts that are a part of that hostgroup would inherit those services. You could also use a host template to contain things like contacts, check times, check commands, etc.

More information:
https://assets.nagios.com/downloads/nag ... #hostgroup
https://assets.nagios.com/downloads/nag ... tance.html

Re: Nrpe custom plugin

Posted: Wed Mar 15, 2017 4:38 pm
by simonx
i have managed to fix the issue.Thank you

Re: Nrpe custom plugin

Posted: Wed Mar 15, 2017 4:43 pm
by cdienger
Glad to hear you've been able to fix the issue. Is it okay to close the thread at this point or did you have any further questions?

Re: Nrpe custom plugin

Posted: Wed Mar 15, 2017 4:49 pm
by simonx
Please close it , thank you