NRPE: Custom plugin

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
lexer
Posts: 4
Joined: Wed Feb 07, 2018 9:59 am
Location: Kiev, UA

NRPE: Custom plugin

Post by lexer »

Hello!
I had make own custom plugin on Bash that checks *.txt file to control quantity of messages in DB.
Here it is:

Code: Select all

#!/bin/bash
msgs=`cat msgs_stats.txt | tail -1 | awk '{print $5}'`
case $msgs in
[1000-99999999999999999999999999999999999999]*)
echo "OK - $msgs messages in DB"
exit 0
;;
[1-999]*)
echo "WARNING - $msgs messages in DB"
exit 1
;;
[0]*)
echo "CRITICAL - $msgs messages in DB"
exit 2
;;
*)
echo "UNKNOWN - $msgs messages in DB"
exit 3
;;
esac

The result is:

Code: Select all

# ./check_msg_stats.sh
OK - 1609677783 messages in DB
https://prnt.sc/jf7u7p

In Nagios it works fine except graphic data. What I have to do to draw graphics?
http://prntscr.com/jf7usc


P.S. I use Nagios XI 5.4.11
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: NRPE: Custom plugin

Post by tmcdonald »

You need to output a performance data string - https://nagios-plugins.org/doc/guidelines.html#AEN200
Former Nagios employee
lexer
Posts: 4
Joined: Wed Feb 07, 2018 9:59 am
Location: Kiev, UA

Re: NRPE: Custom plugin

Post by lexer »

Can u help me with that?
I'm not a programmer and haven't necessary knowledge to implement that
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: NRPE: Custom plugin

Post by tmcdonald »

If you read the documentation it will make sense. You were able to get most of the way there in bash, the rest is just adding | msgs=$msgs to your output, basically. Read the docs, try some things and come back with specific questions about what is not working, and we can help with that.
Former Nagios employee
lexer
Posts: 4
Joined: Wed Feb 07, 2018 9:59 am
Location: Kiev, UA

Re: NRPE: Custom plugin

Post by lexer »

I almost make it by own, by adding to output only | $msgs.
Now it's working as I need.
Thanks a lot=)
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: NRPE: Custom plugin

Post by tmcdonald »

No problem. Mind if I close this up?
Former Nagios employee
lexer
Posts: 4
Joined: Wed Feb 07, 2018 9:59 am
Location: Kiev, UA

Re: NRPE: Custom plugin

Post by lexer »

Hello.
One more question. Now my script looks like that:

Code: Select all

#!/bin/bash
msgs=`cat /home/wialon/wlocal/storage/ms/msgs_stats.txt | tail -1 | awk '{print $5}'`
case $msgs in
[1000-99999999999999999999999999999999999999]*)
echo "OK - $msgs messages in DB | msgs=$msgs"
exit 0
;;
[1-999]*)
echo "WARNING - $msgs messages in DB | msgs=$msgs"
exit 1
;;
[0]*)
echo "CRITICAL - $msgs messages in DB | msgs=$msgs"
exit 2
;;
*)
echo "UNKNOWN - $msgs messages in DB | msgs=$msgs"
exit 3
;;
esac
When zero messages should be Critical status, but in for some reason it wasn't.
What I should change?
User avatar
cdienger
Support Tech
Posts: 5045
Joined: Tue Feb 07, 2017 11:26 am

Re: NRPE: Custom plugin

Post by cdienger »

[1000-99999999999999999999999999999999999999]*)
echo "OK - $msgs messages in DB | msgs=$msgs"
exit 0
;;
[1-999]*)
The ranges are not valid regex or at least are not doing what you think they should. Here are a couple resources to help:

https://regex101.com
http://gamon.webfactional.com/regexnume ... generator/
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Locked