]> arthur.barton.de Git - netdata.git/commitdiff
added "+ add more charts" and info legend on the dashboard
authorCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Sat, 26 Nov 2016 16:52:53 +0000 (18:52 +0200)
committerCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Sat, 26 Nov 2016 16:52:53 +0000 (18:52 +0200)
src/rrd2json.c
web/dashboard.js
web/index.html

index ac04ca7213e27dd66271651997a93948d2dea825..645f69ffd4dac3a23b2441139e584a7c110231df 100644 (file)
@@ -1,6 +1,6 @@
 #include "common.h"
 
-void rrd_stats_api_v1_chart(RRDSET *st, BUFFER *wb)
+inline void rrd_stats_api_v1_chart_with_data(RRDSET *st, BUFFER *wb, size_t *dimensions_count, size_t *memory_used)
 {
     pthread_rwlock_rdlock(&st->rwlock);
 
@@ -41,7 +41,7 @@ void rrd_stats_api_v1_chart(RRDSET *st, BUFFER *wb)
 
     unsigned long memory = st->memsize;
 
-    int c = 0;
+    size_t c = 0;
     RRDDIM *rd;
     for(rd = st->dimensions; rd ; rd = rd->next) {
         if(rd->flags & RRDDIM_FLAG_HIDDEN) continue;
@@ -58,6 +58,8 @@ void rrd_stats_api_v1_chart(RRDSET *st, BUFFER *wb)
 
         c++;
     }
+    if(dimensions_count) *dimensions_count += c;
+    if(memory_used) *memory_used += memory;
 
     buffer_strcat(wb, "\n\t\t\t},\n\t\t\t\"green\": ");
     buffer_rrd_value(wb, st->green);
@@ -71,9 +73,13 @@ void rrd_stats_api_v1_chart(RRDSET *st, BUFFER *wb)
     pthread_rwlock_unlock(&st->rwlock);
 }
 
+void rrd_stats_api_v1_chart(RRDSET *st, BUFFER *wb) {
+    rrd_stats_api_v1_chart_with_data(st, wb, NULL, NULL);
+}
+
 void rrd_stats_api_v1_charts(BUFFER *wb)
 {
-    long c;
+    size_t c, dimensions = 0, memory = 0;
     RRDSET *st;
 
     buffer_sprintf(wb, "{\n"
@@ -93,13 +99,21 @@ void rrd_stats_api_v1_charts(BUFFER *wb)
             buffer_strcat(wb, "\n\t\t\"");
             buffer_strcat(wb, st->id);
             buffer_strcat(wb, "\": ");
-            rrd_stats_api_v1_chart(st, wb);
+            rrd_stats_api_v1_chart_with_data(st, wb, &dimensions, &memory);
             c++;
         }
     }
     pthread_rwlock_unlock(&localhost.rrdset_root_rwlock);
 
-    buffer_strcat(wb, "\n\t}\n}\n");
+    buffer_sprintf(wb, "\n\t}"
+                    ",\n\t\"charts_count\": %zu"
+                    ",\n\t\"dimensions_count\": %zu"
+                    ",\n\t\"rrd_memory_bytes\": %zu"
+                    "\n}\n"
+                   , c
+                   , dimensions
+                   , memory
+    );
 }
 
 
index 59026f4fd3da44543a0096bfb3ed32418e3b19f1..080ae7dd2cf114009dc633f7d36f56252f2b82b6 100644 (file)
             dashboard_css: NETDATA.serverDefault + 'dashboard.css?v20161002-1',
             background: '#FFFFFF',
             foreground: '#000000',
-            grid: '#DDDDDD',
-            axis: '#CCCCCC',
+            grid: '#F0F0F0',
+            axis: '#F0F0F0',
             colors: [   '#3366CC', '#DC3912',   '#109618', '#FF9900',   '#990099', '#DD4477',
                         '#3B3EAC', '#66AA00',   '#0099C6', '#B82E2E',   '#AAAA11', '#5574A6',
                         '#994499', '#22AA99',   '#6633CC', '#E67300',   '#316395', '#8B0707',
index e8e0b18c90319f6c4d79d85db1569a454ee6d23d..9f5c0f3a6194be3d662f40135a5dfbdcd371d374 100644 (file)
             html += mhead + shtml + '</div></div><hr role="separator"/>';
         }
 
+        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 += '</ul>';
         div.innerHTML = html;
         document.getElementById('sidebar').innerHTML = sidebar;
     </div>
 </body>
 </html>
-<script type="text/javascript" src="dashboard.js?v20161112-1"></script>
+<script type="text/javascript" src="dashboard.js?v20161126-1"></script>