I’m trying to get a specific script to run on a monitored host. All the other usual checks are working, but this script is not returning what I want to see. On the host, the scripts run as expected:
/usr/lib/check_mk_agent/local/check_node_sync.sh
OK - Node is in sync
The check_mk_agent also picks it up:
sudo check_mk_agent | grep -A 10 ‘^<<<local’
<<local:sep(0)>>
OK - Node is in sync
Thanks for your quick reply! So here’s a part of the script I’m running:
BLOCK_DIFF=$(($LATEST_BLOCK_HEIGHT - $LOCAL_BLOCK_HEIGHT))
THRESHOLD=10
if [ “$BLOCK_DIFF” -gt “$THRESHOLD” ]; then
echo “CRITICAL - Node is out of sync by $BLOCK_DIFF blocks”
exit 2
elif [ “$BLOCK_DIFF” -gt 0 ]; then
echo “WARNING - Node is out of sync by $BLOCK_DIFF blocks”
exit 1
else
echo “OK - Node is in sync”
exit 0
fi
How would you recommend I modify the output to be in an acceptable format for CheckMK?
Thanks for your reply. I’m not using Nagios at all. I just want CheckMK to pick up the values. I referred to the Local checks document and this is what my script looks like now:
if [ “$BLOCK_DIFF” -gt “$THRESHOLD” ]; then
echo “2 "Blockchain" - Node is out of sync by $BLOCK_DIFF blocks”
exit 2
elif [ “$BLOCK_DIFF” -gt 0 ]; then
echo “1 "Blockchain" - Node is out of sync by $BLOCK_DIFF blocks”
exit 1
else
echo “0 "Blockchain" - Node is in sync”
exit 0
fi
Here’s what the output looks like:
0 “Blockchain” - Node is in sync
sudo check_mk_agent | grep -A 10 ‘^<<<local’
<<local:sep(0)>>
0 “Blockchain” - Node is in sync
You must make a service discovery for that host. Because of your old check checkmk thought there was a check named - (just a minus/dash sign), but the actual name is Blockchain.
Also, let your script always do an exit 0, even in the WARN/CRIT cases. Any other value cause problems when the script runs asynchronously (say, every five minutes only or so). Exit values != 0 are used only if the script itself could not run properly (missing permissions or something like that).
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed. Contact an admin if you think this should be re-opened.