Munin Query Cache Graphing

March 24th, 2009

Here's a Munin template for graphing effectiveness of MySQL's inbuilt query cache. I'll submit it to MuninExchange once I get a day's worth of traffic to upload a picture of the output graph. Blog readers get a live sample:

IFS=`echo -en "\n\b"`
QUERY=$(mysql --skip-column-names --batch -e "SHOW STATUS LIKE \"Qcache_%\"" | egrep "(Qcache_hits|Qcache_inserts|Qcache_lowmem_prunes)" 2>/dev/null)
case "$1" in
        [ -n "$QUERY" ] && echo yes && exit
        echo no && exit 1
        echo graph_title Mysql query cache hitrate
        echo graph_vlabel hits
        echo graph_args --base 1000
        echo graph_category mysql
        echo Qcache_hits.label Cache hits
        echo Qcache_hits.type DERIVE
        echo Qcache_hits.min 0
        echo Qcache_hits.draw LINE2
        echo Qcache_inserts.label Cache misses/inserts
        echo Qcache_inserts.type DERIVE
        echo Qcache_inserts.min 0
        echo Qcache_inserts.draw LINE2
        echo Qcache_lowmem_prunes.label Cache drops
        echo Qcache_lowmem_prunes.type DERIVE
        echo Qcache_lowmem_prunes.min 0
        echo Qcache_lowmem_prunes.draw LINE2
        for LINE in $(mysql --skip-column-names --batch -e "SHOW STATUS LIKE 'Qcache_%'" | egrep "(Qcache_hits|Qcache_inserts|Qcache_lowmem_prunes)") ; do
                echo `echo $LINE | cut -f1`.value `echo $LINE | cut -f2`

Comments are closed.