Skip to content

Commit

Permalink
graphite-fy the "load average" counters.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jarkko Hietaniemi committed Feb 23, 2015
1 parent 6d8b361 commit df56d1f
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions src/graphite_worker.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,34 @@ static int graphite_build_worker(graphite_worker_t * self, socket_worker_t * w,
do {
#define STATS_VCATF(name) \
if (!fixed_buffer_vcatf(buffer, stats_format, #name, recents.name##_count)) return 0
#define STATS_LOADAVG_VCATF(name, ix, label) \
if (!fixed_buffer_vcatf(buffer, stats_format, #name ".loadavg_" #label, (unsigned long) w->rates[ix].name.rate)) return 0
STATS_VCATF(received);

STATS_LOADAVG_VCATF(received, 0, 1);
STATS_LOADAVG_VCATF(received, 1, 5);
STATS_LOADAVG_VCATF(received, 2, 15);

STATS_VCATF(sent);

STATS_LOADAVG_VCATF(sent, 0, 1);
STATS_LOADAVG_VCATF(sent, 1, 5);
STATS_LOADAVG_VCATF(sent, 2, 15);

STATS_VCATF(partial);

STATS_VCATF(spilled);

STATS_LOADAVG_VCATF(spilled, 0, 1);
STATS_LOADAVG_VCATF(spilled, 1, 5);
STATS_LOADAVG_VCATF(spilled, 2, 15);

STATS_VCATF(dropped);

STATS_LOADAVG_VCATF(dropped, 0, 1);
STATS_LOADAVG_VCATF(dropped, 1, 5);
STATS_LOADAVG_VCATF(dropped, 2, 15);

STATS_VCATF(error);
STATS_VCATF(disk);
STATS_VCATF(disk_error);
Expand Down Expand Up @@ -183,8 +206,8 @@ static int graphite_build(graphite_worker_t * self, fixed_buffer_t * buffer, tim
if (buckets) {
char buckets_format[256];
wrote =
snprintf(buckets_format, sizeof(buckets_format), "%s.buckets.log2_%%d %%ld %lu\n", self->path_root->data,
this_epoch);
snprintf(buckets_format, sizeof(buckets_format), "%s.buckets.log2_%%d %%ld %lu\n",
self->path_root->data, this_epoch);
if (wrote < 0 || wrote >= (int) sizeof(buckets_format)) {
WARN("Failed to initialize buckets format: %s", buckets_format);
return 0;
Expand Down

0 comments on commit df56d1f

Please sign in to comment.