added alarms count on dashboard
Costa Tsaousis (ktsaou) committed
Nov 26, 2016 at 19:18 UTC
c2d1b2cd7e2e573331b43358060e86834aaf7b0b
2 files changed
+15
-6
src/rrd2json.c
+13
-5
@@ -41,7 +41,7 @@ inline void rrd_stats_api_v1_chart_with_data(RRDSET *st, BUFFER *wb, size_t *dim
41
42
unsigned long memory = st->memsize;
43
44
- size_t c = 0;
44
+ size_t dimensions = 0;
45
RRDDIM *rd;
46
for(rd = st->dimensions; rd ; rd = rd->next) {
47
if(rd->flags & RRDDIM_FLAG_HIDDEN) continue;
@@ -51,14 +51,15 @@ inline void rrd_stats_api_v1_chart_with_data(RRDSET *st, BUFFER *wb, size_t *dim
51
buffer_sprintf(wb,
52
"%s"
53
"\t\t\t\t\"%s\": { \"name\": \"%s\" }"
54
- , c?",\n":""
54
+ , dimensions?",\n":""
55
, rd->id
56
, rd->name
57
);
58
59
- c++;
59
+ dimensions++;
60
}
61
- if(dimensions_count) *dimensions_count += c;
61
+
62
+ if(dimensions_count) *dimensions_count += dimensions;
63
if(memory_used) *memory_used += memory;
64
65
buffer_strcat(wb, "\n\t\t\t},\n\t\t\t\"green\": ");
@@ -79,7 +80,7 @@ void rrd_stats_api_v1_chart(RRDSET *st, BUFFER *wb) {
80
81
void rrd_stats_api_v1_charts(BUFFER *wb)
82
{
82
- size_t c, dimensions = 0, memory = 0;
83
+ size_t c, dimensions = 0, memory = 0, alarms = 0;
84
RRDSET *st;
85
86
buffer_sprintf(wb, "{\n"
@@ -103,15 +104,22 @@ void rrd_stats_api_v1_charts(BUFFER *wb)
104
c++;
105
}
106
}
107
+
108
+ RRDCALC *rc;
109
+ for(rc = localhost.alarms; rc ; rc = rc->next) {
110
+ alarms++;
111
+ }
112
pthread_rwlock_unlock(&localhost.rrdset_root_rwlock);
113
114
buffer_sprintf(wb, "\n\t}"
115
",\n\t\"charts_count\": %zu"
116
",\n\t\"dimensions_count\": %zu"
117
+ ",\n\t\"alarms_count\": %zu"
118
",\n\t\"rrd_memory_bytes\": %zu"
119
"\n}\n"
120
, c
121
, dimensions
122
+ , alarms
123
, memory
124
);
125
}
web/index.html
+2
-1
@@ -1326,7 +1326,8 @@
1326
}
1327
1328
sidebar += '<li class="" style="padding-top:15px;"><a href="https://github.com/firehol/netdata/wiki/Add-more-charts-to-netdata" target="_blank"><i class="fa fa-plus" aria-hidden="true"></i> add more charts</a></li>';
1329
- sidebar += '<li class="" style="margin:20px;color:#666;"><small>netdata on <b>' + data.hostname.toString() + '</b>, collects every ' + ((data.update_every == 1)?'second':data.update_every.toString() + ' seconds') + ', <b>' + data.dimensions_count.toLocaleString() + '</b> metrics presented in <b>' + data.charts_count.toLocaleString() + '</b> charts, using ' + Math.round(data.rrd_memory_bytes / 1024 / 1024).toLocaleString() + ' MB of memory, for ' + Math.round(data.history / 3600).toLocaleString() + ' ' + ((data.history == 3600)?'hour':'hours').toString() + ' of real-time history.</small></li>';
1329
+ sidebar += '<li class=""><a href="https://github.com/firehol/netdata/wiki/Add-more-alarms-to-netdata" target="_blank"><i class="fa fa-plus" aria-hidden="true"></i> add more alarms</a></li>';
1330
+ sidebar += '<li class="" style="margin:20px;color:#666;"><small>netdata on <b>' + data.hostname.toString() + '</b>, collects every ' + ((data.update_every == 1)?'second':data.update_every.toString() + ' seconds') + ', <b>' + data.dimensions_count.toLocaleString() + '</b> metrics presented in <b>' + data.charts_count.toLocaleString() + '</b> charts, using ' + Math.round(data.rrd_memory_bytes / 1024 / 1024).toLocaleString() + ' MB of memory, for ' + Math.round(data.history / 3600).toLocaleString() + ' ' + ((data.history == 3600)?'hour':'hours').toString() + ' of real-time history, monitored with <b>' + data.alarms_count.toLocaleString() + '</b> alarms.</small></li>';
1331
sidebar += '</ul>';
1332
div.innerHTML = html;
1333
document.getElementById('sidebar').innerHTML = sidebar;