Created
December 23, 2013 14:10
-
-
Save tkhn/8097674 to your computer and use it in GitHub Desktop.
check redis replication lag
This file contains hidden or 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 | |
| # 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