@cryptotaxi247 / netdata-1 / commits / f1e5ba691

more options

Costa Tsaousis (ktsaou) committed Apr 27, 2014 at 04:05 UTC f1e5ba6915ad011e892d8c4b3011f6771f26afa8
3 files changed +65 -35
netdata.c
+60 -32
@@ -557,6 +557,24 @@ long long config_get_number(char *section, char *name, long long value)
557 return strtoll(s, NULL, 0);
558 }
559
560 +int config_get_boolean(char *section, char *name, int value)
561 +{
562 + char *s;
563 + if(value) s = "yes";
564 + else s = "no";
565 +
566 + s = config_get(section, name, s);
567 +
568 + if(strcmp(s, "yes") == 0 || strcmp(s, "true") == 0 || strcmp(s, "1") == 0) {
569 + strcpy(s, "yes");
570 + return 1;
571 + }
572 + else {
573 + strcpy(s, "no");
574 + return 0;
575 + }
576 +}
577 +
578 void config_set(char *section, char *name, char *value)
579 {
580 struct config_value *cv;
@@ -586,6 +604,15 @@ void config_set_number(char *section, char *name, long long value)
604 config_set(section, name, buffer);
605 }
606
607 +void config_set_boolean(char *section, char *name, int value)
608 +{
609 + char *s;
610 + if(value) s = "yes";
611 + else s = "no";
612 +
613 + config_set(section, name, s);
614 +}
615 +
616
617
618
@@ -715,7 +742,7 @@ RRD_STATS *rrd_stats_create(const char *type, const char *id, const char *name,
742 if(st->entries > HISTORY_MAX) st->entries = HISTORY_MAX;
743
744 st->userpriority = config_get_number(st->id, "priority", priority);
718 - st->enabled = config_get_number(st->id, "enabled", 1);
745 + st->enabled = config_get_boolean(st->id, "enabled", 1);
746 if(!st->enabled) st->entries = 5;
747
748 st->times = calloc(st->entries, sizeof(struct timeval));
@@ -1307,9 +1334,12 @@ void rrd_stats_all_json(struct web_buffer *wb)
1334
1335 wb->bytes += sprintf(&wb->buffer[wb->bytes], RRD_GRAPH_JSON_HEADER);
1336
1310 - for(st = root, c = 0; st ; st = st->next, c++) {
1311 - if(c) wb->bytes += sprintf(&wb->buffer[wb->bytes], "%s", ",\n");
1312 - memory += rrd_stats_one_json(st, NULL, wb);
1337 + for(st = root, c = 0; st ; st = st->next) {
1338 + if(st->enabled) {
1339 + if(c) wb->bytes += sprintf(&wb->buffer[wb->bytes], "%s", ",\n");
1340 + memory += rrd_stats_one_json(st, NULL, wb);
1341 + c++;
1342 + }
1343 }
1344
1345 wb->bytes += sprintf(&wb->buffer[wb->bytes], "\n\t],\n");
@@ -4410,15 +4440,16 @@ void *proc_main(void *ptr)
4440 last.tv_sec -= update_every;
4441
4442 // when ZERO, attempt to do it
4413 - int vdo_proc_net_dev = 0;
4414 - int vdo_proc_diskstats = 0;
4415 - int vdo_proc_net_snmp = 0;
4416 - int vdo_proc_net_netstat = 0;
4417 - int vdo_proc_net_stat_conntrack = 0;
4418 - int vdo_proc_net_ip_vs_stats = 0;
4419 - int vdo_proc_stat = 0;
4420 - int vdo_proc_meminfo = 0;
4421 - int vdo_proc_vmstat = 0;
4443 + int vdo_proc_net_dev = !config_get_boolean("plugin:proc", "/proc/net/dev", 1);
4444 + int vdo_proc_diskstats = !config_get_boolean("plugin:proc", "/proc/diskstats", 1);
4445 + int vdo_proc_net_snmp = !config_get_boolean("plugin:proc", "/proc/net/snmp", 1);
4446 + int vdo_proc_net_netstat = !config_get_boolean("plugin:proc", "/proc/net/netstat", 1);
4447 + int vdo_proc_net_stat_conntrack = !config_get_boolean("plugin:proc", "/proc/net/stat/conntrack", 1);
4448 + int vdo_proc_net_ip_vs_stats = !config_get_boolean("plugin:proc", "/proc/net/ip_vs/stats", 1);
4449 + int vdo_proc_stat = !config_get_boolean("plugin:proc", "/proc/stat", 1);
4450 + int vdo_proc_meminfo = !config_get_boolean("plugin:proc", "/proc/meminfo", 1);
4451 + int vdo_proc_vmstat = !config_get_boolean("plugin:proc", "/proc/vmstat", 1);
4452 + int vdo_cpu_netdata = !config_get_boolean("plugin:proc", "netdata cpu", 1);
4453
4454 RRD_STATS *stcpu = NULL;
4455
@@ -4453,7 +4484,7 @@ void *proc_main(void *ptr)
4484
4485 // --------------------------------------------------------------------
4486
4456 - if(getrusage(RUSAGE_SELF, &me) == 0) {
4487 + if(!vdo_cpu_netdata && getrusage(RUSAGE_SELF, &me) == 0) {
4488
4489 unsigned long long cpuuser = me.ru_utime.tv_sec * 1000000L + me.ru_utime.tv_usec;
4490 unsigned long long cpusyst = me.ru_stime.tv_sec * 1000000L + me.ru_stime.tv_usec;
@@ -4470,12 +4501,13 @@ void *proc_main(void *ptr)
4501 rrd_stats_dimension_set(stcpu, "user", &cpuuser, NULL);
4502 rrd_stats_dimension_set(stcpu, "system", &cpusyst, NULL);
4503 rrd_stats_done(stcpu);
4504 +
4505 + bcopy(&me, &me_last, sizeof(struct rusage));
4506 }
4507
4508 usleep(susec);
4509
4510 // copy current to last
4478 - bcopy(&me, &me_last, sizeof(struct rusage));
4511 bcopy(&now, &last, sizeof(struct timeval));
4512 }
4513
@@ -4672,7 +4704,7 @@ void *tc_main(void *ptr)
4704 struct tc_device *device = NULL;
4705 struct tc_class *class = NULL;
4706
4675 - sprintf(buffer, "exec ./tc-all.sh %d", update_every);
4707 + sprintf(buffer, "exec %s %d", config_get("plugin:tc", "script", "./tc-all.sh"), update_every);
4708 fp = popen(buffer, "r");
4709
4710 while(fgets(buffer, TC_LINE_MAX, fp) != NULL) {
@@ -4782,6 +4814,11 @@ void *tc_main(void *ptr)
4814
4815 void *cpuidlejitter_main(void *ptr)
4816 {
4817 + int sleep_ms = config_get_number("plugin:idlejitter", "loop time in ms", CPU_IDLEJITTER_SLEEP_TIME_MS);
4818 + if(sleep_ms <= 0) {
4819 + config_set_number("plugin:idlejitter", "loop time in ms", CPU_IDLEJITTER_SLEEP_TIME_MS);
4820 + sleep_ms = CPU_IDLEJITTER_SLEEP_TIME_MS;
4821 + }
4822
4823 struct timeval before, after;
4824
@@ -4791,14 +4828,14 @@ void *cpuidlejitter_main(void *ptr)
4828 while(susec < (update_every * 1000000L)) {
4829
4830 gettimeofday(&before, NULL);
4794 - usleep(CPU_IDLEJITTER_SLEEP_TIME_MS * 1000);
4831 + usleep(sleep_ms * 1000);
4832 gettimeofday(&after, NULL);
4833
4834 // calculate the time it took for a full loop
4835 usec = usecdiff(&after, &before);
4836 susec += usec;
4837 }
4801 - usec -= (CPU_IDLEJITTER_SLEEP_TIME_MS * 1000);
4838 + usec -= (sleep_ms * 1000);
4839
4840 RRD_STATS *st = rrd_stats_find("system.idlejitter");
4841 if(!st) {
@@ -5035,7 +5072,7 @@ int main(int argc, char **argv)
5072
5073 // --------------------------------------------------------------------
5074
5038 - daemon = config_get_number("global", "daemon", 0);
5075 + daemon = config_get_boolean("global", "daemon", 0);
5076 }
5077
5078 // never become a problem
@@ -5061,24 +5098,15 @@ int main(int argc, char **argv)
5098
5099
5100 pthread_t p_proc, p_tc, p_jitter;
5064 - int r_proc, r_tc, r_jitter;
5101
5102 // spawn a child to collect data
5067 - r_proc = pthread_create(&p_proc, NULL, proc_main, NULL);
5068 - r_tc = pthread_create(&p_tc, NULL, tc_main, NULL);
5069 - r_jitter = pthread_create(&p_jitter, NULL, cpuidlejitter_main, NULL);
5103 + if(config_get_boolean("plugins", "tc", 1)) pthread_create(&p_tc, NULL, tc_main, NULL);
5104 + if(config_get_boolean("plugins", "idlejitter", 1)) pthread_create(&p_jitter, NULL, cpuidlejitter_main, NULL);
5105 + if(config_get_boolean("plugins", "proc", 1)) pthread_create(&p_proc, NULL, proc_main, NULL);
5106
5107 // the main process - the web server listener
5072 - //sleep(1);
5108 + // this never ends
5109 socket_listen_main(NULL);
5110
5075 - // wait for the childs to finish
5076 - pthread_join(p_tc, NULL);
5077 - pthread_join(p_proc, NULL);
5078 -
5079 - printf("TC thread returns: %d\n", r_tc);
5080 - printf("PROC NET DEV thread returns: %d\n", r_proc);
5081 - printf("CPU JITTER thread returns: %d\n", r_jitter);
5082 -
5111 exit(0);
5112 }
web/index.js
+1 -1
@@ -901,7 +901,7 @@ function initCharts() {
901 }
902 });
903
904 - 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>";
904 + 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 (by default with <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>";
905
906 $.each(categories, function(i, a) {
907 if(a.name == "system") a.priority = 1;
web/netdata.js
+4 -2
@@ -240,7 +240,7 @@ function loadCharts(base_url, doNext) {
240 // hAxis: {title: "Time of Day", viewWindowMode: 'maximized', format:'HH:mm:ss'},
241 hAxis: {viewWindowMode: 'maximized', format:'HH:mm:ss'},
242 vAxis: {title: json.charts[i].units, viewWindowMode: 'pretty', minValue: 0, maxValue: 10},
243 - chartArea : {width: '70%', height: '80%'},
243 + chartArea : {width: '65%', height: '80%'},
244 focusTarget: 'category',
245 annotation: {'1': {style: 'line'}},
246 //colors: ['blue', 'red', 'green', 'lime', 'olive', 'yellow', 'navy', 'fuchsia', 'maroon', 'aqua', 'teal', 'purple', 'black', 'gray', 'silver'],
@@ -263,7 +263,9 @@ function loadCharts(base_url, doNext) {
263 json.charts[i].chartOptions.isStacked = true;
264 json.charts[i].chartOptions.areaOpacity = 0.85;
265 json.charts[i].chartOptions.lineWidth = 1;
266 - //json.charts[i].chartOptions.vAxis.viewWindowMode = 'maximized';
266 +
267 + if(json.charts[i].name == 'system.swap')
268 + json.charts[i].chartOptions.vAxis.viewWindowMode = 'maximized';
269
270 json.charts[i].group_method = "average";
271 }