macos_sysctl.c 72 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523
  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. // --------------------------------------------------------------------
  192. if (next_loadavg_dt <= dt) {
  193. if (likely(do_loadavg)) {
  194. if (unlikely(GETSYSCTL_BY_NAME("vm.loadavg", sysload))) {
  195. do_loadavg = 0;
  196. error("DISABLED: system.load");
  197. } else {
  198. st = rrdset_find_active_bytype_localhost("system", "load");
  199. if (unlikely(!st)) {
  200. st = rrdset_create_localhost(
  201. "system"
  202. , "load"
  203. , NULL
  204. , "load"
  205. , NULL
  206. , "System Load Average"
  207. , "load"
  208. , "macos.plugin"
  209. , "sysctl"
  210. , 100
  211. , (update_every < MIN_LOADAVG_UPDATE_EVERY) ? MIN_LOADAVG_UPDATE_EVERY : update_every
  212. , RRDSET_TYPE_LINE
  213. );
  214. rrddim_add(st, "load1", NULL, 1, 1000, RRD_ALGORITHM_ABSOLUTE);
  215. rrddim_add(st, "load5", NULL, 1, 1000, RRD_ALGORITHM_ABSOLUTE);
  216. rrddim_add(st, "load15", NULL, 1, 1000, RRD_ALGORITHM_ABSOLUTE);
  217. }
  218. else rrdset_next(st);
  219. rrddim_set(st, "load1", (collected_number) ((double)sysload.ldavg[0] / sysload.fscale * 1000));
  220. rrddim_set(st, "load5", (collected_number) ((double)sysload.ldavg[1] / sysload.fscale * 1000));
  221. rrddim_set(st, "load15", (collected_number) ((double)sysload.ldavg[2] / sysload.fscale * 1000));
  222. rrdset_done(st);
  223. }
  224. }
  225. next_loadavg_dt = st->update_every * USEC_PER_SEC;
  226. }
  227. else next_loadavg_dt -= dt;
  228. // --------------------------------------------------------------------
  229. if (likely(do_swap)) {
  230. if (unlikely(GETSYSCTL_BY_NAME("vm.swapusage", swap_usage))) {
  231. do_swap = 0;
  232. error("DISABLED: system.swap");
  233. } else {
  234. st = rrdset_find_active_localhost("system.swap");
  235. if (unlikely(!st)) {
  236. st = rrdset_create_localhost(
  237. "system"
  238. , "swap"
  239. , NULL
  240. , "swap"
  241. , NULL
  242. , "System Swap"
  243. , "MiB"
  244. , "macos.plugin"
  245. , "sysctl"
  246. , 201
  247. , update_every
  248. , RRDSET_TYPE_STACKED
  249. );
  250. rrdset_flag_set(st, RRDSET_FLAG_DETAIL);
  251. rrddim_add(st, "free", NULL, 1, 1048576, RRD_ALGORITHM_ABSOLUTE);
  252. rrddim_add(st, "used", NULL, 1, 1048576, RRD_ALGORITHM_ABSOLUTE);
  253. }
  254. else rrdset_next(st);
  255. rrddim_set(st, "free", swap_usage.xsu_avail);
  256. rrddim_set(st, "used", swap_usage.xsu_used);
  257. rrdset_done(st);
  258. }
  259. }
  260. // --------------------------------------------------------------------
  261. if (likely(do_bandwidth)) {
  262. mib[0] = CTL_NET;
  263. mib[1] = PF_ROUTE;
  264. mib[2] = 0;
  265. mib[3] = AF_INET;
  266. mib[4] = NET_RT_IFLIST2;
  267. mib[5] = 0;
  268. if (unlikely(sysctl(mib, 6, NULL, &size, NULL, 0))) {
  269. error("MACOS: sysctl(%s...) failed: %s", "net interfaces", strerror(errno));
  270. do_bandwidth = 0;
  271. error("DISABLED: system.ipv4");
  272. } else {
  273. ifstatdata = reallocz(ifstatdata, size);
  274. if (unlikely(sysctl(mib, 6, ifstatdata, &size, NULL, 0) < 0)) {
  275. error("MACOS: sysctl(%s...) failed: %s", "net interfaces", strerror(errno));
  276. do_bandwidth = 0;
  277. error("DISABLED: system.ipv4");
  278. } else {
  279. lim = ifstatdata + size;
  280. iftot.ift_ibytes = iftot.ift_obytes = 0;
  281. for (next = ifstatdata; next < lim; ) {
  282. ifm = (struct if_msghdr *)next;
  283. next += ifm->ifm_msglen;
  284. if (ifm->ifm_type == RTM_IFINFO2) {
  285. struct if_msghdr2 *if2m = (struct if_msghdr2 *)ifm;
  286. iftot.ift_ibytes += if2m->ifm_data.ifi_ibytes;
  287. iftot.ift_obytes += if2m->ifm_data.ifi_obytes;
  288. }
  289. }
  290. st = rrdset_find_active_localhost("system.ipv4");
  291. if (unlikely(!st)) {
  292. st = rrdset_create_localhost(
  293. "system"
  294. , "ipv4"
  295. , NULL
  296. , "network"
  297. , NULL
  298. , "IPv4 Bandwidth"
  299. , "kilobits/s"
  300. , "macos.plugin"
  301. , "sysctl"
  302. , 500
  303. , update_every
  304. , RRDSET_TYPE_AREA
  305. );
  306. rrddim_add(st, "InOctets", "received", 8, BITS_IN_A_KILOBIT, RRD_ALGORITHM_INCREMENTAL);
  307. rrddim_add(st, "OutOctets", "sent", -8, BITS_IN_A_KILOBIT, RRD_ALGORITHM_INCREMENTAL);
  308. }
  309. else rrdset_next(st);
  310. rrddim_set(st, "InOctets", iftot.ift_ibytes);
  311. rrddim_set(st, "OutOctets", iftot.ift_obytes);
  312. rrdset_done(st);
  313. }
  314. }
  315. }
  316. // --------------------------------------------------------------------
  317. // see http://net-snmp.sourceforge.net/docs/mibs/tcp.html
  318. if (likely(do_tcp_packets || do_tcp_errors || do_tcp_handshake || do_tcpext_connaborts || do_tcpext_ofo || do_tcpext_syscookies || do_ecn)) {
  319. if (unlikely(GETSYSCTL_BY_NAME("net.inet.tcp.stats", tcpstat))){
  320. do_tcp_packets = 0;
  321. error("DISABLED: ipv4.tcppackets");
  322. do_tcp_errors = 0;
  323. error("DISABLED: ipv4.tcperrors");
  324. do_tcp_handshake = 0;
  325. error("DISABLED: ipv4.tcphandshake");
  326. do_tcpext_connaborts = 0;
  327. error("DISABLED: ipv4.tcpconnaborts");
  328. do_tcpext_ofo = 0;
  329. error("DISABLED: ipv4.tcpofo");
  330. do_tcpext_syscookies = 0;
  331. error("DISABLED: ipv4.tcpsyncookies");
  332. do_ecn = 0;
  333. error("DISABLED: ipv4.ecnpkts");
  334. } else {
  335. if (likely(do_tcp_packets)) {
  336. st = rrdset_find_active_localhost("ipv4.tcppackets");
  337. if (unlikely(!st)) {
  338. st = rrdset_create_localhost(
  339. "ipv4"
  340. , "tcppackets"
  341. , NULL
  342. , "tcp"
  343. , NULL
  344. , "IPv4 TCP Packets"
  345. , "packets/s"
  346. , "macos.plugin"
  347. , "sysctl"
  348. , 2600
  349. , update_every
  350. , RRDSET_TYPE_LINE
  351. );
  352. rrddim_add(st, "InSegs", "received", 1, 1, RRD_ALGORITHM_INCREMENTAL);
  353. rrddim_add(st, "OutSegs", "sent", -1, 1, RRD_ALGORITHM_INCREMENTAL);
  354. } else
  355. rrdset_next(st);
  356. rrddim_set(st, "InSegs", tcpstat.tcps_rcvtotal);
  357. rrddim_set(st, "OutSegs", tcpstat.tcps_sndtotal);
  358. rrdset_done(st);
  359. }
  360. // --------------------------------------------------------------------
  361. if (likely(do_tcp_errors)) {
  362. st = rrdset_find_active_localhost("ipv4.tcperrors");
  363. if (unlikely(!st)) {
  364. st = rrdset_create_localhost(
  365. "ipv4"
  366. , "tcperrors"
  367. , NULL
  368. , "tcp"
  369. , NULL
  370. , "IPv4 TCP Errors"
  371. , "packets/s"
  372. , "macos.plugin"
  373. , "sysctl"
  374. , 2700
  375. , update_every
  376. , RRDSET_TYPE_LINE
  377. );
  378. rrdset_flag_set(st, RRDSET_FLAG_DETAIL);
  379. rrddim_add(st, "InErrs", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
  380. rrddim_add(st, "InCsumErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
  381. rrddim_add(st, "RetransSegs", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);
  382. } else
  383. rrdset_next(st);
  384. rrddim_set(st, "InErrs", tcpstat.tcps_rcvbadoff + tcpstat.tcps_rcvshort);
  385. rrddim_set(st, "InCsumErrors", tcpstat.tcps_rcvbadsum);
  386. rrddim_set(st, "RetransSegs", tcpstat.tcps_sndrexmitpack);
  387. rrdset_done(st);
  388. }
  389. // --------------------------------------------------------------------
  390. if (likely(do_tcp_handshake)) {
  391. st = rrdset_find_active_localhost("ipv4.tcphandshake");
  392. if (unlikely(!st)) {
  393. st = rrdset_create_localhost(
  394. "ipv4"
  395. , "tcphandshake"
  396. , NULL
  397. , "tcp"
  398. , NULL
  399. , "IPv4 TCP Handshake Issues"
  400. , "events/s"
  401. , "macos.plugin"
  402. , "sysctl"
  403. , 2900
  404. , update_every
  405. , RRDSET_TYPE_LINE
  406. );
  407. rrdset_flag_set(st, RRDSET_FLAG_DETAIL);
  408. rrddim_add(st, "EstabResets", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
  409. rrddim_add(st, "ActiveOpens", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
  410. rrddim_add(st, "PassiveOpens", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
  411. rrddim_add(st, "AttemptFails", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
  412. } else
  413. rrdset_next(st);
  414. rrddim_set(st, "EstabResets", tcpstat.tcps_drops);
  415. rrddim_set(st, "ActiveOpens", tcpstat.tcps_connattempt);
  416. rrddim_set(st, "PassiveOpens", tcpstat.tcps_accepts);
  417. rrddim_set(st, "AttemptFails", tcpstat.tcps_conndrops);
  418. rrdset_done(st);
  419. }
  420. // --------------------------------------------------------------------
  421. if (do_tcpext_connaborts == CONFIG_BOOLEAN_YES || (do_tcpext_connaborts == CONFIG_BOOLEAN_AUTO &&
  422. (tcpstat.tcps_rcvpackafterwin ||
  423. tcpstat.tcps_rcvafterclose ||
  424. tcpstat.tcps_rcvmemdrop ||
  425. tcpstat.tcps_persistdrop ||
  426. netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) {
  427. do_tcpext_connaborts = CONFIG_BOOLEAN_YES;
  428. st = rrdset_find_active_localhost("ipv4.tcpconnaborts");
  429. if (unlikely(!st)) {
  430. st = rrdset_create_localhost(
  431. "ipv4"
  432. , "tcpconnaborts"
  433. , NULL
  434. , "tcp"
  435. , NULL
  436. , "TCP Connection Aborts"
  437. , "connections/s"
  438. , "macos.plugin"
  439. , "sysctl"
  440. , 3010
  441. , update_every
  442. , RRDSET_TYPE_LINE
  443. );
  444. rrddim_add(st, "TCPAbortOnData", "baddata", 1, 1, RRD_ALGORITHM_INCREMENTAL);
  445. rrddim_add(st, "TCPAbortOnClose", "userclosed", 1, 1, RRD_ALGORITHM_INCREMENTAL);
  446. rrddim_add(st, "TCPAbortOnMemory", "nomemory", 1, 1, RRD_ALGORITHM_INCREMENTAL);
  447. rrddim_add(st, "TCPAbortOnTimeout", "timeout", 1, 1, RRD_ALGORITHM_INCREMENTAL);
  448. }
  449. else rrdset_next(st);
  450. rrddim_set(st, "TCPAbortOnData", tcpstat.tcps_rcvpackafterwin);
  451. rrddim_set(st, "TCPAbortOnClose", tcpstat.tcps_rcvafterclose);
  452. rrddim_set(st, "TCPAbortOnMemory", tcpstat.tcps_rcvmemdrop);
  453. rrddim_set(st, "TCPAbortOnTimeout", tcpstat.tcps_persistdrop);
  454. rrdset_done(st);
  455. }
  456. // --------------------------------------------------------------------
  457. if (do_tcpext_ofo == CONFIG_BOOLEAN_YES || (do_tcpext_ofo == CONFIG_BOOLEAN_AUTO &&
  458. (tcpstat.tcps_rcvoopack ||
  459. netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) {
  460. do_tcpext_ofo = CONFIG_BOOLEAN_YES;
  461. st = rrdset_find_active_localhost("ipv4.tcpofo");
  462. if (unlikely(!st)) {
  463. st = rrdset_create_localhost(
  464. "ipv4"
  465. , "tcpofo"
  466. , NULL
  467. , "tcp"
  468. , NULL
  469. , "TCP Out-Of-Order Queue"
  470. , "packets/s"
  471. , "macos.plugin"
  472. , "sysctl"
  473. , 3050
  474. , update_every
  475. , RRDSET_TYPE_LINE
  476. );
  477. rrddim_add(st, "TCPOFOQueue", "inqueue", 1, 1, RRD_ALGORITHM_INCREMENTAL);
  478. }
  479. else rrdset_next(st);
  480. rrddim_set(st, "TCPOFOQueue", tcpstat.tcps_rcvoopack);
  481. rrdset_done(st);
  482. }
  483. // --------------------------------------------------------------------
  484. if (do_tcpext_syscookies == CONFIG_BOOLEAN_YES || (do_tcpext_syscookies == CONFIG_BOOLEAN_AUTO &&
  485. (tcpstat.tcps_sc_sendcookie ||
  486. tcpstat.tcps_sc_recvcookie ||
  487. tcpstat.tcps_sc_zonefail ||
  488. netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) {
  489. do_tcpext_syscookies = CONFIG_BOOLEAN_YES;
  490. st = rrdset_find_active_localhost("ipv4.tcpsyncookies");
  491. if (unlikely(!st)) {
  492. st = rrdset_create_localhost(
  493. "ipv4"
  494. , "tcpsyncookies"
  495. , NULL
  496. , "tcp"
  497. , NULL
  498. , "TCP SYN Cookies"
  499. , "packets/s"
  500. , "macos.plugin"
  501. , "sysctl"
  502. , 3100
  503. , update_every
  504. , RRDSET_TYPE_LINE
  505. );
  506. rrddim_add(st, "SyncookiesRecv", "received", 1, 1, RRD_ALGORITHM_INCREMENTAL);
  507. rrddim_add(st, "SyncookiesSent", "sent", -1, 1, RRD_ALGORITHM_INCREMENTAL);
  508. rrddim_add(st, "SyncookiesFailed", "failed", -1, 1, RRD_ALGORITHM_INCREMENTAL);
  509. }
  510. else rrdset_next(st);
  511. rrddim_set(st, "SyncookiesRecv", tcpstat.tcps_sc_recvcookie);
  512. rrddim_set(st, "SyncookiesSent", tcpstat.tcps_sc_sendcookie);
  513. rrddim_set(st, "SyncookiesFailed", tcpstat.tcps_sc_zonefail);
  514. rrdset_done(st);
  515. }
  516. // --------------------------------------------------------------------
  517. #if (defined __MAC_OS_X_VERSION_MIN_REQUIRED && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101100)
  518. if (do_ecn == CONFIG_BOOLEAN_YES || (do_ecn == CONFIG_BOOLEAN_AUTO &&
  519. (tcpstat.tcps_ecn_recv_ce ||
  520. tcpstat.tcps_ecn_not_supported ||
  521. netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) {
  522. do_ecn = CONFIG_BOOLEAN_YES;
  523. st = rrdset_find_active_localhost("ipv4.ecnpkts");
  524. if (unlikely(!st)) {
  525. st = rrdset_create_localhost(
  526. "ipv4"
  527. , "ecnpkts"
  528. , NULL
  529. , "ecn"
  530. , NULL
  531. , "IPv4 ECN Statistics"
  532. , "packets/s"
  533. , "macos.plugin"
  534. , "sysctl"
  535. , 8700
  536. , update_every
  537. , RRDSET_TYPE_LINE
  538. );
  539. rrdset_flag_set(st, RRDSET_FLAG_DETAIL);
  540. rrddim_add(st, "InCEPkts", "CEP", 1, 1, RRD_ALGORITHM_INCREMENTAL);
  541. rrddim_add(st, "InNoECTPkts", "NoECTP", -1, 1, RRD_ALGORITHM_INCREMENTAL);
  542. }
  543. else rrdset_next(st);
  544. rrddim_set(st, "InCEPkts", tcpstat.tcps_ecn_recv_ce);
  545. rrddim_set(st, "InNoECTPkts", tcpstat.tcps_ecn_not_supported);
  546. rrdset_done(st);
  547. }
  548. #endif
  549. }
  550. }
  551. // --------------------------------------------------------------------
  552. // see http://net-snmp.sourceforge.net/docs/mibs/udp.html
  553. if (likely(do_udp_packets || do_udp_errors)) {
  554. if (unlikely(GETSYSCTL_BY_NAME("net.inet.udp.stats", udpstat))) {
  555. do_udp_packets = 0;
  556. error("DISABLED: ipv4.udppackets");
  557. do_udp_errors = 0;
  558. error("DISABLED: ipv4.udperrors");
  559. } else {
  560. if (likely(do_udp_packets)) {
  561. st = rrdset_find_active_localhost("ipv4.udppackets");
  562. if (unlikely(!st)) {
  563. st = rrdset_create_localhost(
  564. "ipv4"
  565. , "udppackets"
  566. , NULL
  567. , "udp"
  568. , NULL
  569. , "IPv4 UDP Packets"
  570. , "packets/s"
  571. , "macos.plugin"
  572. , "sysctl"
  573. , 2601
  574. , update_every
  575. , RRDSET_TYPE_LINE
  576. );
  577. rrddim_add(st, "InDatagrams", "received", 1, 1, RRD_ALGORITHM_INCREMENTAL);
  578. rrddim_add(st, "OutDatagrams", "sent", -1, 1, RRD_ALGORITHM_INCREMENTAL);
  579. } else
  580. rrdset_next(st);
  581. rrddim_set(st, "InDatagrams", udpstat.udps_ipackets);
  582. rrddim_set(st, "OutDatagrams", udpstat.udps_opackets);
  583. rrdset_done(st);
  584. }
  585. // --------------------------------------------------------------------
  586. if (likely(do_udp_errors)) {
  587. st = rrdset_find_active_localhost("ipv4.udperrors");
  588. if (unlikely(!st)) {
  589. st = rrdset_create_localhost(
  590. "ipv4"
  591. , "udperrors"
  592. , NULL
  593. , "udp"
  594. , NULL
  595. , "IPv4 UDP Errors"
  596. , "events/s"
  597. , "macos.plugin"
  598. , "sysctl"
  599. , 2701
  600. , update_every
  601. , RRDSET_TYPE_LINE
  602. );
  603. rrdset_flag_set(st, RRDSET_FLAG_DETAIL);
  604. rrddim_add(st, "RcvbufErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
  605. rrddim_add(st, "InErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
  606. rrddim_add(st, "NoPorts", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
  607. rrddim_add(st, "InCsumErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
  608. #if (defined __MAC_OS_X_VERSION_MIN_REQUIRED && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090)
  609. rrddim_add(st, "IgnoredMulti", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
  610. #endif
  611. } else
  612. rrdset_next(st);
  613. rrddim_set(st, "InErrors", udpstat.udps_hdrops + udpstat.udps_badlen);
  614. rrddim_set(st, "NoPorts", udpstat.udps_noport);
  615. rrddim_set(st, "RcvbufErrors", udpstat.udps_fullsock);
  616. #if (defined __MAC_OS_X_VERSION_MIN_REQUIRED && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090)
  617. rrddim_set(st, "InCsumErrors", udpstat.udps_badsum + udpstat.udps_nosum);
  618. rrddim_set(st, "IgnoredMulti", udpstat.udps_filtermcast);
  619. #else
  620. rrddim_set(st, "InCsumErrors", udpstat.udps_badsum);
  621. #endif
  622. rrdset_done(st);
  623. }
  624. }
  625. }
  626. // --------------------------------------------------------------------
  627. if (likely(do_icmp_packets || do_icmpmsg)) {
  628. if (unlikely(GETSYSCTL_BY_NAME("net.inet.icmp.stats", icmpstat))) {
  629. do_icmp_packets = 0;
  630. error("DISABLED: ipv4.icmp");
  631. error("DISABLED: ipv4.icmp_errors");
  632. do_icmpmsg = 0;
  633. error("DISABLED: ipv4.icmpmsg");
  634. } else {
  635. for (i = 0; i <= ICMP_MAXTYPE; i++) {
  636. icmp_total.msgs_in += icmpstat.icps_inhist[i];
  637. icmp_total.msgs_out += icmpstat.icps_outhist[i];
  638. }
  639. icmp_total.msgs_in += icmpstat.icps_badcode + icmpstat.icps_badlen + icmpstat.icps_checksum + icmpstat.icps_tooshort;
  640. // --------------------------------------------------------------------
  641. if (likely(do_icmp_packets)) {
  642. st = rrdset_find_active_localhost("ipv4.icmp");
  643. if (unlikely(!st)) {
  644. st = rrdset_create_localhost(
  645. "ipv4"
  646. , "icmp"
  647. , NULL
  648. , "icmp"
  649. , NULL
  650. , "IPv4 ICMP Packets"
  651. , "packets/s"
  652. , "macos.plugin"
  653. , "sysctl"
  654. , 2602
  655. , update_every
  656. , RRDSET_TYPE_LINE
  657. );
  658. rrddim_add(st, "InMsgs", "received", 1, 1, RRD_ALGORITHM_INCREMENTAL);
  659. rrddim_add(st, "OutMsgs", "sent", -1, 1, RRD_ALGORITHM_INCREMENTAL);
  660. } else
  661. rrdset_next(st);
  662. rrddim_set(st, "InMsgs", icmp_total.msgs_in);
  663. rrddim_set(st, "OutMsgs", icmp_total.msgs_out);
  664. rrdset_done(st);
  665. // --------------------------------------------------------------------
  666. st = rrdset_find_active_localhost("ipv4.icmp_errors");
  667. if (unlikely(!st)) {
  668. st = rrdset_create_localhost(
  669. "ipv4"
  670. , "icmp_errors"
  671. , NULL
  672. , "icmp"
  673. , NULL
  674. , "IPv4 ICMP Errors"
  675. , "packets/s"
  676. , "macos.plugin"
  677. , "sysctl"
  678. , 2603
  679. , update_every
  680. , RRDSET_TYPE_LINE
  681. );
  682. rrddim_add(st, "InErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
  683. rrddim_add(st, "OutErrors", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);
  684. rrddim_add(st, "InCsumErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
  685. } else
  686. rrdset_next(st);
  687. rrddim_set(st, "InErrors", icmpstat.icps_badcode + icmpstat.icps_badlen + icmpstat.icps_checksum + icmpstat.icps_tooshort);
  688. rrddim_set(st, "OutErrors", icmpstat.icps_error);
  689. rrddim_set(st, "InCsumErrors", icmpstat.icps_checksum);
  690. rrdset_done(st);
  691. }
  692. // --------------------------------------------------------------------
  693. if (likely(do_icmpmsg)) {
  694. st = rrdset_find_active_localhost("ipv4.icmpmsg");
  695. if (unlikely(!st)) {
  696. st = rrdset_create_localhost(
  697. "ipv4"
  698. , "icmpmsg"
  699. , NULL
  700. , "icmp"
  701. , NULL
  702. , "IPv4 ICMP Messages"
  703. , "packets/s"
  704. , "macos.plugin"
  705. , "sysctl"
  706. , 2604
  707. , update_every
  708. , RRDSET_TYPE_LINE
  709. );
  710. rrddim_add(st, "InEchoReps", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
  711. rrddim_add(st, "OutEchoReps", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);
  712. rrddim_add(st, "InEchos", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
  713. rrddim_add(st, "OutEchos", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);
  714. } else
  715. rrdset_next(st);
  716. rrddim_set(st, "InEchoReps", icmpstat.icps_inhist[ICMP_ECHOREPLY]);
  717. rrddim_set(st, "OutEchoReps", icmpstat.icps_outhist[ICMP_ECHOREPLY]);
  718. rrddim_set(st, "InEchos", icmpstat.icps_inhist[ICMP_ECHO]);
  719. rrddim_set(st, "OutEchos", icmpstat.icps_outhist[ICMP_ECHO]);
  720. rrdset_done(st);
  721. }
  722. }
  723. }
  724. // --------------------------------------------------------------------
  725. // see also http://net-snmp.sourceforge.net/docs/mibs/ip.html
  726. if (likely(do_ip_packets || do_ip_fragsout || do_ip_fragsin || do_ip_errors)) {
  727. if (unlikely(GETSYSCTL_BY_NAME("net.inet.ip.stats", ipstat))) {
  728. do_ip_packets = 0;
  729. error("DISABLED: ipv4.packets");
  730. do_ip_fragsout = 0;
  731. error("DISABLED: ipv4.fragsout");
  732. do_ip_fragsin = 0;
  733. error("DISABLED: ipv4.fragsin");
  734. do_ip_errors = 0;
  735. error("DISABLED: ipv4.errors");
  736. } else {
  737. if (likely(do_ip_packets)) {
  738. st = rrdset_find_active_localhost("ipv4.packets");
  739. if (unlikely(!st)) {
  740. st = rrdset_create_localhost(
  741. "ipv4"
  742. , "packets"
  743. , NULL
  744. , "packets"
  745. , NULL
  746. , "IPv4 Packets"
  747. , "packets/s"
  748. , "macos.plugin"
  749. , "sysctl"
  750. , 3000
  751. , update_every
  752. , RRDSET_TYPE_LINE
  753. );
  754. rrddim_add(st, "InReceives", "received", 1, 1, RRD_ALGORITHM_INCREMENTAL);
  755. rrddim_add(st, "OutRequests", "sent", -1, 1, RRD_ALGORITHM_INCREMENTAL);
  756. rrddim_add(st, "ForwDatagrams", "forwarded", 1, 1, RRD_ALGORITHM_INCREMENTAL);
  757. rrddim_add(st, "InDelivers", "delivered", 1, 1, RRD_ALGORITHM_INCREMENTAL);
  758. } else
  759. rrdset_next(st);
  760. rrddim_set(st, "OutRequests", ipstat.ips_localout);
  761. rrddim_set(st, "InReceives", ipstat.ips_total);
  762. rrddim_set(st, "ForwDatagrams", ipstat.ips_forward);
  763. rrddim_set(st, "InDelivers", ipstat.ips_delivered);
  764. rrdset_done(st);
  765. }
  766. // --------------------------------------------------------------------
  767. if (likely(do_ip_fragsout)) {
  768. st = rrdset_find_active_localhost("ipv4.fragsout");
  769. if (unlikely(!st)) {
  770. st = rrdset_create_localhost(
  771. "ipv4"
  772. , "fragsout"
  773. , NULL
  774. , "fragments"
  775. , NULL
  776. , "IPv4 Fragments Sent"
  777. , "packets/s"
  778. , "macos.plugin"
  779. , "sysctl"
  780. , 3010
  781. , update_every
  782. , RRDSET_TYPE_LINE
  783. );
  784. rrdset_flag_set(st, RRDSET_FLAG_DETAIL);
  785. rrddim_add(st, "FragOKs", "ok", 1, 1, RRD_ALGORITHM_INCREMENTAL);
  786. rrddim_add(st, "FragFails", "failed", -1, 1, RRD_ALGORITHM_INCREMENTAL);
  787. rrddim_add(st, "FragCreates", "created", 1, 1, RRD_ALGORITHM_INCREMENTAL);
  788. } else
  789. rrdset_next(st);
  790. rrddim_set(st, "FragOKs", ipstat.ips_fragmented);
  791. rrddim_set(st, "FragFails", ipstat.ips_cantfrag);
  792. rrddim_set(st, "FragCreates", ipstat.ips_ofragments);
  793. rrdset_done(st);
  794. }
  795. // --------------------------------------------------------------------
  796. if (likely(do_ip_fragsin)) {
  797. st = rrdset_find_active_localhost("ipv4.fragsin");
  798. if (unlikely(!st)) {
  799. st = rrdset_create_localhost(
  800. "ipv4"
  801. , "fragsin"
  802. , NULL
  803. , "fragments"
  804. , NULL
  805. , "IPv4 Fragments Reassembly"
  806. , "packets/s"
  807. , "macos.plugin"
  808. , "sysctl"
  809. , 3011
  810. , update_every
  811. , RRDSET_TYPE_LINE
  812. );
  813. rrdset_flag_set(st, RRDSET_FLAG_DETAIL);
  814. rrddim_add(st, "ReasmOKs", "ok", 1, 1, RRD_ALGORITHM_INCREMENTAL);
  815. rrddim_add(st, "ReasmFails", "failed", -1, 1, RRD_ALGORITHM_INCREMENTAL);
  816. rrddim_add(st, "ReasmReqds", "all", 1, 1, RRD_ALGORITHM_INCREMENTAL);
  817. } else
  818. rrdset_next(st);
  819. rrddim_set(st, "ReasmOKs", ipstat.ips_fragments);
  820. rrddim_set(st, "ReasmFails", ipstat.ips_fragdropped);
  821. rrddim_set(st, "ReasmReqds", ipstat.ips_reassembled);
  822. rrdset_done(st);
  823. }
  824. // --------------------------------------------------------------------
  825. if (likely(do_ip_errors)) {
  826. st = rrdset_find_active_localhost("ipv4.errors");
  827. if (unlikely(!st)) {
  828. st = rrdset_create_localhost(
  829. "ipv4"
  830. , "errors"
  831. , NULL
  832. , "errors"
  833. , NULL
  834. , "IPv4 Errors"
  835. , "packets/s"
  836. , "macos.plugin"
  837. , "sysctl"
  838. , 3002
  839. , update_every
  840. , RRDSET_TYPE_LINE
  841. );
  842. rrdset_flag_set(st, RRDSET_FLAG_DETAIL);
  843. rrddim_add(st, "InDiscards", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
  844. rrddim_add(st, "OutDiscards", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);
  845. rrddim_add(st, "InHdrErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
  846. rrddim_add(st, "OutNoRoutes", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);
  847. rrddim_add(st, "InAddrErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
  848. rrddim_add(st, "InUnknownProtos", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
  849. } else
  850. rrdset_next(st);
  851. rrddim_set(st, "InDiscards", ipstat.ips_badsum + ipstat.ips_tooshort + ipstat.ips_toosmall + ipstat.ips_toolong);
  852. rrddim_set(st, "OutDiscards", ipstat.ips_odropped);
  853. rrddim_set(st, "InHdrErrors", ipstat.ips_badhlen + ipstat.ips_badlen + ipstat.ips_badoptions + ipstat.ips_badvers);
  854. rrddim_set(st, "InAddrErrors", ipstat.ips_badaddr);
  855. rrddim_set(st, "InUnknownProtos", ipstat.ips_noproto);
  856. rrddim_set(st, "OutNoRoutes", ipstat.ips_noroute);
  857. rrdset_done(st);
  858. }
  859. }
  860. }
  861. // --------------------------------------------------------------------
  862. if (likely(do_ip6_packets || do_ip6_fragsout || do_ip6_fragsin || do_ip6_errors)) {
  863. if (unlikely(GETSYSCTL_BY_NAME("net.inet6.ip6.stats", ip6stat))) {
  864. do_ip6_packets = 0;
  865. error("DISABLED: ipv6.packets");
  866. do_ip6_fragsout = 0;
  867. error("DISABLED: ipv6.fragsout");
  868. do_ip6_fragsin = 0;
  869. error("DISABLED: ipv6.fragsin");
  870. do_ip6_errors = 0;
  871. error("DISABLED: ipv6.errors");
  872. } else {
  873. if (do_ip6_packets == CONFIG_BOOLEAN_YES || (do_ip6_packets == CONFIG_BOOLEAN_AUTO &&
  874. (ip6stat.ip6s_localout ||
  875. ip6stat.ip6s_total ||
  876. ip6stat.ip6s_forward ||
  877. ip6stat.ip6s_delivered ||
  878. netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) {
  879. do_ip6_packets = CONFIG_BOOLEAN_YES;
  880. st = rrdset_find_active_localhost("ipv6.packets");
  881. if (unlikely(!st)) {
  882. st = rrdset_create_localhost(
  883. "ipv6"
  884. , "packets"
  885. , NULL
  886. , "packets"
  887. , NULL
  888. , "IPv6 Packets"
  889. , "packets/s"
  890. , "macos.plugin"
  891. , "sysctl"
  892. , 3000
  893. , update_every
  894. , RRDSET_TYPE_LINE
  895. );
  896. rrddim_add(st, "received", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
  897. rrddim_add(st, "sent", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);
  898. rrddim_add(st, "forwarded", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
  899. rrddim_add(st, "delivers", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);
  900. } else
  901. rrdset_next(st);
  902. rrddim_set(st, "sent", ip6stat.ip6s_localout);
  903. rrddim_set(st, "received", ip6stat.ip6s_total);
  904. rrddim_set(st, "forwarded", ip6stat.ip6s_forward);
  905. rrddim_set(st, "delivers", ip6stat.ip6s_delivered);
  906. rrdset_done(st);
  907. }
  908. // --------------------------------------------------------------------
  909. if (do_ip6_fragsout == CONFIG_BOOLEAN_YES || (do_ip6_fragsout == CONFIG_BOOLEAN_AUTO &&
  910. (ip6stat.ip6s_fragmented ||
  911. ip6stat.ip6s_cantfrag ||
  912. ip6stat.ip6s_ofragments ||
  913. netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) {
  914. do_ip6_fragsout = CONFIG_BOOLEAN_YES;
  915. st = rrdset_find_active_localhost("ipv6.fragsout");
  916. if (unlikely(!st)) {
  917. st = rrdset_create_localhost(
  918. "ipv6"
  919. , "fragsout"
  920. , NULL
  921. , "fragments"
  922. , NULL
  923. , "IPv6 Fragments Sent"
  924. , "packets/s"
  925. , "macos.plugin"
  926. , "sysctl"
  927. , 3010
  928. , update_every
  929. , RRDSET_TYPE_LINE
  930. );
  931. rrdset_flag_set(st, RRDSET_FLAG_DETAIL);
  932. rrddim_add(st, "ok", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
  933. rrddim_add(st, "failed", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);
  934. rrddim_add(st, "all", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
  935. } else
  936. rrdset_next(st);
  937. rrddim_set(st, "ok", ip6stat.ip6s_fragmented);
  938. rrddim_set(st, "failed", ip6stat.ip6s_cantfrag);
  939. rrddim_set(st, "all", ip6stat.ip6s_ofragments);
  940. rrdset_done(st);
  941. }
  942. // --------------------------------------------------------------------
  943. if (do_ip6_fragsin == CONFIG_BOOLEAN_YES || (do_ip6_fragsin == CONFIG_BOOLEAN_AUTO &&
  944. (ip6stat.ip6s_reassembled ||
  945. ip6stat.ip6s_fragdropped ||
  946. ip6stat.ip6s_fragtimeout ||
  947. ip6stat.ip6s_fragments ||
  948. netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) {
  949. do_ip6_fragsin = CONFIG_BOOLEAN_YES;
  950. st = rrdset_find_active_localhost("ipv6.fragsin");
  951. if (unlikely(!st)) {
  952. st = rrdset_create_localhost(
  953. "ipv6"
  954. , "fragsin"
  955. , NULL
  956. , "fragments"
  957. , NULL
  958. , "IPv6 Fragments Reassembly"
  959. , "packets/s"
  960. , "macos.plugin"
  961. , "sysctl"
  962. , 3011
  963. , update_every
  964. , RRDSET_TYPE_LINE
  965. );
  966. rrdset_flag_set(st, RRDSET_FLAG_DETAIL);
  967. rrddim_add(st, "ok", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
  968. rrddim_add(st, "failed", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);
  969. rrddim_add(st, "timeout", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);
  970. rrddim_add(st, "all", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
  971. } else
  972. rrdset_next(st);
  973. rrddim_set(st, "ok", ip6stat.ip6s_reassembled);
  974. rrddim_set(st, "failed", ip6stat.ip6s_fragdropped);
  975. rrddim_set(st, "timeout", ip6stat.ip6s_fragtimeout);
  976. rrddim_set(st, "all", ip6stat.ip6s_fragments);
  977. rrdset_done(st);
  978. }
  979. // --------------------------------------------------------------------
  980. if (do_ip6_errors == CONFIG_BOOLEAN_YES || (do_ip6_errors == CONFIG_BOOLEAN_AUTO &&
  981. (ip6stat.ip6s_toosmall ||
  982. ip6stat.ip6s_odropped ||
  983. ip6stat.ip6s_badoptions ||
  984. ip6stat.ip6s_badvers ||
  985. ip6stat.ip6s_exthdrtoolong ||
  986. ip6stat.ip6s_sources_none ||
  987. ip6stat.ip6s_tooshort ||
  988. ip6stat.ip6s_cantforward ||
  989. ip6stat.ip6s_noroute ||
  990. netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) {
  991. do_ip6_errors = CONFIG_BOOLEAN_YES;
  992. st = rrdset_find_active_localhost("ipv6.errors");
  993. if (unlikely(!st)) {
  994. st = rrdset_create_localhost(
  995. "ipv6"
  996. , "errors"
  997. , NULL
  998. , "errors"
  999. , NULL
  1000. , "IPv6 Errors"
  1001. , "packets/s"
  1002. , "macos.plugin"
  1003. , "sysctl"
  1004. , 3002
  1005. , update_every
  1006. , RRDSET_TYPE_LINE
  1007. );
  1008. rrdset_flag_set(st, RRDSET_FLAG_DETAIL);
  1009. rrddim_add(st, "InDiscards", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
  1010. rrddim_add(st, "OutDiscards", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);
  1011. rrddim_add(st, "InHdrErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
  1012. rrddim_add(st, "InAddrErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
  1013. rrddim_add(st, "InTruncatedPkts", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
  1014. rrddim_add(st, "InNoRoutes", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
  1015. rrddim_add(st, "OutNoRoutes", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);
  1016. } else
  1017. rrdset_next(st);
  1018. rrddim_set(st, "InDiscards", ip6stat.ip6s_toosmall);
  1019. rrddim_set(st, "OutDiscards", ip6stat.ip6s_odropped);
  1020. rrddim_set(st, "InHdrErrors",
  1021. ip6stat.ip6s_badoptions + ip6stat.ip6s_badvers + ip6stat.ip6s_exthdrtoolong);
  1022. rrddim_set(st, "InAddrErrors", ip6stat.ip6s_sources_none);
  1023. rrddim_set(st, "InTruncatedPkts", ip6stat.ip6s_tooshort);
  1024. rrddim_set(st, "InNoRoutes", ip6stat.ip6s_cantforward);
  1025. rrddim_set(st, "OutNoRoutes", ip6stat.ip6s_noroute);
  1026. rrdset_done(st);
  1027. }
  1028. }
  1029. }
  1030. // --------------------------------------------------------------------
  1031. if (likely(do_icmp6 || do_icmp6_redir || do_icmp6_errors || do_icmp6_echos || do_icmp6_router || do_icmp6_neighbor || do_icmp6_types)) {
  1032. if (unlikely(GETSYSCTL_BY_NAME("net.inet6.icmp6.stats", icmp6stat))) {
  1033. do_icmp6 = 0;
  1034. error("DISABLED: ipv6.icmp");
  1035. } else {
  1036. for (i = 0; i <= ICMP6_MAXTYPE; i++) {
  1037. icmp6_total.msgs_in += icmp6stat.icp6s_inhist[i];
  1038. icmp6_total.msgs_out += icmp6stat.icp6s_outhist[i];
  1039. }
  1040. icmp6_total.msgs_in += icmp6stat.icp6s_badcode + icmp6stat.icp6s_badlen + icmp6stat.icp6s_checksum + icmp6stat.icp6s_tooshort;
  1041. if (do_icmp6 == CONFIG_BOOLEAN_YES || (do_icmp6 == CONFIG_BOOLEAN_AUTO &&
  1042. (icmp6_total.msgs_in ||
  1043. icmp6_total.msgs_out ||
  1044. netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) {
  1045. do_icmp6 = CONFIG_BOOLEAN_YES;
  1046. st = rrdset_find_active_localhost("ipv6.icmp");
  1047. if (unlikely(!st)) {
  1048. st = rrdset_create_localhost(
  1049. "ipv6"
  1050. , "icmp"
  1051. , NULL
  1052. , "icmp"
  1053. , NULL
  1054. , "IPv6 ICMP Messages"
  1055. , "messages/s"
  1056. , "macos.plugin"
  1057. , "sysctl"
  1058. , 10000
  1059. , update_every
  1060. , RRDSET_TYPE_LINE
  1061. );
  1062. rrddim_add(st, "received", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
  1063. rrddim_add(st, "sent", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);
  1064. } else
  1065. rrdset_next(st);
  1066. rrddim_set(st, "sent", icmp6_total.msgs_in);
  1067. rrddim_set(st, "received", icmp6_total.msgs_out);
  1068. rrdset_done(st);
  1069. }
  1070. // --------------------------------------------------------------------
  1071. if (do_icmp6_redir == CONFIG_BOOLEAN_YES || (do_icmp6_redir == CONFIG_BOOLEAN_AUTO &&
  1072. (icmp6stat.icp6s_inhist[ND_REDIRECT] ||
  1073. icmp6stat.icp6s_outhist[ND_REDIRECT] ||
  1074. netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) {
  1075. do_icmp6_redir = CONFIG_BOOLEAN_YES;
  1076. st = rrdset_find_active_localhost("ipv6.icmpredir");
  1077. if (unlikely(!st)) {
  1078. st = rrdset_create_localhost(
  1079. "ipv6"
  1080. , "icmpredir"
  1081. , NULL
  1082. , "icmp"
  1083. , NULL
  1084. , "IPv6 ICMP Redirects"
  1085. , "redirects/s"
  1086. , "macos.plugin"
  1087. , "sysctl"
  1088. , 10050
  1089. , update_every
  1090. , RRDSET_TYPE_LINE
  1091. );
  1092. rrddim_add(st, "received", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
  1093. rrddim_add(st, "sent", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);
  1094. } else
  1095. rrdset_next(st);
  1096. rrddim_set(st, "sent", icmp6stat.icp6s_inhist[ND_REDIRECT]);
  1097. rrddim_set(st, "received", icmp6stat.icp6s_outhist[ND_REDIRECT]);
  1098. rrdset_done(st);
  1099. }
  1100. // --------------------------------------------------------------------
  1101. if (do_icmp6_errors == CONFIG_BOOLEAN_YES || (do_icmp6_errors == CONFIG_BOOLEAN_AUTO &&
  1102. (icmp6stat.icp6s_badcode ||
  1103. icmp6stat.icp6s_badlen ||
  1104. icmp6stat.icp6s_checksum ||
  1105. icmp6stat.icp6s_tooshort ||
  1106. icmp6stat.icp6s_error ||
  1107. icmp6stat.icp6s_inhist[ICMP6_DST_UNREACH] ||
  1108. icmp6stat.icp6s_inhist[ICMP6_TIME_EXCEEDED] ||
  1109. icmp6stat.icp6s_inhist[ICMP6_PARAM_PROB] ||
  1110. icmp6stat.icp6s_outhist[ICMP6_DST_UNREACH] ||
  1111. icmp6stat.icp6s_outhist[ICMP6_TIME_EXCEEDED] ||
  1112. icmp6stat.icp6s_outhist[ICMP6_PARAM_PROB] ||
  1113. netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) {
  1114. do_icmp6_errors = CONFIG_BOOLEAN_YES;
  1115. st = rrdset_find_active_localhost("ipv6.icmperrors");
  1116. if (unlikely(!st)) {
  1117. st = rrdset_create_localhost(
  1118. "ipv6"
  1119. , "icmperrors"
  1120. , NULL
  1121. , "icmp"
  1122. , NULL
  1123. , "IPv6 ICMP Errors"
  1124. , "errors/s"
  1125. , "macos.plugin"
  1126. , "sysctl"
  1127. , 10100
  1128. , update_every
  1129. , RRDSET_TYPE_LINE
  1130. );
  1131. rrddim_add(st, "InErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
  1132. rrddim_add(st, "OutErrors", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);
  1133. rrddim_add(st, "InCsumErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
  1134. rrddim_add(st, "InDestUnreachs", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
  1135. rrddim_add(st, "InPktTooBigs", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
  1136. rrddim_add(st, "InTimeExcds", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
  1137. rrddim_add(st, "InParmProblems", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
  1138. rrddim_add(st, "OutDestUnreachs", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);
  1139. rrddim_add(st, "OutTimeExcds", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);
  1140. rrddim_add(st, "OutParmProblems", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);
  1141. } else
  1142. rrdset_next(st);
  1143. rrddim_set(st, "InErrors", icmp6stat.icp6s_badcode + icmp6stat.icp6s_badlen + icmp6stat.icp6s_checksum + icmp6stat.icp6s_tooshort);
  1144. rrddim_set(st, "OutErrors", icmp6stat.icp6s_error);
  1145. rrddim_set(st, "InCsumErrors", icmp6stat.icp6s_checksum);
  1146. rrddim_set(st, "InDestUnreachs", icmp6stat.icp6s_inhist[ICMP6_DST_UNREACH]);
  1147. rrddim_set(st, "InPktTooBigs", icmp6stat.icp6s_badlen);
  1148. rrddim_set(st, "InTimeExcds", icmp6stat.icp6s_inhist[ICMP6_TIME_EXCEEDED]);
  1149. rrddim_set(st, "InParmProblems", icmp6stat.icp6s_inhist[ICMP6_PARAM_PROB]);
  1150. rrddim_set(st, "OutDestUnreachs", icmp6stat.icp6s_outhist[ICMP6_DST_UNREACH]);
  1151. rrddim_set(st, "OutTimeExcds", icmp6stat.icp6s_outhist[ICMP6_TIME_EXCEEDED]);
  1152. rrddim_set(st, "OutParmProblems", icmp6stat.icp6s_outhist[ICMP6_PARAM_PROB]);
  1153. rrdset_done(st);
  1154. }
  1155. // --------------------------------------------------------------------
  1156. if (do_icmp6_echos == CONFIG_BOOLEAN_YES || (do_icmp6_echos == CONFIG_BOOLEAN_AUTO &&
  1157. (icmp6stat.icp6s_inhist[ICMP6_ECHO_REQUEST] ||
  1158. icmp6stat.icp6s_outhist[ICMP6_ECHO_REQUEST] ||
  1159. icmp6stat.icp6s_inhist[ICMP6_ECHO_REPLY] ||
  1160. icmp6stat.icp6s_outhist[ICMP6_ECHO_REPLY] ||
  1161. netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) {
  1162. do_icmp6_echos = CONFIG_BOOLEAN_YES;
  1163. st = rrdset_find_active_localhost("ipv6.icmpechos");
  1164. if (unlikely(!st)) {
  1165. st = rrdset_create_localhost(
  1166. "ipv6"
  1167. , "icmpechos"
  1168. , NULL
  1169. , "icmp"
  1170. , NULL
  1171. , "IPv6 ICMP Echo"
  1172. , "messages/s"
  1173. , "macos.plugin"
  1174. , "sysctl"
  1175. , 10200
  1176. , update_every
  1177. , RRDSET_TYPE_LINE
  1178. );
  1179. rrddim_add(st, "InEchos", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
  1180. rrddim_add(st, "OutEchos", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);
  1181. rrddim_add(st, "InEchoReplies", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
  1182. rrddim_add(st, "OutEchoReplies", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);
  1183. } else
  1184. rrdset_next(st);
  1185. rrddim_set(st, "InEchos", icmp6stat.icp6s_inhist[ICMP6_ECHO_REQUEST]);
  1186. rrddim_set(st, "OutEchos", icmp6stat.icp6s_outhist[ICMP6_ECHO_REQUEST]);
  1187. rrddim_set(st, "InEchoReplies", icmp6stat.icp6s_inhist[ICMP6_ECHO_REPLY]);
  1188. rrddim_set(st, "OutEchoReplies", icmp6stat.icp6s_outhist[ICMP6_ECHO_REPLY]);
  1189. rrdset_done(st);
  1190. }
  1191. // --------------------------------------------------------------------
  1192. if (do_icmp6_router == CONFIG_BOOLEAN_YES || (do_icmp6_router == CONFIG_BOOLEAN_AUTO &&
  1193. (icmp6stat.icp6s_inhist[ND_ROUTER_SOLICIT] ||
  1194. icmp6stat.icp6s_outhist[ND_ROUTER_SOLICIT] ||
  1195. icmp6stat.icp6s_inhist[ND_ROUTER_ADVERT] ||
  1196. icmp6stat.icp6s_outhist[ND_ROUTER_ADVERT] ||
  1197. netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) {
  1198. do_icmp6_router = CONFIG_BOOLEAN_YES;
  1199. st = rrdset_find_active_localhost("ipv6.icmprouter");
  1200. if (unlikely(!st)) {
  1201. st = rrdset_create_localhost(
  1202. "ipv6"
  1203. , "icmprouter"
  1204. , NULL
  1205. , "icmp"
  1206. , NULL
  1207. , "IPv6 Router Messages"
  1208. , "messages/s"
  1209. , "macos.plugin"
  1210. , "sysctl"
  1211. , 10400
  1212. , update_every
  1213. , RRDSET_TYPE_LINE
  1214. );
  1215. rrddim_add(st, "InSolicits", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
  1216. rrddim_add(st, "OutSolicits", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);
  1217. rrddim_add(st, "InAdvertisements", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
  1218. rrddim_add(st, "OutAdvertisements", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);
  1219. } else
  1220. rrdset_next(st);
  1221. rrddim_set(st, "InSolicits", icmp6stat.icp6s_inhist[ND_ROUTER_SOLICIT]);
  1222. rrddim_set(st, "OutSolicits", icmp6stat.icp6s_outhist[ND_ROUTER_SOLICIT]);
  1223. rrddim_set(st, "InAdvertisements", icmp6stat.icp6s_inhist[ND_ROUTER_ADVERT]);
  1224. rrddim_set(st, "OutAdvertisements", icmp6stat.icp6s_outhist[ND_ROUTER_ADVERT]);
  1225. rrdset_done(st);
  1226. }
  1227. // --------------------------------------------------------------------
  1228. if (do_icmp6_neighbor == CONFIG_BOOLEAN_YES || (do_icmp6_neighbor == CONFIG_BOOLEAN_AUTO &&
  1229. (icmp6stat.icp6s_inhist[ND_NEIGHBOR_SOLICIT] ||
  1230. icmp6stat.icp6s_outhist[ND_NEIGHBOR_SOLICIT] ||
  1231. icmp6stat.icp6s_inhist[ND_NEIGHBOR_ADVERT] ||
  1232. icmp6stat.icp6s_outhist[ND_NEIGHBOR_ADVERT] ||
  1233. netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) {
  1234. do_icmp6_neighbor = CONFIG_BOOLEAN_YES;
  1235. st = rrdset_find_active_localhost("ipv6.icmpneighbor");
  1236. if (unlikely(!st)) {
  1237. st = rrdset_create_localhost(
  1238. "ipv6"
  1239. , "icmpneighbor"
  1240. , NULL
  1241. , "icmp"
  1242. , NULL
  1243. , "IPv6 Neighbor Messages"
  1244. , "messages/s"
  1245. , "macos.plugin"
  1246. , "sysctl"
  1247. , 10500
  1248. , update_every
  1249. , RRDSET_TYPE_LINE
  1250. );
  1251. rrddim_add(st, "InSolicits", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
  1252. rrddim_add(st, "OutSolicits", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);
  1253. rrddim_add(st, "InAdvertisements", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
  1254. rrddim_add(st, "OutAdvertisements", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);
  1255. } else
  1256. rrdset_next(st);
  1257. rrddim_set(st, "InSolicits", icmp6stat.icp6s_inhist[ND_NEIGHBOR_SOLICIT]);
  1258. rrddim_set(st, "OutSolicits", icmp6stat.icp6s_outhist[ND_NEIGHBOR_SOLICIT]);
  1259. rrddim_set(st, "InAdvertisements", icmp6stat.icp6s_inhist[ND_NEIGHBOR_ADVERT]);
  1260. rrddim_set(st, "OutAdvertisements", icmp6stat.icp6s_outhist[ND_NEIGHBOR_ADVERT]);
  1261. rrdset_done(st);
  1262. }
  1263. // --------------------------------------------------------------------
  1264. if (do_icmp6_types == CONFIG_BOOLEAN_YES || (do_icmp6_types == CONFIG_BOOLEAN_AUTO &&
  1265. (icmp6stat.icp6s_inhist[1] ||
  1266. icmp6stat.icp6s_inhist[128] ||
  1267. icmp6stat.icp6s_inhist[129] ||
  1268. icmp6stat.icp6s_inhist[136] ||
  1269. icmp6stat.icp6s_outhist[1] ||
  1270. icmp6stat.icp6s_outhist[128] ||
  1271. icmp6stat.icp6s_outhist[129] ||
  1272. icmp6stat.icp6s_outhist[133] ||
  1273. icmp6stat.icp6s_outhist[135] ||
  1274. icmp6stat.icp6s_outhist[136] ||
  1275. netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) {
  1276. do_icmp6_types = CONFIG_BOOLEAN_YES;
  1277. st = rrdset_find_active_localhost("ipv6.icmptypes");
  1278. if (unlikely(!st)) {
  1279. st = rrdset_create_localhost(
  1280. "ipv6"
  1281. , "icmptypes"
  1282. , NULL
  1283. , "icmp"
  1284. , NULL
  1285. , "IPv6 ICMP Types"
  1286. , "messages/s"
  1287. , "macos.plugin"
  1288. , "sysctl"
  1289. , 10700
  1290. , update_every
  1291. , RRDSET_TYPE_LINE
  1292. );
  1293. rrddim_add(st, "InType1", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
  1294. rrddim_add(st, "InType128", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
  1295. rrddim_add(st, "InType129", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
  1296. rrddim_add(st, "InType136", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
  1297. rrddim_add(st, "OutType1", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);
  1298. rrddim_add(st, "OutType128", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);
  1299. rrddim_add(st, "OutType129", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);
  1300. rrddim_add(st, "OutType133", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);
  1301. rrddim_add(st, "OutType135", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);
  1302. rrddim_add(st, "OutType143", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);
  1303. } else
  1304. rrdset_next(st);
  1305. rrddim_set(st, "InType1", icmp6stat.icp6s_inhist[1]);
  1306. rrddim_set(st, "InType128", icmp6stat.icp6s_inhist[128]);
  1307. rrddim_set(st, "InType129", icmp6stat.icp6s_inhist[129]);
  1308. rrddim_set(st, "InType136", icmp6stat.icp6s_inhist[136]);
  1309. rrddim_set(st, "OutType1", icmp6stat.icp6s_outhist[1]);
  1310. rrddim_set(st, "OutType128", icmp6stat.icp6s_outhist[128]);
  1311. rrddim_set(st, "OutType129", icmp6stat.icp6s_outhist[129]);
  1312. rrddim_set(st, "OutType133", icmp6stat.icp6s_outhist[133]);
  1313. rrddim_set(st, "OutType135", icmp6stat.icp6s_outhist[135]);
  1314. rrddim_set(st, "OutType143", icmp6stat.icp6s_outhist[143]);
  1315. rrdset_done(st);
  1316. }
  1317. }
  1318. }
  1319. // --------------------------------------------------------------------
  1320. if (likely(do_uptime)) {
  1321. if (unlikely(GETSYSCTL_BY_NAME("kern.boottime", boot_time))) {
  1322. do_uptime = 0;
  1323. error("DISABLED: system.uptime");
  1324. } else {
  1325. clock_gettime(CLOCK_REALTIME, &cur_time);
  1326. st = rrdset_find_active_localhost("system.uptime");
  1327. if(unlikely(!st)) {
  1328. st = rrdset_create_localhost(
  1329. "system"
  1330. , "uptime"
  1331. , NULL
  1332. , "uptime"
  1333. , NULL
  1334. , "System Uptime"
  1335. , "seconds"
  1336. , "macos.plugin"
  1337. , "sysctl"
  1338. , 1000
  1339. , update_every
  1340. , RRDSET_TYPE_LINE
  1341. );
  1342. rrddim_add(st, "uptime", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
  1343. }
  1344. else rrdset_next(st);
  1345. rrddim_set(st, "uptime", cur_time.tv_sec - boot_time.tv_sec);
  1346. rrdset_done(st);
  1347. }
  1348. }
  1349. return 0;
  1350. }