Changeset 30b3841abad7acbfffab04c3f0829809791566df

Show
Ignore:
Timestamp:
08/12/11 05:16:02 (3 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
  • src/noit_conf_checks.c

    rb553f9a r30b3841  
    384384} 
    385385static 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} 
     391static int 
    386392noit_console_show_check(noit_console_closure_t ncct, 
    387393                        int argc, char **argv, 
     
    488494      else { 
    489495        stats_t *c = &check->stats.current; 
     496        int mcount=0; 
     497        const char **sorted_keys; 
     498        char buff[256]; 
    490499        struct timeval now, diff; 
     500        noit_boolean filtered; 
     501 
    491502        gettimeofday(&now, NULL); 
    492503        sub_timeval(now, c->whence, &diff); 
     
    499510        nc_printf(ncct, " metrics:\n"); 
    500511        memset(&iter, 0, sizeof(iter)); 
     512        sorted_keys = alloca(c->metrics.size * sizeof(*sorted_keys)); 
    501513        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          } 
    507534        } 
    508535      }