added support for reading and generating netdata.conf
Costa Tsaousis (ktsaou) committed
Apr 27, 2014 at 02:50 UTC
8819556c7b8dff99d42f5726068a08d69d36ee7a
4 files changed
+497
-217
netdata.c
+446
-165
@@ -87,6 +87,7 @@
87
#define D_WEB_CLIENT_ACCESS 0x00000080
88
#define D_TC_LOOP 0x00000100
89
#define D_DEFLATE 0x00000200
90
+#define D_CONFIG 0x00000400
91
92
#define CT_APPLICATION_JSON 1
93
#define CT_TEXT_PLAIN 2
@@ -109,7 +110,7 @@
110
//#define DEBUG (0)
111
112
#define HOSTNAME_MAX 1024
112
-char hostname[HOSTNAME_MAX + 1];
113
+char *hostname;
114
115
unsigned long long debug_flags = DEBUG;
116
char *debug_log = NULL;
@@ -342,6 +343,252 @@ int create_listen_socket(int port)
343
}
344
345
346
+// ----------------------------------------------------------------------------
347
+// CONFIG
348
+
349
+#define CONFIG_MAX_NAME 1024
350
+#define CONFIG_MAX_VALUE 1024
351
+#define CONFIG_FILENAME "netdata.conf"
352
+#define CONFIG_FILE_LINE_MAX 4096
353
+
354
+pthread_mutex_t config_mutex = PTHREAD_MUTEX_INITIALIZER;
355
+
356
+struct config_value {
357
+ char name[CONFIG_MAX_NAME + 1];
358
+ char value[CONFIG_MAX_VALUE + 1];
359
+
360
+ int used;
361
+
362
+ struct config_value *next;
363
+};
364
+
365
+struct config {
366
+ char name[CONFIG_MAX_NAME + 1];
367
+
368
+ struct config_value *values;
369
+
370
+ struct config *next;
371
+} *config_root = NULL;
372
+
373
+
374
+struct config_value *config_value_create(struct config *co, char *name, char *value)
375
+{
376
+ debug(D_CONFIG, "Creating config entry for name '%s', value '%s', in section '%s'.", name, value, co->name);
377
+
378
+ struct config_value *cv = calloc(1, sizeof(struct config_value));
379
+ if(!cv) fatal("Cannot allocate config_value");
380
+
381
+ strncpy(cv->name, name, CONFIG_MAX_NAME);
382
+ strncpy(cv->value, value, CONFIG_MAX_VALUE);
383
+
384
+ // no need for string termination, due to calloc()
385
+
386
+ struct config_value *cv2 = co->values;
387
+ if(cv2) {
388
+ while (cv2->next) cv2 = cv2->next;
389
+ cv2->next = cv;
390
+ }
391
+ else co->values = cv;
392
+
393
+ return cv;
394
+}
395
+
396
+struct config *config_create(char *section)
397
+{
398
+ debug(D_CONFIG, "Creating section '%s'.", section);
399
+
400
+ struct config *co = calloc(1, sizeof(struct config));
401
+ if(!co) fatal("Cannot allocate config");
402
+
403
+ strncpy(co->name, section, CONFIG_MAX_NAME);
404
+
405
+ // no need for string termination, due to calloc()
406
+
407
+ struct config *co2 = config_root;
408
+ if(co2) {
409
+ while (co2->next) co2 = co2->next;
410
+ co2->next = co;
411
+ }
412
+ else config_root = co;
413
+
414
+ return co;
415
+}
416
+
417
+struct config *config_find_section(char *section)
418
+{
419
+ struct config *co;
420
+
421
+ for(co = config_root; co ; co = co->next)
422
+ if(strcmp(co->name, section) == 0) break;
423
+
424
+ return co;
425
+}
426
+
427
+char *trim(char *s)
428
+{
429
+ // skip leading spaces
430
+ while(*s && isspace(*s)) s++;
431
+ if(!*s || *s == '#') return NULL;
432
+
433
+ // skip tailing spaces
434
+ int c = strlen(s) - 1;
435
+ while(c >= 0 && isspace(s[c])) {
436
+ s[c] = '\0';
437
+ c--;
438
+ }
439
+ if(c < 0) return NULL;
440
+ if(!*s) return NULL;
441
+ return s;
442
+}
443
+
444
+int load_config(char *filename, int overwrite_used)
445
+{
446
+ int line = 0;
447
+ struct config *co = NULL;
448
+
449
+ pthread_mutex_lock(&config_mutex);
450
+
451
+ char buffer[CONFIG_FILE_LINE_MAX + 1], *s;
452
+
453
+ if(!filename) filename = CONFIG_FILENAME;
454
+ FILE *fp = fopen(filename, "r");
455
+ if(!fp) {
456
+ error("Cannot open file '%s'", CONFIG_FILENAME);
457
+ pthread_mutex_unlock(&config_mutex);
458
+ return 0;
459
+ }
460
+
461
+ while(fgets(buffer, CONFIG_FILE_LINE_MAX, fp) != NULL) {
462
+ buffer[CONFIG_FILE_LINE_MAX] = '\0';
463
+ line++;
464
+
465
+ s = trim(buffer);
466
+ if(!s) {
467
+ debug(D_CONFIG, "Ignoring line %d, it is empty.", line);
468
+ continue;
469
+ }
470
+
471
+ int len = strlen(s);
472
+ if(*s == '[' && s[len - 1] == ']') {
473
+ // new section
474
+ s[len - 1] = '\0';
475
+ s++;
476
+
477
+ co = config_find_section(s);
478
+ if(!co) co = config_create(s);
479
+
480
+ continue;
481
+ }
482
+
483
+ if(!co) {
484
+ // line outside a section
485
+ error("Ignoring line %d ('%s'), it is outsize all sections.", line, s);
486
+ continue;
487
+ }
488
+
489
+ char *name = s;
490
+ char *value = strchr(s, '=');
491
+ if(!value) {
492
+ error("Ignoring line %d ('%s'), there is no = in it.", line, s);
493
+ continue;
494
+ }
495
+ *value = '\0';
496
+ value++;
497
+
498
+ name = trim(name);
499
+ value = trim(value);
500
+
501
+ if(!name) {
502
+ error("Ignoring line %d, name is empty.", line);
503
+ continue;
504
+ }
505
+ if(!value) {
506
+ debug(D_CONFIG, "Ignoring line %d, value is empty.", line);
507
+ continue;
508
+ }
509
+
510
+ struct config_value *cv;
511
+ for(cv = co->values; cv ; cv = cv->next)
512
+ if(strcmp(cv->name, name) == 0) break;
513
+
514
+ if(!cv) cv = config_value_create(co, name, value);
515
+ else {
516
+ if((cv->used && overwrite_used) || !cv->used) {
517
+ debug(D_CONFIG, "Overwriting '%s/%s'.", line, co->name, cv->name);
518
+ strncpy(cv->value, value, CONFIG_MAX_VALUE);
519
+ // termination is already there
520
+ }
521
+ else
522
+ debug(D_CONFIG, "Ignoring line %d, '%s/%s' is already present and used.", line, co->name, cv->name);
523
+ }
524
+ }
525
+
526
+ fclose(fp);
527
+
528
+ pthread_mutex_unlock(&config_mutex);
529
+ return 1;
530
+}
531
+
532
+char *config_get(char *section, char *name, char *default_value)
533
+{
534
+ struct config_value *cv;
535
+
536
+ pthread_mutex_lock(&config_mutex);
537
+
538
+ struct config *co = config_find_section(section);
539
+ if(!co) co = config_create(section);
540
+
541
+ for(cv = co->values; cv ; cv = cv->next)
542
+ if(strcmp(cv->name, name) == 0) break;
543
+
544
+ if(!cv) cv = config_value_create(co, name, default_value);
545
+ cv->used = 1;
546
+
547
+ pthread_mutex_unlock(&config_mutex);
548
+ return(cv->value);
549
+}
550
+
551
+long long config_get_number(char *section, char *name, long long value)
552
+{
553
+ char buffer[100], *s;
554
+ sprintf(buffer, "%lld", value);
555
+
556
+ s = config_get(section, name, buffer);
557
+ return strtoll(s, NULL, 0);
558
+}
559
+
560
+void config_set(char *section, char *name, char *value)
561
+{
562
+ struct config_value *cv;
563
+
564
+ pthread_mutex_lock(&config_mutex);
565
+
566
+ struct config *co = config_find_section(section);
567
+ if(!co) co = config_create(section);
568
+
569
+ for(cv = co->values; cv ; cv = cv->next)
570
+ if(strcmp(cv->name, name) == 0) break;
571
+
572
+ if(!cv) cv = config_value_create(co, name, value);
573
+ cv->used = 1;
574
+
575
+ strncpy(cv->value, value, CONFIG_MAX_VALUE);
576
+ // termination is already there
577
+
578
+ pthread_mutex_unlock(&config_mutex);
579
+}
580
+
581
+void config_set_number(char *section, char *name, long long value)
582
+{
583
+ char buffer[100];
584
+ sprintf(buffer, "%lld", value);
585
+
586
+ config_set(section, name, buffer);
587
+}
588
+
589
+
590
+
591
+
592
// ----------------------------------------------------------------------------
593
// RRD STATS
594
@@ -387,11 +634,8 @@ struct rrd_stats {
634
char title[RRD_STATS_NAME_MAX + 1]; // title shown to user
635
char units[RRD_STATS_NAME_MAX + 1]; // units of measurement
636
390
- char usertitle[RRD_STATS_NAME_MAX + 1]; // the title as taken from the environment variable
391
- char userpriority[RRD_STATS_NAME_MAX + 1]; // the priority as taken from the environment variable
392
-
393
- char envtitle[RRD_STATS_NAME_MAX + 1]; // the variable name for taking the title
394
- char envpriority[RRD_STATS_NAME_MAX + 1]; // the variable name for taking the priority
637
+ char usertitle[RRD_STATS_NAME_MAX + 1];
638
+ long userpriority;
639
640
size_t entries; // total number of entries in the data set
641
size_t current_entry; // the entry that is currently being updated
@@ -403,6 +647,8 @@ struct rrd_stats {
647
int isdetail; // if set, the data set should be considered as a detail of another
648
// (the master data set should be the one that has the same group and is not detail)
649
650
+ int enabled;
651
+
652
struct timeval *times; // the time in microseconds each data entry was collected
653
RRD_DIMENSION *dimensions; // the actual data for every dimension
654
@@ -413,7 +659,7 @@ typedef struct rrd_stats RRD_STATS;
659
RRD_STATS *root = NULL;
660
pthread_mutex_t root_mutex = PTHREAD_MUTEX_INITIALIZER;
661
416
-RRD_STATS *rrd_stats_create(const char *type, const char *id, const char *name, const char *group, const char *title, const char *units, unsigned long entries)
662
+RRD_STATS *rrd_stats_create(const char *type, const char *id, const char *name, const char *group, const char *title, const char *units, long priority)
663
{
664
RRD_STATS *st = NULL;
665
char *p;
@@ -431,13 +677,6 @@ RRD_STATS *rrd_stats_create(const char *type, const char *id, const char *name,
677
return NULL;
678
}
679
434
- st->times = calloc(entries, sizeof(struct timeval));
435
- if(!st->times) {
436
- free(st);
437
- fatal("Cannot allocate %lu entries of %lu bytes each for RRD_STATS.", st->entries, sizeof(struct timeval));
438
- return NULL;
439
- }
440
-
680
// no need to terminate the strings after strncpy(), because of calloc()
681
682
strncpy(st->id, type, RRD_STATS_NAME_MAX-1);
@@ -466,26 +705,26 @@ RRD_STATS *rrd_stats_create(const char *type, const char *id, const char *name,
705
strncpy(st->units, units, RRD_STATS_NAME_MAX);
706
strncpy(st->type, type, RRD_STATS_NAME_MAX);
707
469
- // check if there is a name for it in the environment
470
- sprintf(st->envtitle, "NETDATA_TITLE_%s", st->id);
471
- while((p = strchr(st->envtitle, '/'))) *p = '_';
472
- while((p = strchr(st->envtitle, '.'))) *p = '_';
473
- while((p = strchr(st->envtitle, '-'))) *p = '_';
474
- p = getenv(st->envtitle);
708
+ snprintf(st->usertitle, RRD_STATS_NAME_MAX, "%s (%s)", st->title, st->name);
709
+ strncpy(st->usertitle, config_get(st->id, "title", st->usertitle), RRD_STATS_NAME_MAX);
710
476
- if(p) strncpy(st->usertitle, p, RRD_STATS_NAME_MAX);
477
- else strncpy(st->usertitle, st->name, RRD_STATS_NAME_MAX);
711
+ p = config_get(st->id, "history", "default");
712
+ st->entries = strtoul(p, NULL, 0);
713
+ if(strcmp(p, "default") == 0) st->entries = save_history;
714
+ if(st->entries < 5) st->entries = 5;
715
+ if(st->entries > HISTORY_MAX) st->entries = HISTORY_MAX;
716
479
- sprintf(st->envpriority, "NETDATA_PRIORITY_%s", st->id);
480
- while((p = strchr(st->envpriority, '/'))) *p = '_';
481
- while((p = strchr(st->envpriority, '.'))) *p = '_';
482
- while((p = strchr(st->envpriority, '-'))) *p = '_';
483
- p = getenv(st->envpriority);
717
+ st->userpriority = config_get_number(st->id, "priority", priority);
718
+ st->enabled = config_get_number(st->id, "enabled", 1);
719
+ if(!st->enabled) st->entries = 5;
720
485
- if(p) strncpy(st->userpriority, p, RRD_STATS_NAME_MAX);
486
- else strncpy(st->userpriority, st->name, RRD_STATS_NAME_MAX);
487
-
488
- st->entries = entries;
721
+ st->times = calloc(st->entries, sizeof(struct timeval));
722
+ if(!st->times) {
723
+ free(st);
724
+ fatal("Cannot allocate %lu entries of %lu bytes each for RRD_STATS.", st->entries, sizeof(struct timeval));
725
+ return NULL;
726
+ }
727
+
728
st->current_entry = 0;
729
// st->last_entry = 0;
730
st->dimensions = NULL;
@@ -978,16 +1217,10 @@ unsigned long rrd_stats_one_json(RRD_STATS *st, char *options, struct web_buffer
1217
wb->bytes += sprintf(&wb->buffer[wb->bytes], "\t\t\t\"name\" : \"%s\",\n", st->name);
1218
wb->bytes += sprintf(&wb->buffer[wb->bytes], "\t\t\t\"type\" : \"%s\",\n", st->type);
1219
wb->bytes += sprintf(&wb->buffer[wb->bytes], "\t\t\t\"group_tag\" : \"%s\",\n", st->group);
981
- wb->bytes += sprintf(&wb->buffer[wb->bytes], "\t\t\t\"title\" : \"%s\",\n", st->title);
982
-
983
- if(strcmp(st->id, st->usertitle) == 0 || strcmp(st->name, st->usertitle) == 0)
984
- wb->bytes += sprintf(&wb->buffer[wb->bytes], "\t\t\t\"usertitle\" : \"%s (%s)\",\n", st->title, st->name);
985
- else
986
- wb->bytes += sprintf(&wb->buffer[wb->bytes], "\t\t\t\"usertitle\" : \"%s %s (%s)\",\n", st->title, st->usertitle, st->name);
987
-
988
- wb->bytes += sprintf(&wb->buffer[wb->bytes], "\t\t\t\"userpriority\" : \"%s\",\n", st->userpriority);
989
- //wb->bytes += sprintf(&wb->buffer[wb->bytes], "\t\t\t\"envtitle\" : \"%s\",\n", st->envtitle);
990
- //wb->bytes += sprintf(&wb->buffer[wb->bytes], "\t\t\t\"envpriority\" : \"%s\",\n", st->envpriority);
1220
+ //wb->bytes += sprintf(&wb->buffer[wb->bytes], "\t\t\t\"title\" : \"%s\",\n", st->title);
1221
+ wb->bytes += sprintf(&wb->buffer[wb->bytes], "\t\t\t\"title\" : \"%s\",\n", st->usertitle);
1222
+ wb->bytes += sprintf(&wb->buffer[wb->bytes], "\t\t\t\"priority\" : %ld,\n", st->userpriority);
1223
+ wb->bytes += sprintf(&wb->buffer[wb->bytes], "\t\t\t\"enabled\" : %d,\n", st->enabled);
1224
wb->bytes += sprintf(&wb->buffer[wb->bytes], "\t\t\t\"units\" : \"%s\",\n", st->units);
1225
wb->bytes += sprintf(&wb->buffer[wb->bytes], "\t\t\t\"url\" : \"/data/%s/%s\",\n", st->name, options?options:"");
1226
wb->bytes += sprintf(&wb->buffer[wb->bytes], "\t\t\t\"entries\" : %ld,\n", st->entries);
@@ -1386,6 +1619,26 @@ unsigned long rrd_stats_json(int type, RRD_STATS *st, struct web_buffer *wb, siz
1619
return last_timestamp;
1620
}
1621
1622
+void generate_config(struct web_buffer *wb)
1623
+{
1624
+ struct config *co;
1625
+ struct config_value *cv;
1626
+
1627
+ for(co = config_root; co ; co = co->next) {
1628
+ web_buffer_increase(wb, CONFIG_MAX_NAME + 4);
1629
+ wb->bytes += sprintf(&wb->buffer[wb->bytes], "\n[%s]\n", co->name);
1630
+
1631
+ for(cv = co->values; cv ; cv = cv->next) {
1632
+ if(!cv->used) {
1633
+ web_buffer_increase(wb, CONFIG_MAX_NAME + 200);
1634
+ wb->bytes += sprintf(&wb->buffer[wb->bytes], "\t# the option '%s' is not used, you can remove it\n", cv->name);
1635
+ }
1636
+ web_buffer_increase(wb, CONFIG_MAX_NAME + CONFIG_MAX_VALUE + 5);
1637
+ wb->bytes += sprintf(&wb->buffer[wb->bytes], "\t%s = %s\n", cv->name, cv->value);
1638
+ }
1639
+ }
1640
+}
1641
+
1642
int mysendfile(struct web_client *w, char *filename)
1643
{
1644
debug(D_WEB_CLIENT, "%llu: Looking for file '%s'...", w->id, filename);
@@ -1833,19 +2086,6 @@ void web_client_process(struct web_client *w)
2086
for ( ; st ; st = st->next )
2087
w->data->bytes += sprintf(&w->data->buffer[w->data->bytes], "%s\n", st->name);
2088
}
1836
- else if(strcmp(tok, "envlist") == 0) {
1837
- code = 200;
1838
-
1839
- debug(D_WEB_CLIENT_ACCESS, "%llu: Sending envlist of RRD_STATS...", w->id);
1840
-
1841
- w->data->bytes = 0;
1842
- RRD_STATS *st = root;
1843
-
1844
- for ( ; st ; st = st->next ) {
1845
- w->data->bytes += sprintf(&w->data->buffer[w->data->bytes], "%s=%s\n", st->envtitle, st->usertitle);
1846
- w->data->bytes += sprintf(&w->data->buffer[w->data->bytes], "%s=%s\n", st->envpriority, st->userpriority);
1847
- }
1848
- }
2089
else if(strcmp(tok, "all.json") == 0) {
2090
code = 200;
2091
debug(D_WEB_CLIENT_ACCESS, "%llu: Sending JSON list of all monitors of RRD_STATS...", w->id);
@@ -1854,6 +2094,14 @@ void web_client_process(struct web_client *w)
2094
w->data->bytes = 0;
2095
rrd_stats_all_json(w->data);
2096
}
2097
+ else if(strcmp(tok, "netdata.conf") == 0) {
2098
+ code = 200;
2099
+ debug(D_WEB_CLIENT_ACCESS, "%llu: Sending netdata.conf ...", w->id);
2100
+
2101
+ w->data->contenttype = CT_TEXT_PLAIN;
2102
+ w->data->bytes = 0;
2103
+ generate_config(w->data);
2104
+ }
2105
else if(strcmp(tok, WEB_PATH_FILE) == 0) { // "file"
2106
tok = mystrsep(&url, "/?&");
2107
if(tok && *tok) code = mysendfile(w, tok);
@@ -2580,7 +2828,7 @@ int do_proc_net_dev() {
2828
2829
RRD_STATS *st = rrd_stats_find_bytype(RRD_TYPE_NET, iface);
2830
if(!st) {
2583
- st = rrd_stats_create(RRD_TYPE_NET, iface, NULL, iface, "Bandwidth", "kilobits/s", save_history);
2831
+ st = rrd_stats_create(RRD_TYPE_NET, iface, NULL, iface, "Bandwidth", "kilobits/s", 1000);
2832
2833
rrd_stats_dimension_add(st, "received", NULL, sizeof(unsigned long long), 0, 8, 1024, RRD_DIMENSION_INCREMENTAL, NULL);
2834
rrd_stats_dimension_add(st, "sent", NULL, sizeof(unsigned long long), 0, -8, 1024, RRD_DIMENSION_INCREMENTAL, NULL);
@@ -2595,7 +2843,7 @@ int do_proc_net_dev() {
2843
2844
st = rrd_stats_find_bytype("net_packets", iface);
2845
if(!st) {
2598
- st = rrd_stats_create("net_packets", iface, NULL, iface, "Packets", "packets/s", save_history);
2846
+ st = rrd_stats_create("net_packets", iface, NULL, iface, "Packets", "packets/s", 1001);
2847
st->isdetail = 1;
2848
2849
rrd_stats_dimension_add(st, "received", NULL, sizeof(unsigned long long), 0, 1, 1, RRD_DIMENSION_INCREMENTAL, NULL);
@@ -2611,7 +2859,7 @@ int do_proc_net_dev() {
2859
2860
st = rrd_stats_find_bytype("net_errors", iface);
2861
if(!st) {
2614
- st = rrd_stats_create("net_errors", iface, NULL, iface, "Interface Errors", "errors/s", save_history);
2862
+ st = rrd_stats_create("net_errors", iface, NULL, iface, "Interface Errors", "errors/s", 1002);
2863
st->isdetail = 1;
2864
2865
rrd_stats_dimension_add(st, "receive", NULL, sizeof(unsigned long long), 0, 1, 1, RRD_DIMENSION_INCREMENTAL, NULL);
@@ -2627,7 +2875,7 @@ int do_proc_net_dev() {
2875
2876
st = rrd_stats_find_bytype("net_fifo", iface);
2877
if(!st) {
2630
- st = rrd_stats_create("net_fifo", iface, NULL, iface, "Interface Queue", "packets", save_history);
2878
+ st = rrd_stats_create("net_fifo", iface, NULL, iface, "Interface Queue", "packets", 1100);
2879
st->isdetail = 1;
2880
2881
rrd_stats_dimension_add(st, "receive", NULL, sizeof(unsigned long long), 0, 1, 1, RRD_DIMENSION_ABSOLUTE, NULL);
@@ -2643,7 +2891,7 @@ int do_proc_net_dev() {
2891
2892
st = rrd_stats_find_bytype("net_compressed", iface);
2893
if(!st) {
2646
- st = rrd_stats_create("net_compressed", iface, NULL, iface, "Compressed Packets", "packets/s", save_history);
2894
+ st = rrd_stats_create("net_compressed", iface, NULL, iface, "Compressed Packets", "packets/s", 1200);
2895
st->isdetail = 1;
2896
2897
rrd_stats_dimension_add(st, "received", NULL, sizeof(unsigned long long), 0, 1, 1, RRD_DIMENSION_INCREMENTAL, NULL);
@@ -2831,7 +3079,7 @@ int do_proc_diskstats() {
3079
}
3080
else error("Cannot read sector size for device %s from %s. Assuming 512.", disk, ssfilename);
3081
2834
- st = rrd_stats_create(RRD_TYPE_DISK, disk, NULL, disk, "Disk I/O", "kilobytes/s", save_history);
3082
+ st = rrd_stats_create(RRD_TYPE_DISK, disk, NULL, disk, "Disk I/O", "kilobytes/s", 2000);
3083
3084
rrd_stats_dimension_add(st, "reads", NULL, sizeof(unsigned long long), 0, sector_size, 1024, RRD_DIMENSION_INCREMENTAL, NULL);
3085
rrd_stats_dimension_add(st, "writes", NULL, sizeof(unsigned long long), 0, sector_size * -1, 1024, RRD_DIMENSION_INCREMENTAL, NULL);
@@ -2846,7 +3094,7 @@ int do_proc_diskstats() {
3094
3095
st = rrd_stats_find_bytype("disk_ops", disk);
3096
if(!st) {
2849
- st = rrd_stats_create("disk_ops", disk, NULL, disk, "Disk Operations", "operations/s", save_history);
3097
+ st = rrd_stats_create("disk_ops", disk, NULL, disk, "Disk Operations", "operations/s", 2001);
3098
st->isdetail = 1;
3099
3100
rrd_stats_dimension_add(st, "reads", NULL, sizeof(unsigned long long), 0, 1, 1, RRD_DIMENSION_INCREMENTAL, NULL);
@@ -2862,7 +3110,7 @@ int do_proc_diskstats() {
3110
3111
st = rrd_stats_find_bytype("disk_merged_ops", disk);
3112
if(!st) {
2865
- st = rrd_stats_create("disk_merged_ops", disk, NULL, disk, "Merged Disk Operations", "operations/s", save_history);
3113
+ st = rrd_stats_create("disk_merged_ops", disk, NULL, disk, "Merged Disk Operations", "operations/s", 2010);
3114
st->isdetail = 1;
3115
3116
rrd_stats_dimension_add(st, "reads", NULL, sizeof(unsigned long long), 0, 1, 1, RRD_DIMENSION_INCREMENTAL, NULL);
@@ -2878,7 +3126,7 @@ int do_proc_diskstats() {
3126
3127
st = rrd_stats_find_bytype("disk_iotime", disk);
3128
if(!st) {
2881
- st = rrd_stats_create("disk_iotime", disk, NULL, disk, "Disk I/O Time", "milliseconds/s", save_history);
3129
+ st = rrd_stats_create("disk_iotime", disk, NULL, disk, "Disk I/O Time", "milliseconds/s", 2005);
3130
st->isdetail = 1;
3131
3132
rrd_stats_dimension_add(st, "reads", NULL, sizeof(unsigned long long), 0, 1, 1, RRD_DIMENSION_INCREMENTAL, NULL);
@@ -2898,7 +3146,7 @@ int do_proc_diskstats() {
3146
3147
st = rrd_stats_find_bytype("disk_cur_ops", disk);
3148
if(!st) {
2901
- st = rrd_stats_create("disk_cur_ops", disk, NULL, disk, "Current Disk I/O operations", "operations", save_history);
3149
+ st = rrd_stats_create("disk_cur_ops", disk, NULL, disk, "Current Disk I/O operations", "operations", 2004);
3150
st->isdetail = 1;
3151
3152
rrd_stats_dimension_add(st, "operations", NULL, sizeof(unsigned long long), 0, 1, 1, RRD_DIMENSION_ABSOLUTE, NULL);
@@ -2954,7 +3202,7 @@ int do_proc_net_snmp() {
3202
3203
RRD_STATS *st = rrd_stats_find(RRD_TYPE_NET_SNMP ".packets");
3204
if(!st) {
2957
- st = rrd_stats_create(RRD_TYPE_NET_SNMP, "packets", NULL, RRD_TYPE_NET_SNMP, "IPv4 Packets", "packets/s", save_history);
3205
+ st = rrd_stats_create(RRD_TYPE_NET_SNMP, "packets", NULL, RRD_TYPE_NET_SNMP, "IPv4 Packets", "packets/s", 3000);
3206
3207
rrd_stats_dimension_add(st, "received", NULL, sizeof(unsigned long long), 0, 1, 1, RRD_DIMENSION_INCREMENTAL, NULL);
3208
rrd_stats_dimension_add(st, "sent", NULL, sizeof(unsigned long long), 0, -1, 1, RRD_DIMENSION_INCREMENTAL, NULL);
@@ -2971,7 +3219,7 @@ int do_proc_net_snmp() {
3219
3220
st = rrd_stats_find(RRD_TYPE_NET_SNMP ".fragsout");
3221
if(!st) {
2974
- st = rrd_stats_create(RRD_TYPE_NET_SNMP, "fragsout", NULL, RRD_TYPE_NET_SNMP, "IPv4 Fragments Sent", "packets/s", save_history);
3222
+ st = rrd_stats_create(RRD_TYPE_NET_SNMP, "fragsout", NULL, RRD_TYPE_NET_SNMP, "IPv4 Fragments Sent", "packets/s", 3010);
3223
st->isdetail = 1;
3224
3225
rrd_stats_dimension_add(st, "ok", NULL, sizeof(unsigned long long), 0, 1, 1, RRD_DIMENSION_INCREMENTAL, NULL);
@@ -2989,7 +3237,7 @@ int do_proc_net_snmp() {
3237
3238
st = rrd_stats_find(RRD_TYPE_NET_SNMP ".fragsin");
3239
if(!st) {
2992
- st = rrd_stats_create(RRD_TYPE_NET_SNMP, "fragsin", NULL, RRD_TYPE_NET_SNMP, "IPv4 Fragments Reassembly", "packets/s", save_history);
3240
+ st = rrd_stats_create(RRD_TYPE_NET_SNMP, "fragsin", NULL, RRD_TYPE_NET_SNMP, "IPv4 Fragments Reassembly", "packets/s", 3011);
3241
st->isdetail = 1;
3242
3243
rrd_stats_dimension_add(st, "ok", NULL, sizeof(unsigned long long), 0, 1, 1, RRD_DIMENSION_INCREMENTAL, NULL);
@@ -3007,7 +3255,7 @@ int do_proc_net_snmp() {
3255
3256
st = rrd_stats_find(RRD_TYPE_NET_SNMP ".errors");
3257
if(!st) {
3010
- st = rrd_stats_create(RRD_TYPE_NET_SNMP, "errors", NULL, RRD_TYPE_NET_SNMP, "IPv4 Errors", "packets/s", save_history);
3258
+ st = rrd_stats_create(RRD_TYPE_NET_SNMP, "errors", NULL, RRD_TYPE_NET_SNMP, "IPv4 Errors", "packets/s", 3002);
3259
st->isdetail = 1;
3260
3261
rrd_stats_dimension_add(st, "InDiscards", NULL, sizeof(unsigned long long), 0, 1, 1, RRD_DIMENSION_INCREMENTAL, NULL);
@@ -3053,7 +3301,7 @@ int do_proc_net_snmp() {
3301
// see http://net-snmp.sourceforge.net/docs/mibs/tcp.html
3302
RRD_STATS *st = rrd_stats_find(RRD_TYPE_NET_SNMP ".tcpsock");
3303
if(!st) {
3056
- st = rrd_stats_create(RRD_TYPE_NET_SNMP, "tcpsock", NULL, "tcp", "IPv4 TCP Connections", "active connections", save_history);
3304
+ st = rrd_stats_create(RRD_TYPE_NET_SNMP, "tcpsock", NULL, "tcp", "IPv4 TCP Connections", "active connections", 2500);
3305
3306
rrd_stats_dimension_add(st, "connections", NULL, sizeof(unsigned long long), 0, 1, 1, RRD_DIMENSION_ABSOLUTE, NULL);
3307
}
@@ -3066,7 +3314,7 @@ int do_proc_net_snmp() {
3314
3315
st = rrd_stats_find(RRD_TYPE_NET_SNMP ".tcppackets");
3316
if(!st) {
3069
- st = rrd_stats_create(RRD_TYPE_NET_SNMP, "tcppackets", NULL, "tcp", "IPv4 TCP Packets", "packets/s", save_history);
3317
+ st = rrd_stats_create(RRD_TYPE_NET_SNMP, "tcppackets", NULL, "tcp", "IPv4 TCP Packets", "packets/s", 2600);
3318
3319
rrd_stats_dimension_add(st, "received", NULL, sizeof(unsigned long long), 0, 1, 1, RRD_DIMENSION_INCREMENTAL, NULL);
3320
rrd_stats_dimension_add(st, "sent", NULL, sizeof(unsigned long long), 0, -1, 1, RRD_DIMENSION_INCREMENTAL, NULL);
@@ -3081,7 +3329,7 @@ int do_proc_net_snmp() {
3329
3330
st = rrd_stats_find(RRD_TYPE_NET_SNMP ".tcperrors");
3331
if(!st) {
3084
- st = rrd_stats_create(RRD_TYPE_NET_SNMP, "tcperrors", NULL, "tcp", "IPv4 TCP Errors", "packets/s", save_history);
3332
+ st = rrd_stats_create(RRD_TYPE_NET_SNMP, "tcperrors", NULL, "tcp", "IPv4 TCP Errors", "packets/s", 2700);
3333
st->isdetail = 1;
3334
3335
rrd_stats_dimension_add(st, "InErrs", NULL, sizeof(unsigned long long), 0, 1, 1, RRD_DIMENSION_INCREMENTAL, NULL);
@@ -3097,7 +3345,7 @@ int do_proc_net_snmp() {
3345
3346
st = rrd_stats_find(RRD_TYPE_NET_SNMP ".tcphandshake");
3347
if(!st) {
3100
- st = rrd_stats_create(RRD_TYPE_NET_SNMP, "tcphandshake", NULL, "tcp", "IPv4 TCP Handshake Issues", "events/s", save_history);
3348
+ st = rrd_stats_create(RRD_TYPE_NET_SNMP, "tcphandshake", NULL, "tcp", "IPv4 TCP Handshake Issues", "events/s", 2900);
3349
st->isdetail = 1;
3350
3351
rrd_stats_dimension_add(st, "EstabResets", NULL, sizeof(unsigned long long), 0, 1, 1, RRD_DIMENSION_INCREMENTAL, NULL);
@@ -3138,7 +3386,7 @@ int do_proc_net_snmp() {
3386
// see http://net-snmp.sourceforge.net/docs/mibs/udp.html
3387
RRD_STATS *st = rrd_stats_find(RRD_TYPE_NET_SNMP ".udppackets");
3388
if(!st) {
3141
- st = rrd_stats_create(RRD_TYPE_NET_SNMP, "udppackets", NULL, "udp", "IPv4 UDP Packets", "packets/s", save_history);
3389
+ st = rrd_stats_create(RRD_TYPE_NET_SNMP, "udppackets", NULL, "udp", "IPv4 UDP Packets", "packets/s", 2601);
3390
3391
rrd_stats_dimension_add(st, "received", NULL, sizeof(unsigned long long), 0, 1, 1, RRD_DIMENSION_INCREMENTAL, NULL);
3392
rrd_stats_dimension_add(st, "sent", NULL, sizeof(unsigned long long), 0, -1, 1, RRD_DIMENSION_INCREMENTAL, NULL);
@@ -3153,7 +3401,7 @@ int do_proc_net_snmp() {
3401
3402
st = rrd_stats_find(RRD_TYPE_NET_SNMP ".udperrors");
3403
if(!st) {
3156
- st = rrd_stats_create(RRD_TYPE_NET_SNMP, "udperrors", NULL, "udp", "IPv4 UDP Errors", "events/s", save_history);
3404
+ st = rrd_stats_create(RRD_TYPE_NET_SNMP, "udperrors", NULL, "udp", "IPv4 UDP Errors", "events/s", 2701);
3405
st->isdetail = 1;
3406
3407
rrd_stats_dimension_add(st, "RcvbufErrors", NULL, sizeof(unsigned long long), 0, 1, 1, RRD_DIMENSION_INCREMENTAL, NULL);
@@ -3220,7 +3468,7 @@ int do_proc_net_netstat() {
3468
3469
RRD_STATS *st = rrd_stats_find("system.ipv4");
3470
if(!st) {
3223
- st = rrd_stats_create("system", "ipv4", NULL, "ipv4", "IPv4 Bandwidth", "kilobits/s", save_history);
3471
+ st = rrd_stats_create("system", "ipv4", NULL, "ipv4", "IPv4 Bandwidth", "kilobits/s", 2000);
3472
3473
rrd_stats_dimension_add(st, "received", NULL, sizeof(unsigned long long), 0, 8, 1024, RRD_DIMENSION_INCREMENTAL, NULL);
3474
rrd_stats_dimension_add(st, "sent", NULL, sizeof(unsigned long long), 0, -8, 1024, RRD_DIMENSION_INCREMENTAL, NULL);
@@ -3235,7 +3483,7 @@ int do_proc_net_netstat() {
3483
3484
st = rrd_stats_find("ipv4.inerrors");
3485
if(!st) {
3238
- st = rrd_stats_create("ipv4", "inerrors", NULL, "ipv4", "IPv4 Input Errors", "packets/s", save_history);
3486
+ st = rrd_stats_create("ipv4", "inerrors", NULL, "ipv4", "IPv4 Input Errors", "packets/s", 4000);
3487
st->isdetail = 1;
3488
3489
rrd_stats_dimension_add(st, "noroutes", NULL, sizeof(unsigned long long), 0, 1, 1, RRD_DIMENSION_INCREMENTAL, NULL);
@@ -3251,7 +3499,7 @@ int do_proc_net_netstat() {
3499
3500
st = rrd_stats_find("ipv4.mcast");
3501
if(!st) {
3254
- st = rrd_stats_create("ipv4", "mcast", NULL, "ipv4", "IPv4 Multicast Bandwidth", "kilobits/s", save_history);
3502
+ st = rrd_stats_create("ipv4", "mcast", NULL, "ipv4", "IPv4 Multicast Bandwidth", "kilobits/s", 9000);
3503
st->isdetail = 1;
3504
3505
rrd_stats_dimension_add(st, "received", NULL, sizeof(unsigned long long), 0, 8, 1024, RRD_DIMENSION_INCREMENTAL, NULL);
@@ -3267,7 +3515,7 @@ int do_proc_net_netstat() {
3515
3516
st = rrd_stats_find("ipv4.bcast");
3517
if(!st) {
3270
- st = rrd_stats_create("ipv4", "bcast", NULL, "ipv4", "IPv4 Broadcast Bandwidth", "kilobits/s", save_history);
3518
+ st = rrd_stats_create("ipv4", "bcast", NULL, "ipv4", "IPv4 Broadcast Bandwidth", "kilobits/s", 8000);
3519
st->isdetail = 1;
3520
3521
rrd_stats_dimension_add(st, "received", NULL, sizeof(unsigned long long), 0, 8, 1024, RRD_DIMENSION_INCREMENTAL, NULL);
@@ -3283,7 +3531,7 @@ int do_proc_net_netstat() {
3531
3532
st = rrd_stats_find("ipv4.mcastpkts");
3533
if(!st) {
3286
- st = rrd_stats_create("ipv4", "mcastpkts", NULL, "ipv4", "IPv4 Multicast Packets", "packets/s", save_history);
3534
+ st = rrd_stats_create("ipv4", "mcastpkts", NULL, "ipv4", "IPv4 Multicast Packets", "packets/s", 9500);
3535
st->isdetail = 1;
3536
3537
rrd_stats_dimension_add(st, "received", NULL, sizeof(unsigned long long), 0, 1, 1, RRD_DIMENSION_INCREMENTAL, NULL);
@@ -3299,7 +3547,7 @@ int do_proc_net_netstat() {
3547
3548
st = rrd_stats_find("ipv4.bcastpkts");
3549
if(!st) {
3302
- st = rrd_stats_create("ipv4", "bcastpkts", NULL, "ipv4", "IPv4 Broadcast Packets", "packets/s", save_history);
3550
+ st = rrd_stats_create("ipv4", "bcastpkts", NULL, "ipv4", "IPv4 Broadcast Packets", "packets/s", 8500);
3551
st->isdetail = 1;
3552
3553
rrd_stats_dimension_add(st, "received", NULL, sizeof(unsigned long long), 0, 1, 1, RRD_DIMENSION_INCREMENTAL, NULL);
@@ -3373,7 +3621,7 @@ int do_proc_net_stat_conntrack() {
3621
3622
RRD_STATS *st = rrd_stats_find(RRD_TYPE_NET_STAT_CONNTRACK ".sockets");
3623
if(!st) {
3376
- st = rrd_stats_create(RRD_TYPE_NET_STAT_CONNTRACK, "sockets", NULL, RRD_TYPE_NET_STAT_CONNTRACK, "Netfilter Connections", "active connections", save_history);
3624
+ st = rrd_stats_create(RRD_TYPE_NET_STAT_CONNTRACK, "sockets", NULL, RRD_TYPE_NET_STAT_CONNTRACK, "Netfilter Connections", "active connections", 1000);
3625
3626
rrd_stats_dimension_add(st, "connections", NULL, sizeof(unsigned long long), 0, 1, 1, RRD_DIMENSION_ABSOLUTE, NULL);
3627
}
@@ -3386,7 +3634,7 @@ int do_proc_net_stat_conntrack() {
3634
3635
st = rrd_stats_find(RRD_TYPE_NET_STAT_CONNTRACK ".new");
3636
if(!st) {
3389
- st = rrd_stats_create(RRD_TYPE_NET_STAT_CONNTRACK, "new", NULL, RRD_TYPE_NET_STAT_CONNTRACK, "Netfilter New Connections", "connections/s", save_history);
3637
+ st = rrd_stats_create(RRD_TYPE_NET_STAT_CONNTRACK, "new", NULL, RRD_TYPE_NET_STAT_CONNTRACK, "Netfilter New Connections", "connections/s", 1001);
3638
3639
rrd_stats_dimension_add(st, "new", NULL, sizeof(unsigned long long), 0, 1, 1, RRD_DIMENSION_INCREMENTAL, NULL);
3640
rrd_stats_dimension_add(st, "ignore", NULL, sizeof(unsigned long long), 0, -1, 1, RRD_DIMENSION_INCREMENTAL, NULL);
@@ -3403,7 +3651,7 @@ int do_proc_net_stat_conntrack() {
3651
3652
st = rrd_stats_find(RRD_TYPE_NET_STAT_CONNTRACK ".changes");
3653
if(!st) {
3406
- st = rrd_stats_create(RRD_TYPE_NET_STAT_CONNTRACK, "changes", NULL, RRD_TYPE_NET_STAT_CONNTRACK, "Netfilter Connection Changes", "changes/s", save_history);
3654
+ st = rrd_stats_create(RRD_TYPE_NET_STAT_CONNTRACK, "changes", NULL, RRD_TYPE_NET_STAT_CONNTRACK, "Netfilter Connection Changes", "changes/s", 1002);
3655
st->isdetail = 1;
3656
3657
rrd_stats_dimension_add(st, "inserted", NULL, sizeof(unsigned long long), 0, 1, 1, RRD_DIMENSION_INCREMENTAL, NULL);
@@ -3421,7 +3669,7 @@ int do_proc_net_stat_conntrack() {
3669
3670
st = rrd_stats_find(RRD_TYPE_NET_STAT_CONNTRACK ".expect");
3671
if(!st) {
3424
- st = rrd_stats_create(RRD_TYPE_NET_STAT_CONNTRACK, "expect", NULL, RRD_TYPE_NET_STAT_CONNTRACK, "Netfilter Connection Expectations", "expectations/s", save_history);
3672
+ st = rrd_stats_create(RRD_TYPE_NET_STAT_CONNTRACK, "expect", NULL, RRD_TYPE_NET_STAT_CONNTRACK, "Netfilter Connection Expectations", "expectations/s", 1003);
3673
st->isdetail = 1;
3674
3675
rrd_stats_dimension_add(st, "created", NULL, sizeof(unsigned long long), 0, 1, 1, RRD_DIMENSION_INCREMENTAL, NULL);
@@ -3439,7 +3687,7 @@ int do_proc_net_stat_conntrack() {
3687
3688
st = rrd_stats_find(RRD_TYPE_NET_STAT_CONNTRACK ".search");
3689
if(!st) {
3442
- st = rrd_stats_create(RRD_TYPE_NET_STAT_CONNTRACK, "search", NULL, RRD_TYPE_NET_STAT_CONNTRACK, "Netfilter Connection Searches", "searches/s", save_history);
3690
+ st = rrd_stats_create(RRD_TYPE_NET_STAT_CONNTRACK, "search", NULL, RRD_TYPE_NET_STAT_CONNTRACK, "Netfilter Connection Searches", "searches/s", 1010);
3691
st->isdetail = 1;
3692
3693
rrd_stats_dimension_add(st, "searched", NULL, sizeof(unsigned long long), 0, 1, 1, RRD_DIMENSION_INCREMENTAL, NULL);
@@ -3457,7 +3705,7 @@ int do_proc_net_stat_conntrack() {
3705
3706
st = rrd_stats_find(RRD_TYPE_NET_STAT_CONNTRACK ".errors");
3707
if(!st) {
3460
- st = rrd_stats_create(RRD_TYPE_NET_STAT_CONNTRACK, "errors", NULL, RRD_TYPE_NET_STAT_CONNTRACK, "Netfilter Errors", "events/s", save_history);
3708
+ st = rrd_stats_create(RRD_TYPE_NET_STAT_CONNTRACK, "errors", NULL, RRD_TYPE_NET_STAT_CONNTRACK, "Netfilter Errors", "events/s", 1005);
3709
st->isdetail = 1;
3710
3711
rrd_stats_dimension_add(st, "icmp_error", NULL, sizeof(unsigned long long), 0, 1, 1, RRD_DIMENSION_INCREMENTAL, NULL);
@@ -3523,7 +3771,7 @@ int do_proc_net_ip_vs_stats() {
3771
3772
RRD_STATS *st = rrd_stats_find(RRD_TYPE_NET_IPVS ".sockets");
3773
if(!st) {
3526
- st = rrd_stats_create(RRD_TYPE_NET_IPVS, "sockets", NULL, RRD_TYPE_NET_IPVS, "IPVS New Connections", "connections/s", save_history);
3774
+ st = rrd_stats_create(RRD_TYPE_NET_IPVS, "sockets", NULL, RRD_TYPE_NET_IPVS, "IPVS New Connections", "connections/s", 1001);
3775
3776
rrd_stats_dimension_add(st, "connections", NULL, sizeof(unsigned long long), 0, 1, 1, RRD_DIMENSION_INCREMENTAL, NULL);
3777
}
@@ -3536,7 +3784,7 @@ int do_proc_net_ip_vs_stats() {
3784
3785
st = rrd_stats_find(RRD_TYPE_NET_IPVS ".packets");
3786
if(!st) {
3539
- st = rrd_stats_create(RRD_TYPE_NET_IPVS, "packets", NULL, RRD_TYPE_NET_IPVS, "IPVS Packets", "packets/s", save_history);
3787
+ st = rrd_stats_create(RRD_TYPE_NET_IPVS, "packets", NULL, RRD_TYPE_NET_IPVS, "IPVS Packets", "packets/s", 1002);
3788
3789
rrd_stats_dimension_add(st, "received", NULL, sizeof(unsigned long long), 0, 1, 1, RRD_DIMENSION_INCREMENTAL, NULL);
3790
rrd_stats_dimension_add(st, "sent", NULL, sizeof(unsigned long long), 0, -1, 1, RRD_DIMENSION_INCREMENTAL, NULL);
@@ -3551,7 +3799,7 @@ int do_proc_net_ip_vs_stats() {
3799
3800
st = rrd_stats_find(RRD_TYPE_NET_IPVS ".net");
3801
if(!st) {
3554
- st = rrd_stats_create(RRD_TYPE_NET_IPVS, "net", NULL, RRD_TYPE_NET_IPVS, "IPVS Bandwidth", "kilobits/s", save_history);
3802
+ st = rrd_stats_create(RRD_TYPE_NET_IPVS, "net", NULL, RRD_TYPE_NET_IPVS, "IPVS Bandwidth", "kilobits/s", 1000);
3803
3804
rrd_stats_dimension_add(st, "received", NULL, sizeof(unsigned long long), 0, 8, 1024, RRD_DIMENSION_INCREMENTAL, NULL);
3805
rrd_stats_dimension_add(st, "sent", NULL, sizeof(unsigned long long), 0, -8, 1024, RRD_DIMENSION_INCREMENTAL, NULL);
@@ -3592,14 +3840,16 @@ int do_proc_stat() {
3840
3841
char *title = "Core utilization";
3842
char *type = RRD_TYPE_STAT;
3843
+ long priority = 1000;
3844
if(strcmp(id, "cpu") == 0) {
3845
title = "Total CPU utilization";
3846
type = "system";
3847
+ priority = 100;
3848
}
3849
3850
RRD_STATS *st = rrd_stats_find_bytype(type, id);
3851
if(!st) {
3602
- st = rrd_stats_create(type, id, NULL, "cpu", title, "percentage", save_history);
3852
+ st = rrd_stats_create(type, id, NULL, "cpu", title, "percentage", priority);
3853
3854
long multiplier = 1;
3855
long divisor = 1; // sysconf(_SC_CLK_TCK);
@@ -3644,7 +3894,7 @@ int do_proc_stat() {
3894
3895
RRD_STATS *st = rrd_stats_find_bytype("system", id);
3896
if(!st) {
3647
- st = rrd_stats_create("system", id, NULL, "cpu", "CPU Interrupts", "interrupts/s", save_history);
3897
+ st = rrd_stats_create("system", id, NULL, "cpu", "CPU Interrupts", "interrupts/s", 900);
3898
st->isdetail = 1;
3899
3900
rrd_stats_dimension_add(st, "interrupts", NULL, sizeof(unsigned long long), 0, 1, 1, RRD_DIMENSION_INCREMENTAL, NULL);
@@ -3667,7 +3917,7 @@ int do_proc_stat() {
3917
3918
RRD_STATS *st = rrd_stats_find_bytype("system", id);
3919
if(!st) {
3670
- st = rrd_stats_create("system", id, NULL, "cpu", "CPU Context Switches", "context switches/s", save_history);
3920
+ st = rrd_stats_create("system", id, NULL, "cpu", "CPU Context Switches", "context switches/s", 800);
3921
3922
rrd_stats_dimension_add(st, "switches", NULL, sizeof(unsigned long long), 0, 1, 1, RRD_DIMENSION_INCREMENTAL, NULL);
3923
}
@@ -3716,7 +3966,7 @@ int do_proc_stat() {
3966
3967
RRD_STATS *st = rrd_stats_find_bytype("system", "forks");
3968
if(!st) {
3719
- st = rrd_stats_create("system", "forks", NULL, "cpu", "New Processes", "processes/s", save_history);
3969
+ st = rrd_stats_create("system", "forks", NULL, "cpu", "New Processes", "processes/s", 700);
3970
st->isdetail = 1;
3971
3972
rrd_stats_dimension_add(st, "started", NULL, sizeof(unsigned long long), 0, 1, 1, RRD_DIMENSION_INCREMENTAL, NULL);
@@ -3730,7 +3980,7 @@ int do_proc_stat() {
3980
3981
st = rrd_stats_find_bytype("system", "processes");
3982
if(!st) {
3733
- st = rrd_stats_create("system", "processes", NULL, "cpu", "Processes", "processes", save_history);
3983
+ st = rrd_stats_create("system", "processes", NULL, "cpu", "Processes", "processes", 600);
3984
3985
rrd_stats_dimension_add(st, "running", NULL, sizeof(unsigned long long), 0, 1, 1, RRD_DIMENSION_ABSOLUTE, NULL);
3986
rrd_stats_dimension_add(st, "blocked", NULL, sizeof(unsigned long long), 0, -1, 1, RRD_DIMENSION_ABSOLUTE, NULL);
@@ -3836,7 +4086,7 @@ int do_proc_meminfo() {
4086
4087
RRD_STATS *st = rrd_stats_find("system.ram");
4088
if(!st) {
3839
- st = rrd_stats_create("system", "ram", NULL, "mem", "System RAM", "MB", save_history);
4089
+ st = rrd_stats_create("system", "ram", NULL, "mem", "System RAM", "MB", 200);
4090
4091
rrd_stats_dimension_add(st, "buffers", NULL, sizeof(unsigned long long), 0, 1, 1024, RRD_DIMENSION_ABSOLUTE, NULL);
4092
rrd_stats_dimension_add(st, "used", NULL, sizeof(unsigned long long), 0, 1, 1024, RRD_DIMENSION_ABSOLUTE, NULL);
@@ -3857,7 +4107,7 @@ int do_proc_meminfo() {
4107
4108
st = rrd_stats_find("system.swap");
4109
if(!st) {
3860
- st = rrd_stats_create("system", "swap", NULL, "mem", "System Swap", "MB", save_history);
4110
+ st = rrd_stats_create("system", "swap", NULL, "mem", "System Swap", "MB", 201);
4111
st->isdetail = 1;
4112
4113
rrd_stats_dimension_add(st, "free", NULL, sizeof(unsigned long long), 0, 1, 1024, RRD_DIMENSION_ABSOLUTE, NULL);
@@ -3874,7 +4124,7 @@ int do_proc_meminfo() {
4124
if(hwcorrupted) {
4125
st = rrd_stats_find("mem.hwcorrupt");
4126
if(!st) {
3877
- st = rrd_stats_create("mem", "hwcorrupt", NULL, "mem", "Hardware Corrupted ECC", "MB", save_history);
4127
+ st = rrd_stats_create("mem", "hwcorrupt", NULL, "mem", "Hardware Corrupted ECC", "MB", 9000);
4128
st->isdetail = 1;
4129
4130
rrd_stats_dimension_add(st, "HardwareCorrupted", NULL, sizeof(unsigned long long), 0, 1, 1024, RRD_DIMENSION_ABSOLUTE, NULL);
@@ -3889,7 +4139,7 @@ int do_proc_meminfo() {
4139
4140
st = rrd_stats_find("mem.committed");
4141
if(!st) {
3892
- st = rrd_stats_create("mem", "committed", NULL, "mem", "Committed (Allocated) Memory", "MB", save_history);
4142
+ st = rrd_stats_create("mem", "committed", NULL, "mem", "Committed (Allocated) Memory", "MB", 5000);
4143
st->isdetail = 1;
4144
4145
rrd_stats_dimension_add(st, "Committed_AS", NULL, sizeof(unsigned long long), 0, 1, 1024, RRD_DIMENSION_ABSOLUTE, NULL);
@@ -3903,7 +4153,7 @@ int do_proc_meminfo() {
4153
4154
st = rrd_stats_find("mem.writeback");
4155
if(!st) {
3906
- st = rrd_stats_create("mem", "writeback", NULL, "mem", "Writeback Memory", "MB", save_history);
4156
+ st = rrd_stats_create("mem", "writeback", NULL, "mem", "Writeback Memory", "MB", 4000);
4157
st->isdetail = 1;
4158
4159
rrd_stats_dimension_add(st, "Dirty", NULL, sizeof(unsigned long long), 0, 1, 1024, RRD_DIMENSION_ABSOLUTE, NULL);
@@ -3925,7 +4175,7 @@ int do_proc_meminfo() {
4175
4176
st = rrd_stats_find("mem.kernel");
4177
if(!st) {
3928
- st = rrd_stats_create("mem", "kernel", NULL, "mem", "Memory Used by Kernel", "MB", save_history);
4178
+ st = rrd_stats_create("mem", "kernel", NULL, "mem", "Memory Used by Kernel", "MB", 6000);
4179
st->isdetail = 1;
4180
4181
rrd_stats_dimension_add(st, "Slab", NULL, sizeof(unsigned long long), 0, 1, 1024, RRD_DIMENSION_ABSOLUTE, NULL);
@@ -3945,7 +4195,7 @@ int do_proc_meminfo() {
4195
4196
st = rrd_stats_find("mem.slab");
4197
if(!st) {
3948
- st = rrd_stats_create("mem", "slab", NULL, "mem", "Reclaimable Kernel Memory", "MB", save_history);
4198
+ st = rrd_stats_create("mem", "slab", NULL, "mem", "Reclaimable Kernel Memory", "MB", 6500);
4199
st->isdetail = 1;
4200
4201
rrd_stats_dimension_add(st, "reclaimable", NULL, sizeof(unsigned long long), 0, 1, 1024, RRD_DIMENSION_ABSOLUTE, NULL);
@@ -4103,7 +4353,7 @@ int do_proc_vmstat() {
4353
4354
RRD_STATS *st = rrd_stats_find("system.swapio");
4355
if(!st) {
4106
- st = rrd_stats_create("system", "swapio", NULL, "mem", "Swap I/O", "kilobytes/s", save_history);
4356
+ st = rrd_stats_create("system", "swapio", NULL, "mem", "Swap I/O", "kilobytes/s", 250);
4357
4358
rrd_stats_dimension_add(st, "in", NULL, sizeof(unsigned long long), 0, sysconf(_SC_PAGESIZE), 1024, RRD_DIMENSION_INCREMENTAL, NULL);
4359
rrd_stats_dimension_add(st, "out", NULL, sizeof(unsigned long long), 0, -sysconf(_SC_PAGESIZE), 1024, RRD_DIMENSION_INCREMENTAL, NULL);
@@ -4118,7 +4368,7 @@ int do_proc_vmstat() {
4368
4369
st = rrd_stats_find("system.io");
4370
if(!st) {
4121
- st = rrd_stats_create("system", "io", NULL, "disk", "Disk I/O", "kilobytes/s", save_history);
4371
+ st = rrd_stats_create("system", "io", NULL, "disk", "Disk I/O", "kilobytes/s", 150);
4372
4373
rrd_stats_dimension_add(st, "in", NULL, sizeof(unsigned long long), 0, 1, 1, RRD_DIMENSION_INCREMENTAL, NULL);
4374
rrd_stats_dimension_add(st, "out", NULL, sizeof(unsigned long long), 0, -1, 1, RRD_DIMENSION_INCREMENTAL, NULL);
@@ -4133,7 +4383,7 @@ int do_proc_vmstat() {
4383
4384
st = rrd_stats_find("system.pgfaults");
4385
if(!st) {
4136
- st = rrd_stats_create("system", "pgfaults", NULL, "mem", "Memory Page Faults", "page faults/s", save_history);
4386
+ st = rrd_stats_create("system", "pgfaults", NULL, "mem", "Memory Page Faults", "page faults/s", 500);
4387
st->isdetail = 1;
4388
4389
rrd_stats_dimension_add(st, "minor", NULL, sizeof(unsigned long long), 0, 1, 1, RRD_DIMENSION_INCREMENTAL, NULL);
@@ -4210,7 +4460,7 @@ void *proc_main(void *ptr)
4460
4461
if(!stcpu) stcpu = rrd_stats_find("cpu.netdata");
4462
if(!stcpu) {
4213
- stcpu = rrd_stats_create("cpu", "netdata", NULL, "cpu", "NetData CPU usage", "milliseconds/s", save_history);
4463
+ stcpu = rrd_stats_create("cpu", "netdata", NULL, "cpu", "NetData CPU usage", "milliseconds/s", 9999);
4464
4465
rrd_stats_dimension_add(stcpu, "user", NULL, sizeof(unsigned long long), 0, 1, 1000, RRD_DIMENSION_INCREMENTAL, NULL);
4466
rrd_stats_dimension_add(stcpu, "system", NULL, sizeof(unsigned long long), 0, 1, 1000, RRD_DIMENSION_INCREMENTAL, NULL);
@@ -4300,7 +4550,7 @@ void tc_device_commit(struct tc_device *d)
4550
if(!st) {
4551
debug(D_TC_LOOP, "TC: Committing new TC device '%s'", d->name);
4552
4303
- st = rrd_stats_create(RRD_TYPE_TC, d->id, d->name, d->group, "Class usage for ", "kilobits/s", save_history);
4553
+ st = rrd_stats_create(RRD_TYPE_TC, d->id, d->name, d->group, "Class Usage", "kilobits/s", 1000);
4554
4555
for ( c = d->classes ; c ; c = c->next) {
4556
if(c->isleaf && c->hasparent)
@@ -4552,7 +4802,7 @@ void *cpuidlejitter_main(void *ptr)
4802
4803
RRD_STATS *st = rrd_stats_find("system.idlejitter");
4804
if(!st) {
4555
- st = rrd_stats_create("system", "idlejitter", NULL, "cpu", "CPU Idle Jitter", "microseconds lost/s", save_history);
4805
+ st = rrd_stats_create("system", "idlejitter", NULL, "cpu", "CPU Idle Jitter", "microseconds lost/s", 9999);
4806
4807
rrd_stats_dimension_add(st, "jitter", NULL, sizeof(unsigned long long), 0, 1, 1, RRD_DIMENSION_ABSOLUTE, NULL);
4808
}
@@ -4675,74 +4925,33 @@ void become_daemon()
4925
int main(int argc, char **argv)
4926
{
4927
int i, daemon = 0;
4928
+ int config_loaded = 0;
4929
+
4930
4931
// parse the arguments
4932
for(i = 1; i < argc ; i++) {
4681
- if(strcmp(argv[i], "-l") == 0 && (i+1) < argc) {
4682
- save_history = atoi(argv[i+1]);
4683
- if(save_history < 5 || save_history > HISTORY_MAX) {
4684
- fprintf(stderr, "Invalid save lines %d given. Defaulting to %d.\n", save_history, HISTORY);
4685
- save_history = HISTORY;
4686
- }
4687
- else {
4688
- debug(D_OPTIONS, "save lines set to %d.", save_history);
4689
- }
4690
- i++;
4691
- }
4692
- else if(strcmp(argv[i], "-u") == 0 && (i+1) < argc) {
4693
- if(become_user(argv[i+1]) != 0) {
4694
- fprintf(stderr, "Cannot become user %s.\n", argv[i+1]);
4933
+ if(strcmp(argv[i], "-c") == 0 && (i+1) < argc) {
4934
+ if(load_config(argv[i+1], 1) != 0) {
4935
+ fprintf(stderr, "Cannot load configuration file %s.\n", argv[i+1]);
4936
exit(1);
4937
}
4938
else {
4698
- debug(D_OPTIONS, "Successfully became user %s.", argv[i+1]);
4939
+ debug(D_OPTIONS, "Configuration loaded from %s.", argv[i+1]);
4940
+ config_loaded = 1;
4941
}
4942
i++;
4943
}
4702
- else if(strcmp(argv[i], "-dl") == 0 && (i+1) < argc) {
4703
- debug_log = argv[i+1];
4704
- debug_fd = open(debug_log, O_WRONLY | O_APPEND | O_CREAT, 0666);
4705
- if(debug_fd < 0) {
4706
- fprintf(stderr, "Cannot open file '%s'. Reason: %s\n", debug_log, strerror(errno));
4707
- exit(1);
4708
- }
4709
- debug(D_OPTIONS, "Debug LOG set to '%s'.", debug_log);
4710
- i++;
4711
- }
4712
- else if(strcmp(argv[i], "-df") == 0 && (i+1) < argc) {
4713
- debug_flags = strtoull(argv[i+1], NULL, 0);
4714
- debug(D_OPTIONS, "Debug flags set to '0x%8llx'.", debug_flags);
4715
- i++;
4716
- }
4717
- else if(strcmp(argv[i], "-t") == 0 && (i+1) < argc) {
4718
- update_every = atoi(argv[i+1]);
4719
- if(update_every < 1 || update_every > 600) {
4720
- fprintf(stderr, "Invalid update timer %d given. Defaulting to %d.\n", update_every, UPDATE_EVERY_MAX);
4721
- update_every = UPDATE_EVERY;
4722
- }
4723
- else {
4724
- debug(D_OPTIONS, "update timer set to %d.", update_every);
4725
- }
4726
- i++;
4727
- }
4728
- else if(strcmp(argv[i], "-p") == 0 && (i+1) < argc) {
4729
- listen_port = atoi(argv[i+1]);
4730
- if(listen_port < 1 || listen_port > 65535) {
4731
- fprintf(stderr, "Invalid listen port %d given. Defaulting to %d.\n", listen_port, LISTEN_PORT);
4732
- listen_port = LISTEN_PORT;
4733
- }
4734
- else {
4735
- debug(D_OPTIONS, "update timer set to %d.", update_every);
4736
- }
4737
- i++;
4738
- }
4739
- else if(strcmp(argv[i], "-d") == 0) {
4740
- daemon = 1;
4741
- debug(D_OPTIONS, "Enabled daemon mode.");
4742
- }
4944
+ else if(strcmp(argv[i], "-dl") == 0 && (i+1) < argc) { config_set("debug", "log", argv[i+1]); i++; }
4945
+ else if(strcmp(argv[i], "-df") == 0 && (i+1) < argc) { config_set("debug", "flags", argv[i+1]); i++; }
4946
+ else if(strcmp(argv[i], "-d") == 0) { config_set_number("global", "daemon", 1); }
4947
+ else if(strcmp(argv[i], "-p") == 0 && (i+1) < argc) { config_set("global", "port", argv[i+1]); i++; }
4948
+ else if(strcmp(argv[i], "-u") == 0 && (i+1) < argc) { config_set("global", "user", argv[i+1]); i++; }
4949
+ else if(strcmp(argv[i], "-l") == 0 && (i+1) < argc) { config_set("global", "history", argv[i+1]); i++; }
4950
+ else if(strcmp(argv[i], "-t") == 0 && (i+1) < argc) { config_set("global", "update_every", argv[i+1]); i++; }
4951
else {
4952
fprintf(stderr, "Cannot understand option '%s'.\n", argv[i]);
4953
fprintf(stderr, "\nUSAGE: %s [-d] [-l LINES_TO_SAVE] [-u UPDATE_TIMER] [-p LISTEN_PORT] [-dl debug log file] [-df debug flags].\n\n", argv[0]);
4954
+ fprintf(stderr, " -c CONFIG FILE the configuration file to load. Default: %s.\n", CONFIG_FILENAME);
4955
fprintf(stderr, " -d enable daemon mode (run in background).\n");
4956
fprintf(stderr, " -l LINES_TO_SAVE can be from 5 to %d lines in JSON data. Default: %d.\n", HISTORY_MAX, HISTORY);
4957
fprintf(stderr, " -t UPDATE_TIMER can be from 1 to %d seconds. Default: %d.\n", UPDATE_EVERY_MAX, UPDATE_EVERY);
@@ -4754,8 +4963,80 @@ int main(int argc, char **argv)
4963
}
4964
}
4965
4757
- if(gethostname(hostname, HOSTNAME_MAX) == -1)
4758
- error("WARNING: Cannot get machine hostname.");
4966
+ if(!config_loaded) load_config(NULL, 0);
4967
+
4968
+ {
4969
+ char buffer[1024];
4970
+
4971
+ // --------------------------------------------------------------------
4972
+
4973
+ if(gethostname(buffer, HOSTNAME_MAX) == -1)
4974
+ error("WARNING: Cannot get machine hostname.");
4975
+ hostname = config_get("global", "hostname", buffer);
4976
+
4977
+ // --------------------------------------------------------------------
4978
+
4979
+ save_history = config_get_number("global", "history", HISTORY);
4980
+ if(save_history < 5 || save_history > HISTORY_MAX) {
4981
+ fprintf(stderr, "Invalid save lines %d given. Defaulting to %d.\n", save_history, HISTORY);
4982
+ save_history = HISTORY;
4983
+ }
4984
+ else {
4985
+ debug(D_OPTIONS, "save lines set to %d.", save_history);
4986
+ }
4987
+
4988
+ // --------------------------------------------------------------------
4989
+
4990
+ debug_log = config_get("debug", "log", "");
4991
+ if(*debug_log) {
4992
+ debug_fd = open(debug_log, O_WRONLY | O_APPEND | O_CREAT, 0666);
4993
+ if(debug_fd < 0) {
4994
+ fprintf(stderr, "Cannot open file '%s'. Reason: %s\n", debug_log, strerror(errno));
4995
+ exit(1);
4996
+ }
4997
+ debug(D_OPTIONS, "Debug LOG set to '%s'.", debug_log);
4998
+ }
4999
+
5000
+ // --------------------------------------------------------------------
5001
+
5002
+ char *user = config_get("global", "user", "");
5003
+ if(*user) {
5004
+ if(become_user(user) != 0) {
5005
+ fprintf(stderr, "Cannot become user %s.\n", user);
5006
+ exit(1);
5007
+ }
5008
+ else debug(D_OPTIONS, "Successfully became user %s.", user);
5009
+ }
5010
+
5011
+ // --------------------------------------------------------------------
5012
+
5013
+ sprintf(buffer, "0x%08llx", debug_flags);
5014
+ char *flags = config_get("debug", "flags", buffer);
5015
+ debug_flags = strtoull(flags, NULL, 0);
5016
+ debug(D_OPTIONS, "Debug flags set to '0x%8llx'.", debug_flags);
5017
+
5018
+ // --------------------------------------------------------------------
5019
+
5020
+ update_every = config_get_number("global", "update_every", UPDATE_EVERY);
5021
+ if(update_every < 1 || update_every > 600) {
5022
+ fprintf(stderr, "Invalid update timer %d given. Defaulting to %d.\n", update_every, UPDATE_EVERY_MAX);
5023
+ update_every = UPDATE_EVERY;
5024
+ }
5025
+ else debug(D_OPTIONS, "update timer set to %d.", update_every);
5026
+
5027
+ // --------------------------------------------------------------------
5028
+
5029
+ listen_port = config_get_number("global", "port", LISTEN_PORT);
5030
+ if(listen_port < 1 || listen_port > 65535) {
5031
+ fprintf(stderr, "Invalid listen port %d given. Defaulting to %d.\n", listen_port, LISTEN_PORT);
5032
+ listen_port = LISTEN_PORT;
5033
+ }
5034
+ else debug(D_OPTIONS, "listen port set to %d.", listen_port);
5035
+
5036
+ // --------------------------------------------------------------------
5037
+
5038
+ daemon = config_get_number("global", "daemon", 0);
5039
+ }
5040
5041
// never become a problem
5042
if(nice(20) == -1) {
netdata.start
+39
-41
@@ -24,17 +24,21 @@ NETDATA_CONFIG_DEBUG=0
24
# our port
25
NETDATA_CONFIG_PORT=19999
26
27
-# get user configuration
27
if [ -f netdata.conf ]
28
then
30
- . netdata.conf
29
+ x="`grep "\[global\]" netdata.conf`"
30
+ if [ -z "$x" ]
31
+ then
32
+ # import the old values
33
+ cat netdata.conf | grep ^NETDATA_CONFIG_ >netdata.conf.tmp
34
+ . netdata.conf.tmp
35
+ rm netdata.conf.tmp
36
+
37
+ mv netdata.conf netdata.conf.old
38
+ echo "You are having an old config. Moved to netdata.conf.old"
39
+ fi
40
fi
41
33
-echo "Stopping a (possibly) running netdata..."
34
-killall netdata 2>/dev/null
35
-killall tc-all.sh 2>/dev/null
36
-sleep 2
37
-
42
echo "Compiling netdata"
43
if [ $NETDATA_CONFIG_DEBUG -eq 1 ]
44
then
@@ -46,44 +50,38 @@ else
50
debug_opts=
51
fi
52
49
-NETDATA_TITLE_DEFAULT=
50
-NETDATA_PRIORITY_DEFAULT=
51
-
52
-# exporting NETDATA variables to netdata
53
-export `set 2>&1 | grep ^NETDATA_TITLE_ `
54
-export `set 2>&1 | grep ^NETDATA_PRIORITY_ `
55
-
56
-echo "Starting netdata"
57
-if [ "$USER" = "root" ]
58
-then
59
- chown -R "$NETDATA_CONFIG_USER" web || exit 1
60
- chmod 0775 web || exit 1
61
- chmod -R 0664 web/* || exit 1
62
- `pwd`/netdata $debug_opts -d -u $NETDATA_CONFIG_USER -t $NETDATA_CONFIG_INTERNAL_UPDATE_EVERY -l $NETDATA_CONFIG_INTERNAL_HISTORY_LINES -p $NETDATA_CONFIG_PORT || exit 1
63
-else
64
- echo >&2 "WARNING: NOT RUNNING AS ROOT - CANNOT SWITCH TO USER $NETDATA_CONFIG_USER"
65
- echo >&2 "WARNING: MAKE SURE FILES IN web/ ARE OWNED BY $USER - or it will not work"
66
- `pwd`/netdata $debug_opts -d -t $NETDATA_CONFIG_INTERNAL_UPDATE_EVERY -l $NETDATA_CONFIG_INTERNAL_HISTORY_LINES -p $NETDATA_CONFIG_PORT || exit 1
67
-fi
53
+echo "Stopping a (possibly) running netdata..."
54
+killall netdata 2>/dev/null
55
+killall tc-all.sh 2>/dev/null
56
sleep 2
57
70
-if [ "$USER" = "root" ]
58
+echo "Starting netdata..."
59
+if [ -f netdata.conf ]
60
then
72
- chown -R "$NETDATA_CONFIG_USER" web || exit 1
73
- chmod 0775 web || exit 1
74
- chmod -R 0664 web/* || exit 1
61
+ `pwd`/netdata
62
+else
63
+ touch netdata.conf
64
+
65
+ if [ "$USER" = "root" ]
66
+ then
67
+ chown -R "$NETDATA_CONFIG_USER" web || exit 1
68
+ chmod 0775 web || exit 1
69
+ chmod -R 0664 web/* || exit 1
70
+ `pwd`/netdata $debug_opts -d -u $NETDATA_CONFIG_USER -t $NETDATA_CONFIG_INTERNAL_UPDATE_EVERY -l $NETDATA_CONFIG_INTERNAL_HISTORY_LINES -p $NETDATA_CONFIG_PORT || exit 1
71
+ else
72
+ echo >&2 "WARNING: NOT RUNNING AS ROOT - CANNOT SWITCH TO USER $NETDATA_CONFIG_USER"
73
+ echo >&2 "WARNING: MAKE SURE FILES IN web/ ARE OWNED BY $USER - or it will not work"
74
+ `pwd`/netdata $debug_opts -d -t $NETDATA_CONFIG_INTERNAL_UPDATE_EVERY -l $NETDATA_CONFIG_INTERNAL_HISTORY_LINES -p $NETDATA_CONFIG_PORT || exit 1
75
+ fi
76
+
77
+ sleep 2
78
+ wget 2>/dev/null -O netdata.conf.new http://localhost:$NETDATA_CONFIG_PORT/netdata.conf
79
+ mv netdata.conf.new netdata.conf
80
+
81
+ echo "Hit http://127.0.0.1:$NETDATA_CONFIG_PORT/ from your browser."
82
+ echo "You can edit config options in file netdata.conf"
83
fi
84
77
-# merge the server variables into the config
78
-eval "`wget -O - http://localhost:$NETDATA_CONFIG_PORT/envlist 2>/dev/null | tr " " "_" `"
79
-
80
-# save config back
81
-set 2>/dev/null |grep ^NETDATA_CONFIG_ >netdata.conf
82
-set 2>/dev/null |grep ^NETDATA_PRIORITY_ >>netdata.conf
83
-set 2>/dev/null |grep ^NETDATA_TITLE_ >>netdata.conf
84
-
85
-echo "All Done."
86
-echo "Just hit http://127.0.0.1:$NETDATA_CONFIG_PORT/ from your browser."
85
echo
88
-echo "You can edit config options in file netdata.conf"
86
+echo "All Done."
87
echo
web/index.js
+10
-1
@@ -75,7 +75,11 @@ function mylog(txt) {
75
}
76
77
function chartssort(a, b) {
78
- if(a.userpriority < b.userpriority) return -1;
78
+ if(a.priority == b.priority) {
79
+ if(a.name < b.name) return -1;
80
+ }
81
+ else if(a.priority < b.priority) return -1;
82
+
83
return 1;
84
}
85
@@ -532,6 +536,11 @@ function mainChartRefresh() {
536
return;
537
}
538
539
+ if(refresh_mode == REFRESH_PAUSED && mainchart.last_updated != 0) {
540
+ hiddenChartRefresh();
541
+ return;
542
+ }
543
+
544
if(!refreshChart(mainchart, hiddenChartRefresh))
545
hiddenChartRefresh();
546
}
web/netdata.js
+2
-10
@@ -228,16 +228,8 @@ function loadCharts(base_url, doNext) {
228
json.charts[i].before = 0;
229
json.charts[i].after = 0;
230
231
- // if the user has given a title, use it
232
- if(json.charts[i].usertitle) json.charts[i].title = json.charts[i].usertitle;
233
-
234
- // check if the userpriority is IGNORE
235
- if(json.charts[i].userpriority == "IGNORE"
236
- || json.charts[i].isdetail
237
- )
238
- json.charts[i].enabled = false;
239
- else
240
- json.charts[i].enabled = true;
231
+ // if it is detail, disable it by default
232
+ if(json.charts[i].isdetail) json.charts[i].enabled = false;
233
234
// set default chart options
235
json.charts[i].chartOptions = {