]> arthur.barton.de Git - netdata.git/commitdiff
added alarms count on dashboard
authorCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Sat, 26 Nov 2016 17:18:04 +0000 (19:18 +0200)
committerCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Sat, 26 Nov 2016 17:18:04 +0000 (19:18 +0200)
src/rrd2json.c
web/index.html

index 645f69ffd4dac3a23b2441139e584a7c110231df..ab66059b46c6d20cad9085ef140aca815090163b 100644 (file)
@@ -41,7 +41,7 @@ inline void rrd_stats_api_v1_chart_with_data(RRDSET *st, BUFFER *wb, size_t *dim
 
     unsigned long memory = st->memsize;
 
-    size_t c = 0;
+    size_t dimensions = 0;
     RRDDIM *rd;
     for(rd = st->dimensions; rd ; rd = rd->next) {
         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
         buffer_sprintf(wb,
             "%s"
             "\t\t\t\t\"%s\": { \"name\": \"%s\" }"
-            , c?",\n":""
+            , dimensions?",\n":""
             , rd->id
             , rd->name
             );
 
-        c++;
+        dimensions++;
     }
-    if(dimensions_count) *dimensions_count += c;
+
+    if(dimensions_count) *dimensions_count += dimensions;
     if(memory_used) *memory_used += memory;
 
     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) {
 
 void rrd_stats_api_v1_charts(BUFFER *wb)
 {
-    size_t c, dimensions = 0, memory = 0;
+    size_t c, dimensions = 0, memory = 0, alarms = 0;
     RRDSET *st;
 
     buffer_sprintf(wb, "{\n"
@@ -103,15 +104,22 @@ void rrd_stats_api_v1_charts(BUFFER *wb)
             c++;
         }
     }
+
+    RRDCALC *rc;
+    for(rc = localhost.alarms; rc ; rc = rc->next) {
+        alarms++;
+    }
     pthread_rwlock_unlock(&localhost.rrdset_root_rwlock);
 
     buffer_sprintf(wb, "\n\t}"
                     ",\n\t\"charts_count\": %zu"
                     ",\n\t\"dimensions_count\": %zu"
+                    ",\n\t\"alarms_count\": %zu"
                     ",\n\t\"rrd_memory_bytes\": %zu"
                     "\n}\n"
                    , c
                    , dimensions
+                   , alarms
                    , memory
     );
 }
index 9f5c0f3a6194be3d662f40135a5dfbdcd371d374..b26300861b6068ff627ba9d6927105ef6686ef88 100644 (file)
         }
 
         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>';
-        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>';
+        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>';
+        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>';
         sidebar += '</ul>';
         div.innerHTML = html;
         document.getElementById('sidebar').innerHTML = sidebar;