diff options
author | Vladimir Kobal <vlad@prokk.net> | 2017-01-09 14:25:00 -0500 |
---|---|---|
committer | Vladimir Kobal <vlad@prokk.net> | 2017-01-09 14:25:00 -0500 |
commit | 7bdec01f04eaa39078e479742a0e3bdd6c98a800 (patch) | |
tree | 65e98c9715c9dbfd46d0b265420a4cf249985384 /src/macos_sysctl.c | |
parent | 5ae05859a22d41489355ee65b2e4f815b7c73240 (diff) |
Add IPv4 UDP charts to macOS plugin
Diffstat (limited to 'src/macos_sysctl.c')
-rw-r--r-- | src/macos_sysctl.c | 66 |
1 files changed, 65 insertions, 1 deletions
diff --git a/src/macos_sysctl.c b/src/macos_sysctl.c index e3d08f7b3b..72fa4fa164 100644 --- a/src/macos_sysctl.c +++ b/src/macos_sysctl.c @@ -6,6 +6,11 @@ #include <sys/socketvar.h> #include <netinet/tcp_var.h> #include <netinet/tcp_fsm.h> +// NEEDED BY do_udp..., do_ip... +#include <netinet/ip_var.h> +// NEEDED BY do_udp... +#include <netinet/udp.h> +#include <netinet/udp_var.h> #define GETSYSCTL(name, var) getsysctl(name, &(var), sizeof(var)) @@ -19,7 +24,8 @@ int do_macos_sysctl(int update_every, usec_t dt) { static int do_loadavg = -1, do_swap = -1, do_bandwidth = -1, do_tcp_packets = -1, do_tcp_errors = -1, do_tcp_handshake = -1, do_ecn = -1, - do_tcpext_syscookies = -1, do_tcpext_ofo = -1, do_tcpext_connaborts = -1; + do_tcpext_syscookies = -1, do_tcpext_ofo = -1, do_tcpext_connaborts = -1, + do_udp_packets = -1, do_udp_errors = -1; if (unlikely(do_loadavg == -1)) { @@ -33,6 +39,8 @@ int do_macos_sysctl(int update_every, usec_t dt) { do_tcpext_syscookies = config_get_boolean_ondemand("plugin:macos:sysctl", "TCP SYN cookies", CONFIG_ONDEMAND_ONDEMAND); do_tcpext_ofo = config_get_boolean_ondemand("plugin:macos:sysctl", "TCP out-of-order queue", CONFIG_ONDEMAND_ONDEMAND); do_tcpext_connaborts = config_get_boolean_ondemand("plugin:macos:sysctl", "TCP connection aborts", CONFIG_ONDEMAND_ONDEMAND); + do_udp_packets = config_get_boolean("plugin:macos:sysctl", "ipv4 UDP packets", 1); + do_udp_errors = config_get_boolean("plugin:macos:sysctl", "ipv4 UDP errors", 1); } RRDSET *st; @@ -63,6 +71,9 @@ int do_macos_sysctl(int update_every, usec_t dt) { struct tcpstat tcpstat; uint64_t tcps_states[TCP_NSTATES]; + // NEEDED BY: do_udp... + struct udpstat udpstat; + if (last_loadavg_usec <= dt) { if (likely(do_loadavg)) { if (unlikely(GETSYSCTL("vm.loadavg", sysload))) { @@ -324,6 +335,59 @@ 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("net.inet.udp.stats", udpstat))) { + do_udp_packets = 0; + error("DISABLED: ipv4.udppackets"); + do_udp_errors = 0; + error("DISABLED: ipv4.udperrors"); + } else { + if (likely(do_udp_packets)) { + st = rrdset_find("ipv4.udppackets"); + if (unlikely(!st)) { + st = rrdset_create("ipv4", "udppackets", NULL, "udp", NULL, "IPv4 UDP Packets", + "packets/s", 2601, update_every, RRDSET_TYPE_LINE); + + rrddim_add(st, "InDatagrams", "received", 1, 1, RRDDIM_INCREMENTAL); + rrddim_add(st, "OutDatagrams", "sent", -1, 1, RRDDIM_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("ipv4.udperrors"); + if (unlikely(!st)) { + st = rrdset_create("ipv4", "udperrors", NULL, "udp", NULL, "IPv4 UDP Errors", "events/s", + 2701, update_every, RRDSET_TYPE_LINE); + st->isdetail = 1; + + rrddim_add(st, "RcvbufErrors", NULL, 1, 1, RRDDIM_INCREMENTAL); + rrddim_add(st, "InErrors", NULL, 1, 1, RRDDIM_INCREMENTAL); + rrddim_add(st, "NoPorts", NULL, 1, 1, RRDDIM_INCREMENTAL); + rrddim_add(st, "InCsumErrors", NULL, 1, 1, RRDDIM_INCREMENTAL); + rrddim_add(st, "IgnoredMulti", NULL, 1, 1, RRDDIM_INCREMENTAL); + } else + rrdset_next(st); + + rrddim_set(st, "InErrors", udpstat.udps_hdrops + udpstat.udps_badlen); + rrddim_set(st, "NoPorts", udpstat.udps_noport); + rrddim_set(st, "RcvbufErrors", udpstat.udps_fullsock); + rrddim_set(st, "InCsumErrors", udpstat.udps_badsum + udpstat.udps_nosum); + rrddim_set(st, "IgnoredMulti", udpstat.udps_filtermcast); + rrdset_done(st); + } + } + } + return 0; } |