Created
June 22, 2011 21:19
-
-
Save gcorrao/1041243 to your computer and use it in GitHub Desktop.
Script that takes varnish stats and writes out a log-like file
This file contains 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 -l | |
function get_stats { | |
( | |
echo "stats" | |
echo "" | |
sleep 1 | |
echo "quit" | |
) | telnet $1 6082 2>&1 | |
} | |
STATS=`get_stats $1` | |
V_HITS=`echo "$STATS" | grep "Cache hits" | grep -v "Cache hits for pass" | awk {'print $1'}` | |
V_PASS=`echo "$STATS" | grep "Cache hits for pass" | awk {'print $1'}` | |
V_MISS=`echo "$STATS" | grep "Cache miss" | awk {'print $1'}` | |
let V_TOTAL="$V_HITS+$V_MISS" | |
let V_RATIO="$V_HITS*100/$V_TOTAL" | |
echo "HITS= $V_HITS" | |
echo "MISS= $V_MISS" | |
echo "HIT_RATIO= $V_RATIO%" | |
echo "PASS= $V_PASS" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment