fix(macos.plugin): correct disks/network devices charts (#19859)
* fix(macos.plugin): correct disks/network devices charts * add filesystem label
Ilya Mashchenko committed
Mar 13, 2025 at 23:44 UTC
622592de25b18558b4a5b1b662c9277511b43de8
1 file changed
+32
-19
src/collectors/macos.plugin/macos_fw.c
+32
-19
@@ -73,7 +73,6 @@ int do_macos_iokit(int update_every, usec_t dt) {
73
// NEEDED BY: do_space, do_inodes
74
struct statfs *mntbuf;
75
int mntsize, i;
76
- char title[4096 + 1];
76
77
// NEEDED BY: do_bandwidth
78
struct ifaddrs *ifa, *ifap;
@@ -154,7 +153,7 @@ int do_macos_iokit(int update_every, usec_t dt) {
153
"disk"
154
, diskstat.name
155
, NULL
157
- , diskstat.name
156
+ , "io"
157
, "disk.io"
158
, "Disk I/O Bandwidth"
159
, "KiB/s"
@@ -167,6 +166,7 @@ int do_macos_iokit(int update_every, usec_t dt) {
166
167
rrddim_add(st, "reads", NULL, 1, 1024, RRD_ALGORITHM_INCREMENTAL);
168
rrddim_add(st, "writes", NULL, -1, 1024, RRD_ALGORITHM_INCREMENTAL);
169
+ rrdlabels_add(st->rrdlabels, "device", diskstat.name, RRDLABEL_SRC_AUTO);
170
}
171
172
prev_diskstat.bytes_read = rrddim_set(st, "reads", diskstat.bytes_read);
@@ -189,7 +189,7 @@ int do_macos_iokit(int update_every, usec_t dt) {
189
"disk_ops"
190
, diskstat.name
191
, NULL
192
- , diskstat.name
192
+ , "ops"
193
, "disk.ops"
194
, "Disk Completed I/O Operations"
195
, "operations/s"
@@ -202,6 +202,7 @@ int do_macos_iokit(int update_every, usec_t dt) {
202
203
rrddim_add(st, "reads", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
204
rrddim_add(st, "writes", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);
205
+ rrdlabels_add(st->rrdlabels, "device", diskstat.name, RRDLABEL_SRC_AUTO);
206
}
207
208
prev_diskstat.operations_read = rrddim_set(st, "reads", diskstat.reads);
@@ -224,7 +225,7 @@ int do_macos_iokit(int update_every, usec_t dt) {
225
"disk_util"
226
, diskstat.name
227
, NULL
227
- , diskstat.name
228
+ , "utilization"
229
, "disk.util"
230
, "Disk Utilization Time"
231
, "% of time working"
@@ -236,6 +237,7 @@ int do_macos_iokit(int update_every, usec_t dt) {
237
);
238
239
rrddim_add(st, "utilization", NULL, 1, 10000000, RRD_ALGORITHM_INCREMENTAL);
240
+ rrdlabels_add(st->rrdlabels, "device", diskstat.name, RRDLABEL_SRC_AUTO);
241
}
242
243
cur_diskstat.busy_time_ns = (diskstat.time_read + diskstat.time_write);
@@ -258,7 +260,7 @@ int do_macos_iokit(int update_every, usec_t dt) {
260
"disk_iotime"
261
, diskstat.name
262
, NULL
261
- , diskstat.name
263
+ , "utilization"
264
, "disk.iotime"
265
, "Disk Total I/O Time"
266
, "milliseconds/s"
@@ -271,6 +273,7 @@ int do_macos_iokit(int update_every, usec_t dt) {
273
274
rrddim_add(st, "reads", NULL, 1, 1000000, RRD_ALGORITHM_INCREMENTAL);
275
rrddim_add(st, "writes", NULL, -1, 1000000, RRD_ALGORITHM_INCREMENTAL);
276
+ rrdlabels_add(st->rrdlabels, "device", diskstat.name, RRDLABEL_SRC_AUTO);
277
}
278
279
cur_diskstat.duration_read_ns = diskstat.time_read + diskstat.latency_read;
@@ -289,7 +292,7 @@ int do_macos_iokit(int update_every, usec_t dt) {
292
"disk_await"
293
, diskstat.name
294
, NULL
292
- , diskstat.name
295
+ , "latency"
296
, "disk.await"
297
, "Average Completed I/O Operation Time"
298
, "milliseconds/operation"
@@ -302,6 +305,7 @@ int do_macos_iokit(int update_every, usec_t dt) {
305
306
rrddim_add(st, "reads", NULL, 1, 1000000, RRD_ALGORITHM_ABSOLUTE);
307
rrddim_add(st, "writes", NULL, -1, 1000000, RRD_ALGORITHM_ABSOLUTE);
308
+ rrdlabels_add(st->rrdlabels, "device", diskstat.name, RRDLABEL_SRC_AUTO);
309
}
310
311
rrddim_set(st, "reads", (diskstat.reads - prev_diskstat.operations_read) ?
@@ -316,7 +320,7 @@ int do_macos_iokit(int update_every, usec_t dt) {
320
"disk_avgsz"
321
, diskstat.name
322
, NULL
319
- , diskstat.name
323
+ , "io"
324
, "disk.avgsz"
325
, "Average Completed I/O Operation Bandwidth"
326
, "KiB/operation"
@@ -329,6 +333,7 @@ int do_macos_iokit(int update_every, usec_t dt) {
333
334
rrddim_add(st, "reads", NULL, 1, 1024, RRD_ALGORITHM_ABSOLUTE);
335
rrddim_add(st, "writes", NULL, -1, 1024, RRD_ALGORITHM_ABSOLUTE);
336
+ rrdlabels_add(st->rrdlabels, "device", diskstat.name, RRDLABEL_SRC_AUTO);
337
}
338
339
rrddim_set(st, "reads", (diskstat.reads - prev_diskstat.operations_read) ?
@@ -343,7 +348,7 @@ int do_macos_iokit(int update_every, usec_t dt) {
348
"disk_svctm"
349
, diskstat.name
350
, NULL
346
- , diskstat.name
351
+ , "latency"
352
, "disk.svctm"
353
, "Average Service Time"
354
, "milliseconds/operation"
@@ -355,6 +360,7 @@ int do_macos_iokit(int update_every, usec_t dt) {
360
);
361
362
rrddim_add(st, "svctm", NULL, 1, 1000000, RRD_ALGORITHM_ABSOLUTE);
363
+ rrdlabels_add(st->rrdlabels, "device", diskstat.name, RRDLABEL_SRC_AUTO);
364
}
365
366
rrddim_set(st, "svctm", ((diskstat.reads - prev_diskstat.operations_read) + (diskstat.writes - prev_diskstat.operations_write)) ?
@@ -429,14 +435,13 @@ int do_macos_iokit(int update_every, usec_t dt) {
435
if (likely(do_space)) {
436
st = rrdset_find_active_bytype_localhost("disk_space", mntbuf[i].f_mntonname);
437
if (unlikely(!st)) {
432
- snprintfz(title, sizeof(title) - 1, "Disk Space Usage for %s [%s]", mntbuf[i].f_mntonname, mntbuf[i].f_mntfromname);
438
st = rrdset_create_localhost(
439
"disk_space"
440
, mntbuf[i].f_mntonname
441
, NULL
437
- , mntbuf[i].f_mntonname
442
+ , "used space"
443
, "disk.space"
439
- , title
444
+ , "Disk Space Usage"
445
, "GiB"
446
, "macos.plugin"
447
, "iokit"
@@ -448,6 +453,8 @@ int do_macos_iokit(int update_every, usec_t dt) {
453
rrddim_add(st, "avail", NULL, mntbuf[i].f_bsize, GIGA_FACTOR, RRD_ALGORITHM_ABSOLUTE);
454
rrddim_add(st, "used", NULL, mntbuf[i].f_bsize, GIGA_FACTOR, RRD_ALGORITHM_ABSOLUTE);
455
rrddim_add(st, "reserved_for_root", "reserved for root", mntbuf[i].f_bsize, GIGA_FACTOR, RRD_ALGORITHM_ABSOLUTE);
456
+ rrdlabels_add(st->rrdlabels, "mount_point", mntbuf[i].f_mntonname, RRDLABEL_SRC_AUTO);
457
+ rrdlabels_add(st->rrdlabels, "filesystem", mntbuf[i].f_fstypename, RRDLABEL_SRC_AUTO);
458
}
459
460
rrddim_set(st, "avail", (collected_number) mntbuf[i].f_bavail);
@@ -461,14 +468,13 @@ int do_macos_iokit(int update_every, usec_t dt) {
468
if (likely(do_inodes)) {
469
st = rrdset_find_active_bytype_localhost("disk_inodes", mntbuf[i].f_mntonname);
470
if (unlikely(!st)) {
464
- snprintfz(title, sizeof(title) - 1, "Disk Files (inodes) Usage for %s [%s]", mntbuf[i].f_mntonname, mntbuf[i].f_mntfromname);
471
st = rrdset_create_localhost(
472
"disk_inodes"
473
, mntbuf[i].f_mntonname
474
, NULL
469
- , mntbuf[i].f_mntonname
475
+ , "used inodes"
476
, "disk.inodes"
471
- , title
477
+ , "Disk Files (inodes) Usage"
478
, "inodes"
479
, "macos.plugin"
480
, "iokit"
@@ -480,6 +486,8 @@ int do_macos_iokit(int update_every, usec_t dt) {
486
rrddim_add(st, "avail", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
487
rrddim_add(st, "used", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
488
rrddim_add(st, "reserved_for_root", "reserved for root", 1, 1, RRD_ALGORITHM_ABSOLUTE);
489
+ rrdlabels_add(st->rrdlabels, "mount_point", mntbuf[i].f_mntonname, RRDLABEL_SRC_AUTO);
490
+ rrdlabels_add(st->rrdlabels, "filesystem", mntbuf[i].f_fstypename, RRDLABEL_SRC_AUTO);
491
}
492
493
rrddim_set(st, "avail", (collected_number) mntbuf[i].f_ffree);
@@ -508,7 +516,7 @@ int do_macos_iokit(int update_every, usec_t dt) {
516
"net"
517
, ifa->ifa_name
518
, NULL
511
- , ifa->ifa_name
519
+ , "traffic"
520
, "net.net"
521
, "Bandwidth"
522
, "kilobits/s"
@@ -521,6 +529,7 @@ int do_macos_iokit(int update_every, usec_t dt) {
529
530
rrddim_add(st, "received", NULL, 8, BITS_IN_A_KILOBIT, RRD_ALGORITHM_INCREMENTAL);
531
rrddim_add(st, "sent", NULL, -8, BITS_IN_A_KILOBIT, RRD_ALGORITHM_INCREMENTAL);
532
+ rrdlabels_add(st->rrdlabels, "device", ifa->ifa_name, RRDLABEL_SRC_AUTO);
533
}
534
535
rrddim_set(st, "received", IFA_DATA(ibytes));
@@ -533,7 +542,7 @@ int do_macos_iokit(int update_every, usec_t dt) {
542
"net_packets"
543
, ifa->ifa_name
544
, NULL
536
- , ifa->ifa_name
545
+ , "packets"
546
, "net.packets"
547
, "Packets"
548
, "packets/s"
@@ -548,6 +557,7 @@ int do_macos_iokit(int update_every, usec_t dt) {
557
rrddim_add(st, "sent", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);
558
rrddim_add(st, "multicast_received", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
559
rrddim_add(st, "multicast_sent", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);
560
+ rrdlabels_add(st->rrdlabels, "device", ifa->ifa_name, RRDLABEL_SRC_AUTO);
561
}
562
563
rrddim_set(st, "received", IFA_DATA(ipackets));
@@ -562,7 +572,7 @@ int do_macos_iokit(int update_every, usec_t dt) {
572
"net_errors"
573
, ifa->ifa_name
574
, NULL
565
- , ifa->ifa_name
575
+ , "errors"
576
, "net.errors"
577
, "Interface Errors"
578
, "errors/s"
@@ -575,6 +585,7 @@ int do_macos_iokit(int update_every, usec_t dt) {
585
586
rrddim_add(st, "inbound", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
587
rrddim_add(st, "outbound", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);
588
+ rrdlabels_add(st->rrdlabels, "device", ifa->ifa_name, RRDLABEL_SRC_AUTO);
589
}
590
591
rrddim_set(st, "inbound", IFA_DATA(ierrors));
@@ -587,7 +598,7 @@ int do_macos_iokit(int update_every, usec_t dt) {
598
"net_drops"
599
, ifa->ifa_name
600
, NULL
590
- , ifa->ifa_name
601
+ , "drops"
602
, "net.drops"
603
, "Interface Drops"
604
, "drops/s"
@@ -599,6 +610,7 @@ int do_macos_iokit(int update_every, usec_t dt) {
610
);
611
612
rrddim_add(st, "inbound", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
613
+ rrdlabels_add(st->rrdlabels, "device", ifa->ifa_name, RRDLABEL_SRC_AUTO);
614
}
615
616
rrddim_set(st, "inbound", IFA_DATA(iqdrops));
@@ -610,7 +622,7 @@ int do_macos_iokit(int update_every, usec_t dt) {
622
"net_events"
623
, ifa->ifa_name
624
, NULL
613
- , ifa->ifa_name
625
+ , "errors"
626
, "net.events"
627
, "Network Interface Events"
628
, "events/s"
@@ -624,6 +636,7 @@ int do_macos_iokit(int update_every, usec_t dt) {
636
rrddim_add(st, "frames", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
637
rrddim_add(st, "collisions", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);
638
rrddim_add(st, "carrier", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);
639
+ rrdlabels_add(st->rrdlabels, "device", ifa->ifa_name, RRDLABEL_SRC_AUTO);
640
}
641
642
rrddim_set(st, "collisions", IFA_DATA(collisions));