diff options
| author | Ronnie Sahlberg <ronniesahlberg@gmail.com> | 2010-09-30 14:59:59 +1000 |
|---|---|---|
| committer | Ronnie Sahlberg <ronniesahlberg@gmail.com> | 2010-09-30 15:01:08 +1000 |
| commit | 1a716ec3002b73d11659f36e27beece92dcaee63 (patch) | |
| tree | c382c338daa35449faef86119498dd75f9f41e22 | |
| parent | 3ba7ac13eb01ad0f10c3c3c033eed99e154afe70 (diff) | |
| download | samba-1a716ec3002b73d11659f36e27beece92dcaee63.tar.gz samba-1a716ec3002b73d11659f36e27beece92dcaee63.tar.xz samba-1a716ec3002b73d11659f36e27beece92dcaee63.zip | |
add a machinereadable version of ctdb stats/statistics
(This used to be ctdb commit 3a033156c48d821d48fd18f12c3b0ac14bbddc93)
| -rw-r--r-- | ctdb/tools/ctdb.c | 80 |
1 files changed, 55 insertions, 25 deletions
diff --git a/ctdb/tools/ctdb.c b/ctdb/tools/ctdb.c index 4f8b7598ad..371567a552 100644 --- a/ctdb/tools/ctdb.c +++ b/ctdb/tools/ctdb.c @@ -211,33 +211,63 @@ static void show_statistics(struct ctdb_statistics *s) tmp /= 24; days = tmp; - printf("CTDB version %u\n", CTDB_VERSION); - printf("Current time of statistics : %s", ctime(&s->statistics_current_time.tv_sec)); - printf("Statistics collected since : (%03d %02d:%02d:%02d) %s", days, hours, minutes, seconds, ctime(&s->statistics_start_time.tv_sec)); - - for (i=0;i<ARRAY_SIZE(fields);i++) { - if (strchr(fields[i].name, '.')) { - preflen = strcspn(fields[i].name, ".")+1; - if (!prefix || strncmp(prefix, fields[i].name, preflen) != 0) { - prefix = fields[i].name; - printf(" %*.*s\n", preflen-1, preflen-1, fields[i].name); + if (options.machinereadable){ + printf("CTDB version:"); + printf("Current time of statistics:"); + printf("Statistics collected since:"); + for (i=0;i<ARRAY_SIZE(fields);i++) { + printf("%s:", fields[i].name); + } + printf("max_reclock_ctdbd:"); + printf("max_reclock_recd:"); + printf("max_call_latency:"); + printf("max_lockwait_latency:"); + printf("max_childwrite_latency:"); + printf("max_childwrite_latency:"); + printf("\n"); + + printf("%d:", CTDB_VERSION); + printf("%d:", (int)s->statistics_current_time.tv_sec); + printf("%d:", (int)s->statistics_start_time.tv_sec); + for (i=0;i<ARRAY_SIZE(fields);i++) { + printf("%d:", *(uint32_t *)(fields[i].offset+(uint8_t *)s)); + } + printf("%.6f:", s->reclock.ctdbd); + printf("%.6f:", s->reclock.recd); + printf("%.6f:", s->max_call_latency); + printf("%.6f:", s->max_lockwait_latency); + printf("%.6f:", s->max_childwrite_latency); + printf("%.6f:", s->max_childwrite_latency); + printf("\n"); + } else { + printf("CTDB version %u\n", CTDB_VERSION); + printf("Current time of statistics : %s", ctime(&s->statistics_current_time.tv_sec)); + printf("Statistics collected since : (%03d %02d:%02d:%02d) %s", days, hours, minutes, seconds, ctime(&s->statistics_start_time.tv_sec)); + + for (i=0;i<ARRAY_SIZE(fields);i++) { + if (strchr(fields[i].name, '.')) { + preflen = strcspn(fields[i].name, ".")+1; + if (!prefix || strncmp(prefix, fields[i].name, preflen) != 0) { + prefix = fields[i].name; + printf(" %*.*s\n", preflen-1, preflen-1, fields[i].name); + } + } else { + preflen = 0; } - } else { - preflen = 0; + printf(" %*s%-22s%*s%10u\n", + preflen?4:0, "", + fields[i].name+preflen, + preflen?0:4, "", + *(uint32_t *)(fields[i].offset+(uint8_t *)s)); } - printf(" %*s%-22s%*s%10u\n", - preflen?4:0, "", - fields[i].name+preflen, - preflen?0:4, "", - *(uint32_t *)(fields[i].offset+(uint8_t *)s)); - } - printf(" %-30s %.6f sec\n", "max_reclock_ctdbd", s->reclock.ctdbd); - printf(" %-30s %.6f sec\n", "max_reclock_recd", s->reclock.recd); - - printf(" %-30s %.6f sec\n", "max_call_latency", s->max_call_latency); - printf(" %-30s %.6f sec\n", "max_lockwait_latency", s->max_lockwait_latency); - printf(" %-30s %.6f sec\n", "max_childwrite_latency", s->max_childwrite_latency); - printf(" %-30s %.6f sec\n", "max_childwrite_latency", s->max_childwrite_latency); + printf(" %-30s %.6f sec\n", "max_reclock_ctdbd", s->reclock.ctdbd); + printf(" %-30s %.6f sec\n", "max_reclock_recd", s->reclock.recd); + + printf(" %-30s %.6f sec\n", "max_call_latency", s->max_call_latency); + printf(" %-30s %.6f sec\n", "max_lockwait_latency", s->max_lockwait_latency); + printf(" %-30s %.6f sec\n", "max_childwrite_latency", s->max_childwrite_latency); + printf(" %-30s %.6f sec\n", "max_childwrite_latency", s->max_childwrite_latency); + } talloc_free(tmp_ctx); } |
