macos_sysctl.c 68 KB

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