disable by default monitoring /snap/*; disable also ram* and loop* block devices
Costa Tsaousis (ktsaou) committed
Mar 15, 2017 at 01:57 UTC
b428238a72b11dc13bbe87257a53ae97f536d513
2 files changed
+38
-22
src/plugin_proc_diskspace.c
+1
-1
@@ -1,6 +1,6 @@
1
#include "common.h"
2
3
-#define DELAULT_EXLUDED_PATHS "/proc/* /sys/* /var/run/user/* /run/user/*"
3
+#define DELAULT_EXLUDED_PATHS "/proc/* /sys/* /var/run/user/* /run/user/* /snap/*"
4
#define DEFAULT_EXCLUDED_FILESYSTEMS ""
5
#define CONFIG_SECTION_DISKSPACE "plugin:proc:diskspace"
6
src/proc_diskstats.c
+37
-21
@@ -6,6 +6,9 @@
6
#define DISK_TYPE_PARTITION 2
7
#define DISK_TYPE_CONTAINER 3
8
9
+#define CONFIG_SECTION_DISKSTATS "plugin:proc:/proc/diskstats"
10
+#define DELAULT_EXLUDED_DISKS "loop* ram*"
11
+
12
static struct disk {
13
char *disk; // the name of the disk (sda, sdb, etc)
14
unsigned long major;
@@ -88,7 +91,7 @@ static struct disk *get_disk(unsigned long major, unsigned long minor, char *dis
91
// get the default path for finding info about the block device
92
if(unlikely(!path_find_block_device[0])) {
93
snprintfz(buffer, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, "/sys/dev/block/%lu:%lu/%s");
91
- snprintfz(path_find_block_device, FILENAME_MAX, "%s", config_get("plugin:proc:/proc/diskstats", "path to get block device infos", buffer));
94
+ snprintfz(path_find_block_device, FILENAME_MAX, "%s", config_get(CONFIG_SECTION_DISKSTATS, "path to get block device infos", buffer));
95
}
96
97
// find if it is a partition
@@ -142,11 +145,11 @@ static struct disk *get_disk(unsigned long major, unsigned long minor, char *dis
145
146
if(unlikely(!path_to_get_hw_sector_size[0])) {
147
snprintfz(buffer, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, "/sys/block/%s/queue/hw_sector_size");
145
- snprintfz(path_to_get_hw_sector_size, FILENAME_MAX, "%s", config_get("plugin:proc:/proc/diskstats", "path to get h/w sector size", buffer));
148
+ snprintfz(path_to_get_hw_sector_size, FILENAME_MAX, "%s", config_get(CONFIG_SECTION_DISKSTATS, "path to get h/w sector size", buffer));
149
}
150
if(unlikely(!path_to_get_hw_sector_size_partitions[0])) {
151
snprintfz(buffer, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, "/sys/dev/block/%lu:%lu/subsystem/%s/../queue/hw_sector_size");
149
- snprintfz(path_to_get_hw_sector_size_partitions, FILENAME_MAX, "%s", config_get("plugin:proc:/proc/diskstats", "path to get h/w sector size for partitions", buffer));
152
+ snprintfz(path_to_get_hw_sector_size_partitions, FILENAME_MAX, "%s", config_get(CONFIG_SECTION_DISKSTATS, "path to get h/w sector size for partitions", buffer));
153
}
154
155
{
@@ -205,7 +208,7 @@ static inline int is_major_enabled(int major) {
208
if(major_configs[major] == -1) {
209
char buffer[CONFIG_MAX_NAME + 1];
210
snprintfz(buffer, CONFIG_MAX_NAME, "performance metrics for disks with major %d", major);
208
- major_configs[major] = (char)config_get_boolean("plugin:proc:/proc/diskstats", buffer, 1);
211
+ major_configs[major] = (char)config_get_boolean(CONFIG_SECTION_DISKSTATS, buffer, 1);
212
}
213
214
return (int)major_configs[major];
@@ -227,19 +230,18 @@ int do_proc_diskstats(int update_every, usec_t dt) {
230
globals_initialized = 0;
231
232
if(unlikely(!globals_initialized)) {
230
- global_enable_new_disks_detected_at_runtime = config_get_boolean("plugin:proc:/proc/diskstats", "enable new disks detected at runtime", global_enable_new_disks_detected_at_runtime);
231
-
232
- global_enable_performance_for_physical_disks = config_get_boolean_ondemand("plugin:proc:/proc/diskstats", "performance metrics for physical disks", global_enable_performance_for_physical_disks);
233
- global_enable_performance_for_virtual_disks = config_get_boolean_ondemand("plugin:proc:/proc/diskstats", "performance metrics for virtual disks", global_enable_performance_for_virtual_disks);
234
- global_enable_performance_for_partitions = config_get_boolean_ondemand("plugin:proc:/proc/diskstats", "performance metrics for partitions", global_enable_performance_for_partitions);
235
-
236
- global_do_io = config_get_boolean_ondemand("plugin:proc:/proc/diskstats", "bandwidth for all disks", global_do_io);
237
- global_do_ops = config_get_boolean_ondemand("plugin:proc:/proc/diskstats", "operations for all disks", global_do_ops);
238
- global_do_mops = config_get_boolean_ondemand("plugin:proc:/proc/diskstats", "merged operations for all disks", global_do_mops);
239
- global_do_iotime = config_get_boolean_ondemand("plugin:proc:/proc/diskstats", "i/o time for all disks", global_do_iotime);
240
- global_do_qops = config_get_boolean_ondemand("plugin:proc:/proc/diskstats", "queued operations for all disks", global_do_qops);
241
- global_do_util = config_get_boolean_ondemand("plugin:proc:/proc/diskstats", "utilization percentage for all disks", global_do_util);
242
- global_do_backlog = config_get_boolean_ondemand("plugin:proc:/proc/diskstats", "backlog for all disks", global_do_backlog);
233
+ global_enable_new_disks_detected_at_runtime = config_get_boolean(CONFIG_SECTION_DISKSTATS, "enable new disks detected at runtime", global_enable_new_disks_detected_at_runtime);
234
+ global_enable_performance_for_physical_disks = config_get_boolean_ondemand(CONFIG_SECTION_DISKSTATS, "performance metrics for physical disks", global_enable_performance_for_physical_disks);
235
+ global_enable_performance_for_virtual_disks = config_get_boolean_ondemand(CONFIG_SECTION_DISKSTATS, "performance metrics for virtual disks", global_enable_performance_for_virtual_disks);
236
+ global_enable_performance_for_partitions = config_get_boolean_ondemand(CONFIG_SECTION_DISKSTATS, "performance metrics for partitions", global_enable_performance_for_partitions);
237
+
238
+ global_do_io = config_get_boolean_ondemand(CONFIG_SECTION_DISKSTATS, "bandwidth for all disks", global_do_io);
239
+ global_do_ops = config_get_boolean_ondemand(CONFIG_SECTION_DISKSTATS, "operations for all disks", global_do_ops);
240
+ global_do_mops = config_get_boolean_ondemand(CONFIG_SECTION_DISKSTATS, "merged operations for all disks", global_do_mops);
241
+ global_do_iotime = config_get_boolean_ondemand(CONFIG_SECTION_DISKSTATS, "i/o time for all disks", global_do_iotime);
242
+ global_do_qops = config_get_boolean_ondemand(CONFIG_SECTION_DISKSTATS, "queued operations for all disks", global_do_qops);
243
+ global_do_util = config_get_boolean_ondemand(CONFIG_SECTION_DISKSTATS, "utilization percentage for all disks", global_do_util);
244
+ global_do_backlog = config_get_boolean_ondemand(CONFIG_SECTION_DISKSTATS, "backlog for all disks", global_do_backlog);
245
246
globals_initialized = 1;
247
}
@@ -249,7 +251,7 @@ int do_proc_diskstats(int update_every, usec_t dt) {
251
if(unlikely(!ff)) {
252
char filename[FILENAME_MAX + 1];
253
snprintfz(filename, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, "/proc/diskstats");
252
- ff = procfile_open(config_get("plugin:proc:/proc/diskstats", "filename to monitor", filename), " \t", PROCFILE_FLAG_DEFAULT);
254
+ ff = procfile_open(config_get(CONFIG_SECTION_DISKSTATS, "filename to monitor", filename), " \t", PROCFILE_FLAG_DEFAULT);
255
}
256
if(unlikely(!ff)) return 0;
257
@@ -344,10 +346,26 @@ int do_proc_diskstats(int update_every, usec_t dt) {
346
// Check the configuration for the device
347
348
if(unlikely(!d->configured)) {
349
+ d->configured = 1;
350
+
351
+ static SIMPLE_PATTERN *excluded_disks = NULL;
352
+
353
+ if(unlikely(!excluded_disks)) {
354
+ excluded_disks = simple_pattern_create(
355
+ config_get(CONFIG_SECTION_DISKSTATS, "exclude disks", DELAULT_EXLUDED_DISKS),
356
+ SIMPLE_PATTERN_EXACT
357
+ );
358
+ }
359
+
360
+ int def_enable = global_enable_new_disks_detected_at_runtime;
361
+
362
+ if(def_enable != CONFIG_BOOLEAN_NO && simple_pattern_matches(excluded_disks, disk))
363
+ def_enable = CONFIG_BOOLEAN_NO;
364
+
365
char var_name[4096 + 1];
366
snprintfz(var_name, 4096, "plugin:proc:/proc/diskstats:%s", disk);
367
350
- int def_enable = config_get_boolean_ondemand(var_name, "enable", global_enable_new_disks_detected_at_runtime);
368
+ def_enable = config_get_boolean_ondemand(var_name, "enable", def_enable);
369
if(unlikely(def_enable == CONFIG_BOOLEAN_NO)) {
370
// the user does not want any metrics for this disk
371
d->do_io = CONFIG_BOOLEAN_NO;
@@ -420,8 +438,6 @@ int do_proc_diskstats(int update_every, usec_t dt) {
438
d->do_util = config_get_boolean_ondemand(var_name, "utilization percentage", ddo_util);
439
d->do_backlog = config_get_boolean_ondemand(var_name, "backlog", ddo_backlog);
440
}
423
-
424
- d->configured = 1;
441
}
442
443
// --------------------------------------------------------------------------