@cryptotaxi247 / netdata-1 / commits / 2971f0145

switched cpu.netdata to incremental

Costa Tsaousis (ktsaou) committed Apr 26, 2014 at 05:15 UTC 2971f0145e128abdc1a8404e0fb6b70b281dfa1b
2 files changed +16 -15
netdata.c
+15 -14
@@ -4179,8 +4179,6 @@ void *proc_main(void *ptr)
4179 if(!vdo_proc_vmstat) vdo_proc_vmstat = do_proc_vmstat(usec);
4180 // END -- the job is done
4181
4182 - getrusage(RUSAGE_SELF, &me);
4183 -
4182 // find the time to sleep in order to wait exactly update_every seconds
4183 gettimeofday(&now, NULL);
4184 usec = usecdiff(&now, &last) - susec;
@@ -4194,21 +4192,24 @@ void *proc_main(void *ptr)
4192
4193 // --------------------------------------------------------------------
4194
4197 - unsigned long long cpuuser = usecdiff(&me.ru_utime, &me_last.ru_utime) * (usec + susec) / (update_every * 1000000);
4198 - unsigned long long cpusyst = usecdiff(&me.ru_stime, &me_last.ru_stime) * (usec + susec) / (update_every * 1000000);
4195 + if(getrusage(RUSAGE_SELF, &me) == 0) {
4196 +
4197 + unsigned long long cpuuser = me.ru_utime.tv_sec * 1000000L + me.ru_utime.tv_usec;
4198 + unsigned long long cpusyst = me.ru_stime.tv_sec * 1000000L + me.ru_stime.tv_usec;
4199
4200 - if(!stcpu) stcpu = rrd_stats_find("cpu.netdata");
4201 - if(!stcpu) {
4202 - stcpu = rrd_stats_create("cpu", "netdata", NULL, "cpu", "NetData CPU usage", "milliseconds/s", save_history);
4200 + if(!stcpu) stcpu = rrd_stats_find("cpu.netdata");
4201 + if(!stcpu) {
4202 + stcpu = rrd_stats_create("cpu", "netdata", NULL, "cpu", "NetData CPU usage", "milliseconds/s", save_history);
4203
4204 - rrd_stats_dimension_add(stcpu, "user", NULL, sizeof(unsigned long long), 0, 1, 1000, RRD_DIMENSION_ABSOLUTE, NULL);
4205 - rrd_stats_dimension_add(stcpu, "system", NULL, sizeof(unsigned long long), 0, 1, 1000, RRD_DIMENSION_ABSOLUTE, NULL);
4206 - }
4207 - else rrd_stats_next(stcpu);
4204 + rrd_stats_dimension_add(stcpu, "user", NULL, sizeof(unsigned long long), 0, 1, 1000, RRD_DIMENSION_INCREMENTAL, NULL);
4205 + rrd_stats_dimension_add(stcpu, "system", NULL, sizeof(unsigned long long), 0, 1, 1000, RRD_DIMENSION_INCREMENTAL, NULL);
4206 + }
4207 + else rrd_stats_next(stcpu);
4208
4209 - rrd_stats_dimension_set(stcpu, "user", &cpuuser, NULL);
4210 - rrd_stats_dimension_set(stcpu, "system", &cpusyst, NULL);
4211 - rrd_stats_done(stcpu);
4209 + rrd_stats_dimension_set(stcpu, "user", &cpuuser, NULL);
4210 + rrd_stats_dimension_set(stcpu, "system", &cpusyst, NULL);
4211 + rrd_stats_done(stcpu);
4212 + }
4213
4214 usleep(susec);
4215
web/index.js
+1 -1
@@ -892,7 +892,7 @@ function initCharts() {
892 }
893 });
894
895 - document.getElementById('server_summary_id').innerHTML = "<small>NetData server at <b>" + all.hostname + "</b> is maintaining <b>" + mycharts.length + "</b> charts, having <b>" + dimensions + "</b> dimensions of <b>" + all.history + "</b> entries each, which are updated every <b>" + all.update_every + "s</b>, using a total of <b>" + (Math.round(all.memory * 10 / 1024 / 1024) / 10) + " MB</b> for the round robbin database.</small>";
895 + document.getElementById('server_summary_id').innerHTML = "<small>NetData server at <b>" + all.hostname + "</b> is maintaining <b>" + mycharts.length + "</b> charts, having <b>" + dimensions + "</b> dimensions of <b>" + all.history + "</b> entries each, which are updated every <b>" + all.update_every + "s</b>, using a total of <b>" + (Math.round(all.memory * 10 / 1024 / 1024) / 10) + " MB</b> for the round robin database.</small>";
896
897 $.each(categories, function(i, a) {
898 if(a.name == "system") a.priority = 1;