diff options
author | Costa Tsaousis (ktsaou) <costa@tsaousis.gr> | 2017-10-15 04:13:44 +0300 |
---|---|---|
committer | Costa Tsaousis (ktsaou) <costa@tsaousis.gr> | 2017-10-15 04:13:44 +0300 |
commit | 7adbfe8a3b5bb42f02a9891d43a38126097a7acb (patch) | |
tree | 11e613eb2422fc1a274959cacfc941915998fb68 | |
parent | 0b7cf3ecd2ad9669c4864ff3f6cd5981edcb0577 (diff) |
added plugin, module and alarms to /api/v1/chart(s)
-rw-r--r-- | src/rrd2json.c | 46 |
1 files changed, 38 insertions, 8 deletions
diff --git a/src/rrd2json.c b/src/rrd2json.c index f962ca1321..00d7a552ff 100644 --- a/src/rrd2json.c +++ b/src/rrd2json.c @@ -13,6 +13,8 @@ void rrd_stats_api_v1_chart_with_data(RRDSET *st, BUFFER *wb, size_t *dimensions "\t\t\t\"context\": \"%s\",\n" "\t\t\t\"title\": \"%s (%s)\",\n" "\t\t\t\"priority\": %ld,\n" + "\t\t\t\"plugin\": \"%s\",\n" + "\t\t\t\"module\": \"%s\",\n" "\t\t\t\"enabled\": %s,\n" "\t\t\t\"units\": \"%s\",\n" "\t\t\t\"data_url\": \"/api/v1/data?chart=%s\",\n" @@ -29,6 +31,8 @@ void rrd_stats_api_v1_chart_with_data(RRDSET *st, BUFFER *wb, size_t *dimensions , st->context , st->title, st->name , st->priority + , st->plugin_name?st->plugin_name:"" + , st->module_name?st->module_name:"" , rrdset_flag_check(st, RRDSET_FLAG_ENABLED)?"true":"false" , st->units , st->name @@ -48,13 +52,14 @@ void rrd_stats_api_v1_chart_with_data(RRDSET *st, BUFFER *wb, size_t *dimensions memory += rd->memsize; - buffer_sprintf(wb, - "%s" - "\t\t\t\t\"%s\": { \"name\": \"%s\" }" - , dimensions?",\n":"" - , rd->id - , rd->name - ); + buffer_sprintf( + wb + , "%s" + "\t\t\t\t\"%s\": { \"name\": \"%s\" }" + , dimensions ? ",\n" : "" + , rd->id + , rd->name + ); dimensions++; } @@ -67,8 +72,33 @@ void rrd_stats_api_v1_chart_with_data(RRDSET *st, BUFFER *wb, size_t *dimensions buffer_strcat(wb, ",\n\t\t\t\"red\": "); buffer_rrd_value(wb, st->red); + buffer_strcat(wb, ",\n\t\t\t\"alarms\": {\n"); + size_t alarms = 0; + RRDCALC *rc; + for(rc = st->alarms; rc ; rc = rc->rrdset_next) { + + buffer_sprintf( + wb + , "%s" + "\t\t\t\t\"%s\": {\n" + "\t\t\t\t\t\"id\": %u,\n" + "\t\t\t\t\t\"status\": \"%s\",\n" + "\t\t\t\t\t\"units\": \"%s\",\n" + "\t\t\t\t\t\"update_every\": %d\n" + "\t\t\t\t}" + , (alarms) ? ",\n" : "" + , rc->name + , rc->id + , rrdcalc_status2string(rc->status) + , rc->units + , rc->update_every + ); + + alarms++; + } + buffer_sprintf(wb, - "\n\t\t}" + "\n\t\t\t}\n\t\t}" ); rrdset_unlock(st); |