| 1 | // SPDX-License-Identifier: GPL-3.0-or-later |
| 2 | |
| 3 | #include "plugin_macos.h" |
| 4 | |
| 5 | #include <Availability.h> |
| 6 | // NEEDED BY: do_bandwidth |
| 7 | #include <net/route.h> |
| 8 | // NEEDED BY do_tcp... |
| 9 | #include <sys/socketvar.h> |
| 10 | #include <netinet/tcp_var.h> |
| 11 | #include <netinet/tcp_fsm.h> |
| 12 | // NEEDED BY do_udp..., do_ip... |
| 13 | #include <netinet/ip_var.h> |
| 14 | // NEEDED BY do_udp... |
| 15 | #include <netinet/udp.h> |
| 16 | #include <netinet/udp_var.h> |
| 17 | // NEEDED BY do_icmp... |
| 18 | #include <netinet/ip.h> |
| 19 | #include <netinet/ip_icmp.h> |
| 20 | #include <netinet/icmp_var.h> |
| 21 | // NEEDED BY do_icmp6... |
| 22 | #include <netinet/icmp6.h> |
| 23 | // NEEDED BY do_uptime |
| 24 | #include <time.h> |
| 25 | |
| 26 | // MacOS calculates load averages once every 5 seconds |
| 27 | #define MIN_LOADAVG_UPDATE_EVERY 5 |
| 28 | |
| 29 | int do_macos_sysctl(int update_every, usec_t dt) { |
| 30 | static int do_loadavg = -1, do_swap = -1, do_bandwidth = -1, |
| 31 | do_tcp_packets = -1, do_tcp_errors = -1, do_tcp_handshake = -1, do_ecn = -1, |
| 32 | do_tcpext_syscookies = -1, do_tcpext_ofo = -1, do_tcpext_connaborts = -1, |
| 33 | do_udp_packets = -1, do_udp_errors = -1, do_icmp_packets = -1, do_icmpmsg = -1, |
| 34 | do_ip_packets = -1, do_ip_fragsout = -1, do_ip_fragsin = -1, do_ip_errors = -1, |
| 35 | do_ip6_packets = -1, do_ip6_fragsout = -1, do_ip6_fragsin = -1, do_ip6_errors = -1, |
| 36 | do_icmp6 = -1, do_icmp6_redir = -1, do_icmp6_errors = -1, do_icmp6_echos = -1, |
| 37 | do_icmp6_router = -1, do_icmp6_neighbor = -1, do_icmp6_types = -1, do_uptime = -1; |
| 38 | |
| 39 | |
| 40 | if (unlikely(do_loadavg == -1)) { |
| 41 | do_loadavg = inicfg_get_boolean(&netdata_config, "plugin:macos:sysctl", "enable load average", 1); |
| 42 | do_swap = inicfg_get_boolean(&netdata_config, "plugin:macos:sysctl", "system swap", 1); |
| 43 | do_bandwidth = inicfg_get_boolean(&netdata_config, "plugin:macos:sysctl", "bandwidth", 1); |
| 44 | do_tcp_packets = inicfg_get_boolean(&netdata_config, "plugin:macos:sysctl", "ipv4 TCP packets", 1); |
| 45 | do_tcp_errors = inicfg_get_boolean(&netdata_config, "plugin:macos:sysctl", "ipv4 TCP errors", 1); |
| 46 | do_tcp_handshake = inicfg_get_boolean(&netdata_config, "plugin:macos:sysctl", "ipv4 TCP handshake issues", 1); |
| 47 | do_ecn = inicfg_get_boolean_ondemand(&netdata_config, "plugin:macos:sysctl", "ECN packets", CONFIG_BOOLEAN_AUTO); |
| 48 | do_tcpext_syscookies = inicfg_get_boolean_ondemand(&netdata_config, "plugin:macos:sysctl", "TCP SYN cookies", CONFIG_BOOLEAN_AUTO); |
| 49 | do_tcpext_ofo = inicfg_get_boolean_ondemand(&netdata_config, "plugin:macos:sysctl", "TCP out-of-order queue", CONFIG_BOOLEAN_AUTO); |
| 50 | do_tcpext_connaborts = inicfg_get_boolean_ondemand(&netdata_config, "plugin:macos:sysctl", "TCP connection aborts", CONFIG_BOOLEAN_AUTO); |
| 51 | do_udp_packets = inicfg_get_boolean(&netdata_config, "plugin:macos:sysctl", "ipv4 UDP packets", 1); |
| 52 | do_udp_errors = inicfg_get_boolean(&netdata_config, "plugin:macos:sysctl", "ipv4 UDP errors", 1); |
| 53 | do_icmp_packets = inicfg_get_boolean(&netdata_config, "plugin:macos:sysctl", "ipv4 ICMP packets", 1); |
| 54 | do_icmpmsg = inicfg_get_boolean(&netdata_config, "plugin:macos:sysctl", "ipv4 ICMP messages", 1); |
| 55 | do_ip_packets = inicfg_get_boolean(&netdata_config, "plugin:macos:sysctl", "ipv4 packets", 1); |
| 56 | do_ip_fragsout = inicfg_get_boolean(&netdata_config, "plugin:macos:sysctl", "ipv4 fragments sent", 1); |
| 57 | do_ip_fragsin = inicfg_get_boolean(&netdata_config, "plugin:macos:sysctl", "ipv4 fragments assembly", 1); |
| 58 | do_ip_errors = inicfg_get_boolean(&netdata_config, "plugin:macos:sysctl", "ipv4 errors", 1); |
| 59 | do_ip6_packets = inicfg_get_boolean_ondemand(&netdata_config, "plugin:macos:sysctl", "ipv6 packets", CONFIG_BOOLEAN_AUTO); |
| 60 | do_ip6_fragsout = inicfg_get_boolean_ondemand(&netdata_config, "plugin:macos:sysctl", "ipv6 fragments sent", CONFIG_BOOLEAN_AUTO); |
| 61 | do_ip6_fragsin = inicfg_get_boolean_ondemand(&netdata_config, "plugin:macos:sysctl", "ipv6 fragments assembly", CONFIG_BOOLEAN_AUTO); |
| 62 | do_ip6_errors = inicfg_get_boolean_ondemand(&netdata_config, "plugin:macos:sysctl", "ipv6 errors", CONFIG_BOOLEAN_AUTO); |
| 63 | do_icmp6 = inicfg_get_boolean_ondemand(&netdata_config, "plugin:macos:sysctl", "icmp", CONFIG_BOOLEAN_AUTO); |
| 64 | do_icmp6_redir = inicfg_get_boolean_ondemand(&netdata_config, "plugin:macos:sysctl", "icmp redirects", CONFIG_BOOLEAN_AUTO); |
| 65 | do_icmp6_errors = inicfg_get_boolean_ondemand(&netdata_config, "plugin:macos:sysctl", "icmp errors", CONFIG_BOOLEAN_AUTO); |
| 66 | do_icmp6_echos = inicfg_get_boolean_ondemand(&netdata_config, "plugin:macos:sysctl", "icmp echos", CONFIG_BOOLEAN_AUTO); |
| 67 | do_icmp6_router = inicfg_get_boolean_ondemand(&netdata_config, "plugin:macos:sysctl", "icmp router", CONFIG_BOOLEAN_AUTO); |
| 68 | do_icmp6_neighbor = inicfg_get_boolean_ondemand(&netdata_config, "plugin:macos:sysctl", "icmp neighbor", CONFIG_BOOLEAN_AUTO); |
| 69 | do_icmp6_types = inicfg_get_boolean_ondemand(&netdata_config, "plugin:macos:sysctl", "icmp types", CONFIG_BOOLEAN_AUTO); |
| 70 | do_uptime = inicfg_get_boolean(&netdata_config, "plugin:macos:sysctl", "system uptime", 1); |
| 71 | } |
| 72 | |
| 73 | RRDSET *st = NULL; |
| 74 | |
| 75 | int i; |
| 76 | size_t size; |
| 77 | |
| 78 | // NEEDED BY: do_loadavg |
| 79 | static usec_t next_loadavg_dt = 0; |
| 80 | struct loadavg sysload; |
| 81 | |
| 82 | // NEEDED BY: do_swap |
| 83 | struct xsw_usage swap_usage; |
| 84 | |
| 85 | // NEEDED BY: do_bandwidth |
| 86 | int mib[6]; |
| 87 | static char *ifstatdata = NULL; |
| 88 | char *lim, *next; |
| 89 | struct if_msghdr *ifm; |
| 90 | struct iftot { |
| 91 | u_long ift_ibytes; |
| 92 | u_long ift_obytes; |
| 93 | } iftot = {0, 0}; |
| 94 | |
| 95 | // NEEDED BY: do_tcp... |
| 96 | struct tcpstat tcpstat; |
| 97 | |
| 98 | // NEEDED BY: do_udp... |
| 99 | struct udpstat udpstat; |
| 100 | |
| 101 | // NEEDED BY: do_icmp... |
| 102 | struct icmpstat icmpstat; |
| 103 | struct icmp_total { |
| 104 | u_long msgs_in; |
| 105 | u_long msgs_out; |
| 106 | } icmp_total = {0, 0}; |
| 107 | |
| 108 | // NEEDED BY: do_ip... |
| 109 | struct ipstat ipstat; |
| 110 | |
| 111 | // NEEDED BY: do_ip6... |
| 112 | /* |
| 113 | * Dirty workaround for /usr/include/netinet6/ip6_var.h absence. |
| 114 | * Struct ip6stat was copied from bsd/netinet6/ip6_var.h from xnu sources. |
| 115 | * Do the same for previously missing scope6_var.h on OS X < 10.11. |
| 116 | */ |
| 117 | #define IP6S_SRCRULE_COUNT 16 |
| 118 | |
| 119 | #if (defined __MAC_OS_X_VERSION_MIN_REQUIRED && __MAC_OS_X_VERSION_MIN_REQUIRED < 101100) |
| 120 | #ifndef _NETINET6_SCOPE6_VAR_H_ |
| 121 | #define _NETINET6_SCOPE6_VAR_H_ |
| 122 | #include <sys/appleapiopts.h> |
| 123 | |
| 124 | #define SCOPE6_ID_MAX 16 |
| 125 | #endif |
| 126 | #else |
| 127 | #include <netinet6/scope6_var.h> |
| 128 | #endif |
| 129 | |
| 130 | struct ip6stat { |
| 131 | u_quad_t ip6s_total; /* total packets received */ |
| 132 | u_quad_t ip6s_tooshort; /* packet too short */ |
| 133 | u_quad_t ip6s_toosmall; /* not enough data */ |
| 134 | u_quad_t ip6s_fragments; /* fragments received */ |
| 135 | u_quad_t ip6s_fragdropped; /* frags dropped(dups, out of space) */ |
| 136 | u_quad_t ip6s_fragtimeout; /* fragments timed out */ |
| 137 | u_quad_t ip6s_fragoverflow; /* fragments that exceeded limit */ |
| 138 | u_quad_t ip6s_forward; /* packets forwarded */ |
| 139 | u_quad_t ip6s_cantforward; /* packets rcvd for unreachable dest */ |
| 140 | u_quad_t ip6s_redirectsent; /* packets forwarded on same net */ |
| 141 | u_quad_t ip6s_delivered; /* datagrams delivered to upper level */ |
| 142 | u_quad_t ip6s_localout; /* total ip packets generated here */ |
| 143 | u_quad_t ip6s_odropped; /* lost packets due to nobufs, etc. */ |
| 144 | u_quad_t ip6s_reassembled; /* total packets reassembled ok */ |
| 145 | u_quad_t ip6s_atmfrag_rcvd; /* atomic fragments received */ |
| 146 | u_quad_t ip6s_fragmented; /* datagrams successfully fragmented */ |
| 147 | u_quad_t ip6s_ofragments; /* output fragments created */ |
| 148 | u_quad_t ip6s_cantfrag; /* don't fragment flag was set, etc. */ |
| 149 | u_quad_t ip6s_badoptions; /* error in option processing */ |
| 150 | u_quad_t ip6s_noroute; /* packets discarded due to no route */ |
| 151 | u_quad_t ip6s_badvers; /* ip6 version != 6 */ |
| 152 | u_quad_t ip6s_rawout; /* total raw ip packets generated */ |
| 153 | u_quad_t ip6s_badscope; /* scope error */ |
| 154 | u_quad_t ip6s_notmember; /* don't join this multicast group */ |
| 155 | u_quad_t ip6s_nxthist[256]; /* next header history */ |
| 156 | u_quad_t ip6s_m1; /* one mbuf */ |
| 157 | u_quad_t ip6s_m2m[32]; /* two or more mbuf */ |
| 158 | u_quad_t ip6s_mext1; /* one ext mbuf */ |
| 159 | u_quad_t ip6s_mext2m; /* two or more ext mbuf */ |
| 160 | u_quad_t ip6s_exthdrtoolong; /* ext hdr are not continuous */ |
| 161 | u_quad_t ip6s_nogif; /* no match gif found */ |
| 162 | u_quad_t ip6s_toomanyhdr; /* discarded due to too many headers */ |
| 163 | |
| 164 | /* |
| 165 | * statistics for improvement of the source address selection |
| 166 | * algorithm: |
| 167 | */ |
| 168 | /* number of times that address selection fails */ |
| 169 | u_quad_t ip6s_sources_none; |
| 170 | /* number of times that an address on the outgoing I/F is chosen */ |
| 171 | u_quad_t ip6s_sources_sameif[SCOPE6_ID_MAX]; |
| 172 | /* number of times that an address on a non-outgoing I/F is chosen */ |
| 173 | u_quad_t ip6s_sources_otherif[SCOPE6_ID_MAX]; |
| 174 | /* |
| 175 | * number of times that an address that has the same scope |
| 176 | * from the destination is chosen. |
| 177 | */ |
| 178 | u_quad_t ip6s_sources_samescope[SCOPE6_ID_MAX]; |
| 179 | /* |
| 180 | * number of times that an address that has a different scope |
| 181 | * from the destination is chosen. |
| 182 | */ |
| 183 | u_quad_t ip6s_sources_otherscope[SCOPE6_ID_MAX]; |
| 184 | /* number of times that a deprecated address is chosen */ |
| 185 | u_quad_t ip6s_sources_deprecated[SCOPE6_ID_MAX]; |
| 186 | |
| 187 | u_quad_t ip6s_forward_cachehit; |
| 188 | u_quad_t ip6s_forward_cachemiss; |
| 189 | |
| 190 | /* number of times that each rule of source selection is applied. */ |
| 191 | u_quad_t ip6s_sources_rule[IP6S_SRCRULE_COUNT]; |
| 192 | |
| 193 | /* number of times we ignored address on expensive secondary interfaces */ |
| 194 | u_quad_t ip6s_sources_skip_expensive_secondary_if; |
| 195 | |
| 196 | /* pkt dropped, no mbufs for control data */ |
| 197 | u_quad_t ip6s_pktdropcntrl; |
| 198 | |
| 199 | /* total packets trimmed/adjusted */ |
| 200 | u_quad_t ip6s_adj; |
| 201 | /* hwcksum info discarded during adjustment */ |
| 202 | u_quad_t ip6s_adj_hwcsum_clr; |
| 203 | |
| 204 | /* duplicate address detection collisions */ |
| 205 | u_quad_t ip6s_dad_collide; |
| 206 | |
| 207 | /* DAD NS looped back */ |
| 208 | u_quad_t ip6s_dad_loopcount; |
| 209 | } ip6stat; |
| 210 | |
| 211 | // NEEDED BY: do_icmp6... |
| 212 | struct icmp6stat icmp6stat; |
| 213 | struct icmp6_total { |
| 214 | u_long msgs_in; |
| 215 | u_long msgs_out; |
| 216 | } icmp6_total = {0, 0}; |
| 217 | |
| 218 | // NEEDED BY: do_uptime |
| 219 | struct timespec boot_time, cur_time; |
| 220 | |
| 221 | if (next_loadavg_dt <= dt) { |
| 222 | if (likely(do_loadavg)) { |
| 223 | if (unlikely(GETSYSCTL_BY_NAME("vm.loadavg", sysload))) { |
| 224 | do_loadavg = 0; |
| 225 | collector_error("DISABLED: system.load"); |
| 226 | } else { |
| 227 | |
| 228 | st = rrdset_find_active_bytype_localhost("system", "load"); |
| 229 | if (unlikely(!st)) { |
| 230 | st = rrdset_create_localhost( |
| 231 | "system" |
| 232 | , "load" |
| 233 | , NULL |
| 234 | , "load" |
| 235 | , NULL |
| 236 | , "System Load Average" |
| 237 | , "load" |
| 238 | , "macos.plugin" |
| 239 | , "sysctl" |
| 240 | , 100 |
| 241 | , (update_every < MIN_LOADAVG_UPDATE_EVERY) ? MIN_LOADAVG_UPDATE_EVERY : update_every |
| 242 | , RRDSET_TYPE_LINE |
| 243 | ); |
| 244 | rrddim_add(st, "load1", NULL, 1, 1000, RRD_ALGORITHM_ABSOLUTE); |
| 245 | rrddim_add(st, "load5", NULL, 1, 1000, RRD_ALGORITHM_ABSOLUTE); |
| 246 | rrddim_add(st, "load15", NULL, 1, 1000, RRD_ALGORITHM_ABSOLUTE); |
| 247 | } |
| 248 | |
| 249 | rrddim_set(st, "load1", (collected_number) ((double)sysload.ldavg[0] / sysload.fscale * 1000)); |
| 250 | rrddim_set(st, "load5", (collected_number) ((double)sysload.ldavg[1] / sysload.fscale * 1000)); |
| 251 | rrddim_set(st, "load15", (collected_number) ((double)sysload.ldavg[2] / sysload.fscale * 1000)); |
| 252 | rrdset_done(st); |
| 253 | } |
| 254 | } |
| 255 | |
| 256 | next_loadavg_dt = st->update_every * USEC_PER_SEC; |
| 257 | } |
| 258 | else next_loadavg_dt -= dt; |
| 259 | |
| 260 | if (likely(do_swap)) { |
| 261 | if (unlikely(GETSYSCTL_BY_NAME("vm.swapusage", swap_usage))) { |
| 262 | do_swap = 0; |
| 263 | collector_error("DISABLED: mem.swap"); |
| 264 | } else { |
| 265 | st = rrdset_find_active_localhost("mem.swap"); |
| 266 | if (unlikely(!st)) { |
| 267 | st = rrdset_create_localhost( |
| 268 | "mem" |
| 269 | , "swap" |
| 270 | , NULL |
| 271 | , "swap" |
| 272 | , NULL |
| 273 | , "System Swap" |
| 274 | , "MiB" |
| 275 | , "macos.plugin" |
| 276 | , "sysctl" |
| 277 | , 201 |
| 278 | , update_every |
| 279 | , RRDSET_TYPE_STACKED |
| 280 | ); |
| 281 | |
| 282 | rrddim_add(st, "free", NULL, 1, 1048576, RRD_ALGORITHM_ABSOLUTE); |
| 283 | rrddim_add(st, "used", NULL, 1, 1048576, RRD_ALGORITHM_ABSOLUTE); |
| 284 | } |
| 285 | |
| 286 | rrddim_set(st, "free", swap_usage.xsu_avail); |
| 287 | rrddim_set(st, "used", swap_usage.xsu_used); |
| 288 | rrdset_done(st); |
| 289 | } |
| 290 | } |
| 291 | |
| 292 | if (likely(do_bandwidth)) { |
| 293 | mib[0] = CTL_NET; |
| 294 | mib[1] = PF_ROUTE; |
| 295 | mib[2] = 0; |
| 296 | mib[3] = AF_INET; |
| 297 | mib[4] = NET_RT_IFLIST2; |
| 298 | mib[5] = 0; |
| 299 | if (unlikely(sysctl(mib, 6, NULL, &size, NULL, 0))) { |
| 300 | collector_error("MACOS: sysctl(%s...) failed: %s", "net interfaces", strerror(errno)); |
| 301 | do_bandwidth = 0; |
| 302 | collector_error("DISABLED: system.ipv4"); |
| 303 | } else { |
| 304 | ifstatdata = reallocz(ifstatdata, size); |
| 305 | if (unlikely(sysctl(mib, 6, ifstatdata, &size, NULL, 0) < 0)) { |
| 306 | collector_error("MACOS: sysctl(%s...) failed: %s", "net interfaces", strerror(errno)); |
| 307 | do_bandwidth = 0; |
| 308 | collector_error("DISABLED: system.ipv4"); |
| 309 | } else { |
| 310 | lim = ifstatdata + size; |
| 311 | iftot.ift_ibytes = iftot.ift_obytes = 0; |
| 312 | for (next = ifstatdata; next < lim; ) { |
| 313 | ifm = (struct if_msghdr *)next; |
| 314 | next += ifm->ifm_msglen; |
| 315 | |
| 316 | if (ifm->ifm_type == RTM_IFINFO2) { |
| 317 | struct if_msghdr2 *if2m = (struct if_msghdr2 *)ifm; |
| 318 | |
| 319 | iftot.ift_ibytes += if2m->ifm_data.ifi_ibytes; |
| 320 | iftot.ift_obytes += if2m->ifm_data.ifi_obytes; |
| 321 | } |
| 322 | } |
| 323 | st = rrdset_find_active_localhost("system.ipv4"); |
| 324 | if (unlikely(!st)) { |
| 325 | st = rrdset_create_localhost( |
| 326 | "system" |
| 327 | , "ipv4" |
| 328 | , NULL |
| 329 | , "network" |
| 330 | , NULL |
| 331 | , "IPv4 Bandwidth" |
| 332 | , "kilobits/s" |
| 333 | , "macos.plugin" |
| 334 | , "sysctl" |
| 335 | , 500 |
| 336 | , update_every |
| 337 | , RRDSET_TYPE_AREA |
| 338 | ); |
| 339 | |
| 340 | rrddim_add(st, "InOctets", "received", 8, BITS_IN_A_KILOBIT, RRD_ALGORITHM_INCREMENTAL); |
| 341 | rrddim_add(st, "OutOctets", "sent", -8, BITS_IN_A_KILOBIT, RRD_ALGORITHM_INCREMENTAL); |
| 342 | } |
| 343 | |
| 344 | rrddim_set(st, "InOctets", iftot.ift_ibytes); |
| 345 | rrddim_set(st, "OutOctets", iftot.ift_obytes); |
| 346 | rrdset_done(st); |
| 347 | } |
| 348 | } |
| 349 | } |
| 350 | |
| 351 | // see http://net-snmp.sourceforge.net/docs/mibs/tcp.html |
| 352 | if (likely(do_tcp_packets || do_tcp_errors || do_tcp_handshake || do_tcpext_connaborts || do_tcpext_ofo || do_tcpext_syscookies || do_ecn)) { |
| 353 | if (unlikely(GETSYSCTL_BY_NAME("net.inet.tcp.stats", tcpstat))){ |
| 354 | do_tcp_packets = 0; |
| 355 | collector_error("DISABLED: ipv4.tcppackets"); |
| 356 | do_tcp_errors = 0; |
| 357 | collector_error("DISABLED: ipv4.tcperrors"); |
| 358 | do_tcp_handshake = 0; |
| 359 | collector_error("DISABLED: ipv4.tcphandshake"); |
| 360 | do_tcpext_connaborts = 0; |
| 361 | collector_error("DISABLED: ipv4.tcpconnaborts"); |
| 362 | do_tcpext_ofo = 0; |
| 363 | collector_error("DISABLED: ipv4.tcpofo"); |
| 364 | do_tcpext_syscookies = 0; |
| 365 | collector_error("DISABLED: ipv4.tcpsyncookies"); |
| 366 | do_ecn = 0; |
| 367 | collector_error("DISABLED: ipv4.ecnpkts"); |
| 368 | } else { |
| 369 | if (likely(do_tcp_packets)) { |
| 370 | st = rrdset_find_active_localhost("ipv4.tcppackets"); |
| 371 | if (unlikely(!st)) { |
| 372 | st = rrdset_create_localhost( |
| 373 | "ipv4" |
| 374 | , "tcppackets" |
| 375 | , NULL |
| 376 | , "tcp" |
| 377 | , NULL |
| 378 | , "IPv4 TCP Packets" |
| 379 | , "packets/s" |
| 380 | , "macos.plugin" |
| 381 | , "sysctl" |
| 382 | , 2600 |
| 383 | , update_every |
| 384 | , RRDSET_TYPE_LINE |
| 385 | ); |
| 386 | |
| 387 | rrddim_add(st, "InSegs", "received", 1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 388 | rrddim_add(st, "OutSegs", "sent", -1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 389 | } |
| 390 | |
| 391 | rrddim_set(st, "InSegs", tcpstat.tcps_rcvtotal); |
| 392 | rrddim_set(st, "OutSegs", tcpstat.tcps_sndtotal); |
| 393 | rrdset_done(st); |
| 394 | } |
| 395 | |
| 396 | if (likely(do_tcp_errors)) { |
| 397 | st = rrdset_find_active_localhost("ipv4.tcperrors"); |
| 398 | if (unlikely(!st)) { |
| 399 | st = rrdset_create_localhost( |
| 400 | "ipv4" |
| 401 | , "tcperrors" |
| 402 | , NULL |
| 403 | , "tcp" |
| 404 | , NULL |
| 405 | , "IPv4 TCP Errors" |
| 406 | , "packets/s" |
| 407 | , "macos.plugin" |
| 408 | , "sysctl" |
| 409 | , 2700 |
| 410 | , update_every |
| 411 | , RRDSET_TYPE_LINE |
| 412 | ); |
| 413 | |
| 414 | rrddim_add(st, "InErrs", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 415 | rrddim_add(st, "InCsumErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 416 | rrddim_add(st, "RetransSegs", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 417 | } |
| 418 | |
| 419 | rrddim_set(st, "InErrs", tcpstat.tcps_rcvbadoff + tcpstat.tcps_rcvshort); |
| 420 | rrddim_set(st, "InCsumErrors", tcpstat.tcps_rcvbadsum); |
| 421 | rrddim_set(st, "RetransSegs", tcpstat.tcps_sndrexmitpack); |
| 422 | rrdset_done(st); |
| 423 | } |
| 424 | |
| 425 | if (likely(do_tcp_handshake)) { |
| 426 | st = rrdset_find_active_localhost("ipv4.tcphandshake"); |
| 427 | if (unlikely(!st)) { |
| 428 | st = rrdset_create_localhost( |
| 429 | "ipv4" |
| 430 | , "tcphandshake" |
| 431 | , NULL |
| 432 | , "tcp" |
| 433 | , NULL |
| 434 | , "IPv4 TCP Handshake Issues" |
| 435 | , "events/s" |
| 436 | , "macos.plugin" |
| 437 | , "sysctl" |
| 438 | , 2900 |
| 439 | , update_every |
| 440 | , RRDSET_TYPE_LINE |
| 441 | ); |
| 442 | |
| 443 | rrddim_add(st, "EstabResets", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 444 | rrddim_add(st, "ActiveOpens", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 445 | rrddim_add(st, "PassiveOpens", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 446 | rrddim_add(st, "AttemptFails", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 447 | } |
| 448 | |
| 449 | rrddim_set(st, "EstabResets", tcpstat.tcps_drops); |
| 450 | rrddim_set(st, "ActiveOpens", tcpstat.tcps_connattempt); |
| 451 | rrddim_set(st, "PassiveOpens", tcpstat.tcps_accepts); |
| 452 | rrddim_set(st, "AttemptFails", tcpstat.tcps_conndrops); |
| 453 | rrdset_done(st); |
| 454 | } |
| 455 | |
| 456 | if (do_tcpext_connaborts == CONFIG_BOOLEAN_YES || do_tcpext_connaborts == CONFIG_BOOLEAN_AUTO) { |
| 457 | do_tcpext_connaborts = CONFIG_BOOLEAN_YES; |
| 458 | st = rrdset_find_active_localhost("ipv4.tcpconnaborts"); |
| 459 | if (unlikely(!st)) { |
| 460 | st = rrdset_create_localhost( |
| 461 | "ipv4" |
| 462 | , "tcpconnaborts" |
| 463 | , NULL |
| 464 | , "tcp" |
| 465 | , NULL |
| 466 | , "TCP Connection Aborts" |
| 467 | , "connections/s" |
| 468 | , "macos.plugin" |
| 469 | , "sysctl" |
| 470 | , 3010 |
| 471 | , update_every |
| 472 | , RRDSET_TYPE_LINE |
| 473 | ); |
| 474 | |
| 475 | rrddim_add(st, "TCPAbortOnData", "baddata", 1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 476 | rrddim_add(st, "TCPAbortOnClose", "userclosed", 1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 477 | rrddim_add(st, "TCPAbortOnMemory", "nomemory", 1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 478 | rrddim_add(st, "TCPAbortOnTimeout", "timeout", 1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 479 | } |
| 480 | |
| 481 | rrddim_set(st, "TCPAbortOnData", tcpstat.tcps_rcvpackafterwin); |
| 482 | rrddim_set(st, "TCPAbortOnClose", tcpstat.tcps_rcvafterclose); |
| 483 | rrddim_set(st, "TCPAbortOnMemory", tcpstat.tcps_rcvmemdrop); |
| 484 | rrddim_set(st, "TCPAbortOnTimeout", tcpstat.tcps_persistdrop); |
| 485 | rrdset_done(st); |
| 486 | } |
| 487 | |
| 488 | if (do_tcpext_ofo == CONFIG_BOOLEAN_YES || do_tcpext_ofo == CONFIG_BOOLEAN_AUTO) { |
| 489 | do_tcpext_ofo = CONFIG_BOOLEAN_YES; |
| 490 | st = rrdset_find_active_localhost("ipv4.tcpofo"); |
| 491 | if (unlikely(!st)) { |
| 492 | st = rrdset_create_localhost( |
| 493 | "ipv4" |
| 494 | , "tcpofo" |
| 495 | , NULL |
| 496 | , "tcp" |
| 497 | , NULL |
| 498 | , "TCP Out-Of-Order Queue" |
| 499 | , "packets/s" |
| 500 | , "macos.plugin" |
| 501 | , "sysctl" |
| 502 | , 3050 |
| 503 | , update_every |
| 504 | , RRDSET_TYPE_LINE |
| 505 | ); |
| 506 | |
| 507 | rrddim_add(st, "TCPOFOQueue", "inqueue", 1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 508 | } |
| 509 | |
| 510 | rrddim_set(st, "TCPOFOQueue", tcpstat.tcps_rcvoopack); |
| 511 | rrdset_done(st); |
| 512 | } |
| 513 | |
| 514 | if (do_tcpext_syscookies == CONFIG_BOOLEAN_YES || do_tcpext_syscookies == CONFIG_BOOLEAN_AUTO) { |
| 515 | do_tcpext_syscookies = CONFIG_BOOLEAN_YES; |
| 516 | |
| 517 | st = rrdset_find_active_localhost("ipv4.tcpsyncookies"); |
| 518 | if (unlikely(!st)) { |
| 519 | st = rrdset_create_localhost( |
| 520 | "ipv4" |
| 521 | , "tcpsyncookies" |
| 522 | , NULL |
| 523 | , "tcp" |
| 524 | , NULL |
| 525 | , "TCP SYN Cookies" |
| 526 | , "packets/s" |
| 527 | , "macos.plugin" |
| 528 | , "sysctl" |
| 529 | , 3100 |
| 530 | , update_every |
| 531 | , RRDSET_TYPE_LINE |
| 532 | ); |
| 533 | |
| 534 | rrddim_add(st, "SyncookiesRecv", "received", 1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 535 | rrddim_add(st, "SyncookiesSent", "sent", -1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 536 | #if __MAC_OS_X_VERSION_MAX_ALLOWED < 160000 |
| 537 | rrddim_add(st, "SyncookiesFailed", "failed", -1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 538 | #endif |
| 539 | } |
| 540 | |
| 541 | rrddim_set(st, "SyncookiesRecv", tcpstat.tcps_sc_recvcookie); |
| 542 | rrddim_set(st, "SyncookiesSent", tcpstat.tcps_sc_sendcookie); |
| 543 | #if __MAC_OS_X_VERSION_MAX_ALLOWED < 160000 |
| 544 | rrddim_set(st, "SyncookiesFailed", tcpstat.tcps_sc_zonefail); |
| 545 | #endif |
| 546 | rrdset_done(st); |
| 547 | } |
| 548 | |
| 549 | #if (defined __MAC_OS_X_VERSION_MIN_REQUIRED && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101100) |
| 550 | if (do_ecn == CONFIG_BOOLEAN_YES || do_ecn == CONFIG_BOOLEAN_AUTO) { |
| 551 | do_ecn = CONFIG_BOOLEAN_YES; |
| 552 | st = rrdset_find_active_localhost("ipv4.ecnpkts"); |
| 553 | if (unlikely(!st)) { |
| 554 | st = rrdset_create_localhost( |
| 555 | "ipv4" |
| 556 | , "ecnpkts" |
| 557 | , NULL |
| 558 | , "ecn" |
| 559 | , NULL |
| 560 | , "IPv4 ECN Statistics" |
| 561 | , "packets/s" |
| 562 | , "macos.plugin" |
| 563 | , "sysctl" |
| 564 | , 8700 |
| 565 | , update_every |
| 566 | , RRDSET_TYPE_LINE |
| 567 | ); |
| 568 | |
| 569 | rrddim_add(st, "InCEPkts", "CEP", 1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 570 | rrddim_add(st, "InNoECTPkts", "NoECTP", -1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 571 | } |
| 572 | |
| 573 | rrddim_set(st, "InCEPkts", tcpstat.tcps_ecn_recv_ce); |
| 574 | rrddim_set(st, "InNoECTPkts", tcpstat.tcps_ecn_not_supported); |
| 575 | rrdset_done(st); |
| 576 | } |
| 577 | #endif |
| 578 | |
| 579 | } |
| 580 | } |
| 581 | |
| 582 | // see http://net-snmp.sourceforge.net/docs/mibs/udp.html |
| 583 | if (likely(do_udp_packets || do_udp_errors)) { |
| 584 | if (unlikely(GETSYSCTL_BY_NAME("net.inet.udp.stats", udpstat))) { |
| 585 | do_udp_packets = 0; |
| 586 | collector_error("DISABLED: ipv4.udppackets"); |
| 587 | do_udp_errors = 0; |
| 588 | collector_error("DISABLED: ipv4.udperrors"); |
| 589 | } else { |
| 590 | if (likely(do_udp_packets)) { |
| 591 | st = rrdset_find_active_localhost("ipv4.udppackets"); |
| 592 | if (unlikely(!st)) { |
| 593 | st = rrdset_create_localhost( |
| 594 | "ipv4" |
| 595 | , "udppackets" |
| 596 | , NULL |
| 597 | , "udp" |
| 598 | , NULL |
| 599 | , "IPv4 UDP Packets" |
| 600 | , "packets/s" |
| 601 | , "macos.plugin" |
| 602 | , "sysctl" |
| 603 | , 2601 |
| 604 | , update_every |
| 605 | , RRDSET_TYPE_LINE |
| 606 | ); |
| 607 | |
| 608 | rrddim_add(st, "InDatagrams", "received", 1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 609 | rrddim_add(st, "OutDatagrams", "sent", -1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 610 | } |
| 611 | |
| 612 | rrddim_set(st, "InDatagrams", udpstat.udps_ipackets); |
| 613 | rrddim_set(st, "OutDatagrams", udpstat.udps_opackets); |
| 614 | rrdset_done(st); |
| 615 | } |
| 616 | |
| 617 | if (likely(do_udp_errors)) { |
| 618 | st = rrdset_find_active_localhost("ipv4.udperrors"); |
| 619 | if (unlikely(!st)) { |
| 620 | st = rrdset_create_localhost( |
| 621 | "ipv4" |
| 622 | , "udperrors" |
| 623 | , NULL |
| 624 | , "udp" |
| 625 | , NULL |
| 626 | , "IPv4 UDP Errors" |
| 627 | , "events/s" |
| 628 | , "macos.plugin" |
| 629 | , "sysctl" |
| 630 | , 2701 |
| 631 | , update_every |
| 632 | , RRDSET_TYPE_LINE |
| 633 | ); |
| 634 | |
| 635 | rrddim_add(st, "RcvbufErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 636 | rrddim_add(st, "InErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 637 | rrddim_add(st, "NoPorts", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 638 | rrddim_add(st, "InCsumErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 639 | #if (defined __MAC_OS_X_VERSION_MIN_REQUIRED && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090) |
| 640 | rrddim_add(st, "IgnoredMulti", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 641 | #endif |
| 642 | } |
| 643 | |
| 644 | rrddim_set(st, "InErrors", udpstat.udps_hdrops + udpstat.udps_badlen); |
| 645 | rrddim_set(st, "NoPorts", udpstat.udps_noport); |
| 646 | rrddim_set(st, "RcvbufErrors", udpstat.udps_fullsock); |
| 647 | #if (defined __MAC_OS_X_VERSION_MIN_REQUIRED && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090) |
| 648 | rrddim_set(st, "InCsumErrors", udpstat.udps_badsum + udpstat.udps_nosum); |
| 649 | rrddim_set(st, "IgnoredMulti", udpstat.udps_filtermcast); |
| 650 | #else |
| 651 | rrddim_set(st, "InCsumErrors", udpstat.udps_badsum); |
| 652 | #endif |
| 653 | rrdset_done(st); |
| 654 | } |
| 655 | } |
| 656 | } |
| 657 | |
| 658 | if (likely(do_icmp_packets || do_icmpmsg)) { |
| 659 | if (unlikely(GETSYSCTL_BY_NAME("net.inet.icmp.stats", icmpstat))) { |
| 660 | do_icmp_packets = 0; |
| 661 | collector_error("DISABLED: ipv4.icmp"); |
| 662 | collector_error("DISABLED: ipv4.icmp_errors"); |
| 663 | do_icmpmsg = 0; |
| 664 | collector_error("DISABLED: ipv4.icmpmsg"); |
| 665 | } else { |
| 666 | for (i = 0; i <= ICMP_MAXTYPE; i++) { |
| 667 | icmp_total.msgs_in += icmpstat.icps_inhist[i]; |
| 668 | icmp_total.msgs_out += icmpstat.icps_outhist[i]; |
| 669 | } |
| 670 | icmp_total.msgs_in += icmpstat.icps_badcode + icmpstat.icps_badlen + icmpstat.icps_checksum + icmpstat.icps_tooshort; |
| 671 | |
| 672 | // -------------------------------------------------------------------- |
| 673 | |
| 674 | if (likely(do_icmp_packets)) { |
| 675 | st = rrdset_find_active_localhost("ipv4.icmp"); |
| 676 | if (unlikely(!st)) { |
| 677 | st = rrdset_create_localhost( |
| 678 | "ipv4" |
| 679 | , "icmp" |
| 680 | , NULL |
| 681 | , "icmp" |
| 682 | , NULL |
| 683 | , "IPv4 ICMP Packets" |
| 684 | , "packets/s" |
| 685 | , "macos.plugin" |
| 686 | , "sysctl" |
| 687 | , 2602 |
| 688 | , update_every |
| 689 | , RRDSET_TYPE_LINE |
| 690 | ); |
| 691 | |
| 692 | rrddim_add(st, "InMsgs", "received", 1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 693 | rrddim_add(st, "OutMsgs", "sent", -1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 694 | } |
| 695 | |
| 696 | rrddim_set(st, "InMsgs", icmp_total.msgs_in); |
| 697 | rrddim_set(st, "OutMsgs", icmp_total.msgs_out); |
| 698 | rrdset_done(st); |
| 699 | |
| 700 | st = rrdset_find_active_localhost("ipv4.icmp_errors"); |
| 701 | if (unlikely(!st)) { |
| 702 | st = rrdset_create_localhost( |
| 703 | "ipv4" |
| 704 | , "icmp_errors" |
| 705 | , NULL |
| 706 | , "icmp" |
| 707 | , NULL |
| 708 | , "IPv4 ICMP Errors" |
| 709 | , "packets/s" |
| 710 | , "macos.plugin" |
| 711 | , "sysctl" |
| 712 | , 2603 |
| 713 | , update_every |
| 714 | , RRDSET_TYPE_LINE |
| 715 | ); |
| 716 | |
| 717 | rrddim_add(st, "InErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 718 | rrddim_add(st, "OutErrors", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 719 | rrddim_add(st, "InCsumErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 720 | } |
| 721 | |
| 722 | rrddim_set(st, "InErrors", icmpstat.icps_badcode + icmpstat.icps_badlen + icmpstat.icps_checksum + icmpstat.icps_tooshort); |
| 723 | rrddim_set(st, "OutErrors", icmpstat.icps_error); |
| 724 | rrddim_set(st, "InCsumErrors", icmpstat.icps_checksum); |
| 725 | rrdset_done(st); |
| 726 | } |
| 727 | |
| 728 | if (likely(do_icmpmsg)) { |
| 729 | st = rrdset_find_active_localhost("ipv4.icmpmsg"); |
| 730 | if (unlikely(!st)) { |
| 731 | st = rrdset_create_localhost( |
| 732 | "ipv4" |
| 733 | , "icmpmsg" |
| 734 | , NULL |
| 735 | , "icmp" |
| 736 | , NULL |
| 737 | , "IPv4 ICMP Messages" |
| 738 | , "packets/s" |
| 739 | , "macos.plugin" |
| 740 | , "sysctl" |
| 741 | , 2604 |
| 742 | , update_every |
| 743 | , RRDSET_TYPE_LINE |
| 744 | ); |
| 745 | |
| 746 | rrddim_add(st, "InEchoReps", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 747 | rrddim_add(st, "OutEchoReps", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 748 | rrddim_add(st, "InEchos", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 749 | rrddim_add(st, "OutEchos", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 750 | } |
| 751 | |
| 752 | rrddim_set(st, "InEchoReps", icmpstat.icps_inhist[ICMP_ECHOREPLY]); |
| 753 | rrddim_set(st, "OutEchoReps", icmpstat.icps_outhist[ICMP_ECHOREPLY]); |
| 754 | rrddim_set(st, "InEchos", icmpstat.icps_inhist[ICMP_ECHO]); |
| 755 | rrddim_set(st, "OutEchos", icmpstat.icps_outhist[ICMP_ECHO]); |
| 756 | rrdset_done(st); |
| 757 | } |
| 758 | } |
| 759 | } |
| 760 | |
| 761 | // see also http://net-snmp.sourceforge.net/docs/mibs/ip.html |
| 762 | if (likely(do_ip_packets || do_ip_fragsout || do_ip_fragsin || do_ip_errors)) { |
| 763 | if (unlikely(GETSYSCTL_BY_NAME("net.inet.ip.stats", ipstat))) { |
| 764 | do_ip_packets = 0; |
| 765 | collector_error("DISABLED: ipv4.packets"); |
| 766 | do_ip_fragsout = 0; |
| 767 | collector_error("DISABLED: ipv4.fragsout"); |
| 768 | do_ip_fragsin = 0; |
| 769 | collector_error("DISABLED: ipv4.fragsin"); |
| 770 | do_ip_errors = 0; |
| 771 | collector_error("DISABLED: ipv4.errors"); |
| 772 | } else { |
| 773 | if (likely(do_ip_packets)) { |
| 774 | st = rrdset_find_active_localhost("ipv4.packets"); |
| 775 | if (unlikely(!st)) { |
| 776 | st = rrdset_create_localhost( |
| 777 | "ipv4" |
| 778 | , "packets" |
| 779 | , NULL |
| 780 | , "packets" |
| 781 | , NULL |
| 782 | , "IPv4 Packets" |
| 783 | , "packets/s" |
| 784 | , "macos.plugin" |
| 785 | , "sysctl" |
| 786 | , 3000 |
| 787 | , update_every |
| 788 | , RRDSET_TYPE_LINE |
| 789 | ); |
| 790 | |
| 791 | rrddim_add(st, "InReceives", "received", 1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 792 | rrddim_add(st, "OutRequests", "sent", -1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 793 | rrddim_add(st, "ForwDatagrams", "forwarded", 1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 794 | rrddim_add(st, "InDelivers", "delivered", 1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 795 | } |
| 796 | |
| 797 | rrddim_set(st, "OutRequests", ipstat.ips_localout); |
| 798 | rrddim_set(st, "InReceives", ipstat.ips_total); |
| 799 | rrddim_set(st, "ForwDatagrams", ipstat.ips_forward); |
| 800 | rrddim_set(st, "InDelivers", ipstat.ips_delivered); |
| 801 | rrdset_done(st); |
| 802 | } |
| 803 | |
| 804 | if (likely(do_ip_fragsout)) { |
| 805 | st = rrdset_find_active_localhost("ipv4.fragsout"); |
| 806 | if (unlikely(!st)) { |
| 807 | st = rrdset_create_localhost( |
| 808 | "ipv4" |
| 809 | , "fragsout" |
| 810 | , NULL |
| 811 | , "fragments" |
| 812 | , NULL |
| 813 | , "IPv4 Fragments Sent" |
| 814 | , "packets/s" |
| 815 | , "macos.plugin" |
| 816 | , "sysctl" |
| 817 | , 3010 |
| 818 | , update_every |
| 819 | , RRDSET_TYPE_LINE |
| 820 | ); |
| 821 | |
| 822 | rrddim_add(st, "FragOKs", "ok", 1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 823 | rrddim_add(st, "FragFails", "failed", -1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 824 | rrddim_add(st, "FragCreates", "created", 1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 825 | } |
| 826 | |
| 827 | rrddim_set(st, "FragOKs", ipstat.ips_fragmented); |
| 828 | rrddim_set(st, "FragFails", ipstat.ips_cantfrag); |
| 829 | rrddim_set(st, "FragCreates", ipstat.ips_ofragments); |
| 830 | rrdset_done(st); |
| 831 | } |
| 832 | |
| 833 | if (likely(do_ip_fragsin)) { |
| 834 | st = rrdset_find_active_localhost("ipv4.fragsin"); |
| 835 | if (unlikely(!st)) { |
| 836 | st = rrdset_create_localhost( |
| 837 | "ipv4" |
| 838 | , "fragsin" |
| 839 | , NULL |
| 840 | , "fragments" |
| 841 | , NULL |
| 842 | , "IPv4 Fragments Reassembly" |
| 843 | , "packets/s" |
| 844 | , "macos.plugin" |
| 845 | , "sysctl" |
| 846 | , 3011 |
| 847 | , update_every |
| 848 | , RRDSET_TYPE_LINE |
| 849 | ); |
| 850 | |
| 851 | rrddim_add(st, "ReasmOKs", "ok", 1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 852 | rrddim_add(st, "ReasmFails", "failed", -1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 853 | rrddim_add(st, "ReasmReqds", "all", 1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 854 | } |
| 855 | |
| 856 | rrddim_set(st, "ReasmOKs", ipstat.ips_fragments); |
| 857 | rrddim_set(st, "ReasmFails", ipstat.ips_fragdropped); |
| 858 | rrddim_set(st, "ReasmReqds", ipstat.ips_reassembled); |
| 859 | rrdset_done(st); |
| 860 | } |
| 861 | |
| 862 | if (likely(do_ip_errors)) { |
| 863 | st = rrdset_find_active_localhost("ipv4.errors"); |
| 864 | if (unlikely(!st)) { |
| 865 | st = rrdset_create_localhost( |
| 866 | "ipv4" |
| 867 | , "errors" |
| 868 | , NULL |
| 869 | , "errors" |
| 870 | , NULL |
| 871 | , "IPv4 Errors" |
| 872 | , "packets/s" |
| 873 | , "macos.plugin" |
| 874 | , "sysctl" |
| 875 | , 3002 |
| 876 | , update_every |
| 877 | , RRDSET_TYPE_LINE |
| 878 | ); |
| 879 | |
| 880 | rrddim_add(st, "InDiscards", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 881 | rrddim_add(st, "OutDiscards", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 882 | |
| 883 | rrddim_add(st, "InHdrErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 884 | rrddim_add(st, "OutNoRoutes", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 885 | |
| 886 | rrddim_add(st, "InAddrErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 887 | rrddim_add(st, "InUnknownProtos", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 888 | } |
| 889 | |
| 890 | rrddim_set(st, "InDiscards", ipstat.ips_badsum + ipstat.ips_tooshort + ipstat.ips_toosmall + ipstat.ips_toolong); |
| 891 | rrddim_set(st, "OutDiscards", ipstat.ips_odropped); |
| 892 | rrddim_set(st, "InHdrErrors", ipstat.ips_badhlen + ipstat.ips_badlen + ipstat.ips_badoptions + ipstat.ips_badvers); |
| 893 | rrddim_set(st, "InAddrErrors", ipstat.ips_badaddr); |
| 894 | rrddim_set(st, "InUnknownProtos", ipstat.ips_noproto); |
| 895 | rrddim_set(st, "OutNoRoutes", ipstat.ips_noroute); |
| 896 | rrdset_done(st); |
| 897 | } |
| 898 | } |
| 899 | } |
| 900 | |
| 901 | if (likely(do_ip6_packets || do_ip6_fragsout || do_ip6_fragsin || do_ip6_errors)) { |
| 902 | if (unlikely(GETSYSCTL_BY_NAME("net.inet6.ip6.stats", ip6stat))) { |
| 903 | do_ip6_packets = 0; |
| 904 | collector_error("DISABLED: ipv6.packets"); |
| 905 | do_ip6_fragsout = 0; |
| 906 | collector_error("DISABLED: ipv6.fragsout"); |
| 907 | do_ip6_fragsin = 0; |
| 908 | collector_error("DISABLED: ipv6.fragsin"); |
| 909 | do_ip6_errors = 0; |
| 910 | collector_error("DISABLED: ipv6.errors"); |
| 911 | } else { |
| 912 | if (do_ip6_packets == CONFIG_BOOLEAN_YES || do_ip6_packets == CONFIG_BOOLEAN_AUTO) { |
| 913 | do_ip6_packets = CONFIG_BOOLEAN_YES; |
| 914 | st = rrdset_find_active_localhost("ipv6.packets"); |
| 915 | if (unlikely(!st)) { |
| 916 | st = rrdset_create_localhost( |
| 917 | "ipv6" |
| 918 | , "packets" |
| 919 | , NULL |
| 920 | , "packets" |
| 921 | , NULL |
| 922 | , "IPv6 Packets" |
| 923 | , "packets/s" |
| 924 | , "macos.plugin" |
| 925 | , "sysctl" |
| 926 | , 3000 |
| 927 | , update_every |
| 928 | , RRDSET_TYPE_LINE |
| 929 | ); |
| 930 | |
| 931 | rrddim_add(st, "received", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 932 | rrddim_add(st, "sent", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 933 | rrddim_add(st, "forwarded", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 934 | rrddim_add(st, "delivers", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 935 | } |
| 936 | |
| 937 | rrddim_set(st, "sent", ip6stat.ip6s_localout); |
| 938 | rrddim_set(st, "received", ip6stat.ip6s_total); |
| 939 | rrddim_set(st, "forwarded", ip6stat.ip6s_forward); |
| 940 | rrddim_set(st, "delivers", ip6stat.ip6s_delivered); |
| 941 | rrdset_done(st); |
| 942 | } |
| 943 | |
| 944 | if (do_ip6_fragsout == CONFIG_BOOLEAN_YES || do_ip6_fragsout == CONFIG_BOOLEAN_AUTO) { |
| 945 | do_ip6_fragsout = CONFIG_BOOLEAN_YES; |
| 946 | st = rrdset_find_active_localhost("ipv6.fragsout"); |
| 947 | if (unlikely(!st)) { |
| 948 | st = rrdset_create_localhost( |
| 949 | "ipv6" |
| 950 | , "fragsout" |
| 951 | , NULL |
| 952 | , "fragments" |
| 953 | , NULL |
| 954 | , "IPv6 Fragments Sent" |
| 955 | , "packets/s" |
| 956 | , "macos.plugin" |
| 957 | , "sysctl" |
| 958 | , 3010 |
| 959 | , update_every |
| 960 | , RRDSET_TYPE_LINE |
| 961 | ); |
| 962 | |
| 963 | rrddim_add(st, "ok", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 964 | rrddim_add(st, "failed", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 965 | rrddim_add(st, "all", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 966 | } |
| 967 | |
| 968 | rrddim_set(st, "ok", ip6stat.ip6s_fragmented); |
| 969 | rrddim_set(st, "failed", ip6stat.ip6s_cantfrag); |
| 970 | rrddim_set(st, "all", ip6stat.ip6s_ofragments); |
| 971 | rrdset_done(st); |
| 972 | } |
| 973 | |
| 974 | if (do_ip6_fragsin == CONFIG_BOOLEAN_YES || do_ip6_fragsin == CONFIG_BOOLEAN_AUTO) { |
| 975 | do_ip6_fragsin = CONFIG_BOOLEAN_YES; |
| 976 | st = rrdset_find_active_localhost("ipv6.fragsin"); |
| 977 | if (unlikely(!st)) { |
| 978 | st = rrdset_create_localhost( |
| 979 | "ipv6" |
| 980 | , "fragsin" |
| 981 | , NULL |
| 982 | , "fragments" |
| 983 | , NULL |
| 984 | , "IPv6 Fragments Reassembly" |
| 985 | , "packets/s" |
| 986 | , "macos.plugin" |
| 987 | , "sysctl" |
| 988 | , 3011 |
| 989 | , update_every |
| 990 | , RRDSET_TYPE_LINE |
| 991 | ); |
| 992 | |
| 993 | rrddim_add(st, "ok", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 994 | rrddim_add(st, "failed", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 995 | rrddim_add(st, "timeout", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 996 | rrddim_add(st, "all", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 997 | } |
| 998 | |
| 999 | rrddim_set(st, "ok", ip6stat.ip6s_reassembled); |
| 1000 | rrddim_set(st, "failed", ip6stat.ip6s_fragdropped); |
| 1001 | rrddim_set(st, "timeout", ip6stat.ip6s_fragtimeout); |
| 1002 | rrddim_set(st, "all", ip6stat.ip6s_fragments); |
| 1003 | rrdset_done(st); |
| 1004 | } |
| 1005 | |
| 1006 | if (do_ip6_errors == CONFIG_BOOLEAN_YES || do_ip6_errors == CONFIG_BOOLEAN_AUTO) { |
| 1007 | do_ip6_errors = CONFIG_BOOLEAN_YES; |
| 1008 | st = rrdset_find_active_localhost("ipv6.errors"); |
| 1009 | if (unlikely(!st)) { |
| 1010 | st = rrdset_create_localhost( |
| 1011 | "ipv6" |
| 1012 | , "errors" |
| 1013 | , NULL |
| 1014 | , "errors" |
| 1015 | , NULL |
| 1016 | , "IPv6 Errors" |
| 1017 | , "packets/s" |
| 1018 | , "macos.plugin" |
| 1019 | , "sysctl" |
| 1020 | , 3002 |
| 1021 | , update_every |
| 1022 | , RRDSET_TYPE_LINE |
| 1023 | ); |
| 1024 | |
| 1025 | rrddim_add(st, "InDiscards", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 1026 | rrddim_add(st, "OutDiscards", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 1027 | |
| 1028 | rrddim_add(st, "InHdrErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 1029 | rrddim_add(st, "InAddrErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 1030 | rrddim_add(st, "InTruncatedPkts", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 1031 | rrddim_add(st, "InNoRoutes", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 1032 | |
| 1033 | rrddim_add(st, "OutNoRoutes", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 1034 | } |
| 1035 | |
| 1036 | rrddim_set(st, "InDiscards", ip6stat.ip6s_toosmall); |
| 1037 | rrddim_set(st, "OutDiscards", ip6stat.ip6s_odropped); |
| 1038 | |
| 1039 | rrddim_set(st, "InHdrErrors", |
| 1040 | ip6stat.ip6s_badoptions + ip6stat.ip6s_badvers + ip6stat.ip6s_exthdrtoolong); |
| 1041 | rrddim_set(st, "InAddrErrors", ip6stat.ip6s_sources_none); |
| 1042 | rrddim_set(st, "InTruncatedPkts", ip6stat.ip6s_tooshort); |
| 1043 | rrddim_set(st, "InNoRoutes", ip6stat.ip6s_cantforward); |
| 1044 | |
| 1045 | rrddim_set(st, "OutNoRoutes", ip6stat.ip6s_noroute); |
| 1046 | rrdset_done(st); |
| 1047 | } |
| 1048 | } |
| 1049 | } |
| 1050 | |
| 1051 | if (likely(do_icmp6 || do_icmp6_redir || do_icmp6_errors || do_icmp6_echos || do_icmp6_router || do_icmp6_neighbor || do_icmp6_types)) { |
| 1052 | if (unlikely(GETSYSCTL_BY_NAME("net.inet6.icmp6.stats", icmp6stat))) { |
| 1053 | do_icmp6 = 0; |
| 1054 | collector_error("DISABLED: ipv6.icmp"); |
| 1055 | } else { |
| 1056 | for (i = 0; i <= ICMP6_MAXTYPE; i++) { |
| 1057 | icmp6_total.msgs_in += icmp6stat.icp6s_inhist[i]; |
| 1058 | icmp6_total.msgs_out += icmp6stat.icp6s_outhist[i]; |
| 1059 | } |
| 1060 | icmp6_total.msgs_in += icmp6stat.icp6s_badcode + icmp6stat.icp6s_badlen + icmp6stat.icp6s_checksum + icmp6stat.icp6s_tooshort; |
| 1061 | |
| 1062 | if (do_icmp6 == CONFIG_BOOLEAN_YES || do_icmp6 == CONFIG_BOOLEAN_AUTO) { |
| 1063 | do_icmp6 = CONFIG_BOOLEAN_YES; |
| 1064 | st = rrdset_find_active_localhost("ipv6.icmp"); |
| 1065 | if (unlikely(!st)) { |
| 1066 | st = rrdset_create_localhost( |
| 1067 | "ipv6" |
| 1068 | , "icmp" |
| 1069 | , NULL |
| 1070 | , "icmp" |
| 1071 | , NULL |
| 1072 | , "IPv6 ICMP Messages" |
| 1073 | , "messages/s" |
| 1074 | , "macos.plugin" |
| 1075 | , "sysctl" |
| 1076 | , 10000 |
| 1077 | , update_every |
| 1078 | , RRDSET_TYPE_LINE |
| 1079 | ); |
| 1080 | |
| 1081 | rrddim_add(st, "received", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 1082 | rrddim_add(st, "sent", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 1083 | } |
| 1084 | |
| 1085 | rrddim_set(st, "sent", icmp6_total.msgs_in); |
| 1086 | rrddim_set(st, "received", icmp6_total.msgs_out); |
| 1087 | rrdset_done(st); |
| 1088 | } |
| 1089 | |
| 1090 | if (do_icmp6_redir == CONFIG_BOOLEAN_YES || do_icmp6_redir == CONFIG_BOOLEAN_AUTO) { |
| 1091 | do_icmp6_redir = CONFIG_BOOLEAN_YES; |
| 1092 | st = rrdset_find_active_localhost("ipv6.icmpredir"); |
| 1093 | if (unlikely(!st)) { |
| 1094 | st = rrdset_create_localhost( |
| 1095 | "ipv6" |
| 1096 | , "icmpredir" |
| 1097 | , NULL |
| 1098 | , "icmp" |
| 1099 | , NULL |
| 1100 | , "IPv6 ICMP Redirects" |
| 1101 | , "redirects/s" |
| 1102 | , "macos.plugin" |
| 1103 | , "sysctl" |
| 1104 | , 10050 |
| 1105 | , update_every |
| 1106 | , RRDSET_TYPE_LINE |
| 1107 | ); |
| 1108 | |
| 1109 | rrddim_add(st, "received", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 1110 | rrddim_add(st, "sent", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 1111 | } |
| 1112 | |
| 1113 | rrddim_set(st, "sent", icmp6stat.icp6s_inhist[ND_REDIRECT]); |
| 1114 | rrddim_set(st, "received", icmp6stat.icp6s_outhist[ND_REDIRECT]); |
| 1115 | rrdset_done(st); |
| 1116 | } |
| 1117 | |
| 1118 | if (do_icmp6_errors == CONFIG_BOOLEAN_YES || do_icmp6_errors == CONFIG_BOOLEAN_AUTO) { |
| 1119 | do_icmp6_errors = CONFIG_BOOLEAN_YES; |
| 1120 | st = rrdset_find_active_localhost("ipv6.icmperrors"); |
| 1121 | if (unlikely(!st)) { |
| 1122 | st = rrdset_create_localhost( |
| 1123 | "ipv6" |
| 1124 | , "icmperrors" |
| 1125 | , NULL |
| 1126 | , "icmp" |
| 1127 | , NULL |
| 1128 | , "IPv6 ICMP Errors" |
| 1129 | , "errors/s" |
| 1130 | , "macos.plugin" |
| 1131 | , "sysctl" |
| 1132 | , 10100 |
| 1133 | , update_every |
| 1134 | , RRDSET_TYPE_LINE |
| 1135 | ); |
| 1136 | |
| 1137 | rrddim_add(st, "InErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 1138 | rrddim_add(st, "OutErrors", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 1139 | |
| 1140 | rrddim_add(st, "InCsumErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 1141 | rrddim_add(st, "InDestUnreachs", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 1142 | rrddim_add(st, "InPktTooBigs", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 1143 | rrddim_add(st, "InTimeExcds", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 1144 | rrddim_add(st, "InParmProblems", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 1145 | rrddim_add(st, "OutDestUnreachs", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 1146 | rrddim_add(st, "OutTimeExcds", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 1147 | rrddim_add(st, "OutParmProblems", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 1148 | } |
| 1149 | |
| 1150 | rrddim_set(st, "InErrors", icmp6stat.icp6s_badcode + icmp6stat.icp6s_badlen + icmp6stat.icp6s_checksum + icmp6stat.icp6s_tooshort); |
| 1151 | rrddim_set(st, "OutErrors", icmp6stat.icp6s_error); |
| 1152 | rrddim_set(st, "InCsumErrors", icmp6stat.icp6s_checksum); |
| 1153 | rrddim_set(st, "InDestUnreachs", icmp6stat.icp6s_inhist[ICMP6_DST_UNREACH]); |
| 1154 | rrddim_set(st, "InPktTooBigs", icmp6stat.icp6s_badlen); |
| 1155 | rrddim_set(st, "InTimeExcds", icmp6stat.icp6s_inhist[ICMP6_TIME_EXCEEDED]); |
| 1156 | rrddim_set(st, "InParmProblems", icmp6stat.icp6s_inhist[ICMP6_PARAM_PROB]); |
| 1157 | rrddim_set(st, "OutDestUnreachs", icmp6stat.icp6s_outhist[ICMP6_DST_UNREACH]); |
| 1158 | rrddim_set(st, "OutTimeExcds", icmp6stat.icp6s_outhist[ICMP6_TIME_EXCEEDED]); |
| 1159 | rrddim_set(st, "OutParmProblems", icmp6stat.icp6s_outhist[ICMP6_PARAM_PROB]); |
| 1160 | rrdset_done(st); |
| 1161 | } |
| 1162 | |
| 1163 | if (do_icmp6_echos == CONFIG_BOOLEAN_YES || do_icmp6_echos == CONFIG_BOOLEAN_AUTO) { |
| 1164 | do_icmp6_echos = CONFIG_BOOLEAN_YES; |
| 1165 | st = rrdset_find_active_localhost("ipv6.icmpechos"); |
| 1166 | if (unlikely(!st)) { |
| 1167 | st = rrdset_create_localhost( |
| 1168 | "ipv6" |
| 1169 | , "icmpechos" |
| 1170 | , NULL |
| 1171 | , "icmp" |
| 1172 | , NULL |
| 1173 | , "IPv6 ICMP Echo" |
| 1174 | , "messages/s" |
| 1175 | , "macos.plugin" |
| 1176 | , "sysctl" |
| 1177 | , 10200 |
| 1178 | , update_every |
| 1179 | , RRDSET_TYPE_LINE |
| 1180 | ); |
| 1181 | |
| 1182 | rrddim_add(st, "InEchos", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 1183 | rrddim_add(st, "OutEchos", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 1184 | rrddim_add(st, "InEchoReplies", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 1185 | rrddim_add(st, "OutEchoReplies", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 1186 | } |
| 1187 | |
| 1188 | rrddim_set(st, "InEchos", icmp6stat.icp6s_inhist[ICMP6_ECHO_REQUEST]); |
| 1189 | rrddim_set(st, "OutEchos", icmp6stat.icp6s_outhist[ICMP6_ECHO_REQUEST]); |
| 1190 | rrddim_set(st, "InEchoReplies", icmp6stat.icp6s_inhist[ICMP6_ECHO_REPLY]); |
| 1191 | rrddim_set(st, "OutEchoReplies", icmp6stat.icp6s_outhist[ICMP6_ECHO_REPLY]); |
| 1192 | rrdset_done(st); |
| 1193 | } |
| 1194 | |
| 1195 | if (do_icmp6_router == CONFIG_BOOLEAN_YES || do_icmp6_router == CONFIG_BOOLEAN_AUTO) { |
| 1196 | do_icmp6_router = CONFIG_BOOLEAN_YES; |
| 1197 | st = rrdset_find_active_localhost("ipv6.icmprouter"); |
| 1198 | if (unlikely(!st)) { |
| 1199 | st = rrdset_create_localhost( |
| 1200 | "ipv6" |
| 1201 | , "icmprouter" |
| 1202 | , NULL |
| 1203 | , "icmp" |
| 1204 | , NULL |
| 1205 | , "IPv6 Router Messages" |
| 1206 | , "messages/s" |
| 1207 | , "macos.plugin" |
| 1208 | , "sysctl" |
| 1209 | , 10400 |
| 1210 | , update_every |
| 1211 | , RRDSET_TYPE_LINE |
| 1212 | ); |
| 1213 | |
| 1214 | rrddim_add(st, "InSolicits", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 1215 | rrddim_add(st, "OutSolicits", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 1216 | rrddim_add(st, "InAdvertisements", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 1217 | rrddim_add(st, "OutAdvertisements", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 1218 | } |
| 1219 | |
| 1220 | rrddim_set(st, "InSolicits", icmp6stat.icp6s_inhist[ND_ROUTER_SOLICIT]); |
| 1221 | rrddim_set(st, "OutSolicits", icmp6stat.icp6s_outhist[ND_ROUTER_SOLICIT]); |
| 1222 | rrddim_set(st, "InAdvertisements", icmp6stat.icp6s_inhist[ND_ROUTER_ADVERT]); |
| 1223 | rrddim_set(st, "OutAdvertisements", icmp6stat.icp6s_outhist[ND_ROUTER_ADVERT]); |
| 1224 | rrdset_done(st); |
| 1225 | } |
| 1226 | |
| 1227 | if (do_icmp6_neighbor == CONFIG_BOOLEAN_YES || do_icmp6_neighbor == CONFIG_BOOLEAN_AUTO) { |
| 1228 | do_icmp6_neighbor = CONFIG_BOOLEAN_YES; |
| 1229 | st = rrdset_find_active_localhost("ipv6.icmpneighbor"); |
| 1230 | if (unlikely(!st)) { |
| 1231 | st = rrdset_create_localhost( |
| 1232 | "ipv6" |
| 1233 | , "icmpneighbor" |
| 1234 | , NULL |
| 1235 | , "icmp" |
| 1236 | , NULL |
| 1237 | , "IPv6 Neighbor Messages" |
| 1238 | , "messages/s" |
| 1239 | , "macos.plugin" |
| 1240 | , "sysctl" |
| 1241 | , 10500 |
| 1242 | , update_every |
| 1243 | , RRDSET_TYPE_LINE |
| 1244 | ); |
| 1245 | |
| 1246 | rrddim_add(st, "InSolicits", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 1247 | rrddim_add(st, "OutSolicits", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 1248 | rrddim_add(st, "InAdvertisements", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 1249 | rrddim_add(st, "OutAdvertisements", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 1250 | } |
| 1251 | |
| 1252 | rrddim_set(st, "InSolicits", icmp6stat.icp6s_inhist[ND_NEIGHBOR_SOLICIT]); |
| 1253 | rrddim_set(st, "OutSolicits", icmp6stat.icp6s_outhist[ND_NEIGHBOR_SOLICIT]); |
| 1254 | rrddim_set(st, "InAdvertisements", icmp6stat.icp6s_inhist[ND_NEIGHBOR_ADVERT]); |
| 1255 | rrddim_set(st, "OutAdvertisements", icmp6stat.icp6s_outhist[ND_NEIGHBOR_ADVERT]); |
| 1256 | } |
| 1257 | |
| 1258 | if (do_icmp6_types == CONFIG_BOOLEAN_YES || do_icmp6_types == CONFIG_BOOLEAN_AUTO) { |
| 1259 | do_icmp6_types = CONFIG_BOOLEAN_YES; |
| 1260 | st = rrdset_find_active_localhost("ipv6.icmptypes"); |
| 1261 | if (unlikely(!st)) { |
| 1262 | st = rrdset_create_localhost( |
| 1263 | "ipv6" |
| 1264 | , "icmptypes" |
| 1265 | , NULL |
| 1266 | , "icmp" |
| 1267 | , NULL |
| 1268 | , "IPv6 ICMP Types" |
| 1269 | , "messages/s" |
| 1270 | , "macos.plugin" |
| 1271 | , "sysctl" |
| 1272 | , 10700 |
| 1273 | , update_every |
| 1274 | , RRDSET_TYPE_LINE |
| 1275 | ); |
| 1276 | |
| 1277 | rrddim_add(st, "InType1", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 1278 | rrddim_add(st, "InType128", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 1279 | rrddim_add(st, "InType129", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 1280 | rrddim_add(st, "InType136", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 1281 | rrddim_add(st, "OutType1", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 1282 | rrddim_add(st, "OutType128", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 1283 | rrddim_add(st, "OutType129", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 1284 | rrddim_add(st, "OutType133", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 1285 | rrddim_add(st, "OutType135", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 1286 | rrddim_add(st, "OutType143", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); |
| 1287 | } |
| 1288 | |
| 1289 | rrddim_set(st, "InType1", icmp6stat.icp6s_inhist[1]); |
| 1290 | rrddim_set(st, "InType128", icmp6stat.icp6s_inhist[128]); |
| 1291 | rrddim_set(st, "InType129", icmp6stat.icp6s_inhist[129]); |
| 1292 | rrddim_set(st, "InType136", icmp6stat.icp6s_inhist[136]); |
| 1293 | rrddim_set(st, "OutType1", icmp6stat.icp6s_outhist[1]); |
| 1294 | rrddim_set(st, "OutType128", icmp6stat.icp6s_outhist[128]); |
| 1295 | rrddim_set(st, "OutType129", icmp6stat.icp6s_outhist[129]); |
| 1296 | rrddim_set(st, "OutType133", icmp6stat.icp6s_outhist[133]); |
| 1297 | rrddim_set(st, "OutType135", icmp6stat.icp6s_outhist[135]); |
| 1298 | rrddim_set(st, "OutType143", icmp6stat.icp6s_outhist[143]); |
| 1299 | rrdset_done(st); |
| 1300 | } |
| 1301 | } |
| 1302 | } |
| 1303 | |
| 1304 | if (likely(do_uptime)) { |
| 1305 | if (unlikely(GETSYSCTL_BY_NAME("kern.boottime", boot_time))) { |
| 1306 | do_uptime = 0; |
| 1307 | collector_error("DISABLED: system.uptime"); |
| 1308 | } else { |
| 1309 | clock_gettime(CLOCK_REALTIME, &cur_time); |
| 1310 | st = rrdset_find_active_localhost("system.uptime"); |
| 1311 | |
| 1312 | if(unlikely(!st)) { |
| 1313 | st = rrdset_create_localhost( |
| 1314 | "system" |
| 1315 | , "uptime" |
| 1316 | , NULL |
| 1317 | , "uptime" |
| 1318 | , NULL |
| 1319 | , "System Uptime" |
| 1320 | , "seconds" |
| 1321 | , "macos.plugin" |
| 1322 | , "sysctl" |
| 1323 | , 1000 |
| 1324 | , update_every |
| 1325 | , RRDSET_TYPE_LINE |
| 1326 | ); |
| 1327 | rrddim_add(st, "uptime", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE); |
| 1328 | } |
| 1329 | |
| 1330 | rrddim_set(st, "uptime", cur_time.tv_sec - boot_time.tv_sec); |
| 1331 | rrdset_done(st); |
| 1332 | } |
| 1333 | } |
| 1334 | |
| 1335 | return 0; |
| 1336 | } |