we are running a bash script on a unix-server to check a value against a treshold and sent the result to a monitoring system via snmp. The goal is to sent a defined alarmtext to the monitoring infrastructure if the value is greater than the defined treshold.
When running a debug of this script everything works fine and the correct alarmtext is displayed via echo on the cli.
Scriptsnippet:
## LOGIC ##
if [[ ${ActiveRecipientsQueue} -gt ${Threshold} ]]; then
echo "$AlarmText";
exit 1;
else
echo "$NoAlarmText";
exit 0;
fi
Result of debug - scenario threshold reached:
+ [[ 15 -gt 5 ]]
+ echo 'Treshsold was reached!'
Treshsold was reached!
+ exit 1
Result of debug - scenario everything ok:
+ [[ 15 -gt 500 ]]
+ echo 'Everything is fine'
Everything is fine
+ exit 0
The issue is now that on the monitoring infrastructure everytime the "everything ok" message is displayed, no matter if the threshold was reached or not.
I am still confused about this and can't find any logical explanation for this.
May you can help me?
Thanks a lot!