]>
git.immae.eu Git - perso/Immae/Config/Nix.git/blob - modules/private/monitoring/plugins/check_redis_replication
10 info
=$(redis-cli -s $socket info replication)
11 lag
=$(echo "$info" | grep master_last_io_seconds_ago | cut -d":" -f2 | sed -e "s/\s//g")
12 slave_offset
=$(echo "$info" | grep slave_repl_offset | cut -d":" -f2 | sed -e "s/\s//g")
13 master_offset
=$(echo "$info" | grep master_repl_offset | cut -d":" -f2 | sed -e "s/\s//g")
14 offset
=$(($master_offset - $slave_offset))
18 if [[ $exit_code -ne 0 ]]; then
19 echo "UNKNOWN - Impossible to run redis command"
21 elif [[ -z "$lag" ]]; then
22 echo "UNKNOWN - No replication found"
25 output
="Replication lag for redis is ${lag}s and offset is ${offset}"
26 LC_ALL
=C lag
=$(printf "%.*f" 0 $lag)
28 if [[ $lag -lt 5 && $offset -lt 5 ]]; then
31 elif [[ $lag -lt 10 && $offset -lt 10 ]]; then
32 echo "WARNING - $output"
35 echo "CRITICAL - $output"