@cryptotaxi247 / netdata-1 / commits / 6cec7fe4e

improvement(macos.plugin): add options to filter net ifaces and mountpoints (#19865)

* improvement(macos.plugin): add "exclude mountpoints by path" option * add "disable by default network interfaces matching" * iokit

Ilya Mashchenko committed Mar 14, 2025 at 23:22 UTC 6cec7fe4e3c9a35fd289479c5e1c9398800fa42f
1 file changed +30
src/collectors/macos.plugin/macos_fw.c
+30
@@ -24,6 +24,9 @@
24 int do_macos_iokit(int update_every, usec_t dt) {
25 (void)dt;
26
27 + static SIMPLE_PATTERN *excluded_mountpoints = NULL;
28 + static SIMPLE_PATTERN *disabled_net_interfaces = NULL;
29 +
30 static int do_io = -1, do_space = -1, do_inodes = -1, do_bandwidth = -1;
31
32 if (unlikely(do_io == -1)) {
@@ -31,6 +34,25 @@ int do_macos_iokit(int update_every, usec_t dt) {
34 do_space = inicfg_get_boolean(&netdata_config, "plugin:macos:sysctl", "space usage for all disks", 1);
35 do_inodes = inicfg_get_boolean(&netdata_config, "plugin:macos:sysctl", "inodes usage for all disks", 1);
36 do_bandwidth = inicfg_get_boolean(&netdata_config, "plugin:macos:sysctl", "bandwidth", 1);
37 +
38 + excluded_mountpoints = simple_pattern_create(
39 + inicfg_get(
40 + &netdata_config,
41 + "plugin:macos:iokit",
42 + "exclude mountpoints by path",
43 + "/System/Volumes/* /private/var/folders/* /Volumes/Recovery"),
44 + NULL,
45 + SIMPLE_PATTERN_EXACT,
46 + true);
47 + disabled_net_interfaces = simple_pattern_create(
48 + inicfg_get(
49 + &netdata_config,
50 + "plugin:macos:iokit",
51 + "disable by default network interfaces matching",
52 + "lo* awdl* llw* anpi* gif* bridge* ap*"),
53 + NULL,
54 + SIMPLE_PATTERN_EXACT,
55 + true);
56 }
57
58 RRDSET *st;
@@ -430,6 +452,10 @@ int do_macos_iokit(int update_every, usec_t dt) {
452 strcmp(mntbuf[i].f_fstypename, "none") == 0)
453 continue;
454
455 + if (simple_pattern_matches(excluded_mountpoints, mntbuf[i].f_mntonname)) {
456 + continue;
457 + }
458 +
459 // --------------------------------------------------------------------------
460
461 if (likely(do_space)) {
@@ -510,6 +536,10 @@ int do_macos_iokit(int update_every, usec_t dt) {
536 if (ifa->ifa_addr->sa_family != AF_LINK)
537 continue;
538
539 + if (simple_pattern_matches(disabled_net_interfaces, ifa->ifa_name)) {
540 + continue;
541 + }
542 +
543 st = rrdset_find_active_bytype_localhost("net", ifa->ifa_name);
544 if (unlikely(!st)) {
545 st = rrdset_create_localhost(