@cryptotaxi247 / netdata-1 / commits / e17f6ade7

added "+ add more charts" and info legend on the dashboard

Costa Tsaousis (ktsaou) committed Nov 26, 2016 at 18:52 UTC e17f6ade778fdffa8c070c571dc9af1265e330f7
3 files changed +24 -8
src/rrd2json.c
+19 -5
@@ -1,6 +1,6 @@
1 #include "common.h"
2
3 -void rrd_stats_api_v1_chart(RRDSET *st, BUFFER *wb)
3 +inline void rrd_stats_api_v1_chart_with_data(RRDSET *st, BUFFER *wb, size_t *dimensions_count, size_t *memory_used)
4 {
5 pthread_rwlock_rdlock(&st->rwlock);
6
@@ -41,7 +41,7 @@ void rrd_stats_api_v1_chart(RRDSET *st, BUFFER *wb)
41
42 unsigned long memory = st->memsize;
43
44 - int c = 0;
44 + size_t c = 0;
45 RRDDIM *rd;
46 for(rd = st->dimensions; rd ; rd = rd->next) {
47 if(rd->flags & RRDDIM_FLAG_HIDDEN) continue;
@@ -58,6 +58,8 @@ void rrd_stats_api_v1_chart(RRDSET *st, BUFFER *wb)
58
59 c++;
60 }
61 + if(dimensions_count) *dimensions_count += c;
62 + if(memory_used) *memory_used += memory;
63
64 buffer_strcat(wb, "\n\t\t\t},\n\t\t\t\"green\": ");
65 buffer_rrd_value(wb, st->green);
@@ -71,9 +73,13 @@ void rrd_stats_api_v1_chart(RRDSET *st, BUFFER *wb)
73 pthread_rwlock_unlock(&st->rwlock);
74 }
75
76 +void rrd_stats_api_v1_chart(RRDSET *st, BUFFER *wb) {
77 + rrd_stats_api_v1_chart_with_data(st, wb, NULL, NULL);
78 +}
79 +
80 void rrd_stats_api_v1_charts(BUFFER *wb)
81 {
76 - long c;
82 + size_t c, dimensions = 0, memory = 0;
83 RRDSET *st;
84
85 buffer_sprintf(wb, "{\n"
@@ -93,13 +99,21 @@ void rrd_stats_api_v1_charts(BUFFER *wb)
99 buffer_strcat(wb, "\n\t\t\"");
100 buffer_strcat(wb, st->id);
101 buffer_strcat(wb, "\": ");
96 - rrd_stats_api_v1_chart(st, wb);
102 + rrd_stats_api_v1_chart_with_data(st, wb, &dimensions, &memory);
103 c++;
104 }
105 }
106 pthread_rwlock_unlock(&localhost.rrdset_root_rwlock);
107
102 - buffer_strcat(wb, "\n\t}\n}\n");
108 + buffer_sprintf(wb, "\n\t}"
109 + ",\n\t\"charts_count\": %zu"
110 + ",\n\t\"dimensions_count\": %zu"
111 + ",\n\t\"rrd_memory_bytes\": %zu"
112 + "\n}\n"
113 + , c
114 + , dimensions
115 + , memory
116 + );
117 }
118
119
web/dashboard.js
+2 -2
@@ -129,8 +129,8 @@
129 dashboard_css: NETDATA.serverDefault + 'dashboard.css?v20161002-1',
130 background: '#FFFFFF',
131 foreground: '#000000',
132 - grid: '#DDDDDD',
133 - axis: '#CCCCCC',
132 + grid: '#F0F0F0',
133 + axis: '#F0F0F0',
134 colors: [ '#3366CC', '#DC3912', '#109618', '#FF9900', '#990099', '#DD4477',
135 '#3B3EAC', '#66AA00', '#0099C6', '#B82E2E', '#AAAA11', '#5574A6',
136 '#994499', '#22AA99', '#6633CC', '#E67300', '#316395', '#8B0707',
web/index.html
+3 -1
@@ -1325,6 +1325,8 @@
1325 html += mhead + shtml + '</div></div><hr role="separator"/>';
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>';
1330 sidebar += '</ul>';
1331 div.innerHTML = html;
1332 document.getElementById('sidebar').innerHTML = sidebar;
@@ -3167,4 +3169,4 @@
3169 </div>
3170 </body>
3171 </html>
3170 -<script type="text/javascript" src="dashboard.js?v20161112-1"></script>
3172 +<script type="text/javascript" src="dashboard.js?v20161126-1"></script>