macos_sysctl.c 71 KB

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