Skip to content

Instantly share code, notes, and snippets.

@mms-gianni
Last active October 18, 2019 06:24
Show Gist options
  • Save mms-gianni/c2e0faa782a40c0092579518ee5a7a60 to your computer and use it in GitHub Desktop.
Save mms-gianni/c2e0faa782a40c0092579518ee5a7a60 to your computer and use it in GitHub Desktop.
Icinga/Nagios Moniroting plugin for gearman
#!/bin/bash
# example: ./check_gearman_workers.sh gearman-1 some:task 13 10
HOST=$1
JOB=$2
WARN=$3
CRIT=$4
WORKERS_LEFT=$((echo status ; sleep 0.1) | netcat $HOST 4730 -q1 | grep $JOB | awk '{ print $4-$3-$2}')
case $((
($WORKERS_LEFT > $WARN) * 1 +
($WORKERS_LEFT <= $WARN && $WORKERS_LEFT > $CRIT) * 2 +
($WORKERS_LEFT <= $CRIT) * 3)) in
(1) STATUS="OK"; EXITCODE=0;;
(2) STATUS="WARNING"; EXITCODE=1;;
(3) STATUS="CRITICAL"; EXITCODE=2;;
(0) STATUS="UKNOWN"; EXITCODE=3;;
esac
echo "$STATUS - $WORKERS_LEFT workers available in \"$JOB\""
exit $EXITCODE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment