#!/bin/bash
. $MUNIN_LIBDIR/plugins/plugin.sh
if [ "$1" = "autoconf" ]; then
echo yes
exit 0
fi
if [ "$1" = "config" ]; then
echo 'graph_title Nginx cache hit rat's
# echo 'graph_args --base 1000 -l 0'
echo 'graph_category nginx'
echo 'graph_vlabel Numbers'
echo 'hit.label hit'
echo 'miss.label miss'
echo 'graph_info numbers of HIT and MISS every five minutes'
exit
fi
log="/var/log/nginx/access.log"
allnumber=$(wc -l $log |awk '{print $1}')
#get time for 5 minute ago
ftime=$(date -d '5 minute ago' +"%Y:%H:%M" |head -n 1)
#get line number at specify time
startline=$(grep -no "$ftime" $log |head -n 1 |awk -F ":" '{print $1}')
liveline=$(($allnumber - $startline))
allline=$(tail -n $liveline $log)
#get result
echo "miss.value $(echo -e "$allline" |awk '{if ($NF=="cs=MISS") print "m"}' |wc -l |grep -o '[0-9].*')"
echo "hit.value $(echo -e "$allline" |awk '{if ($NF=="cs=HIT") print "h"}' |wc -l |grep -o '[0-9].*')"
munin plugin for proxy_cache by shell
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.