60s) on $hostname\" "; $def[$defcnt] = ""; $def[$defcnt] .= "DEF:longrun=$RRDFILE[$i]:$DS[$i]:AVERAGE:reduce=LAST " ; $def[$defcnt] .= "AREA:longrun#111111 "; $def[$defcnt] .= "VDEF:vlongrun=longrun,LAST " ; $def[$defcnt] .= "GPRINT:vlongrun:\"%.0lf long running processes \" " ; $defcnt++; } if(preg_match('/^keycache_hitrate_now$/', $NAME[$i])) { $ds_name[$defcnt] = "MyISAM key cache hitrate"; $opt[$defcnt] = "--vertical-label \"Percent\" --title \"MyISAM key cache hitrate on $hostname\" --upper-limit 100 --lower-limit 0 "; $def[$defcnt] = ""; for ($ii = 1; $ii <= $ds_count; $ii++) { if(preg_match('/^keycache_hitrate$/', $NAME[$ii])) { $def[$defcnt] .= "DEF:hitrate=$RRDFILE[$ii]:$DS[$ii]:AVERAGE:reduce=LAST " ; $def[$defcnt] .= "CDEF:ar=hitrate,$CRIT_MIN[$ii],LE,hitrate,0,GT,INF,UNKN,IF,UNKN,IF,ISINF,hitrate,0,IF "; $def[$defcnt] .= "CDEF:ay=hitrate,$WARN_MIN[$ii],LE,hitrate,$CRIT_MIN[$ii],GT,INF,UNKN,IF,UNKN,IF,ISINF,hitrate,0,IF "; $def[$defcnt] .= "CDEF:ag=hitrate,100,LE,hitrate,$WARN_MIN[$ii],GT,INF,UNKN,IF,UNKN,IF,ISINF,hitrate,0,IF "; $def[$defcnt] .= "AREA:ag#$green: " ; $def[$defcnt] .= "AREA:ay#$yellow: " ; $def[$defcnt] .= "AREA:ar#$red: " ; $def[$defcnt] .= "LINE1.5:hitrate#111111:\" \" "; $def[$defcnt] .= "VDEF:vhitrate=hitrate,LAST " ; $def[$defcnt] .= "GPRINT:vhitrate:\"Hitratio (since epoch) is %3.2lf percent \\n\" "; } if(preg_match('/^keycache_hitrate_now$/', $NAME[$ii])) { $def[$defcnt] .= "DEF:hitratenow=$RRDFILE[$ii]:$DS[$ii]:AVERAGE:reduce=LAST " ; $def[$defcnt] .= "LINE1.5:hitratenow#$now:\" \" "; $def[$defcnt] .= "VDEF:vhitratenow=hitratenow,LAST " ; $def[$defcnt] .= "GPRINT:vhitratenow:\"Hitratio (current) is %3.2lf percent \\n\" "; } } $defcnt++; } if(preg_match('/^qcache_hitrate_now$/', $NAME[$i])) { $ds_name[$defcnt] = "Query cache hitrate"; $opt[$defcnt] = "--vertical-label \"Percent\" --title \"Query cache hitrate on $hostname\" --upper-limit 100 --lower-limit 0 "; $def[$defcnt] = ""; for ($ii = 1; $ii <= $ds_count; $ii++) { if(preg_match('/^qcache_hitrate$/', $NAME[$ii])) { $def[$defcnt] .= "DEF:hitrate=$RRDFILE[$ii]:$DS[$ii]:AVERAGE:reduce=LAST " ; $def[$defcnt] .= "CDEF:ar=hitrate,$CRIT_MIN[$ii],LE,hitrate,0,GT,INF,UNKN,IF,UNKN,IF,ISINF,hitrate,0,IF "; $def[$defcnt] .= "CDEF:ay=hitrate,$WARN_MIN[$ii],LE,hitrate,$CRIT_MIN[$ii],GT,INF,UNKN,IF,UNKN,IF,ISINF,hitrate,0,IF "; $def[$defcnt] .= "CDEF:ag=hitrate,100,LE,hitrate,$WARN_MIN[$ii],GT,INF,UNKN,IF,UNKN,IF,ISINF,hitrate,0,IF "; $def[$defcnt] .= "AREA:ag#$green: " ; $def[$defcnt] .= "AREA:ay#$yellow: " ; $def[$defcnt] .= "AREA:ar#$red: " ; $def[$defcnt] .= "LINE1.5:hitrate#111111:\" \" "; $def[$defcnt] .= "VDEF:vhitrate=hitrate,LAST " ; $def[$defcnt] .= "GPRINT:vhitrate:\"Hitratio (since epoch) is %3.2lf percent \\n\" "; } if(preg_match('/^qcache_hitrate_now$/', $NAME[$ii])) { $def[$defcnt] .= "DEF:hitratenow=$RRDFILE[$ii]:$DS[$ii]:AVERAGE:reduce=LAST " ; $def[$defcnt] .= "LINE1.5:hitratenow#$now:\" \" "; $def[$defcnt] .= "VDEF:vhitratenow=hitratenow,LAST " ; $def[$defcnt] .= "GPRINT:vhitratenow:\"Hitratio (current) is %3.2lf percent \\n\" "; } } $defcnt++; $ds_name[$defcnt] = "Selects per second"; $opt[$defcnt] = "--vertical-label \"Selects / sec\" --title \"Selects per second on $hostname\" "; $def[$defcnt] = ""; for ($ii = 1; $ii <= $ds_count; $ii++) { if(preg_match('/^selects_per_sec$/', $NAME[$ii])) { $def[$defcnt] .= "DEF:sps=$RRDFILE[$ii]:$DS[$ii]:AVERAGE:reduce=LAST " ; $def[$defcnt] .= "AREA:sps#$now:\" \" "; $def[$defcnt] .= "VDEF:vsps=sps,LAST " ; $def[$defcnt] .= "GPRINT:vsps:\"%3.2lf Selects per second \\n\" "; } } $defcnt++; } if(preg_match('/^qcache_lowmem_prunes_rate$/', $NAME[$i])) { $ds_name[$defcnt] = "Query cache low memory prunes"; $opt[$defcnt] = "--vertical-label \"Prunes / sec\" --title \"Query cache low mem prunes on $hostname\" "; $def[$defcnt] = ""; $def[$defcnt] .= "DEF:prunes=$RRDFILE[$i]:$DS[$i]:AVERAGE:reduce=LAST " ; $def[$defcnt] .= "AREA:prunes#111111 "; $def[$defcnt] .= "VDEF:vprunes=prunes,LAST " ; $def[$defcnt] .= "GPRINT:vprunes:\"Rate is %3.2lf Prunes / Second \" " ; $defcnt++; } if(preg_match('/^slow_queries_rate$/', $NAME[$i])) { $ds_name[$defcnt] = "Slow query rate"; $opt[$defcnt] = "--vertical-label \"Slow queries / sec\" --title \"Slow queries on $hostname\" "; $def[$defcnt] = ""; $def[$defcnt] .= "DEF:prunes=$RRDFILE[$i]:$DS[$i]:AVERAGE:reduce=LAST " ; $def[$defcnt] .= "AREA:prunes#111111 "; $def[$defcnt] .= "VDEF:vprunes=prunes,LAST " ; $def[$defcnt] .= "GPRINT:vprunes:\"%3.2lf Slow queries / Second \" " ; $defcnt++; } if(preg_match('/^tablelock_contention_now$/', $NAME[$i])) { $ds_name[$defcnt] = "Table lock contention"; # set upper limit to 10, because 3 means an already dead database $opt[$defcnt] = "--vertical-label \"Percent\" --title \"Table lock contention on $hostname\" --upper-limit 10 --lower-limit 0 "; $def[$defcnt] = ""; for ($ii = 1; $ii <= $ds_count; $ii++) { if(preg_match('/^tablelock_contention$/', $NAME[$ii])) { $def[$defcnt] .= "DEF:tbllckcont=$RRDFILE[$ii]:$DS[$ii]:AVERAGE:reduce=LAST " ; $def[$defcnt] .= "CDEF:ag=tbllckcont,$WARN[$ii],LE,tbllckcont,0,GT,INF,UNKN,IF,UNKN,IF,ISINF,tbllckcont,0,IF "; $def[$defcnt] .= "CDEF:ay=tbllckcont,$CRIT[$ii],LE,tbllckcont,$WARN[$ii],GT,INF,UNKN,IF,UNKN,IF,ISINF,tbllckcont,0,IF "; $def[$defcnt] .= "CDEF:ar=tbllckcont,100,LE,tbllckcont,$CRIT[$ii],GT,INF,UNKN,IF,UNKN,IF,ISINF,tbllckcont,0,IF "; $def[$defcnt] .= "AREA:ag#$green: " ; $def[$defcnt] .= "AREA:ay#$yellow: " ; $def[$defcnt] .= "AREA:ar#$red: " ; $def[$defcnt] .= "LINE:tbllckcont#111111:\" \" "; $def[$defcnt] .= "VDEF:vtbllckcont=tbllckcont,LAST " ; $def[$defcnt] .= "GPRINT:vtbllckcont:\"Lock contention (since epoch) is %3.2lf%%\\n\" " ; } if(preg_match('/^tablelock_contention_now$/', $NAME[$ii])) { $def[$defcnt] .= "DEF:tbllckcontnow=$RRDFILE[$ii]:$DS[$ii]:AVERAGE:reduce=LAST " ; $def[$defcnt] .= "LINE1.5:tbllckcontnow#$now:\" \" "; $def[$defcnt] .= "VDEF:vtbllckcontnow=tbllckcontnow,LAST " ; $def[$defcnt] .= "GPRINT:vtbllckcontnow:\"Lock contention (current) is %3.2lf%%\" "; } } $defcnt++; } if(preg_match('/^tablecache_fillrate$/', $NAME[$i])) { $ds_name[$defcnt] = "Table cache hitrate"; $opt[$defcnt] = "--vertical-label \"Percent\" --title \"Table cache hitrate on $hostname\" --upper-limit 100 --lower-limit 0 "; $def[$defcnt] = ""; for ($ii = 1; $ii <= $ds_count; $ii++) { if(preg_match('/^tablecache_hitrate$/', $NAME[$ii])) { $def[$defcnt] .= "DEF:hitrate=$RRDFILE[$ii]:$DS[$ii]:AVERAGE:reduce=LAST " ; $def[$defcnt] .= "CDEF:ar=hitrate,$CRIT_MIN[$ii],LE,hitrate,0,GT,INF,UNKN,IF,UNKN,IF,ISINF,hitrate,0,IF "; $def[$defcnt] .= "CDEF:ay=hitrate,$WARN_MIN[$ii],LE,hitrate,$CRIT_MIN[$ii],GT,INF,UNKN,IF,UNKN,IF,ISINF,hitrate,0,IF "; $def[$defcnt] .= "CDEF:ag=hitrate,100,LE,hitrate,$WARN_MIN[$ii],GT,INF,UNKN,IF,UNKN,IF,ISINF,hitrate,0,IF "; $def[$defcnt] .= "AREA:ag#$green: " ; $def[$defcnt] .= "AREA:ay#$yellow: " ; $def[$defcnt] .= "AREA:ar#$red: " ; $def[$defcnt] .= "LINE:hitrate#111111:\" \" "; $def[$defcnt] .= "VDEF:vhitrate=hitrate,LAST " ; $def[$defcnt] .= "GPRINT:vhitrate:\"Hitratio is %3.2lf percent \\n\" "; } if(preg_match('/^tablecache_fillrate$/', $NAME[$ii])) { $def[$defcnt] .= "DEF:hitratenow=$RRDFILE[$ii]:$DS[$ii]:AVERAGE:reduce=LAST " ; $def[$defcnt] .= "LINE1.5:hitratenow#$now:\" \" "; $def[$defcnt] .= "VDEF:vhitratenow=hitratenow,LAST " ; $def[$defcnt] .= "GPRINT:vhitratenow:\"%3.2lf%% of the cache is filled \\n\" "; } } $defcnt++; } if(preg_match('/^pct_tmp_table_on_disk_now$/', $NAME[$i])) { $ds_name[$defcnt] = "Temporary tables created on disk "; $opt[$defcnt] = "--vertical-label \"Percent\" --title \"Temporary tables created on disk on $hostname\" --upper-limit 10 --lower-limit 0 "; $def[$defcnt] = ""; for ($ii = 1; $ii <= $ds_count; $ii++) { if(preg_match('/^pct_tmp_table_on_disk$/', $NAME[$ii])) { $def[$defcnt] .= "DEF:tmptbldsk=$RRDFILE[$ii]:$DS[$ii]:AVERAGE:reduce=LAST " ; $def[$defcnt] .= "CDEF:ag=tmptbldsk,$WARN[$ii],LE,tmptbldsk,0,GT,INF,UNKN,IF,UNKN,IF,ISINF,tmptbldsk,0,IF "; $def[$defcnt] .= "CDEF:ay=tmptbldsk,$CRIT[$ii],LE,tmptbldsk,$WARN[$ii],GT,INF,UNKN,IF,UNKN,IF,ISINF,tmptbldsk,0,IF "; $def[$defcnt] .= "CDEF:ar=tmptbldsk,100,LE,tmptbldsk,$CRIT[$ii],GT,INF,UNKN,IF,UNKN,IF,ISINF,tmptbldsk,0,IF "; $def[$defcnt] .= "AREA:ag#$green: " ; $def[$defcnt] .= "AREA:ay#$yellow: " ; $def[$defcnt] .= "AREA:ar#$red: " ; $def[$defcnt] .= "LINE:tmptbldsk#111111:\" \" "; $def[$defcnt] .= "VDEF:vtmptbldsk=tmptbldsk,LAST " ; $def[$defcnt] .= "GPRINT:vtmptbldsk:\"%3.2lf percent of temp tables were created on disk (since epoch)\\n\" " ; } if(preg_match('/^pct_tmp_table_on_disk_now$/', $NAME[$ii])) { $def[$defcnt] .= "DEF:tmptbldsknow=$RRDFILE[$ii]:$DS[$ii]:AVERAGE:reduce=LAST " ; $def[$defcnt] .= "LINE1.5:tmptbldsknow#$now:\" \" "; $def[$defcnt] .= "VDEF:vtmptbldsknow=tmptbldsknow,LAST " ; $def[$defcnt] .= "GPRINT:vtmptbldsknow:\"%3.2lf percent of temp tables were created on disk (recently)\\n\" " ; } } $defcnt++; } if(preg_match('/^thread_cache_hitrate_now$/', $NAME[$i])) { $ds_name[$defcnt] = "Thread cache hitrate"; $opt[$defcnt] = "--vertical-label \"Percent\" --title \"Thread cache hitrate on $hostname\" --upper-limit 100 --lower-limit 0 "; $def[$defcnt] = ""; for ($ii = 1; $ii <= $ds_count; $ii++) { if(preg_match('/^thread_cache_hitrate$/', $NAME[$ii])) { $def[$defcnt] .= "DEF:hitrate=$RRDFILE[$ii]:$DS[$ii]:AVERAGE:reduce=LAST " ; $def[$defcnt] .= "CDEF:ar=hitrate,$CRIT_MIN[$ii],LE,hitrate,0,GT,INF,UNKN,IF,UNKN,IF,ISINF,hitrate,0,IF "; $def[$defcnt] .= "CDEF:ay=hitrate,$WARN_MIN[$ii],LE,hitrate,$CRIT_MIN[$ii],GT,INF,UNKN,IF,UNKN,IF,ISINF,hitrate,0,IF "; $def[$defcnt] .= "CDEF:ag=hitrate,100,LE,hitrate,$WARN_MIN[$ii],GT,INF,UNKN,IF,UNKN,IF,ISINF,hitrate,0,IF "; $def[$defcnt] .= "AREA:ag#$green: " ; $def[$defcnt] .= "AREA:ay#$yellow: " ; $def[$defcnt] .= "AREA:ar#$red: " ; $def[$defcnt] .= "LINE:hitrate#111111:\" \" "; $def[$defcnt] .= "VDEF:vhitrate=hitrate,LAST " ; $def[$defcnt] .= "GPRINT:vhitrate:\"Hitratio (since epoch) is %3.2lf percent \\n\" "; } if(preg_match('/^thread_cache_hitrate_now$/', $NAME[$ii])) { $def[$defcnt] .= "DEF:hitratenow=$RRDFILE[$ii]:$DS[$ii]:AVERAGE:reduce=LAST " ; $def[$defcnt] .= "LINE1.5:hitratenow#$now:\" \" "; $def[$defcnt] .= "VDEF:vhitratenow=hitratenow,LAST " ; $def[$defcnt] .= "GPRINT:vhitratenow:\"Hitratio (current) is %3.2lf percent \\n\" "; } } $defcnt++; $ds_name[$defcnt] = "Connects per second"; $opt[$defcnt] = "--vertical-label \"Conects / sec\" --title \"Connects per second on $hostname\" "; $def[$defcnt] = ""; for ($ii = 1; $ii <= $ds_count; $ii++) { if(preg_match('/^connections_per_sec$/', $NAME[$ii])) { $def[$defcnt] .= "DEF:sps=$RRDFILE[$ii]:$DS[$ii]:AVERAGE:reduce=LAST " ; $def[$defcnt] .= "AREA:sps#$now:\" \" "; $def[$defcnt] .= "VDEF:vsps=sps,LAST " ; $def[$defcnt] .= "GPRINT:vsps:\"%3.2lf Connects per second \\n\" "; } } $defcnt++; } if(preg_match('/^threads_connected$/', $NAME[$i])) { $ds_name[$defcnt] = "Connection threads"; $opt[$defcnt] = "--vertical-label \"Threads\" --title \"Connection threads on $hostname\" "; $def[$defcnt] = ""; $def[$defcnt] .= "DEF:threads=$RRDFILE[$i]:$DS[$i]:AVERAGE:reduce=LAST " ; $def[$defcnt] .= "AREA:threads#111111 "; $def[$defcnt] .= "VDEF:vthreads=threads,LAST " ; $def[$defcnt] .= "GPRINT:vthreads:\"%.0lf Connection threads \" " ; $defcnt++; } } ?>