This support forum board is for support questions relating to
Nagios XI , our flagship commercial network monitoring solution.
lexer
Posts: 4 Joined: Wed Feb 07, 2018 9:59 am
Location: Kiev, UA
Post
by lexer » Tue May 08, 2018 5:45 am
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
lexer
Posts: 4 Joined: Wed Feb 07, 2018 9:59 am
Location: Kiev, UA
Post
by lexer » Tue May 08, 2018 10:17 am
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
Post
by tmcdonald » Tue May 08, 2018 10:25 am
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
Post
by lexer » Tue May 08, 2018 1:50 pm
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
Post
by tmcdonald » Wed May 09, 2018 9:04 am
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
Post
by lexer » Fri May 11, 2018 1:34 am
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?