Changeset 30b3841abad7acbfffab04c3f0829809791566df
- Timestamp:
- 08/12/11 05:16:02
(2 years ago)
- Author:
- Theo Schlossnagle <jesus@omniti.com>
- git-committer:
- Theo Schlossnagle <jesus@omniti.com> 1313126162 -0400
- git-parent:
[811c412ce800f3a4eeaa9c2bc4d5c35fe9982384]
- git-author:
- Theo Schlossnagle <jesus@omniti.com> 1313126162 -0400
- Message:
This makes the telnet console output for checks
present the metrics in a alphabetical ordering.
Long-standing annoyance fixed.
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| rb553f9a |
r30b3841 |
|
| 384 | 384 | } |
|---|
| 385 | 385 | static int |
|---|
| | 386 | _qsort_string_compare(const void *i1, const void *i2) { |
|---|
| | 387 | const char *s1 = ((const char **)i1)[0]; |
|---|
| | 388 | const char *s2 = ((const char **)i2)[0]; |
|---|
| | 389 | return strcasecmp(s1, s2); |
|---|
| | 390 | } |
|---|
| | 391 | static int |
|---|
| 386 | 392 | noit_console_show_check(noit_console_closure_t ncct, |
|---|
| 387 | 393 | int argc, char **argv, |
|---|
| … | … | |
| 488 | 494 | else { |
|---|
| 489 | 495 | stats_t *c = &check->stats.current; |
|---|
| | 496 | int mcount=0; |
|---|
| | 497 | const char **sorted_keys; |
|---|
| | 498 | char buff[256]; |
|---|
| 490 | 499 | struct timeval now, diff; |
|---|
| | 500 | noit_boolean filtered; |
|---|
| | 501 | |
|---|
| 491 | 502 | gettimeofday(&now, NULL); |
|---|
| 492 | 503 | sub_timeval(now, c->whence, &diff); |
|---|
| … | … | |
| 499 | 510 | nc_printf(ncct, " metrics:\n"); |
|---|
| 500 | 511 | memset(&iter, 0, sizeof(iter)); |
|---|
| | 512 | sorted_keys = alloca(c->metrics.size * sizeof(*sorted_keys)); |
|---|
| 501 | 513 | while(noit_hash_next(&c->metrics, &iter, &k, &klen, &data)) { |
|---|
| 502 | | char buff[256]; |
|---|
| 503 | | noit_boolean filtered; |
|---|
| 504 | | noit_stats_snprint_metric(buff, sizeof(buff), (metric_t *)data); |
|---|
| 505 | | filtered = !noit_apply_filterset(check->filterset, check, (metric_t *)data); |
|---|
| 506 | | nc_printf(ncct, " %c%s\n", filtered ? '*' : ' ', buff); |
|---|
| | 514 | if(sorted_keys) sorted_keys[mcount++] = k; |
|---|
| | 515 | else { |
|---|
| | 516 | noit_stats_snprint_metric(buff, sizeof(buff), (metric_t *)data); |
|---|
| | 517 | filtered = !noit_apply_filterset(check->filterset, check, (metric_t *)data); |
|---|
| | 518 | nc_printf(ncct, " %c%s\n", filtered ? '*' : ' ', buff); |
|---|
| | 519 | } |
|---|
| | 520 | } |
|---|
| | 521 | if(sorted_keys) { |
|---|
| | 522 | int j; |
|---|
| | 523 | qsort(sorted_keys, mcount, sizeof(*sorted_keys), |
|---|
| | 524 | _qsort_string_compare); |
|---|
| | 525 | for(j=0;j<mcount;j++) { |
|---|
| | 526 | if(noit_hash_retrieve(&c->metrics, |
|---|
| | 527 | sorted_keys[j], strlen(sorted_keys[j]), |
|---|
| | 528 | &data)) { |
|---|
| | 529 | noit_stats_snprint_metric(buff, sizeof(buff), (metric_t *)data); |
|---|
| | 530 | filtered = !noit_apply_filterset(check->filterset, check, (metric_t *)data); |
|---|
| | 531 | nc_printf(ncct, " %c%s\n", filtered ? '*' : ' ', buff); |
|---|
| | 532 | } |
|---|
| | 533 | } |
|---|
| 507 | 534 | } |
|---|
| 508 | 535 | } |
|---|