diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2022-11-30 18:47:05 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2022-11-30 18:47:05 +0000 |
commit | 97e01009d69b8fbebfebf68f51e3d126d0ed43fc (patch) | |
tree | 02e8b836c3a9d89806f3e67d4a5fe9f52dbb0061 /collectors/macos.plugin | |
parent | Releasing debian version 1.36.1-1. (diff) | |
download | netdata-97e01009d69b8fbebfebf68f51e3d126d0ed43fc.tar.xz netdata-97e01009d69b8fbebfebf68f51e3d126d0ed43fc.zip |
Merging upstream version 1.37.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'collectors/macos.plugin')
-rw-r--r-- | collectors/macos.plugin/macos_fw.c | 46 | ||||
-rw-r--r-- | collectors/macos.plugin/macos_mach_smi.c | 16 | ||||
-rw-r--r-- | collectors/macos.plugin/macos_sysctl.c | 153 | ||||
-rw-r--r-- | collectors/macos.plugin/plugin_macos.h | 6 |
4 files changed, 33 insertions, 188 deletions
diff --git a/collectors/macos.plugin/macos_fw.c b/collectors/macos.plugin/macos_fw.c index 08d1ddadd..07f7d773d 100644 --- a/collectors/macos.plugin/macos_fw.c +++ b/collectors/macos.plugin/macos_fw.c @@ -168,14 +168,11 @@ int do_macos_iokit(int update_every, usec_t dt) { rrddim_add(st, "reads", NULL, 1, 1024, RRD_ALGORITHM_INCREMENTAL); rrddim_add(st, "writes", NULL, -1, 1024, RRD_ALGORITHM_INCREMENTAL); } - else rrdset_next(st); prev_diskstat.bytes_read = rrddim_set(st, "reads", diskstat.bytes_read); prev_diskstat.bytes_write = rrddim_set(st, "writes", diskstat.bytes_write); rrdset_done(st); - // -------------------------------------------------------------------- - /* Get number of reads. */ if (likely(number = (CFNumberRef)CFDictionaryGetValue(statistics, CFSTR(kIOBlockStorageDriverStatisticsReadsKey)))) { CFNumberGetValue(number, kCFNumberSInt64Type, &diskstat.reads); @@ -207,14 +204,11 @@ int do_macos_iokit(int update_every, usec_t dt) { rrddim_add(st, "reads", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); rrddim_add(st, "writes", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); } - else rrdset_next(st); prev_diskstat.operations_read = rrddim_set(st, "reads", diskstat.reads); prev_diskstat.operations_write = rrddim_set(st, "writes", diskstat.writes); rrdset_done(st); - // -------------------------------------------------------------------- - /* Get reads time. */ if (likely(number = (CFNumberRef)CFDictionaryGetValue(statistics, CFSTR(kIOBlockStorageDriverStatisticsTotalReadTimeKey)))) { CFNumberGetValue(number, kCFNumberSInt64Type, &diskstat.time_read); @@ -245,14 +239,11 @@ int do_macos_iokit(int update_every, usec_t dt) { rrddim_add(st, "utilization", NULL, 1, 10000000, RRD_ALGORITHM_INCREMENTAL); } - else rrdset_next(st); cur_diskstat.busy_time_ns = (diskstat.time_read + diskstat.time_write); prev_diskstat.busy_time_ns = rrddim_set(st, "utilization", cur_diskstat.busy_time_ns); rrdset_done(st); - // -------------------------------------------------------------------- - /* Get reads latency. */ if (likely(number = (CFNumberRef)CFDictionaryGetValue(statistics, CFSTR(kIOBlockStorageDriverStatisticsLatentReadTimeKey)))) { CFNumberGetValue(number, kCFNumberSInt64Type, &diskstat.latency_read); @@ -284,7 +275,6 @@ int do_macos_iokit(int update_every, usec_t dt) { rrddim_add(st, "reads", NULL, 1, 1000000, RRD_ALGORITHM_INCREMENTAL); rrddim_add(st, "writes", NULL, -1, 1000000, RRD_ALGORITHM_INCREMENTAL); } - else rrdset_next(st); cur_diskstat.duration_read_ns = diskstat.time_read + diskstat.latency_read; cur_diskstat.duration_write_ns = diskstat.time_write + diskstat.latency_write; @@ -292,14 +282,10 @@ int do_macos_iokit(int update_every, usec_t dt) { prev_diskstat.duration_write_ns = rrddim_set(st, "writes", cur_diskstat.duration_write_ns); rrdset_done(st); - // -------------------------------------------------------------------- // calculate differential charts // only if this is not the first time we run if (likely(dt)) { - - // -------------------------------------------------------------------- - st = rrdset_find_active_bytype_localhost("disk_await", diskstat.name); if (unlikely(!st)) { st = rrdset_create_localhost( @@ -321,7 +307,6 @@ int do_macos_iokit(int update_every, usec_t dt) { rrddim_add(st, "reads", NULL, 1, 1000000, RRD_ALGORITHM_ABSOLUTE); rrddim_add(st, "writes", NULL, -1, 1000000, RRD_ALGORITHM_ABSOLUTE); } - else rrdset_next(st); rrddim_set(st, "reads", (diskstat.reads - prev_diskstat.operations_read) ? (cur_diskstat.duration_read_ns - prev_diskstat.duration_read_ns) / (diskstat.reads - prev_diskstat.operations_read) : 0); @@ -329,8 +314,6 @@ int do_macos_iokit(int update_every, usec_t dt) { (cur_diskstat.duration_write_ns - prev_diskstat.duration_write_ns) / (diskstat.writes - prev_diskstat.operations_write) : 0); rrdset_done(st); - // -------------------------------------------------------------------- - st = rrdset_find_active_bytype_localhost("disk_avgsz", diskstat.name); if (unlikely(!st)) { st = rrdset_create_localhost( @@ -352,7 +335,6 @@ int do_macos_iokit(int update_every, usec_t dt) { rrddim_add(st, "reads", NULL, 1, 1024, RRD_ALGORITHM_ABSOLUTE); rrddim_add(st, "writes", NULL, -1, 1024, RRD_ALGORITHM_ABSOLUTE); } - else rrdset_next(st); rrddim_set(st, "reads", (diskstat.reads - prev_diskstat.operations_read) ? (diskstat.bytes_read - prev_diskstat.bytes_read) / (diskstat.reads - prev_diskstat.operations_read) : 0); @@ -360,8 +342,6 @@ int do_macos_iokit(int update_every, usec_t dt) { (diskstat.bytes_write - prev_diskstat.bytes_write) / (diskstat.writes - prev_diskstat.operations_write) : 0); rrdset_done(st); - // -------------------------------------------------------------------- - st = rrdset_find_active_bytype_localhost("disk_svctm", diskstat.name); if (unlikely(!st)) { st = rrdset_create_localhost( @@ -382,7 +362,6 @@ int do_macos_iokit(int update_every, usec_t dt) { rrddim_add(st, "svctm", NULL, 1, 1000000, RRD_ALGORITHM_ABSOLUTE); } - else rrdset_next(st); rrddim_set(st, "svctm", ((diskstat.reads - prev_diskstat.operations_read) + (diskstat.writes - prev_diskstat.operations_write)) ? (cur_diskstat.busy_time_ns - prev_diskstat.busy_time_ns) / ((diskstat.reads - prev_diskstat.operations_read) + (diskstat.writes - prev_diskstat.operations_write)) : 0); @@ -423,7 +402,6 @@ int do_macos_iokit(int update_every, usec_t dt) { rrddim_add(st, "in", NULL, 1, 1024, RRD_ALGORITHM_INCREMENTAL); rrddim_add(st, "out", NULL, -1, 1024, RRD_ALGORITHM_INCREMENTAL); } - else rrdset_next(st); rrddim_set(st, "in", total_disk_reads); rrddim_set(st, "out", total_disk_writes); @@ -431,7 +409,6 @@ int do_macos_iokit(int update_every, usec_t dt) { } // Can be merged with FreeBSD plugin - // -------------------------------------------------------------------------- if (likely(do_space || do_inodes)) { // there is no mount info in sysctl MIBs @@ -477,8 +454,7 @@ int do_macos_iokit(int update_every, usec_t dt) { rrddim_add(st, "avail", NULL, mntbuf[i].f_bsize, GIGA_FACTOR, RRD_ALGORITHM_ABSOLUTE); rrddim_add(st, "used", NULL, mntbuf[i].f_bsize, GIGA_FACTOR, RRD_ALGORITHM_ABSOLUTE); rrddim_add(st, "reserved_for_root", "reserved for root", mntbuf[i].f_bsize, GIGA_FACTOR, RRD_ALGORITHM_ABSOLUTE); - } else - rrdset_next(st); + } rrddim_set(st, "avail", (collected_number) mntbuf[i].f_bavail); rrddim_set(st, "used", (collected_number) (mntbuf[i].f_blocks - mntbuf[i].f_bfree)); @@ -510,8 +486,7 @@ int do_macos_iokit(int update_every, usec_t dt) { rrddim_add(st, "avail", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE); rrddim_add(st, "used", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE); rrddim_add(st, "reserved_for_root", "reserved for root", 1, 1, RRD_ALGORITHM_ABSOLUTE); - } else - rrdset_next(st); + } rrddim_set(st, "avail", (collected_number) mntbuf[i].f_ffree); rrddim_set(st, "used", (collected_number) (mntbuf[i].f_files - mntbuf[i].f_ffree)); @@ -522,7 +497,6 @@ int do_macos_iokit(int update_every, usec_t dt) { } // Can be merged with FreeBSD plugin - // -------------------------------------------------------------------- if (likely(do_bandwidth)) { if (unlikely(getifaddrs(&ifap))) { @@ -534,8 +508,6 @@ int do_macos_iokit(int update_every, usec_t dt) { if (ifa->ifa_addr->sa_family != AF_LINK) continue; - // -------------------------------------------------------------------- - st = rrdset_find_active_bytype_localhost("net", ifa->ifa_name); if (unlikely(!st)) { st = rrdset_create_localhost( @@ -556,14 +528,11 @@ int do_macos_iokit(int update_every, usec_t dt) { rrddim_add(st, "received", NULL, 8, BITS_IN_A_KILOBIT, RRD_ALGORITHM_INCREMENTAL); rrddim_add(st, "sent", NULL, -8, BITS_IN_A_KILOBIT, RRD_ALGORITHM_INCREMENTAL); } - else rrdset_next(st); rrddim_set(st, "received", IFA_DATA(ibytes)); rrddim_set(st, "sent", IFA_DATA(obytes)); rrdset_done(st); - // -------------------------------------------------------------------- - st = rrdset_find_active_bytype_localhost("net_packets", ifa->ifa_name); if (unlikely(!st)) { st = rrdset_create_localhost( @@ -587,7 +556,6 @@ int do_macos_iokit(int update_every, usec_t dt) { rrddim_add(st, "multicast_received", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); rrddim_add(st, "multicast_sent", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); } - else rrdset_next(st); rrddim_set(st, "received", IFA_DATA(ipackets)); rrddim_set(st, "sent", IFA_DATA(opackets)); @@ -595,8 +563,6 @@ int do_macos_iokit(int update_every, usec_t dt) { rrddim_set(st, "multicast_sent", IFA_DATA(omcasts)); rrdset_done(st); - // -------------------------------------------------------------------- - st = rrdset_find_active_bytype_localhost("net_errors", ifa->ifa_name); if (unlikely(!st)) { st = rrdset_create_localhost( @@ -618,14 +584,11 @@ int do_macos_iokit(int update_every, usec_t dt) { rrddim_add(st, "inbound", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); rrddim_add(st, "outbound", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); } - else rrdset_next(st); rrddim_set(st, "inbound", IFA_DATA(ierrors)); rrddim_set(st, "outbound", IFA_DATA(oerrors)); rrdset_done(st); - // -------------------------------------------------------------------- - st = rrdset_find_active_bytype_localhost("net_drops", ifa->ifa_name); if (unlikely(!st)) { st = rrdset_create_localhost( @@ -646,13 +609,10 @@ int do_macos_iokit(int update_every, usec_t dt) { rrddim_add(st, "inbound", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); } - else rrdset_next(st); rrddim_set(st, "inbound", IFA_DATA(iqdrops)); rrdset_done(st); - // -------------------------------------------------------------------- - st = rrdset_find_active_bytype_localhost("net_events", ifa->ifa_name); if (unlikely(!st)) { st = rrdset_create_localhost( @@ -675,7 +635,6 @@ int do_macos_iokit(int update_every, usec_t dt) { rrddim_add(st, "collisions", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); rrddim_add(st, "carrier", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); } - else rrdset_next(st); rrddim_set(st, "collisions", IFA_DATA(collisions)); rrdset_done(st); @@ -685,6 +644,5 @@ int do_macos_iokit(int update_every, usec_t dt) { } } - return 0; } diff --git a/collectors/macos.plugin/macos_mach_smi.c b/collectors/macos.plugin/macos_mach_smi.c index f2c4623c9..53b2607b4 100644 --- a/collectors/macos.plugin/macos_mach_smi.c +++ b/collectors/macos.plugin/macos_mach_smi.c @@ -39,8 +39,6 @@ int do_macos_mach_smi(int update_every, usec_t dt) { if (unlikely(kr != KERN_SUCCESS)) return -1; - // -------------------------------------------------------------------- - if (likely(do_cpu)) { if (unlikely(HOST_CPU_LOAD_INFO_COUNT != 4)) { error("MACOS: There are %d CPU states (4 was expected)", HOST_CPU_LOAD_INFO_COUNT); @@ -78,7 +76,6 @@ int do_macos_mach_smi(int update_every, usec_t dt) { rrddim_add(st, "idle", NULL, 1, 1, RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL); rrddim_hide(st, "idle"); } - else rrdset_next(st); rrddim_set(st, "user", cp_time[CPU_STATE_USER]); rrddim_set(st, "nice", cp_time[CPU_STATE_NICE]); @@ -87,9 +84,7 @@ int do_macos_mach_smi(int update_every, usec_t dt) { rrdset_done(st); } } - } - - // -------------------------------------------------------------------- + } if (likely(do_ram || do_swapio || do_pgfaults)) { #if (defined __MAC_OS_X_VERSION_MIN_REQUIRED && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1060) @@ -137,7 +132,6 @@ int do_macos_mach_smi(int update_every, usec_t dt) { rrddim_add(st, "speculative", NULL, system_pagesize, 1048576, RRD_ALGORITHM_ABSOLUTE); rrddim_add(st, "free", NULL, system_pagesize, 1048576, RRD_ALGORITHM_ABSOLUTE); } - else rrdset_next(st); rrddim_set(st, "active", vm_statistics.active_count); rrddim_set(st, "wired", vm_statistics.wire_count); @@ -153,8 +147,6 @@ int do_macos_mach_smi(int update_every, usec_t dt) { } #if (defined __MAC_OS_X_VERSION_MIN_REQUIRED && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090) - // -------------------------------------------------------------------- - if (likely(do_swapio)) { st = rrdset_find_active_localhost("system.swapio"); if (unlikely(!st)) { @@ -176,7 +168,6 @@ int do_macos_mach_smi(int update_every, usec_t dt) { rrddim_add(st, "in", NULL, system_pagesize, 1024, RRD_ALGORITHM_INCREMENTAL); rrddim_add(st, "out", NULL, -system_pagesize, 1024, RRD_ALGORITHM_INCREMENTAL); } - else rrdset_next(st); rrddim_set(st, "in", vm_statistics.swapins); rrddim_set(st, "out", vm_statistics.swapouts); @@ -184,8 +175,6 @@ int do_macos_mach_smi(int update_every, usec_t dt) { } #endif - // -------------------------------------------------------------------- - if (likely(do_pgfaults)) { st = rrdset_find_active_localhost("mem.pgfaults"); if (unlikely(!st)) { @@ -217,7 +206,6 @@ int do_macos_mach_smi(int update_every, usec_t dt) { rrddim_add(st, "reactivate", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); rrddim_add(st, "purge", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); } - else rrdset_next(st); rrddim_set(st, "memory", vm_statistics.faults); rrddim_set(st, "cow", vm_statistics.cow_faults); @@ -235,7 +223,5 @@ int do_macos_mach_smi(int update_every, usec_t dt) { } } - // -------------------------------------------------------------------- - return 0; } diff --git a/collectors/macos.plugin/macos_sysctl.c b/collectors/macos.plugin/macos_sysctl.c index 34d3f0b3e..1f04f6e41 100644 --- a/collectors/macos.plugin/macos_sysctl.c +++ b/collectors/macos.plugin/macos_sysctl.c @@ -218,8 +218,6 @@ int do_macos_sysctl(int update_every, usec_t dt) { // NEEDED BY: do_uptime struct timespec boot_time, cur_time; - // -------------------------------------------------------------------- - if (next_loadavg_dt <= dt) { if (likely(do_loadavg)) { if (unlikely(GETSYSCTL_BY_NAME("vm.loadavg", sysload))) { @@ -247,7 +245,6 @@ int do_macos_sysctl(int update_every, usec_t dt) { rrddim_add(st, "load5", NULL, 1, 1000, RRD_ALGORITHM_ABSOLUTE); rrddim_add(st, "load15", NULL, 1, 1000, RRD_ALGORITHM_ABSOLUTE); } - else rrdset_next(st); rrddim_set(st, "load1", (collected_number) ((double)sysload.ldavg[0] / sysload.fscale * 1000)); rrddim_set(st, "load5", (collected_number) ((double)sysload.ldavg[1] / sysload.fscale * 1000)); @@ -260,8 +257,6 @@ int do_macos_sysctl(int update_every, usec_t dt) { } else next_loadavg_dt -= dt; - // -------------------------------------------------------------------- - if (likely(do_swap)) { if (unlikely(GETSYSCTL_BY_NAME("vm.swapusage", swap_usage))) { do_swap = 0; @@ -288,7 +283,6 @@ int do_macos_sysctl(int update_every, usec_t dt) { rrddim_add(st, "free", NULL, 1, 1048576, RRD_ALGORITHM_ABSOLUTE); rrddim_add(st, "used", NULL, 1, 1048576, RRD_ALGORITHM_ABSOLUTE); } - else rrdset_next(st); rrddim_set(st, "free", swap_usage.xsu_avail); rrddim_set(st, "used", swap_usage.xsu_used); @@ -296,8 +290,6 @@ int do_macos_sysctl(int update_every, usec_t dt) { } } - // -------------------------------------------------------------------- - if (likely(do_bandwidth)) { mib[0] = CTL_NET; mib[1] = PF_ROUTE; @@ -349,7 +341,6 @@ int do_macos_sysctl(int update_every, usec_t dt) { rrddim_add(st, "InOctets", "received", 8, BITS_IN_A_KILOBIT, RRD_ALGORITHM_INCREMENTAL); rrddim_add(st, "OutOctets", "sent", -8, BITS_IN_A_KILOBIT, RRD_ALGORITHM_INCREMENTAL); } - else rrdset_next(st); rrddim_set(st, "InOctets", iftot.ift_ibytes); rrddim_set(st, "OutOctets", iftot.ift_obytes); @@ -358,8 +349,6 @@ int do_macos_sysctl(int update_every, usec_t dt) { } } - // -------------------------------------------------------------------- - // see http://net-snmp.sourceforge.net/docs/mibs/tcp.html if (likely(do_tcp_packets || do_tcp_errors || do_tcp_handshake || do_tcpext_connaborts || do_tcpext_ofo || do_tcpext_syscookies || do_ecn)) { if (unlikely(GETSYSCTL_BY_NAME("net.inet.tcp.stats", tcpstat))){ @@ -398,16 +387,13 @@ int do_macos_sysctl(int update_every, usec_t dt) { rrddim_add(st, "InSegs", "received", 1, 1, RRD_ALGORITHM_INCREMENTAL); rrddim_add(st, "OutSegs", "sent", -1, 1, RRD_ALGORITHM_INCREMENTAL); - } else - rrdset_next(st); + } rrddim_set(st, "InSegs", tcpstat.tcps_rcvtotal); rrddim_set(st, "OutSegs", tcpstat.tcps_sndtotal); rrdset_done(st); } - // -------------------------------------------------------------------- - if (likely(do_tcp_errors)) { st = rrdset_find_active_localhost("ipv4.tcperrors"); if (unlikely(!st)) { @@ -430,8 +416,7 @@ int do_macos_sysctl(int update_every, usec_t dt) { rrddim_add(st, "InErrs", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); rrddim_add(st, "InCsumErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); rrddim_add(st, "RetransSegs", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); - } else - rrdset_next(st); + } rrddim_set(st, "InErrs", tcpstat.tcps_rcvbadoff + tcpstat.tcps_rcvshort); rrddim_set(st, "InCsumErrors", tcpstat.tcps_rcvbadsum); @@ -439,8 +424,6 @@ int do_macos_sysctl(int update_every, usec_t dt) { rrdset_done(st); } - // -------------------------------------------------------------------- - if (likely(do_tcp_handshake)) { st = rrdset_find_active_localhost("ipv4.tcphandshake"); if (unlikely(!st)) { @@ -464,8 +447,7 @@ int do_macos_sysctl(int update_every, usec_t dt) { rrddim_add(st, "ActiveOpens", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); rrddim_add(st, "PassiveOpens", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); rrddim_add(st, "AttemptFails", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); - } else - rrdset_next(st); + } rrddim_set(st, "EstabResets", tcpstat.tcps_drops); rrddim_set(st, "ActiveOpens", tcpstat.tcps_connattempt); @@ -474,8 +456,6 @@ int do_macos_sysctl(int update_every, usec_t dt) { rrdset_done(st); } - // -------------------------------------------------------------------- - if (do_tcpext_connaborts == CONFIG_BOOLEAN_YES || (do_tcpext_connaborts == CONFIG_BOOLEAN_AUTO && (tcpstat.tcps_rcvpackafterwin || tcpstat.tcps_rcvafterclose || @@ -505,7 +485,6 @@ int do_macos_sysctl(int update_every, usec_t dt) { rrddim_add(st, "TCPAbortOnMemory", "nomemory", 1, 1, RRD_ALGORITHM_INCREMENTAL); rrddim_add(st, "TCPAbortOnTimeout", "timeout", 1, 1, RRD_ALGORITHM_INCREMENTAL); } - else rrdset_next(st); rrddim_set(st, "TCPAbortOnData", tcpstat.tcps_rcvpackafterwin); rrddim_set(st, "TCPAbortOnClose", tcpstat.tcps_rcvafterclose); @@ -514,8 +493,6 @@ int do_macos_sysctl(int update_every, usec_t dt) { rrdset_done(st); } - // -------------------------------------------------------------------- - if (do_tcpext_ofo == CONFIG_BOOLEAN_YES || (do_tcpext_ofo == CONFIG_BOOLEAN_AUTO && (tcpstat.tcps_rcvoopack || netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { @@ -539,14 +516,11 @@ int do_macos_sysctl(int update_every, usec_t dt) { rrddim_add(st, "TCPOFOQueue", "inqueue", 1, 1, RRD_ALGORITHM_INCREMENTAL); } - else rrdset_next(st); rrddim_set(st, "TCPOFOQueue", tcpstat.tcps_rcvoopack); rrdset_done(st); } - // -------------------------------------------------------------------- - if (do_tcpext_syscookies == CONFIG_BOOLEAN_YES || (do_tcpext_syscookies == CONFIG_BOOLEAN_AUTO && (tcpstat.tcps_sc_sendcookie || tcpstat.tcps_sc_recvcookie || @@ -575,7 +549,6 @@ int do_macos_sysctl(int update_every, usec_t dt) { rrddim_add(st, "SyncookiesSent", "sent", -1, 1, RRD_ALGORITHM_INCREMENTAL); rrddim_add(st, "SyncookiesFailed", "failed", -1, 1, RRD_ALGORITHM_INCREMENTAL); } - else rrdset_next(st); rrddim_set(st, "SyncookiesRecv", tcpstat.tcps_sc_recvcookie); rrddim_set(st, "SyncookiesSent", tcpstat.tcps_sc_sendcookie); @@ -583,9 +556,6 @@ int do_macos_sysctl(int update_every, usec_t dt) { rrdset_done(st); } - // -------------------------------------------------------------------- - - #if (defined __MAC_OS_X_VERSION_MIN_REQUIRED && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101100) if (do_ecn == CONFIG_BOOLEAN_YES || (do_ecn == CONFIG_BOOLEAN_AUTO && (tcpstat.tcps_ecn_recv_ce || @@ -613,7 +583,6 @@ int do_macos_sysctl(int update_every, usec_t dt) { rrddim_add(st, "InCEPkts", "CEP", 1, 1, RRD_ALGORITHM_INCREMENTAL); rrddim_add(st, "InNoECTPkts", "NoECTP", -1, 1, RRD_ALGORITHM_INCREMENTAL); } - else rrdset_next(st); rrddim_set(st, "InCEPkts", tcpstat.tcps_ecn_recv_ce); rrddim_set(st, "InNoECTPkts", tcpstat.tcps_ecn_not_supported); @@ -624,8 +593,6 @@ int do_macos_sysctl(int update_every, usec_t dt) { } } - // -------------------------------------------------------------------- - // see http://net-snmp.sourceforge.net/docs/mibs/udp.html if (likely(do_udp_packets || do_udp_errors)) { if (unlikely(GETSYSCTL_BY_NAME("net.inet.udp.stats", udpstat))) { @@ -654,16 +621,13 @@ int do_macos_sysctl(int update_every, usec_t dt) { rrddim_add(st, "InDatagrams", "received", 1, 1, RRD_ALGORITHM_INCREMENTAL); rrddim_add(st, "OutDatagrams", "sent", -1, 1, RRD_ALGORITHM_INCREMENTAL); - } else - rrdset_next(st); + } rrddim_set(st, "InDatagrams", udpstat.udps_ipackets); rrddim_set(st, "OutDatagrams", udpstat.udps_opackets); rrdset_done(st); } - // -------------------------------------------------------------------- - if (likely(do_udp_errors)) { st = rrdset_find_active_localhost("ipv4.udperrors"); if (unlikely(!st)) { @@ -690,8 +654,7 @@ int do_macos_sysctl(int update_every, usec_t dt) { #if (defined __MAC_OS_X_VERSION_MIN_REQUIRED && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090) rrddim_add(st, "IgnoredMulti", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); #endif - } else - rrdset_next(st); + } rrddim_set(st, "InErrors", udpstat.udps_hdrops + udpstat.udps_badlen); rrddim_set(st, "NoPorts", udpstat.udps_noport); @@ -707,8 +670,6 @@ int do_macos_sysctl(int update_every, usec_t dt) { } } - // -------------------------------------------------------------------- - if (likely(do_icmp_packets || do_icmpmsg)) { if (unlikely(GETSYSCTL_BY_NAME("net.inet.icmp.stats", icmpstat))) { do_icmp_packets = 0; @@ -745,16 +706,12 @@ int do_macos_sysctl(int update_every, usec_t dt) { rrddim_add(st, "InMsgs", "received", 1, 1, RRD_ALGORITHM_INCREMENTAL); rrddim_add(st, "OutMsgs", "sent", -1, 1, RRD_ALGORITHM_INCREMENTAL); - } else - rrdset_next(st); + } rrddim_set(st, "InMsgs", icmp_total.msgs_in); rrddim_set(st, "OutMsgs", icmp_total.msgs_out); - rrdset_done(st); - // -------------------------------------------------------------------- - st = rrdset_find_active_localhost("ipv4.icmp_errors"); if (unlikely(!st)) { st = rrdset_create_localhost( @@ -775,18 +732,14 @@ int do_macos_sysctl(int update_every, usec_t dt) { rrddim_add(st, "InErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); rrddim_add(st, "OutErrors", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); rrddim_add(st, "InCsumErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); - } else - rrdset_next(st); + } rrddim_set(st, "InErrors", icmpstat.icps_badcode + icmpstat.icps_badlen + icmpstat.icps_checksum + icmpstat.icps_tooshort); rrddim_set(st, "OutErrors", icmpstat.icps_error); rrddim_set(st, "InCsumErrors", icmpstat.icps_checksum); - rrdset_done(st); } - // -------------------------------------------------------------------- - if (likely(do_icmpmsg)) { st = rrdset_find_active_localhost("ipv4.icmpmsg"); if (unlikely(!st)) { @@ -809,21 +762,17 @@ int do_macos_sysctl(int update_every, usec_t dt) { rrddim_add(st, "OutEchoReps", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); rrddim_add(st, "InEchos", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); rrddim_add(st, "OutEchos", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); - } else - rrdset_next(st); - - rrddim_set(st, "InEchoReps", icmpstat.icps_inhist[ICMP_ECHOREPLY]); - rrddim_set(st, "OutEchoReps", icmpstat.icps_outhist[ICMP_ECHOREPLY]); - rrddim_set(st, "InEchos", icmpstat.icps_inhist[ICMP_ECHO]); - rrddim_set(st, "OutEchos", icmpstat.icps_outhist[ICMP_ECHO]); + } + rrddim_set(st, "InEchoReps", icmpstat.icps_inhist[ICMP_ECHOREPLY]); + rrddim_set(st, "OutEchoReps", icmpstat.icps_outhist[ICMP_ECHOREPLY]); + rrddim_set(st, "InEchos", icmpstat.icps_inhist[ICMP_ECHO]); + rrddim_set(st, "OutEchos", icmpstat.icps_outhist[ICMP_ECHO]); rrdset_done(st); } } } - // -------------------------------------------------------------------- - // see also http://net-snmp.sourceforge.net/docs/mibs/ip.html if (likely(do_ip_packets || do_ip_fragsout || do_ip_fragsin || do_ip_errors)) { if (unlikely(GETSYSCTL_BY_NAME("net.inet.ip.stats", ipstat))) { @@ -858,8 +807,7 @@ int do_macos_sysctl(int update_every, usec_t dt) { rrddim_add(st, "OutRequests", "sent", -1, 1, RRD_ALGORITHM_INCREMENTAL); rrddim_add(st, "ForwDatagrams", "forwarded", 1, 1, RRD_ALGORITHM_INCREMENTAL); rrddim_add(st, "InDelivers", "delivered", 1, 1, RRD_ALGORITHM_INCREMENTAL); - } else - rrdset_next(st); + } rrddim_set(st, "OutRequests", ipstat.ips_localout); rrddim_set(st, "InReceives", ipstat.ips_total); @@ -868,8 +816,6 @@ int do_macos_sysctl(int update_every, usec_t dt) { rrdset_done(st); } - // -------------------------------------------------------------------- - if (likely(do_ip_fragsout)) { st = rrdset_find_active_localhost("ipv4.fragsout"); if (unlikely(!st)) { @@ -892,8 +838,7 @@ int do_macos_sysctl(int update_every, usec_t dt) { rrddim_add(st, "FragOKs", "ok", 1, 1, RRD_ALGORITHM_INCREMENTAL); rrddim_add(st, "FragFails", "failed", -1, 1, RRD_ALGORITHM_INCREMENTAL); rrddim_add(st, "FragCreates", "created", 1, 1, RRD_ALGORITHM_INCREMENTAL); - } else - rrdset_next(st); + } rrddim_set(st, "FragOKs", ipstat.ips_fragmented); rrddim_set(st, "FragFails", ipstat.ips_cantfrag); @@ -901,8 +846,6 @@ int do_macos_sysctl(int update_every, usec_t dt) { rrdset_done(st); } - // -------------------------------------------------------------------- - if (likely(do_ip_fragsin)) { st = rrdset_find_active_localhost("ipv4.fragsin"); if (unlikely(!st)) { @@ -925,8 +868,7 @@ int do_macos_sysctl(int update_every, usec_t dt) { rrddim_add(st, "ReasmOKs", "ok", 1, 1, RRD_ALGORITHM_INCREMENTAL); rrddim_add(st, "ReasmFails", "failed", -1, 1, RRD_ALGORITHM_INCREMENTAL); rrddim_add(st, "ReasmReqds", "all", 1, 1, RRD_ALGORITHM_INCREMENTAL); - } else - rrdset_next(st); + } rrddim_set(st, "ReasmOKs", ipstat.ips_fragments); rrddim_set(st, "ReasmFails", ipstat.ips_fragdropped); @@ -934,8 +876,6 @@ int do_macos_sysctl(int update_every, usec_t dt) { rrdset_done(st); } - // -------------------------------------------------------------------- - if (likely(do_ip_errors)) { st = rrdset_find_active_localhost("ipv4.errors"); if (unlikely(!st)) { @@ -963,8 +903,7 @@ int do_macos_sysctl(int update_every, usec_t dt) { rrddim_add(st, "InAddrErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); rrddim_add(st, "InUnknownProtos", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); - } else - rrdset_next(st); + } rrddim_set(st, "InDiscards", ipstat.ips_badsum + ipstat.ips_tooshort + ipstat.ips_toosmall + ipstat.ips_toolong); rrddim_set(st, "OutDiscards", ipstat.ips_odropped); @@ -977,8 +916,6 @@ int do_macos_sysctl(int update_every, usec_t dt) { } } - // -------------------------------------------------------------------- - if (likely(do_ip6_packets || do_ip6_fragsout || do_ip6_fragsin || do_ip6_errors)) { if (unlikely(GETSYSCTL_BY_NAME("net.inet6.ip6.stats", ip6stat))) { do_ip6_packets = 0; @@ -1018,8 +955,7 @@ int do_macos_sysctl(int update_every, usec_t dt) { rrddim_add(st, "sent", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); rrddim_add(st, "forwarded", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); rrddim_add(st, "delivers", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); - } else - rrdset_next(st); + } rrddim_set(st, "sent", ip6stat.ip6s_localout); rrddim_set(st, "received", ip6stat.ip6s_total); @@ -1028,8 +964,6 @@ int do_macos_sysctl(int update_every, usec_t dt) { rrdset_done(st); } - // -------------------------------------------------------------------- - if (do_ip6_fragsout == CONFIG_BOOLEAN_YES || (do_ip6_fragsout == CONFIG_BOOLEAN_AUTO && (ip6stat.ip6s_fragmented || ip6stat.ip6s_cantfrag || @@ -1057,8 +991,7 @@ int do_macos_sysctl(int update_every, usec_t dt) { rrddim_add(st, "ok", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); rrddim_add(st, "failed", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); rrddim_add(st, "all", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); - } else - rrdset_next(st); + } rrddim_set(st, "ok", ip6stat.ip6s_fragmented); rrddim_set(st, "failed", ip6stat.ip6s_cantfrag); @@ -1066,8 +999,6 @@ int do_macos_sysctl(int update_every, usec_t dt) { rrdset_done(st); } - // -------------------------------------------------------------------- - if (do_ip6_fragsin == CONFIG_BOOLEAN_YES || (do_ip6_fragsin == CONFIG_BOOLEAN_AUTO && (ip6stat.ip6s_reassembled || ip6stat.ip6s_fragdropped || @@ -1097,8 +1028,7 @@ int do_macos_sysctl(int update_every, usec_t dt) { rrddim_add(st, "failed", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); rrddim_add(st, "timeout", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); rrddim_add(st, "all", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); - } else - rrdset_next(st); + } rrddim_set(st, "ok", ip6stat.ip6s_reassembled); rrddim_set(st, "failed", ip6stat.ip6s_fragdropped); @@ -1107,8 +1037,6 @@ int do_macos_sysctl(int update_every, usec_t dt) { rrdset_done(st); } - // -------------------------------------------------------------------- - if (do_ip6_errors == CONFIG_BOOLEAN_YES || (do_ip6_errors == CONFIG_BOOLEAN_AUTO && (ip6stat.ip6s_toosmall || ip6stat.ip6s_odropped || @@ -1148,8 +1076,7 @@ int do_macos_sysctl(int update_every, usec_t dt) { rrddim_add(st, "InNoRoutes", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); rrddim_add(st, "OutNoRoutes", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); - } else - rrdset_next(st); + } rrddim_set(st, "InDiscards", ip6stat.ip6s_toosmall); rrddim_set(st, "OutDiscards", ip6stat.ip6s_odropped); @@ -1166,8 +1093,6 @@ int do_macos_sysctl(int update_every, usec_t dt) { } } - // -------------------------------------------------------------------- - if (likely(do_icmp6 || do_icmp6_redir || do_icmp6_errors || do_icmp6_echos || do_icmp6_router || do_icmp6_neighbor || do_icmp6_types)) { if (unlikely(GETSYSCTL_BY_NAME("net.inet6.icmp6.stats", icmp6stat))) { do_icmp6 = 0; @@ -1202,16 +1127,13 @@ int do_macos_sysctl(int update_every, usec_t dt) { rrddim_add(st, "received", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); rrddim_add(st, "sent", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); - } else - rrdset_next(st); + } rrddim_set(st, "sent", icmp6_total.msgs_in); rrddim_set(st, "received", icmp6_total.msgs_out); rrdset_done(st); } - // -------------------------------------------------------------------- - if (do_icmp6_redir == CONFIG_BOOLEAN_YES || (do_icmp6_redir == CONFIG_BOOLEAN_AUTO && (icmp6stat.icp6s_inhist[ND_REDIRECT] || icmp6stat.icp6s_outhist[ND_REDIRECT] || @@ -1236,16 +1158,13 @@ int do_macos_sysctl(int update_every, usec_t dt) { rrddim_add(st, "received", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); rrddim_add(st, "sent", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); - } else - rrdset_next(st); + } rrddim_set(st, "sent", icmp6stat.icp6s_inhist[ND_REDIRECT]); rrddim_set(st, "received", icmp6stat.icp6s_outhist[ND_REDIRECT]); rrdset_done(st); } - // -------------------------------------------------------------------- - if (do_icmp6_errors == CONFIG_BOOLEAN_YES || (do_icmp6_errors == CONFIG_BOOLEAN_AUTO && (icmp6stat.icp6s_badcode || icmp6stat.icp6s_badlen || @@ -1288,8 +1207,7 @@ int do_macos_sysctl(int update_every, usec_t dt) { rrddim_add(st, "OutDestUnreachs", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); rrddim_add(st, "OutTimeExcds", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); rrddim_add(st, "OutParmProblems", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); - } else - rrdset_next(st); + } rrddim_set(st, "InErrors", icmp6stat.icp6s_badcode + icmp6stat.icp6s_badlen + icmp6stat.icp6s_checksum + icmp6stat.icp6s_tooshort); rrddim_set(st, "OutErrors", icmp6stat.icp6s_error); @@ -1304,8 +1222,6 @@ int do_macos_sysctl(int update_every, usec_t dt) { rrdset_done(st); } - // -------------------------------------------------------------------- - if (do_icmp6_echos == CONFIG_BOOLEAN_YES || (do_icmp6_echos == CONFIG_BOOLEAN_AUTO && (icmp6stat.icp6s_inhist[ICMP6_ECHO_REQUEST] || icmp6stat.icp6s_outhist[ICMP6_ECHO_REQUEST] || @@ -1334,8 +1250,7 @@ int do_macos_sysctl(int update_every, usec_t dt) { rrddim_add(st, "OutEchos", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); rrddim_add(st, "InEchoReplies", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); rrddim_add(st, "OutEchoReplies", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); - } else - rrdset_next(st); + } rrddim_set(st, "InEchos", icmp6stat.icp6s_inhist[ICMP6_ECHO_REQUEST]); rrddim_set(st, "OutEchos", icmp6stat.icp6s_outhist[ICMP6_ECHO_REQUEST]); @@ -1344,8 +1259,6 @@ int do_macos_sysctl(int update_every, usec_t dt) { rrdset_done(st); } - // -------------------------------------------------------------------- - if (do_icmp6_router == CONFIG_BOOLEAN_YES || (do_icmp6_router == CONFIG_BOOLEAN_AUTO && (icmp6stat.icp6s_inhist[ND_ROUTER_SOLICIT] || icmp6stat.icp6s_outhist[ND_ROUTER_SOLICIT] || @@ -1374,8 +1287,7 @@ int do_macos_sysctl(int update_every, usec_t dt) { rrddim_add(st, "OutSolicits", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); rrddim_add(st, "InAdvertisements", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); rrddim_add(st, "OutAdvertisements", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); - } else - rrdset_next(st); + } rrddim_set(st, "InSolicits", icmp6stat.icp6s_inhist[ND_ROUTER_SOLICIT]); rrddim_set(st, "OutSolicits", icmp6stat.icp6s_outhist[ND_ROUTER_SOLICIT]); @@ -1384,8 +1296,6 @@ int do_macos_sysctl(int update_every, usec_t dt) { rrdset_done(st); } - // -------------------------------------------------------------------- - if (do_icmp6_neighbor == CONFIG_BOOLEAN_YES || (do_icmp6_neighbor == CONFIG_BOOLEAN_AUTO && (icmp6stat.icp6s_inhist[ND_NEIGHBOR_SOLICIT] || icmp6stat.icp6s_outhist[ND_NEIGHBOR_SOLICIT] || @@ -1414,18 +1324,14 @@ int do_macos_sysctl(int update_every, usec_t dt) { rrddim_add(st, "OutSolicits", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); rrddim_add(st, "InAdvertisements", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); rrddim_add(st, "OutAdvertisements", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); - } else - rrdset_next(st); + } rrddim_set(st, "InSolicits", icmp6stat.icp6s_inhist[ND_NEIGHBOR_SOLICIT]); rrddim_set(st, "OutSolicits", icmp6stat.icp6s_outhist[ND_NEIGHBOR_SOLICIT]); rrddim_set(st, "InAdvertisements", icmp6stat.icp6s_inhist[ND_NEIGHBOR_ADVERT]); rrddim_set(st, "OutAdvertisements", icmp6stat.icp6s_outhist[ND_NEIGHBOR_ADVERT]); - rrdset_done(st); } - // -------------------------------------------------------------------- - if (do_icmp6_types == CONFIG_BOOLEAN_YES || (do_icmp6_types == CONFIG_BOOLEAN_AUTO && (icmp6stat.icp6s_inhist[1] || icmp6stat.icp6s_inhist[128] || @@ -1466,8 +1372,7 @@ int do_macos_sysctl(int update_every, usec_t dt) { rrddim_add(st, "OutType133", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); rrddim_add(st, "OutType135", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); rrddim_add(st, "OutType143", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); - } else - rrdset_next(st); + } rrddim_set(st, "InType1", icmp6stat.icp6s_inhist[1]); rrddim_set(st, "InType128", icmp6stat.icp6s_inhist[128]); @@ -1484,8 +1389,6 @@ int do_macos_sysctl(int update_every, usec_t dt) { } } - // -------------------------------------------------------------------- - if (likely(do_uptime)) { if (unlikely(GETSYSCTL_BY_NAME("kern.boottime", boot_time))) { do_uptime = 0; @@ -1511,7 +1414,6 @@ int do_macos_sysctl(int update_every, usec_t dt) { ); rrddim_add(st, "uptime", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE); } - else rrdset_next(st); rrddim_set(st, "uptime", cur_time.tv_sec - boot_time.tv_sec); rrdset_done(st); @@ -1520,4 +1422,3 @@ int do_macos_sysctl(int update_every, usec_t dt) { return 0; } - diff --git a/collectors/macos.plugin/plugin_macos.h b/collectors/macos.plugin/plugin_macos.h index b4c2cf542..2c673a224 100644 --- a/collectors/macos.plugin/plugin_macos.h +++ b/collectors/macos.plugin/plugin_macos.h @@ -5,8 +5,8 @@ #include "daemon/common.h" -extern int do_macos_sysctl(int update_every, usec_t dt); -extern int do_macos_mach_smi(int update_every, usec_t dt); -extern int do_macos_iokit(int update_every, usec_t dt); +int do_macos_sysctl(int update_every, usec_t dt); +int do_macos_mach_smi(int update_every, usec_t dt); +int do_macos_iokit(int update_every, usec_t dt); #endif /* NETDATA_PLUGIN_MACOS_H */ |