Created
July 16, 2015 23:28
-
-
Save gardenmwm/da0046a22d9ac3b06ccf to your computer and use it in GitHub Desktop.
Quick script for checking size of a redis queue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# nagios plugin check_redisqueue | |
# | |
# check size of redis queue, doesn't use option flags, so | |
# check_redisqueue <queuename> <warn> <crit> | |
# If you don't want graphite set below to 0 | |
#command vars | |
SENDTOGRAPHITE=1 | |
GRAPHITEHOST=localhost | |
GRAPHITEPORT=2003 | |
#nagios const | |
STATE_OK=0 | |
STATE_WARNING=1 | |
STATE_CRITICAL=2 | |
STATE_UNKNOWN=3 | |
#init, also usefull for testing | |
RETURN=$STATE_CRITICAL | |
OUTPUT="$0 executing with args $1 $2 $3 " | |
QUEUELENGTH=`redis-cli llen $1 | cut -f2` | |
if [[ $QUEUELENGTH -le $2 ]]; then | |
RETURN=$STATE_OK | |
OUTPUT="OK: $QUEUELENGTH" | |
elif [[ $QUELENGTH -le $3 ]]; then | |
RETURN=$STATE_WARNING | |
OUTPUT="WARNING: $QUEUELENGTH" | |
else | |
RETURN=$STATE_CRITICAL | |
OUTPUT="PROBLEM: Error" | |
fi | |
if [[ SENDTOGRAPHITE -eq 1 ]]; then | |
echo "services.redis.queue.$1.length $QUEUELENGTH `date +%s`" | nc ${GRAPHITEHOST} ${GRAPHITEPORT} | |
fi | |
#plugin output and return code | |
echo $OUTPUT | |
exit $RETURN |
davidlwillson
commented
Oct 20, 2015
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment