cleanup & fixes

This commit is contained in:
Olaf Rempel 2006-10-09 14:40:38 +02:00
parent b9e011d2aa
commit 135d209392
6 changed files with 134 additions and 35 deletions

View File

@ -46,10 +46,10 @@ static char *ds_def = {
}; };
struct stats { struct stats {
uint32_t total_accesses; uint64_t total_accesses;
uint32_t total_kbytes; uint64_t total_kbytes;
uint32_t busy_workers; uint64_t busy_workers;
uint32_t idle_workers; uint64_t idle_workers;
}; };
struct sammler_plugin plugin; struct sammler_plugin plugin;
@ -97,10 +97,10 @@ static int probe(void)
else if (!strcmp(part[0], "Total kBytes")) else if (!strcmp(part[0], "Total kBytes"))
stats.total_kbytes = atoll(part[1]); stats.total_kbytes = atoll(part[1]);
else if (!strcmp(part[0], "BusyWorkers")) else if (!strcmp(part[0], "BusyWorkers") || !strcmp(part[0], "BusyServers"))
stats.busy_workers = atoll(part[1]); stats.busy_workers = atoll(part[1]);
else if (!strcmp(part[0], "IdleWorkers")) else if (!strcmp(part[0], "IdleWorkers") || !strcmp(part[0], "IdleServers"))
stats.idle_workers = atoll(part[1]); stats.idle_workers = atoll(part[1]);
tmp = NULL; tmp = NULL;
@ -226,7 +226,7 @@ static int fini(void)
struct sammler_plugin plugin = { struct sammler_plugin plugin = {
.name = "apache", .name = "apache",
.interval = 10, .interval = 60,
.init = &init, .init = &init,
.fini = &fini, .fini = &fini,
.probe = &probe, .probe = &probe,

View File

@ -56,20 +56,21 @@ static char *commands_ds_def = {
}; };
static char *qcache_ds_def = { static char *qcache_ds_def = {
"DS:qc_free_blocks:COUNTER:90:0:U " "DS:qc_free_blocks:GAUGE:90:0:U "
"DS:qc_free_memory:COUNTER:90:0:U " "DS:qc_free_memory:GAUGE:90:0:U "
"DS:qc_hits:COUNTER:90:0:U " "DS:qc_hits:COUNTER:90:0:U "
"DS:qc_inserts:COUNTER:90:0:U " "DS:qc_inserts:COUNTER:90:0:U "
"DS:qc_lowmem_prunes:COUNTER:90:0:U " "DS:qc_lowmem_prunes:COUNTER:90:0:U "
"DS:qc_queries_in_cache:COUNTER:90:0:U " "DS:qc_not_cached:COUNTER:90:0:U "
"DS:qc_total_blocks:COUNTER:90:0:U " "DS:qc_queries_in_cache:GAUGE:90:0:U "
"DS:qc_total_blocks:GAUGE:90:0:U "
}; };
static char *threads_ds_def = { static char *threads_ds_def = {
"DS:threads_cached:COUNTER:90:0:U " "DS:threads_cached:GAUGE:90:0:U "
"DS:threads_connected:COUNTER:90:0:U " "DS:threads_connected:GAUGE:90:0:U "
"DS:threads_created:COUNTER:90:0:U " "DS:threads_created:COUNTER:90:0:U "
"DS:threads_running:COUNTER:90:0:U " "DS:threads_running:GAUGE:90:0:U "
}; };
static char * get_ds(int ds_id) static char * get_ds(int ds_id)
@ -130,11 +131,11 @@ static int probe(void)
if (len < 0 || len >= sizeof(filename)) if (len < 0 || len >= sizeof(filename))
continue; continue;
probe_submit(&plugin, filename, DS_QCACHE, "%llu:%llu:%llu:%llu:%llu:%llu:%llu", probe_submit(&plugin, filename, DS_QCACHE, "%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu",
stats.qc_free_blocks, stats.qc_free_memory, stats.qc_free_blocks, stats.qc_free_memory,
stats.qc_hits, stats.qc_inserts, stats.qc_hits, stats.qc_inserts,
stats.qc_lowmem_prunes, stats.qc_queries_in_cache, stats.qc_lowmem_prunes, stats.qc_not_cached,
stats.qc_total_blocks); stats.qc_queries_in_cache, stats.qc_total_blocks);
len = snprintf(filename, sizeof(filename), "mysql-threads-%s.rrd", entry->name); len = snprintf(filename, sizeof(filename), "mysql-threads-%s.rrd", entry->name);
if (len < 0 || len >= sizeof(filename)) if (len < 0 || len >= sizeof(filename))
@ -164,7 +165,7 @@ static int init(void)
continue; continue;
char *part[4]; char *part[4];
int ret = strsplit(tupel->parameter, ":", part, 4); int ret = strsplit(tupel->parameter, ",", part, 4);
if (ret != 4) { if (ret != 4) {
log_print(LOG_ERROR, "p_mysql: parse error"); log_print(LOG_ERROR, "p_mysql: parse error");
continue; continue;

View File

@ -108,6 +108,9 @@ int get_stats(void *mysql, struct mysql_stats *stats)
else if (!strcmp(key +7, "lowmem_prunes")) else if (!strcmp(key +7, "lowmem_prunes"))
stats->qc_lowmem_prunes = val; stats->qc_lowmem_prunes = val;
else if (!strcmp(key +7, "not_cached"))
stats->qc_not_cached = val;
else if (!strcmp(key +7, "queries_in_cache")) else if (!strcmp(key +7, "queries_in_cache"))
stats->qc_queries_in_cache = val; stats->qc_queries_in_cache = val;

View File

@ -16,6 +16,7 @@ struct mysql_stats {
uint64_t qc_hits; uint64_t qc_hits;
uint64_t qc_inserts; uint64_t qc_inserts;
uint64_t qc_lowmem_prunes; uint64_t qc_lowmem_prunes;
uint64_t qc_not_cached;
uint64_t qc_queries_in_cache; uint64_t qc_queries_in_cache;
uint64_t qc_total_blocks; uint64_t qc_total_blocks;
uint64_t questions; uint64_t questions;

View File

@ -102,18 +102,17 @@ static int probe(void)
if (numfields < 5) if (numfields < 5)
continue; continue;
if (numfields >= 8) { else if (numfields == 5)
val[5] = val[6] = val[7] = val[8] = "0";
else if (numfields == 8)
val[8] = "0";
probe_submit(&plugin, filename, DS_CPU, probe_submit(&plugin, filename, DS_CPU,
"%s:%s:%s:%s:%s:%s:%s:%s", "%s:%s:%s:%s:%s:%s:%s:%s",
val[1], val[2], val[3], val[4], val[1], val[2], val[3], val[4],
val[5], val[6], val[7], val[8]); val[5], val[6], val[7], val[8]);
} else {
probe_submit(&plugin, filename, DS_CPU,
"%s:%s:%s:%s:0:0:0",
val[1], val[2], val[3], val[4]);
}
} else if (!strncmp(buffer, "intr", 4)) { } else if (!strncmp(buffer, "intr", 4)) {
proc.intr = atoll(buffer + 5); proc.intr = atoll(buffer + 5);

View File

@ -295,17 +295,29 @@ function show_rrd($conf) {
$cmd = RRDTOOL." graph - --imgformat PNG --start {$view} --end -10 --title \"{$title}\" --rigid "; $cmd = RRDTOOL." graph - --imgformat PNG --start {$view} --end -10 --title \"{$title}\" --rigid ";
$tmp = explode('-', basename($rrdfile)); $tmp1 = explode('-', basename($rrdfile));
$tmp = explode('_', $tmp[0]); $tmp2 = explode('_', $tmp1[0]);
$tmp = explode('.', $tmp[0]); $tmp3 = explode('.', $tmp2[0]);
switch ($tmp[0]) { switch ($tmp3[0]) {
case 'apache':
$cmd .= "--base=1000 --height={$height} --width={$width} --alt-autoscale-max --lower-limit=0 --vertical-label=\"Workers\" ".
"DEF:aa={$rrdfile}:total_accesses:AVERAGE ".
"DEF:b={$rrdfile}:total_kbytes:AVERAGE ".
"DEF:c={$rrdfile}:busy_workers:AVERAGE ".
"DEF:d={$rrdfile}:idle_workers:AVERAGE ".
'CDEF:a=aa,60,* '.
'AREA:c#FF0000:"Busy Workers" GPRINT:c:LAST:"Current\:%8.2lf %s" GPRINT:c:AVERAGE:"Average\:%8.2lf %s" GPRINT:c:MAX:"Maximum\:%8.2lf %s\n" '.
'STACK:d#00CF00:"Idle Workers" GPRINT:d:LAST:"Current\:%8.2lf %s" GPRINT:d:AVERAGE:"Average\:%8.2lf %s" GPRINT:d:MAX:"Maximum\:%8.2lf %s\n" '.
'LINE2:a#0000FF:"Accesses " GPRINT:a:LAST:"Current\:%8.2lf %s" GPRINT:a:AVERAGE:"Average\:%8.2lf %s" GPRINT:a:MAX:"Maximum\:%8.2lf %s" '.
'';
break;
case 'cpu': case 'cpu':
$height *= 2; $height *= 2;
$cmd .= "--base=1000 --height={$height} --width={$width} --alt-autoscale-max --lower-limit=0 --vertical-label=\"percent\" ". $cmd .= "--base=1000 --height={$height} --width={$width} --alt-autoscale-max --lower-limit=0 --vertical-label=\"percent\" ".
"DEF:a={$rrdfile}:user:AVERAGE ". "DEF:a={$rrdfile}:user:AVERAGE ".
"DEF:b={$rrdfile}:nice:AVERAGE ". "DEF:b={$rrdfile}:nice:AVERAGE ".
"DEF:c={$rrdfile}:system:AVERAGE ". "DEF:c={$rrdfile}:system:AVERAGE ".
"DEF:d={$rrdfile}:idle:AVERAGE ".
"DEF:e={$rrdfile}:iowait:AVERAGE ". "DEF:e={$rrdfile}:iowait:AVERAGE ".
"DEF:f={$rrdfile}:irq:AVERAGE ". "DEF:f={$rrdfile}:irq:AVERAGE ".
"DEF:g={$rrdfile}:softirq:AVERAGE ". "DEF:g={$rrdfile}:softirq:AVERAGE ".
@ -318,7 +330,7 @@ function show_rrd($conf) {
"DEF:gmax={$rrdfile}:softirq:MAX ". "DEF:gmax={$rrdfile}:softirq:MAX ".
"DEF:hmax={$rrdfile}:steal:MAX ". "DEF:hmax={$rrdfile}:steal:MAX ".
"CDEF:allmax=amax,bmax,cmax,emax,fmax,gmax,hmax,+,+,+,+,+,+ ". "CDEF:allmax=amax,bmax,cmax,emax,fmax,gmax,hmax,+,+,+,+,+,+ ".
'AREA:allmax#C0C0C0 LINE:allmax#808080 '. 'AREA:allmax#C0C0C0 LINE1:allmax#808080 '.
'AREA:h#000000:"Stolen " GPRINT:h:LAST:"Current\:%8.2lf %s" GPRINT:h:AVERAGE:"Average\:%8.2lf %s" GPRINT:h:MAX:"Maximum\:%8.2lf %s\n" '. 'AREA:h#000000:"Stolen " GPRINT:h:LAST:"Current\:%8.2lf %s" GPRINT:h:AVERAGE:"Average\:%8.2lf %s" GPRINT:h:MAX:"Maximum\:%8.2lf %s\n" '.
'STACK:c#FF0000:"System " GPRINT:c:LAST:"Current\:%8.2lf %s" GPRINT:c:AVERAGE:"Average\:%8.2lf %s" GPRINT:c:MAX:"Maximum\:%8.2lf %s\n" '. 'STACK:c#FF0000:"System " GPRINT:c:LAST:"Current\:%8.2lf %s" GPRINT:c:AVERAGE:"Average\:%8.2lf %s" GPRINT:c:MAX:"Maximum\:%8.2lf %s\n" '.
'STACK:f#EA8F00:"IRQ " GPRINT:f:LAST:"Current\:%8.2lf %s" GPRINT:f:AVERAGE:"Average\:%8.2lf %s" GPRINT:f:MAX:"Maximum\:%8.2lf %s\n" '. 'STACK:f#EA8F00:"IRQ " GPRINT:f:LAST:"Current\:%8.2lf %s" GPRINT:f:AVERAGE:"Average\:%8.2lf %s" GPRINT:f:MAX:"Maximum\:%8.2lf %s\n" '.
@ -416,6 +428,89 @@ function show_rrd($conf) {
'LINE1:b#404040 '; 'LINE1:b#404040 ';
break; break;
case 'mysql':
switch ($tmp1[1]) {
case 'commands':
$cmd .= "--base=1000 --height={$height} --width={$width} --alt-autoscale-max --lower-limit=0 --vertical-label=\"commands\" ".
"DEF:aa={$rrdfile}:com_delete:AVERAGE ".
"DEF:bb={$rrdfile}:com_insert:AVERAGE ".
"DEF:cc={$rrdfile}:com_select:AVERAGE ".
"DEF:dd={$rrdfile}:com_update:AVERAGE ".
"DEF:ee={$rrdfile}:questions:AVERAGE ".
'CDEF:a=aa,60,* '.
'CDEF:b=bb,60,* '.
'CDEF:c=cc,60,* '.
'CDEF:d=dd,60,* '.
'CDEF:e=ee,60,* '.
'AREA:e#0000FF:"All Commands " GPRINT:e:LAST:"Current\:%8.2lf %s" GPRINT:e:AVERAGE:"Average\:%8.2lf %s" GPRINT:e:MAX:"Maximum\:%8.2lf %s\n" '.
'AREA:a#FF0000:"DELETE ... " GPRINT:a:LAST:"Current\:%8.2lf %s" GPRINT:a:AVERAGE:"Average\:%8.2lf %s" GPRINT:a:MAX:"Maximum\:%8.2lf %s\n" '.
'STACK:b#FF7D00:"INSERT ... " GPRINT:b:LAST:"Current\:%8.2lf %s" GPRINT:b:AVERAGE:"Average\:%8.2lf %s" GPRINT:b:MAX:"Maximum\:%8.2lf %s\n" '.
'STACK:d#FFC73B:"UPDATE ... " GPRINT:d:LAST:"Current\:%8.2lf %s" GPRINT:d:AVERAGE:"Average\:%8.2lf %s" GPRINT:d:MAX:"Maximum\:%8.2lf %s\n" '.
'STACK:c#00CF00:"SELECT ... " GPRINT:c:LAST:"Current\:%8.2lf %s" GPRINT:c:AVERAGE:"Average\:%8.2lf %s" GPRINT:c:MAX:"Maximum\:%8.2lf %s\n" '.
'';
break;
case 'qcache':
$cmd .= "--base=1024 --height={$height} --width={$width} --alt-autoscale-max --lower-limit=0 --vertical-label=\"???\" ".
"DEF:a={$rrdfile}:qc_free_blocks:AVERAGE ".
"DEF:b={$rrdfile}:qc_free_memory:AVERAGE ".
"DEF:cc={$rrdfile}:qc_hits:AVERAGE ".
"DEF:dd={$rrdfile}:qc_inserts:AVERAGE ".
"DEF:ee={$rrdfile}:qc_lowmem_prunes:AVERAGE ".
"DEF:ff={$rrdfile}:qc_not_cached:AVERAGE ".
"DEF:g={$rrdfile}:qc_queries_in_cache:AVERAGE ".
"DEF:h={$rrdfile}:qc_total_blocks:AVERAGE ".
'CDEF:c=cc,60,* '.
'CDEF:d=dd,60,* '.
'CDEF:e=ee,60,* '.
'CDEF:f=ff,60,* '.
'LINE1:a#FF0000:"qc_free_blocks " GPRINT:a:LAST:"Current\:%8.2lf %s" GPRINT:a:AVERAGE:"Average\:%8.2lf %s" GPRINT:a:MAX:"Maximum\:%8.2lf %s\n" '.
'LINE1:b#FFFF00:"qc_free_memory " GPRINT:b:LAST:"Current\:%8.2lf %s" GPRINT:b:AVERAGE:"Average\:%8.2lf %s" GPRINT:b:MAX:"Maximum\:%8.2lf %s\n" '.
'LINE1:c#00FF00:"qc_hits " GPRINT:c:LAST:"Current\:%8.2lf %s" GPRINT:c:AVERAGE:"Average\:%8.2lf %s" GPRINT:c:MAX:"Maximum\:%8.2lf %s\n" '.
'LINE1:d#00FFFF:"qc_inserts " GPRINT:d:LAST:"Current\:%8.2lf %s" GPRINT:d:AVERAGE:"Average\:%8.2lf %s" GPRINT:d:MAX:"Maximum\:%8.2lf %s\n" '.
'LINE1:e#0000FF:"qc_lowmemprunes " GPRINT:e:LAST:"Current\:%8.2lf %s" GPRINT:e:AVERAGE:"Average\:%8.2lf %s" GPRINT:e:MAX:"Maximum\:%8.2lf %s\n" '.
'LINE1:f#FF00FF:"qc_not_cached " GPRINT:f:LAST:"Current\:%8.2lf %s" GPRINT:f:AVERAGE:"Average\:%8.2lf %s" GPRINT:f:MAX:"Maximum\:%8.2lf %s\n" '.
'LINE1:g#FF00FF:"qc_queries_in_cache" GPRINT:g:LAST:"Current\:%8.2lf %s" GPRINT:g:AVERAGE:"Average\:%8.2lf %s" GPRINT:g:MAX:"Maximum\:%8.2lf %s\n" '.
'LINE1:h#000000:"qc_total_blocks " GPRINT:h:LAST:"Current\:%8.2lf %s" GPRINT:h:AVERAGE:"Average\:%8.2lf %s" GPRINT:h:MAX:"Maximum\:%8.2lf %s\n" '.
'';
break;
case 'threads':
$cmd .= "--base=1024 --height={$height} --width={$width} --alt-autoscale-max --lower-limit=0 --vertical-label=\"threads\" ".
"DEF:a={$rrdfile}:threads_cached:AVERAGE ".
"DEF:b={$rrdfile}:threads_connected:AVERAGE ".
"DEF:cc={$rrdfile}:threads_created:AVERAGE ".
"DEF:d={$rrdfile}:threads_running:AVERAGE ".
'CDEF:c=cc,60,* '.
'LINE1:c#00CF00:"threads created " GPRINT:c:LAST:"Current\:%8.2lf %s" GPRINT:c:AVERAGE:"Average\:%8.2lf %s" GPRINT:c:MAX:"Maximum\:%8.2lf %s\n" '.
'LINE1:d#FF0000:"threads running " GPRINT:d:LAST:"Current\:%8.2lf %s" GPRINT:d:AVERAGE:"Average\:%8.2lf %s" GPRINT:d:MAX:"Maximum\:%8.2lf %s\n" '.
'LINE1:b#00FFFF:"threads connected" GPRINT:b:LAST:"Current\:%8.2lf %s" GPRINT:b:AVERAGE:"Average\:%8.2lf %s" GPRINT:b:MAX:"Maximum\:%8.2lf %s\n" '.
'LINE1:a#0000FF:"threads cached " GPRINT:a:LAST:"Current\:%8.2lf %s" GPRINT:a:AVERAGE:"Average\:%8.2lf %s" GPRINT:a:MAX:"Maximum\:%8.2lf %s\n" '.
'';
break;
case 'traffic':
$cmd .= "--base=1000 --height={$height} --width={$width} --alt-autoscale-max --vertical-label=\"bytes per second\" ".
"DEF:imax={$rrdfile}:bytes_received:MAX ".
"DEF:iavg={$rrdfile}:bytes_received:AVERAGE ".
"DEF:imin={$rrdfile}:bytes_received:MIN ".
"DEF:omax={$rrdfile}:bytes_sent:MAX ".
"DEF:oavg={$rrdfile}:bytes_sent:AVERAGE ".
"DEF:omin={$rrdfile}:bytes_sent:MIN ".
'CDEF:omaxn=omax,-1,* CDEF:oavgn=oavg,-1,* CDEF:ominn=omin,-1,* '.
'CDEF:imid=imax,imin,- CDEF:omid=omaxn,ominn,- '.
'HRULE:0#FF0000 '.
'AREA:imin STACK:imid#A0FFA0:"min/max Inbound " GPRINT:imin:MIN:"%6.2lf%s" GPRINT:imax:MAX:"%6.2lf%s" '.
'LINE1:imin#a0a0a0 LINE1:imax#a0a0a0 LINE1:iavg#008000:"avg Inbound " '.
'GPRINT:iavg:MIN:"min\: %6.2lf%s" GPRINT:iavg:AVERAGE:"avg\: %6.2lf%s" GPRINT:iavg:MAX:"max\: %6.2lf%s\n" '.
'AREA:ominn STACK:omid#C0C0FF:"min/max Outbound" GPRINT:omin:MIN:"%6.2lf%s" GPRINT:omax:MAX:"%6.2lf%s" '.
'LINE1:ominn#a0a0a0 LINE1:omaxn#a0a0a0 LINE1:oavgn#000080:"avg Outbound" '.
'GPRINT:oavg:MIN:"min\: %6.2lf%s" GPRINT:oavg:AVERAGE:"avg\: %6.2lf%s" GPRINT:oavg:MAX:"max\: %6.2lf%s\n" ';
break;
}
break;
case 'net': case 'net':
$height *= 2; $height *= 2;
$cmd .= "--base=1000 --height={$height} --width={$width} --alt-autoscale-max --vertical-label=\"bytes per second\" ". $cmd .= "--base=1000 --height={$height} --width={$width} --alt-autoscale-max --vertical-label=\"bytes per second\" ".