I created a custom bash script to monitor the amount of processes a specific service creates. This check is working as it should and displaying on the icingaweb interface. My question is how do I set warning/critical thresholds for this custom service so when the number of processes goes over a certain number the service enters the warning/critical stage? I tried the basic way of adding the 'var.processname_warning = 50 " to the services.conf file but this is not being registered/detected by icinga. Do i have to specify these values in the bash script itself?
You need to make sure that the return code from your script reflects “OK”,
“warning”, “critical” or “unknown”.
https://www.monitoring-plugins.org/doc/guidelines.html#AEN78
Antony.
Hello. Thanks for your reply. So what would the syntax be for doing this? I mean i know how to get the return code but how do i reflect it as ok/warning/critical?
If you want the result to be displayed as OK, you use “exit 0”.
If you want the result to be displayed as a warning, you use “exit 1”.
If you want the result to be displayed as a critical error, you use “exit 2”.
If your script cannot get a result or there is some other problem meaning that
you want the result to be displayed as “unknown”, you use “exit 3”.
Antony.
I’ve added the exit=0 as such to my bash script but on the icingaweb it still displays as OK.
if [ $number -gt 90 ]
then
echo “Postgres proccesses are critical: $number”
exit=2
elif [ $number -lt 90 -a $number -gt 70 ]
then
echo “postgress processes are warning: $number”
exit=1
else [ $number -gt 90 ]
echo "postgres processes are ok: $number"
exit=0
fi
This is my script currently.
I’ve added the exit=0 as such to my bash script but on the icingaweb it
still displays as OK.
I did not say you should use an equals sign.
“exit=0” is not the same as “exit 0”.
You are simply assigning a value to a variable named “exit”.
You want to execute the bash command "exit " with the parameter 0 instead.
This is my script currently.
Change:
exit=2
exit=1
exit=0
to:
exit 2
exit 1
exit 0
Antony.
Thanks for your help. I mistakenly added the equal sign. (Sorry its early ) . Your suggestion worked and now the critical/warning state is reflected in icingaweb. Thanks again.
I’ve added the exit=0 as such to my bash script but on the icingaweb it
still displays as OK.
I’ve just read your script in more detail and apart from “exit=0” beig “exit
0”, I have the following comments:
if [ $number -gt 90 ]
then
echo “Postgres proccesses are critical: $number”
exit=2
Only one c in processes
elif [ $number -lt 90 -a $number -gt 70 ]
You’ve already done “if number > 90” and this is now an “else if…” so
there’s no reason to include “number <90”. Also, what would you want to
happen if number = 90?
then
echo “postgress processes are warning: $number”
exit=1else [ $number -gt 90 ]
That isn’t valid bash syntax, and since it is an “else” that is the only word
you need on the line. “number > 90” at this point would make no sense anyway.
echo "postgres processes are ok: $number" exit=0
fi
This is my script currently.
Antony.
Good catch on the spelling error.
I’ve replaced [ $number -gt 90 ] with [ $number -ge 90] so this should give a critical warning if the number equals 90.
The last part of my code was a mistake. I meant to have it else [ $number -lt 7- ]
echo “proccesses are ok”
exit 0
But your’e right that all extra and not needed. I can just do the echo and exit 0 as you suggested. Thank you.