| 1 |
<?php |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
$defcnt = 1; |
| 11 |
|
| 12 |
$green = "33FF00E0"; |
| 13 |
$yellow = "FFFF00E0"; |
| 14 |
$red = "F83838E0"; |
| 15 |
$now = "FF00FF"; |
| 16 |
$ds_count = count($DS); |
| 17 |
|
| 18 |
for ($i = 1; $i <= $ds_count; $i++) { |
| 19 |
$warning = ($WARN[$i] != "") ? $WARN[$i] : ""; |
| 20 |
$warnmin = ($WARN_MIN[$i] != "") ? $WARN_MIN[$i] : ""; |
| 21 |
$warnmax = ($WARN_MAX[$i] != "") ? $WARN_MAX[$i] : ""; |
| 22 |
$critical = ($CRIT[$i] != "") ? $CRIT[$i] : ""; |
| 23 |
$critmin = ($CRIT_MIN[$i] != "") ? $CRIT_MIN[$i] : ""; |
| 24 |
$critmax = ($CRIT_MAX[$i] != "") ? $CRIT_MAX[$i] : ""; |
| 25 |
$minimum = ($MIN[$i] != "") ? $MIN[$i] : ""; |
| 26 |
$maximum = ($MAX[$i] != "") ? $MAX[$i] : ""; |
| 27 |
|
| 28 |
if(preg_match('/^pct_open_files$/', $NAME[$i])) { |
| 29 |
$ds_name[$defcnt] = "Open Files Usage"; |
| 30 |
$opt[$defcnt] = "--vertical-label \"Percent\" --title \"Open files usage on $hostname\" --upper-limit 100 --lower-limit 0"; |
| 31 |
$def[$defcnt] = ""; |
| 32 |
$def[$defcnt] .= "DEF:openfiles_pct=$RRDFILE[$i]:$DS[$i]:AVERAGE:reduce=LAST " ; |
| 33 |
$def[$defcnt] .= "AREA:openfiles_pct#111111:\" \" "; |
| 34 |
$def[$defcnt] .= "VDEF:vopenfiles=openfiles_pct,LAST " ; |
| 35 |
$def[$defcnt] .= "GPRINT:vopenfiles:\"Open files usage is %3.2lf percent\\n\" " ; |
| 36 |
$defcnt++; |
| 37 |
} |
| 38 |
if(preg_match('/^connects_aborted_per_sec$/', $NAME[$i])) { |
| 39 |
$ds_name[$defcnt] = "Aborted connections per second"; |
| 40 |
$opt[$defcnt] = "--vertical-label \"Seconds\" --title \"Aborted connections per second on $hostname\" "; |
| 41 |
$def[$defcnt] = ""; |
| 42 |
$def[$defcnt] .= "DEF:aborted_conn=$RRDFILE[$i]:$DS[$i]:AVERAGE:reduce=LAST " ; |
| 43 |
$def[$defcnt] .= "AREA:aborted_conn#444444:\" \" "; |
| 44 |
$def[$defcnt] .= "VDEF:vaborted_conn=aborted_conn,LAST " ; |
| 45 |
$def[$defcnt] .= "GPRINT:vaborted_conn:\"Aborted connections per sec is %3.2lf \\n\" " ; |
| 46 |
$defcnt++; |
| 47 |
} |
| 48 |
if(preg_match('/^connection_time$/', $NAME[$i])) { |
| 49 |
$ds_name[$defcnt] = "Time to connect"; |
| 50 |
$opt[$defcnt] = "--vertical-label \"Seconds\" --title \"Time to establish a connection to $hostname\" "; |
| 51 |
$def[$defcnt] = ""; |
| 52 |
$def[$defcnt] .= "DEF:connectiontime=$RRDFILE[$i]:$DS[$i]:AVERAGE:reduce=LAST " ; |
| 53 |
$def[$defcnt] .= "AREA:connectiontime#111111 "; |
| 54 |
$def[$defcnt] .= "VDEF:vconnetiontime=connectiontime,LAST " ; |
| 55 |
$def[$defcnt] .= "GPRINT:vconnetiontime:\"is %3.2lf Seconds \" " ; |
| 56 |
$defcnt++; |
| 57 |
} |
| 58 |
if(preg_match('/^uptime$/', $NAME[$i])) { |
| 59 |
$ds_name[$defcnt] = "Uptime"; |
| 60 |
$opt[$defcnt] = "--vertical-label \"Seconds\" --title \"Uptime of the database at $hostname\" "; |
| 61 |
$def[$defcnt] = ""; |
| 62 |
$def[$defcnt] .= "DEF:uptime=$RRDFILE[$i]:$DS[$i]:AVERAGE:reduce=LAST " ; |
| 63 |
$def[$defcnt] .= "AREA:uptime#111111 "; |
| 64 |
$def[$defcnt] .= "CDEF:uptimed=uptime,86400,/ " ; |
| 65 |
$def[$defcnt] .= "CDEF:uptimew=uptimed,7,/ " ; |
| 66 |
$def[$defcnt] .= "VDEF:vuptime=uptime,LAST " ; |
| 67 |
$def[$defcnt] .= "VDEF:vuptimed=uptimed,LAST " ; |
| 68 |
$def[$defcnt] .= "VDEF:vuptimew=uptimew,LAST " ; |
| 69 |
$def[$defcnt] .= "GPRINT:vuptime:\"%.0lf Seconds \" " ; |
| 70 |
$def[$defcnt] .= "GPRINT:vuptimed:\"%.0lf Days \" " ; |
| 71 |
$def[$defcnt] .= "GPRINT:vuptimew:\"%.0lf Weeks \" " ; |
| 72 |
$defcnt++; |
| 73 |
} |
| 74 |
if(preg_match('/^index_usage_now$/', $NAME[$i])) { |
| 75 |
$ds_name[$defcnt] = "Index usage"; |
| 76 |
$opt[$defcnt] = "--vertical-label \"Percent\" --title \"Index usage $hostname\" --upper-limit 100 --lower-limit 0 "; |
| 77 |
$def[$defcnt] = ""; |
| 78 |
for ($ii = 1; $ii <= $ds_count; $ii++) { |
| 79 |
if(preg_match('/^index_usage$/', $NAME[$ii])) { |
| 80 |
$def[$defcnt] .= "DEF:indexusage=$RRDFILE[$ii]:$DS[$ii]:AVERAGE:reduce=LAST " ; |
| 81 |
$def[$defcnt] .= "CDEF:ar=indexusage,$CRIT_MIN[$ii],LE,indexusage,0,GT,INF,UNKN,IF,UNKN,IF,ISINF,indexusage,0,IF "; |
| 82 |
$def[$defcnt] .= "CDEF:ay=indexusage,$WARN_MIN[$ii],LE,indexusage,$CRIT_MIN[$ii],GT,INF,UNKN,IF,UNKN,IF,ISINF,indexusage,0,IF "; |
| 83 |
$def[$defcnt] .= "CDEF:ag=indexusage,100,LE,indexusage,$WARN_MIN[$ii],GT,INF,UNKN,IF,UNKN,IF,ISINF,indexusage,0,IF "; |
| 84 |
$def[$defcnt] .= "AREA:ag#$green: " ; |
| 85 |
$def[$defcnt] .= "AREA:ay#$yellow: " ; |
| 86 |
$def[$defcnt] .= "AREA:ar#$red: " ; |
| 87 |
$def[$defcnt] .= "LINE:indexusage#111111:\" \" "; |
| 88 |
$def[$defcnt] .= "VDEF:vindexusage=indexusage,LAST " ; |
| 89 |
$def[$defcnt] .= "GPRINT:vindexusage:\"Index usage (since epoch) is %3.2lf percent\\n\" " ; |
| 90 |
} |
| 91 |
if(preg_match('/^index_usage_now$/', $NAME[$ii])) { |
| 92 |
$def[$defcnt] .= "DEF:indexusagenow=$RRDFILE[$ii]:$DS[$ii]:AVERAGE:reduce=LAST " ; |
| 93 |
$def[$defcnt] .= "LINE1.5:indexusagenow#$now:\" \" "; |
| 94 |
$def[$defcnt] .= "VDEF:vindexusagenow=indexusagenow,LAST " ; |
| 95 |
$def[$defcnt] .= "GPRINT:vindexusagenow:\"Index usage (current) is %3.2lf percent\\n\" "; |
| 96 |
} |
| 97 |
} |
| 98 |
$defcnt++; |
| 99 |
} |
| 100 |
if(preg_match('/^bufferpool_hitrate_now$/', $NAME[$i])) { |
| 101 |
$ds_name[$defcnt] = "Innodb buffer pool hitrate"; |
| 102 |
$opt[$defcnt] = "--vertical-label \"Percent\" --title \"Innodb buffer pool hitrate on $hostname\" --upper-limit 100 --lower-limit 0 "; |
| 103 |
$def[$defcnt] = ""; |
| 104 |
for ($ii = 1; $ii <= $ds_count; $ii++) { |
| 105 |
if(preg_match('/^bufferpool_hitrate$/', $NAME[$ii])) { |
| 106 |
$def[$defcnt] .= "DEF:hitrate=$RRDFILE[$ii]:$DS[$ii]:AVERAGE:reduce=LAST " ; |
| 107 |
$def[$defcnt] .= "CDEF:ar=hitrate,$CRIT_MIN[$ii],LE,hitrate,0,GT,INF,UNKN,IF,UNKN,IF,ISINF,hitrate,0,IF "; |
| 108 |
$def[$defcnt] .= "CDEF:ay=hitrate,$WARN_MIN[$ii],LE,hitrate,$CRIT_MIN[$ii],GT,INF,UNKN,IF,UNKN,IF,ISINF,hitrate,0,IF "; |
| 109 |
$def[$defcnt] .= "CDEF:ag=hitrate,100,LE,hitrate,$WARN_MIN[$ii],GT,INF,UNKN,IF,UNKN,IF,ISINF,hitrate,0,IF "; |
| 110 |
$def[$defcnt] .= "AREA:ag#$green: " ; |
| 111 |
$def[$defcnt] .= "AREA:ay#$yellow: " ; |
| 112 |
$def[$defcnt] .= "AREA:ar#$red: " ; |
| 113 |
$def[$defcnt] .= "LINE1.5:hitrate#111111:\" \" "; |
| 114 |
$def[$defcnt] .= "VDEF:vhitrate=hitrate,LAST " ; |
| 115 |
$def[$defcnt] .= "GPRINT:vhitrate:\"Hitratio (since epoch) is %3.2lf percent \\n\" "; |
| 116 |
} |
| 117 |
if(preg_match('/^bufferpool_hitrate_now$/', $NAME[$ii])) { |
| 118 |
$def[$defcnt] .= "DEF:hitratenow=$RRDFILE[$ii]:$DS[$ii]:AVERAGE:reduce=LAST " ; |
| 119 |
$def[$defcnt] .= "LINE1.5:hitratenow#$now:\" \" "; |
| 120 |
$def[$defcnt] .= "VDEF:vhitratenow=hitratenow,LAST " ; |
| 121 |
$def[$defcnt] .= "GPRINT:vhitratenow:\"Hitratio (current) is %3.2lf percent \\n\" "; |
| 122 |
} |
| 123 |
} |
| 124 |
$defcnt++; |
| 125 |
} |
| 126 |
if(preg_match('/^bufferpool_free_waits_rate$/', $NAME[$i])) { |
| 127 |
$ds_name[$defcnt] = "Innodb buffer pool waits rate"; |
| 128 |
$opt[$defcnt] = "--vertical-label \"Waits/sec\" --title \"Innodb buffer pool waits on $hostname\" "; |
| 129 |
$def[$defcnt] = ""; |
| 130 |
$def[$defcnt] .= "DEF:logwait=$RRDFILE[$i]:$DS[$i]:AVERAGE:reduce=LAST " ; |
| 131 |
$def[$defcnt] .= "AREA:logwait#111111 "; |
| 132 |
$def[$defcnt] .= "VDEF:vlogwait=logwait,LAST " ; |
| 133 |
$def[$defcnt] .= "GPRINT:vlogwait:\"Rate is %3.2lf Waits / Second \" " ; |
| 134 |
$defcnt++; |
| 135 |
} |
| 136 |
if(preg_match('/^innodb_log_waits_rate$/', $NAME[$i])) { |
| 137 |
$ds_name[$defcnt] = "Innodb log buffer waits rate"; |
| 138 |
$opt[$defcnt] = "--vertical-label \"Waits/sec\" --title \"Innodb waits for log buffer $hostname\" "; |
| 139 |
$def[$defcnt] = ""; |
| 140 |
$def[$defcnt] .= "DEF:logwait=$RRDFILE[$i]:$DS[$i]:AVERAGE:reduce=LAST " ; |
| 141 |
$def[$defcnt] .= "AREA:logwait#111111 "; |
| 142 |
$def[$defcnt] .= "VDEF:vlogwait=logwait,LAST " ; |
| 143 |
$def[$defcnt] .= "GPRINT:vlogwait:\"Rate is %3.2lf Waits / Second \" " ; |
| 144 |
$defcnt++; |
| 145 |
} |
| 146 |
if(preg_match('/^long_running_procs$/', $NAME[$i])) { |
| 147 |
$ds_name[$defcnt] = "Long running processes"; |
| 148 |
$opt[$defcnt] = "--vertical-label \"Processes\" --title \"Long running processes (>60s) on $hostname\" "; |
| 149 |
$def[$defcnt] = ""; |
| 150 |
$def[$defcnt] .= "DEF:longrun=$RRDFILE[$i]:$DS[$i]:AVERAGE:reduce=LAST " ; |
| 151 |
$def[$defcnt] .= "AREA:longrun#111111 "; |
| 152 |
$def[$defcnt] .= "VDEF:vlongrun=longrun,LAST " ; |
| 153 |
$def[$defcnt] .= "GPRINT:vlongrun:\"%.0lf long running processes \" " ; |
| 154 |
$defcnt++; |
| 155 |
} |
| 156 |
if(preg_match('/^keycache_hitrate_now$/', $NAME[$i])) { |
| 157 |
$ds_name[$defcnt] = "MyISAM key cache hitrate"; |
| 158 |
$opt[$defcnt] = "--vertical-label \"Percent\" --title \"MyISAM key cache hitrate on $hostname\" --upper-limit 100 --lower-limit 0 "; |
| 159 |
$def[$defcnt] = ""; |
| 160 |
for ($ii = 1; $ii <= $ds_count; $ii++) { |
| 161 |
if(preg_match('/^keycache_hitrate$/', $NAME[$ii])) { |
| 162 |
$def[$defcnt] .= "DEF:hitrate=$RRDFILE[$ii]:$DS[$ii]:AVERAGE:reduce=LAST " ; |
| 163 |
$def[$defcnt] .= "CDEF:ar=hitrate,$CRIT_MIN[$ii],LE,hitrate,0,GT,INF,UNKN,IF,UNKN,IF,ISINF,hitrate,0,IF "; |
| 164 |
$def[$defcnt] .= "CDEF:ay=hitrate,$WARN_MIN[$ii],LE,hitrate,$CRIT_MIN[$ii],GT,INF,UNKN,IF,UNKN,IF,ISINF,hitrate,0,IF "; |
| 165 |
$def[$defcnt] .= "CDEF:ag=hitrate,100,LE,hitrate,$WARN_MIN[$ii],GT,INF,UNKN,IF,UNKN,IF,ISINF,hitrate,0,IF "; |
| 166 |
$def[$defcnt] .= "AREA:ag#$green: " ; |
| 167 |
$def[$defcnt] .= "AREA:ay#$yellow: " ; |
| 168 |
$def[$defcnt] .= "AREA:ar#$red: " ; |
| 169 |
$def[$defcnt] .= "LINE1.5:hitrate#111111:\" \" "; |
| 170 |
$def[$defcnt] .= "VDEF:vhitrate=hitrate,LAST " ; |
| 171 |
$def[$defcnt] .= "GPRINT:vhitrate:\"Hitratio (since epoch) is %3.2lf percent \\n\" "; |
| 172 |
} |
| 173 |
if(preg_match('/^keycache_hitrate_now$/', $NAME[$ii])) { |
| 174 |
$def[$defcnt] .= "DEF:hitratenow=$RRDFILE[$ii]:$DS[$ii]:AVERAGE:reduce=LAST " ; |
| 175 |
$def[$defcnt] .= "LINE1.5:hitratenow#$now:\" \" "; |
| 176 |
$def[$defcnt] .= "VDEF:vhitratenow=hitratenow,LAST " ; |
| 177 |
$def[$defcnt] .= "GPRINT:vhitratenow:\"Hitratio (current) is %3.2lf percent \\n\" "; |
| 178 |
} |
| 179 |
} |
| 180 |
$defcnt++; |
| 181 |
} |
| 182 |
if(preg_match('/^qcache_hitrate_now$/', $NAME[$i])) { |
| 183 |
$ds_name[$defcnt] = "Query cache hitrate"; |
| 184 |
$opt[$defcnt] = "--vertical-label \"Percent\" --title \"Query cache hitrate on $hostname\" --upper-limit 100 --lower-limit 0 "; |
| 185 |
$def[$defcnt] = ""; |
| 186 |
for ($ii = 1; $ii <= $ds_count; $ii++) { |
| 187 |
if(preg_match('/^qcache_hitrate$/', $NAME[$ii])) { |
| 188 |
$def[$defcnt] .= "DEF:hitrate=$RRDFILE[$ii]:$DS[$ii]:AVERAGE:reduce=LAST " ; |
| 189 |
$def[$defcnt] .= "CDEF:ar=hitrate,$CRIT_MIN[$ii],LE,hitrate,0,GT,INF,UNKN,IF,UNKN,IF,ISINF,hitrate,0,IF "; |
| 190 |
$def[$defcnt] .= "CDEF:ay=hitrate,$WARN_MIN[$ii],LE,hitrate,$CRIT_MIN[$ii],GT,INF,UNKN,IF,UNKN,IF,ISINF,hitrate,0,IF "; |
| 191 |
$def[$defcnt] .= "CDEF:ag=hitrate,100,LE,hitrate,$WARN_MIN[$ii],GT,INF,UNKN,IF,UNKN,IF,ISINF,hitrate,0,IF "; |
| 192 |
$def[$defcnt] .= "AREA:ag#$green: " ; |
| 193 |
$def[$defcnt] .= "AREA:ay#$yellow: " ; |
| 194 |
$def[$defcnt] .= "AREA:ar#$red: " ; |
| 195 |
$def[$defcnt] .= "LINE1.5:hitrate#111111:\" \" "; |
| 196 |
$def[$defcnt] .= "VDEF:vhitrate=hitrate,LAST " ; |
| 197 |
$def[$defcnt] .= "GPRINT:vhitrate:\"Hitratio (since epoch) is %3.2lf percent \\n\" "; |
| 198 |
} |
| 199 |
if(preg_match('/^qcache_hitrate_now$/', $NAME[$ii])) { |
| 200 |
$def[$defcnt] .= "DEF:hitratenow=$RRDFILE[$ii]:$DS[$ii]:AVERAGE:reduce=LAST " ; |
| 201 |
$def[$defcnt] .= "LINE1.5:hitratenow#$now:\" \" "; |
| 202 |
$def[$defcnt] .= "VDEF:vhitratenow=hitratenow,LAST " ; |
| 203 |
$def[$defcnt] .= "GPRINT:vhitratenow:\"Hitratio (current) is %3.2lf percent \\n\" "; |
| 204 |
} |
| 205 |
} |
| 206 |
$defcnt++; |
| 207 |
$ds_name[$defcnt] = "Selects per second"; |
| 208 |
$opt[$defcnt] = "--vertical-label \"Selects / sec\" --title \"Selects per second on $hostname\" "; |
| 209 |
$def[$defcnt] = ""; |
| 210 |
for ($ii = 1; $ii <= $ds_count; $ii++) { |
| 211 |
if(preg_match('/^selects_per_sec$/', $NAME[$ii])) { |
| 212 |
$def[$defcnt] .= "DEF:sps=$RRDFILE[$ii]:$DS[$ii]:AVERAGE:reduce=LAST " ; |
| 213 |
$def[$defcnt] .= "AREA:sps#$now:\" \" "; |
| 214 |
$def[$defcnt] .= "VDEF:vsps=sps,LAST " ; |
| 215 |
$def[$defcnt] .= "GPRINT:vsps:\"%3.2lf Selects per second \\n\" "; |
| 216 |
} |
| 217 |
} |
| 218 |
$defcnt++; |
| 219 |
} |
| 220 |
if(preg_match('/^qcache_lowmem_prunes_rate$/', $NAME[$i])) { |
| 221 |
$ds_name[$defcnt] = "Query cache low memory prunes"; |
| 222 |
$opt[$defcnt] = "--vertical-label \"Prunes / sec\" --title \"Query cache low mem prunes on $hostname\" "; |
| 223 |
$def[$defcnt] = ""; |
| 224 |
$def[$defcnt] .= "DEF:prunes=$RRDFILE[$i]:$DS[$i]:AVERAGE:reduce=LAST " ; |
| 225 |
$def[$defcnt] .= "AREA:prunes#111111 "; |
| 226 |
$def[$defcnt] .= "VDEF:vprunes=prunes,LAST " ; |
| 227 |
$def[$defcnt] .= "GPRINT:vprunes:\"Rate is %3.2lf Prunes / Second \" " ; |
| 228 |
$defcnt++; |
| 229 |
} |
| 230 |
if(preg_match('/^slow_queries_rate$/', $NAME[$i])) { |
| 231 |
$ds_name[$defcnt] = "Slow query rate"; |
| 232 |
$opt[$defcnt] = "--vertical-label \"Slow queries / sec\" --title \"Slow queries on $hostname\" "; |
| 233 |
$def[$defcnt] = ""; |
| 234 |
$def[$defcnt] .= "DEF:prunes=$RRDFILE[$i]:$DS[$i]:AVERAGE:reduce=LAST " ; |
| 235 |
$def[$defcnt] .= "AREA:prunes#111111 "; |
| 236 |
$def[$defcnt] .= "VDEF:vprunes=prunes,LAST " ; |
| 237 |
$def[$defcnt] .= "GPRINT:vprunes:\"%3.2lf Slow queries / Second \" " ; |
| 238 |
$defcnt++; |
| 239 |
} |
| 240 |
if(preg_match('/^tablelock_contention_now$/', $NAME[$i])) { |
| 241 |
$ds_name[$defcnt] = "Table lock contention"; |
| 242 |
|
| 243 |
$opt[$defcnt] = "--vertical-label \"Percent\" --title \"Table lock contention on $hostname\" --upper-limit 10 --lower-limit 0 "; |
| 244 |
$def[$defcnt] = ""; |
| 245 |
for ($ii = 1; $ii <= $ds_count; $ii++) { |
| 246 |
if(preg_match('/^tablelock_contention$/', $NAME[$ii])) { |
| 247 |
$def[$defcnt] .= "DEF:tbllckcont=$RRDFILE[$ii]:$DS[$ii]:AVERAGE:reduce=LAST " ; |
| 248 |
$def[$defcnt] .= "CDEF:ag=tbllckcont,$WARN[$ii],LE,tbllckcont,0,GT,INF,UNKN,IF,UNKN,IF,ISINF,tbllckcont,0,IF "; |
| 249 |
$def[$defcnt] .= "CDEF:ay=tbllckcont,$CRIT[$ii],LE,tbllckcont,$WARN[$ii],GT,INF,UNKN,IF,UNKN,IF,ISINF,tbllckcont,0,IF "; |
| 250 |
$def[$defcnt] .= "CDEF:ar=tbllckcont,100,LE,tbllckcont,$CRIT[$ii],GT,INF,UNKN,IF,UNKN,IF,ISINF,tbllckcont,0,IF "; |
| 251 |
$def[$defcnt] .= "AREA:ag#$green: " ; |
| 252 |
$def[$defcnt] .= "AREA:ay#$yellow: " ; |
| 253 |
$def[$defcnt] .= "AREA:ar#$red: " ; |
| 254 |
$def[$defcnt] .= "LINE:tbllckcont#111111:\" \" "; |
| 255 |
$def[$defcnt] .= "VDEF:vtbllckcont=tbllckcont,LAST " ; |
| 256 |
$def[$defcnt] .= "GPRINT:vtbllckcont:\"Lock contention (since epoch) is %3.2lf%%\\n\" " ; |
| 257 |
} |
| 258 |
if(preg_match('/^tablelock_contention_now$/', $NAME[$ii])) { |
| 259 |
$def[$defcnt] .= "DEF:tbllckcontnow=$RRDFILE[$ii]:$DS[$ii]:AVERAGE:reduce=LAST " ; |
| 260 |
$def[$defcnt] .= "LINE1.5:tbllckcontnow#$now:\" \" "; |
| 261 |
$def[$defcnt] .= "VDEF:vtbllckcontnow=tbllckcontnow,LAST " ; |
| 262 |
$def[$defcnt] .= "GPRINT:vtbllckcontnow:\"Lock contention (current) is %3.2lf%%\" "; |
| 263 |
} |
| 264 |
} |
| 265 |
$defcnt++; |
| 266 |
} |
| 267 |
if(preg_match('/^tablecache_fillrate$/', $NAME[$i])) { |
| 268 |
$ds_name[$defcnt] = "Table cache hitrate"; |
| 269 |
$opt[$defcnt] = "--vertical-label \"Percent\" --title \"Table cache hitrate on $hostname\" --upper-limit 100 --lower-limit 0 "; |
| 270 |
$def[$defcnt] = ""; |
| 271 |
for ($ii = 1; $ii <= $ds_count; $ii++) { |
| 272 |
if(preg_match('/^tablecache_hitrate$/', $NAME[$ii])) { |
| 273 |
$def[$defcnt] .= "DEF:hitrate=$RRDFILE[$ii]:$DS[$ii]:AVERAGE:reduce=LAST " ; |
| 274 |
$def[$defcnt] .= "CDEF:ar=hitrate,$CRIT_MIN[$ii],LE,hitrate,0,GT,INF,UNKN,IF,UNKN,IF,ISINF,hitrate,0,IF "; |
| 275 |
$def[$defcnt] .= "CDEF:ay=hitrate,$WARN_MIN[$ii],LE,hitrate,$CRIT_MIN[$ii],GT,INF,UNKN,IF,UNKN,IF,ISINF,hitrate,0,IF "; |
| 276 |
$def[$defcnt] .= "CDEF:ag=hitrate,100,LE,hitrate,$WARN_MIN[$ii],GT,INF,UNKN,IF,UNKN,IF,ISINF,hitrate,0,IF "; |
| 277 |
$def[$defcnt] .= "AREA:ag#$green: " ; |
| 278 |
$def[$defcnt] .= "AREA:ay#$yellow: " ; |
| 279 |
$def[$defcnt] .= "AREA:ar#$red: " ; |
| 280 |
$def[$defcnt] .= "LINE:hitrate#111111:\" \" "; |
| 281 |
$def[$defcnt] .= "VDEF:vhitrate=hitrate,LAST " ; |
| 282 |
$def[$defcnt] .= "GPRINT:vhitrate:\"Hitratio is %3.2lf percent \\n\" "; |
| 283 |
} |
| 284 |
if(preg_match('/^tablecache_fillrate$/', $NAME[$ii])) { |
| 285 |
$def[$defcnt] .= "DEF:hitratenow=$RRDFILE[$ii]:$DS[$ii]:AVERAGE:reduce=LAST " ; |
| 286 |
$def[$defcnt] .= "LINE1.5:hitratenow#$now:\" \" "; |
| 287 |
$def[$defcnt] .= "VDEF:vhitratenow=hitratenow,LAST " ; |
| 288 |
$def[$defcnt] .= "GPRINT:vhitratenow:\"%3.2lf%% of the cache is filled \\n\" "; |
| 289 |
} |
| 290 |
} |
| 291 |
$defcnt++; |
| 292 |
} |
| 293 |
if(preg_match('/^pct_tmp_table_on_disk_now$/', $NAME[$i])) { |
| 294 |
$ds_name[$defcnt] = "Temporary tables created on disk "; |
| 295 |
$opt[$defcnt] = "--vertical-label \"Percent\" --title \"Temporary tables created on disk on $hostname\" --upper-limit 10 --lower-limit 0 "; |
| 296 |
$def[$defcnt] = ""; |
| 297 |
for ($ii = 1; $ii <= $ds_count; $ii++) { |
| 298 |
if(preg_match('/^pct_tmp_table_on_disk$/', $NAME[$ii])) { |
| 299 |
|
| 300 |
$def[$defcnt] .= "DEF:tmptbldsk=$RRDFILE[$ii]:$DS[$ii]:AVERAGE:reduce=LAST " ; |
| 301 |
$def[$defcnt] .= "CDEF:ag=tmptbldsk,$WARN[$ii],LE,tmptbldsk,0,GT,INF,UNKN,IF,UNKN,IF,ISINF,tmptbldsk,0,IF "; |
| 302 |
$def[$defcnt] .= "CDEF:ay=tmptbldsk,$CRIT[$ii],LE,tmptbldsk,$WARN[$ii],GT,INF,UNKN,IF,UNKN,IF,ISINF,tmptbldsk,0,IF "; |
| 303 |
$def[$defcnt] .= "CDEF:ar=tmptbldsk,100,LE,tmptbldsk,$CRIT[$ii],GT,INF,UNKN,IF,UNKN,IF,ISINF,tmptbldsk,0,IF "; |
| 304 |
$def[$defcnt] .= "AREA:ag#$green: " ; |
| 305 |
$def[$defcnt] .= "AREA:ay#$yellow: " ; |
| 306 |
$def[$defcnt] .= "AREA:ar#$red: " ; |
| 307 |
$def[$defcnt] .= "LINE:tmptbldsk#111111:\" \" "; |
| 308 |
$def[$defcnt] .= "VDEF:vtmptbldsk=tmptbldsk,LAST " ; |
| 309 |
$def[$defcnt] .= "GPRINT:vtmptbldsk:\"%3.2lf percent of temp tables were created on disk (since epoch)\\n\" " ; |
| 310 |
} |
| 311 |
if(preg_match('/^pct_tmp_table_on_disk_now$/', $NAME[$ii])) { |
| 312 |
$def[$defcnt] .= "DEF:tmptbldsknow=$RRDFILE[$ii]:$DS[$ii]:AVERAGE:reduce=LAST " ; |
| 313 |
$def[$defcnt] .= "LINE1.5:tmptbldsknow#$now:\" \" "; |
| 314 |
$def[$defcnt] .= "VDEF:vtmptbldsknow=tmptbldsknow,LAST " ; |
| 315 |
$def[$defcnt] .= "GPRINT:vtmptbldsknow:\"%3.2lf percent of temp tables were created on disk (recently)\\n\" " ; |
| 316 |
} |
| 317 |
} |
| 318 |
$defcnt++; |
| 319 |
} |
| 320 |
if(preg_match('/^thread_cache_hitrate_now$/', $NAME[$i])) { |
| 321 |
$ds_name[$defcnt] = "Thread cache hitrate"; |
| 322 |
$opt[$defcnt] = "--vertical-label \"Percent\" --title \"Thread cache hitrate on $hostname\" --upper-limit 100 --lower-limit 0 "; |
| 323 |
$def[$defcnt] = ""; |
| 324 |
for ($ii = 1; $ii <= $ds_count; $ii++) { |
| 325 |
if(preg_match('/^thread_cache_hitrate$/', $NAME[$ii])) { |
| 326 |
$def[$defcnt] .= "DEF:hitrate=$RRDFILE[$ii]:$DS[$ii]:AVERAGE:reduce=LAST " ; |
| 327 |
$def[$defcnt] .= "CDEF:ar=hitrate,$CRIT_MIN[$ii],LE,hitrate,0,GT,INF,UNKN,IF,UNKN,IF,ISINF,hitrate,0,IF "; |
| 328 |
$def[$defcnt] .= "CDEF:ay=hitrate,$WARN_MIN[$ii],LE,hitrate,$CRIT_MIN[$ii],GT,INF,UNKN,IF,UNKN,IF,ISINF,hitrate,0,IF "; |
| 329 |
$def[$defcnt] .= "CDEF:ag=hitrate,100,LE,hitrate,$WARN_MIN[$ii],GT,INF,UNKN,IF,UNKN,IF,ISINF,hitrate,0,IF "; |
| 330 |
$def[$defcnt] .= "AREA:ag#$green: " ; |
| 331 |
$def[$defcnt] .= "AREA:ay#$yellow: " ; |
| 332 |
$def[$defcnt] .= "AREA:ar#$red: " ; |
| 333 |
$def[$defcnt] .= "LINE:hitrate#111111:\" \" "; |
| 334 |
$def[$defcnt] .= "VDEF:vhitrate=hitrate,LAST " ; |
| 335 |
$def[$defcnt] .= "GPRINT:vhitrate:\"Hitratio (since epoch) is %3.2lf percent \\n\" "; |
| 336 |
} |
| 337 |
if(preg_match('/^thread_cache_hitrate_now$/', $NAME[$ii])) { |
| 338 |
$def[$defcnt] .= "DEF:hitratenow=$RRDFILE[$ii]:$DS[$ii]:AVERAGE:reduce=LAST " ; |
| 339 |
$def[$defcnt] .= "LINE1.5:hitratenow#$now:\" \" "; |
| 340 |
$def[$defcnt] .= "VDEF:vhitratenow=hitratenow,LAST " ; |
| 341 |
$def[$defcnt] .= "GPRINT:vhitratenow:\"Hitratio (current) is %3.2lf percent \\n\" "; |
| 342 |
} |
| 343 |
} |
| 344 |
$defcnt++; |
| 345 |
$ds_name[$defcnt] = "Connects per second"; |
| 346 |
$opt[$defcnt] = "--vertical-label \"Conects / sec\" --title \"Connects per second on $hostname\" "; |
| 347 |
$def[$defcnt] = ""; |
| 348 |
for ($ii = 1; $ii <= $ds_count; $ii++) { |
| 349 |
if(preg_match('/^connections_per_sec$/', $NAME[$ii])) { |
| 350 |
$def[$defcnt] .= "DEF:sps=$RRDFILE[$ii]:$DS[$ii]:AVERAGE:reduce=LAST " ; |
| 351 |
$def[$defcnt] .= "AREA:sps#$now:\" \" "; |
| 352 |
$def[$defcnt] .= "VDEF:vsps=sps,LAST " ; |
| 353 |
$def[$defcnt] .= "GPRINT:vsps:\"%3.2lf Connects per second \\n\" "; |
| 354 |
} |
| 355 |
} |
| 356 |
$defcnt++; |
| 357 |
} |
| 358 |
if(preg_match('/^threads_connected$/', $NAME[$i])) { |
| 359 |
$ds_name[$defcnt] = "Connection threads"; |
| 360 |
$opt[$defcnt] = "--vertical-label \"Threads\" --title \"Connection threads on $hostname\" "; |
| 361 |
$def[$defcnt] = ""; |
| 362 |
$def[$defcnt] .= "DEF:threads=$RRDFILE[$i]:$DS[$i]:AVERAGE:reduce=LAST " ; |
| 363 |
$def[$defcnt] .= "AREA:threads#111111 "; |
| 364 |
$def[$defcnt] .= "VDEF:vthreads=threads,LAST " ; |
| 365 |
$def[$defcnt] .= "GPRINT:vthreads:\"%.0lf Connection threads \" " ; |
| 366 |
$defcnt++; |
| 367 |
} |
| 368 |
} |
| 369 |
?> |
| 370 |
|