summaryrefslogtreecommitdiffstats
path: root/roles/nagios_client/files/scripts/check_redis_queue.sh
blob: ca1f186e068fe595d8cc7870a07c7d50cc40c53c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/env bash

. /usr/lib64/nagios/plugins/utils.sh

if [[ "$#" -ne 3 ]]; then
  echo "Arguments: key warn crit"
  exit $STATE_UNKNOWN
fi

tasks="$(redis-cli llen "$1" | awk '{print $1}')"

check_range $tasks $2:$3
status=$?

if [[ "$status" == "$STATE_OK" ]]; then
  echo "OK: $1 queue has $tasks tasks"
elif [[ "$status" == "$STATE_WARNING" ]]; then
  echo "WARNING: $1 queue has $tasks tasks"
elif [[ "$status" == "$STATE_CRITICAL" ]]; then
  echo "CRITICAL: $1 queue has $tasks tasks"
fi

exit $status