Skip to content

Instantly share code, notes, and snippets.

@tkhn
Created December 23, 2013 14:10
Show Gist options
  • Select an option

  • Save tkhn/8097674 to your computer and use it in GitHub Desktop.

Select an option

Save tkhn/8097674 to your computer and use it in GitHub Desktop.
check redis replication lag
#!/bin/bash
# defaults
warning=3
critical=5
while getopts "w:c:" OPTION
do
case $OPTION in
h)
usage
exit 1
;;
w)
warning=$OPTARG
;;
c)
critical=$OPTARG
;;
?)
usage
exit
;;
esac
done
master_last_io_seconds_ago=$( redis-cli info | grep master_last_io_seconds_ago | awk -F ":" '{print $2}' | sed -e s/\\r//g )
echo $master_last_io_seconds_ago
if [ "$master_last_io_seconds_ago" -gt "$critical" ] ; then echo "CRITICAL - redis replication lag is more that $critical sec."; exit 2;
elif [ "$master_last_io_seconds_ago" -lt "$warning" && "$master_last_io_seconds_ago" -gt "0" ] ; then echo "WARNING - redis replication lag is more that $warning sec." ; exit 1;
elif [ "$master_last_io_seconds_ago" -eq "0" ] ; then echo "OK - redis replication lag is 0."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment