#!/bin/bashstat_ok=0stat_warning=1stat_critical=2stat_unknown=3rds= '/home/rediserver/bin/redis-cli ' stats= ' $rds info stats ']+/, "", "G", $ $)} "ho " $stats "| awk '/keyspace_hits/{print gensub (/[ a-z_:\n]+/, "", "G", $)} "echo " $stats "| awk '/keyspace_misses/{print gensub (/[a-z_:\n]+/," " , "G", "$"} "o " $stats "|awk '/expired_keys/{print gensub (/[a-z_:\nsummary=" keyspace_hits:$ Keyspace_hits keyspace_misses: $keyspace _misses expired_keys: $expired _keys " pmem=" Ps -eo pmem,rsz,comm,pcpu|grep redis-server ' eval $ (echo $pmem |awk ' {print "precent=" $ , "res=" $, "name=" $, "cpu=" $4} ') prec= ' echo $precent |awk ' {print int ($)} ' mem=$[ $res/1024] msg_ok= "memory ok - used: $precent%,${mem}mb,cpu: $cpu% $name | $ Summary "msg_warn=" memory warning - used: $precent%,${mem}mb,cpu: $cpu% $name | $summary "Msg_critiCal= "memory critical - used: $precent%,${mem}mb,cpu: $cpu% $name | $ Summary "if [ $prec -gt 90 ];then echo $msg _critical exit $STAT _criticalelif [ $ prec -gt 80 ];then echo $msg _warn exit $STAT _warningelse echo $msg _ok exit $STAT _OKFI
Monitoring the memory used by the Redis process