renamed several options and added a few more
Costa Tsaousis (ktsaou) committed
Apr 29, 2014 at 00:34 UTC
d2b21dbe9943ab3972e47fe5f2e2e4b1c3b4063b
1 file changed
+45
-23
netdata.c
+45
-23
@@ -703,6 +703,8 @@ struct rrd_stats {
703
// it goes around in a round-robin fashion
704
// size_t last_entry;
705
706
+ int update_every; // every how many seconds is this updated?
707
+
708
time_t last_updated; // when this data set was last updated
709
710
int isdetail; // if set, the data set should be considered as a detail of another
@@ -791,6 +793,7 @@ RRD_STATS *rrd_stats_create(const char *type, const char *id, const char *name,
793
// st->last_entry = 0;
794
st->dimensions = NULL;
795
st->last_updated = time(NULL);
796
+ st->update_every = update_every;
797
798
pthread_mutex_init(&st->mutex, NULL);
799
pthread_mutex_lock(&st->mutex);
@@ -1045,7 +1048,7 @@ void rrd_stats_done(RRD_STATS *st)
1048
1049
// find if there are any obsolete dimensions (not updated recently)
1050
for( rd = st->dimensions, last = NULL ; rd ; ) {
1048
- if((rd->last_updated + (10 * update_every)) < st->last_updated) { // remove it only it is not updated in 10 seconds
1051
+ if((rd->last_updated + (10 * st->update_every)) < st->last_updated) { // remove it only it is not updated in 10 seconds
1052
debug(D_RRD_STATS, "Removing obsolete dimension '%s' (%s) of '%s' (%s).", rd->name, rd->id, st->name, st->id);
1053
1054
if(!last) {
@@ -1063,7 +1066,7 @@ void rrd_stats_done(RRD_STATS *st)
1066
continue;
1067
}
1068
}
1066
- else if((rd->last_updated + update_every) < st->last_updated) {
1069
+ else if((rd->last_updated + st->update_every) < st->last_updated) {
1070
debug(D_RRD_STATS, "Clearing obsolete dimension '%s' (%s) of '%s' (%s).", rd->name, rd->id, st->name, st->id);
1071
1072
unsigned char zero[rd->bytes];
@@ -1300,7 +1303,7 @@ unsigned long rrd_stats_one_json(RRD_STATS *st, char *options, struct web_buffer
1303
//web_buffer_printf(wb, "\t\t\t\"last_entry\" : %ld,\n", st->current_entry);
1304
web_buffer_printf(wb, "\t\t\t\"last_entry_t\" : %lu,\n", st->last_updated);
1305
//web_buffer_printf(wb, "\t\t\t\"last_entry_secs_ago\" : %lu,\n", time(NULL) - st->last_updated);
1303
- web_buffer_printf(wb, "\t\t\t\"update_every\" : %d,\n", update_every);
1306
+ web_buffer_printf(wb, "\t\t\t\"update_every\" : %d,\n", st->update_every);
1307
web_buffer_printf(wb, "\t\t\t\"isdetail\" : %d,\n", st->isdetail);
1308
web_buffer_printf(wb, "\t\t\t\"dimensions\" : [\n");
1309
@@ -1548,8 +1551,8 @@ unsigned long rrd_stats_json(int type, RRD_STATS *st, struct web_buffer *wb, siz
1551
if(before < after)
1552
debug(D_RRD_STATS, "WARNING: %s The newest value in the database (%lu) is earlier than the oldest (%lu)", st->name, before, after);
1553
1551
- if((before - after) > st->entries * update_every)
1552
- debug(D_RRD_STATS, "WARNING: %s The time difference between the oldest and the newest entries (%lu) is higher than the capacity of the database (%lu)", st->name, before - after, st->entries * update_every);
1554
+ if((before - after) > st->entries * st->update_every)
1555
+ debug(D_RRD_STATS, "WARNING: %s The time difference between the oldest and the newest entries (%lu) is higher than the capacity of the database (%lu)", st->name, before - after, st->entries * st->update_every);
1556
1557
// loop in dimension data
1558
int annotate_reset = 0;
@@ -2179,6 +2182,11 @@ void web_client_process(struct web_client *w)
2182
2183
debug(D_WEB_CLIENT_ACCESS, "%llu: Mirroring...", w->id);
2184
2185
+ // replace the zero bytes with spaces
2186
+ int i;
2187
+ for(i = 0; i < w->data->size; i++)
2188
+ if(w->data->buffer[i] == '\0') w->data->buffer[i] = ' ';
2189
+
2190
// just leave the buffer as is
2191
// it will be copied back to the client
2192
}
@@ -2894,13 +2902,16 @@ void *socket_listen_main(void *ptr)
2902
#define MAX_PROC_NET_DEV_IFACE_NAME 1024
2903
2904
int do_proc_net_dev() {
2905
+ static int enable_new_interfaces = -1;
2906
static int do_bandwidth = -1, do_packets = -1, do_errors = -1, do_fifo = -1, do_compressed = -1;
2907
2899
- if(do_bandwidth == -1) do_bandwidth = config_get_boolean("plugin:proc:/proc/net/dev", "bandwidth", 1);
2900
- if(do_packets == -1) do_packets = config_get_boolean("plugin:proc:/proc/net/dev", "packets", 1);
2901
- if(do_errors == -1) do_errors = config_get_boolean("plugin:proc:/proc/net/dev", "errors", 1);
2902
- if(do_fifo == -1) do_fifo = config_get_boolean("plugin:proc:/proc/net/dev", "fifo", 1);
2903
- if(do_compressed == -1) do_compressed = config_get_boolean("plugin:proc:/proc/net/dev", "compressed", 1);
2908
+ if(enable_new_interfaces == -1) enable_new_interfaces = config_get_boolean("plugin:proc:/proc/net/dev", "enable new interfaces detected at runtime", 1);
2909
+
2910
+ if(do_bandwidth == -1) do_bandwidth = config_get_boolean("plugin:proc:/proc/net/dev", "bandwidth for all interfaces", 1);
2911
+ if(do_packets == -1) do_packets = config_get_boolean("plugin:proc:/proc/net/dev", "packets for all interfaces", 1);
2912
+ if(do_errors == -1) do_errors = config_get_boolean("plugin:proc:/proc/net/dev", "errors for all interfaces", 1);
2913
+ if(do_fifo == -1) do_fifo = config_get_boolean("plugin:proc:/proc/net/dev", "fifo for all interfaces", 1);
2914
+ if(do_compressed == -1) do_compressed = config_get_boolean("plugin:proc:/proc/net/dev", "compressed packets for all interfaces", 1);
2915
2916
char buffer[MAX_PROC_NET_DEV_LINE+1] = "";
2917
char iface[MAX_PROC_NET_DEV_IFACE_NAME + 1] = "";
@@ -2943,7 +2954,7 @@ int do_proc_net_dev() {
2954
{
2955
char var_name[4096 + 1];
2956
snprintf(var_name, 4096, "interface %s", iface);
2946
- if(!config_get_boolean("plugin:proc:/proc/net/dev", var_name, 1)) continue;
2957
+ if(!config_get_boolean("plugin:proc:/proc/net/dev", var_name, enable_new_interfaces)) continue;
2958
}
2959
2960
RRD_STATS *st;
@@ -3049,13 +3060,16 @@ int do_proc_net_dev() {
3060
#define MAX_PROC_DISKSTATS_DISK_NAME 1024
3061
3062
int do_proc_diskstats() {
3063
+ static int enable_new_disks = -1;
3064
static int do_io = -1, do_ops = -1, do_merged_ops = -1, do_iotime = -1, do_cur_ops = -1;
3065
3054
- if(do_io == -1) do_io = config_get_boolean("plugin:proc:/proc/diskstats", "bandwidth", 1);
3055
- if(do_ops == -1) do_ops = config_get_boolean("plugin:proc:/proc/diskstats", "operations", 1);
3056
- if(do_merged_ops == -1) do_merged_ops = config_get_boolean("plugin:proc:/proc/diskstats", "merged operations", 1);
3057
- if(do_iotime == -1) do_iotime = config_get_boolean("plugin:proc:/proc/diskstats", "i/o time", 1);
3058
- if(do_cur_ops == -1) do_cur_ops = config_get_boolean("plugin:proc:/proc/diskstats", "current operations", 1);
3066
+ if(enable_new_disks == -1) enable_new_disks = config_get_boolean("plugin:proc:/proc/diskstats", "enable new disks detected at runtime", 1);
3067
+
3068
+ if(do_io == -1) do_io = config_get_boolean("plugin:proc:/proc/diskstats", "bandwidth for all disks", 1);
3069
+ if(do_ops == -1) do_ops = config_get_boolean("plugin:proc:/proc/diskstats", "operations for all disks", 1);
3070
+ if(do_merged_ops == -1) do_merged_ops = config_get_boolean("plugin:proc:/proc/diskstats", "merged operations for all disks", 1);
3071
+ if(do_iotime == -1) do_iotime = config_get_boolean("plugin:proc:/proc/diskstats", "i/o time for all disks", 1);
3072
+ if(do_cur_ops == -1) do_cur_ops = config_get_boolean("plugin:proc:/proc/diskstats", "current operations for all disks", 1);
3073
3074
char buffer[MAX_PROC_DISKSTATS_LINE+1] = "";
3075
char disk[MAX_PROC_DISKSTATS_DISK_NAME + 1] = "";
@@ -3099,7 +3113,7 @@ int do_proc_diskstats() {
3113
case 199: // veritas
3114
case 201: // veritas
3115
case 251: // dm
3102
- def_enabled = 1;
3116
+ def_enabled = enable_new_disks;
3117
break;
3118
3119
case 48: // RAID
@@ -3122,7 +3136,7 @@ int do_proc_diskstats() {
3136
case 179: // MMC
3137
case 180: // USB
3138
if(minor % 8) def_enabled = 0; // partitions
3125
- else def_enabled = 1;
3139
+ else def_enabled = enable_new_disks;
3140
break;
3141
3142
case 8: // scsi disks
@@ -3174,13 +3188,13 @@ int do_proc_diskstats() {
3188
case 256: // flash
3189
case 257: // flash
3190
if(minor % 16) def_enabled = 0; // partitions
3177
- else def_enabled = 1;
3191
+ else def_enabled = enable_new_disks;
3192
break;
3193
3194
case 160: // raid
3195
case 161: // raid
3196
if(minor % 32) def_enabled = 0; // partitions
3183
- else def_enabled = 1;
3197
+ else def_enabled = enable_new_disks;
3198
break;
3199
3200
case 3: // ide
@@ -3195,7 +3209,7 @@ int do_proc_diskstats() {
3209
case 90: // ide
3210
case 91: // ide
3211
if(minor % 64) def_enabled = 0; // partitions
3198
- else def_enabled = 1;
3212
+ else def_enabled = enable_new_disks;
3213
break;
3214
3215
default:
@@ -4737,6 +4751,10 @@ void *proc_main(void *ptr)
4751
gettimeofday(&last, NULL);
4752
last.tv_sec -= update_every;
4753
4754
+ // disable (by default) various interface that are not needed
4755
+ config_get_boolean("plugin:proc:/proc/net/dev", "interface lo", 0);
4756
+ config_get_boolean("plugin:proc:/proc/net/dev", "interface fireqos_monitor", 0);
4757
+
4758
// when ZERO, attempt to do it
4759
int vdo_proc_net_dev = !config_get_boolean("plugin:proc", "/proc/net/dev", 1);
4760
int vdo_proc_diskstats = !config_get_boolean("plugin:proc", "/proc/diskstats", 1);
@@ -4844,6 +4862,10 @@ struct tc_device {
4862
4863
void tc_device_commit(struct tc_device *d)
4864
{
4865
+ static int enable_new_interfaces = -1;
4866
+
4867
+ if(enable_new_interfaces == -1) enable_new_interfaces = config_get_boolean("plugin:tc", "enable new interfaces detected at runtime", 1);
4868
+
4869
// we only need to add leaf classes
4870
struct tc_class *c, *x;
4871
@@ -4878,7 +4900,7 @@ void tc_device_commit(struct tc_device *d)
4900
4901
char var_name[4096 + 1];
4902
snprintf(var_name, 4096, "qos for %s", d->id);
4881
- if(config_get_boolean("plugin:tc", var_name, 1)) {
4903
+ if(config_get_boolean("plugin:tc", var_name, enable_new_interfaces)) {
4904
RRD_STATS *st = rrd_stats_find_bytype(RRD_TYPE_TC, d->id);
4905
if(!st) {
4906
debug(D_TC_LOOP, "TC: Committing new TC device '%s'", d->name);
@@ -5006,7 +5028,7 @@ void *tc_main(void *ptr)
5028
struct tc_device *device = NULL;
5029
struct tc_class *class = NULL;
5030
5009
- snprintf(buffer, TC_LINE_MAX, "exec %s %d", config_get("plugin:tc", "script", "./tc-all.sh"), update_every);
5031
+ snprintf(buffer, TC_LINE_MAX, "exec %s %d", config_get("plugin:tc", "script to run to get tc values", "./tc-all.sh"), update_every);
5032
fp = popen(buffer, "r");
5033
5034
while(fgets(buffer, TC_LINE_MAX, fp) != NULL) {