@cryptotaxi247 / netdata-1 / commits / 41b96a419

Add IPv6 charts to macOS plugin

Vladimir Kobal committed Jan 9, 2017 at 16:45 UTC 41b96a419eaee9e1923af56b07a7014b91bdd129
1 file changed +463 -1
src/macos_sysctl.c
+463 -1
@@ -15,6 +15,8 @@
15 #include <netinet/ip.h>
16 #include <netinet/ip_icmp.h>
17 #include <netinet/icmp_var.h>
18 +// NEEDED BY do_icmp6...
19 +#include <netinet/icmp6.h>
20
21 #define GETSYSCTL(name, var) getsysctl(name, &(var), sizeof(var))
22
@@ -30,7 +32,10 @@ int do_macos_sysctl(int update_every, usec_t dt) {
32 do_tcp_packets = -1, do_tcp_errors = -1, do_tcp_handshake = -1, do_ecn = -1,
33 do_tcpext_syscookies = -1, do_tcpext_ofo = -1, do_tcpext_connaborts = -1,
34 do_udp_packets = -1, do_udp_errors = -1, do_icmp_packets = -1, do_icmpmsg = -1,
33 - do_ip_packets = -1, do_ip_fragsout = -1, do_ip_fragsin = -1, do_ip_errors = -1;
35 + do_ip_packets = -1, do_ip_fragsout = -1, do_ip_fragsin = -1, do_ip_errors = -1,
36 + do_ip6_packets = -1, do_ip6_fragsout = -1, do_ip6_fragsin = -1, do_ip6_errors = -1,
37 + do_icmp6 = -1, do_icmp6_redir = -1, do_icmp6_errors = -1, do_icmp6_echos = -1,
38 + do_icmp6_router = -1, do_icmp6_neighbor = -1, do_icmp6_types = -1;
39
40
41 if (unlikely(do_loadavg == -1)) {
@@ -52,6 +57,17 @@ int do_macos_sysctl(int update_every, usec_t dt) {
57 do_ip_fragsout = config_get_boolean("plugin:freebsd:sysctl", "ipv4 fragments sent", 1);
58 do_ip_fragsin = config_get_boolean("plugin:freebsd:sysctl", "ipv4 fragments assembly", 1);
59 do_ip_errors = config_get_boolean("plugin:freebsd:sysctl", "ipv4 errors", 1);
60 + do_ip6_packets = config_get_boolean_ondemand("plugin:freebsd:sysctl", "ipv6 packets", CONFIG_ONDEMAND_ONDEMAND);
61 + do_ip6_fragsout = config_get_boolean_ondemand("plugin:freebsd:sysctl", "ipv6 fragments sent", CONFIG_ONDEMAND_ONDEMAND);
62 + do_ip6_fragsin = config_get_boolean_ondemand("plugin:freebsd:sysctl", "ipv6 fragments assembly", CONFIG_ONDEMAND_ONDEMAND);
63 + do_ip6_errors = config_get_boolean_ondemand("plugin:freebsd:sysctl", "ipv6 errors", CONFIG_ONDEMAND_ONDEMAND);
64 + do_icmp6 = config_get_boolean_ondemand("plugin:freebsd:sysctl", "icmp", CONFIG_ONDEMAND_ONDEMAND);
65 + do_icmp6_redir = config_get_boolean_ondemand("plugin:freebsd:sysctl", "icmp redirects", CONFIG_ONDEMAND_ONDEMAND);
66 + do_icmp6_errors = config_get_boolean_ondemand("plugin:freebsd:sysctl", "icmp errors", CONFIG_ONDEMAND_ONDEMAND);
67 + do_icmp6_echos = config_get_boolean_ondemand("plugin:freebsd:sysctl", "icmp echos", CONFIG_ONDEMAND_ONDEMAND);
68 + do_icmp6_router = config_get_boolean_ondemand("plugin:freebsd:sysctl", "icmp router", CONFIG_ONDEMAND_ONDEMAND);
69 + do_icmp6_neighbor = config_get_boolean_ondemand("plugin:freebsd:sysctl", "icmp neighbor", CONFIG_ONDEMAND_ONDEMAND);
70 + do_icmp6_types = config_get_boolean_ondemand("plugin:freebsd:sysctl", "icmp types", CONFIG_ONDEMAND_ONDEMAND);
71 }
72
73 RRDSET *st;
@@ -95,6 +111,101 @@ int do_macos_sysctl(int update_every, usec_t dt) {
111 // NEEDED BY: do_ip...
112 struct ipstat ipstat;
113
114 + // NEEDED BY: do_ip6...
115 + /*
116 + * Dirty workaround for /usr/include/netinet6/ip6_var.h absense.
117 + * Struct ip6stat was copied from bsd/netinet6/ip6_var.h from xnu sources.
118 + */
119 +#define IP6S_SRCRULE_COUNT 16
120 +#include <netinet6/scope6_var.h>
121 + struct ip6stat {
122 + u_quad_t ip6s_total; /* total packets received */
123 + u_quad_t ip6s_tooshort; /* packet too short */
124 + u_quad_t ip6s_toosmall; /* not enough data */
125 + u_quad_t ip6s_fragments; /* fragments received */
126 + u_quad_t ip6s_fragdropped; /* frags dropped(dups, out of space) */
127 + u_quad_t ip6s_fragtimeout; /* fragments timed out */
128 + u_quad_t ip6s_fragoverflow; /* fragments that exceeded limit */
129 + u_quad_t ip6s_forward; /* packets forwarded */
130 + u_quad_t ip6s_cantforward; /* packets rcvd for unreachable dest */
131 + u_quad_t ip6s_redirectsent; /* packets forwarded on same net */
132 + u_quad_t ip6s_delivered; /* datagrams delivered to upper level */
133 + u_quad_t ip6s_localout; /* total ip packets generated here */
134 + u_quad_t ip6s_odropped; /* lost packets due to nobufs, etc. */
135 + u_quad_t ip6s_reassembled; /* total packets reassembled ok */
136 + u_quad_t ip6s_atmfrag_rcvd; /* atomic fragments received */
137 + u_quad_t ip6s_fragmented; /* datagrams successfully fragmented */
138 + u_quad_t ip6s_ofragments; /* output fragments created */
139 + u_quad_t ip6s_cantfrag; /* don't fragment flag was set, etc. */
140 + u_quad_t ip6s_badoptions; /* error in option processing */
141 + u_quad_t ip6s_noroute; /* packets discarded due to no route */
142 + u_quad_t ip6s_badvers; /* ip6 version != 6 */
143 + u_quad_t ip6s_rawout; /* total raw ip packets generated */
144 + u_quad_t ip6s_badscope; /* scope error */
145 + u_quad_t ip6s_notmember; /* don't join this multicast group */
146 + u_quad_t ip6s_nxthist[256]; /* next header history */
147 + u_quad_t ip6s_m1; /* one mbuf */
148 + u_quad_t ip6s_m2m[32]; /* two or more mbuf */
149 + u_quad_t ip6s_mext1; /* one ext mbuf */
150 + u_quad_t ip6s_mext2m; /* two or more ext mbuf */
151 + u_quad_t ip6s_exthdrtoolong; /* ext hdr are not continuous */
152 + u_quad_t ip6s_nogif; /* no match gif found */
153 + u_quad_t ip6s_toomanyhdr; /* discarded due to too many headers */
154 +
155 + /*
156 + * statistics for improvement of the source address selection
157 + * algorithm:
158 + */
159 + /* number of times that address selection fails */
160 + u_quad_t ip6s_sources_none;
161 + /* number of times that an address on the outgoing I/F is chosen */
162 + u_quad_t ip6s_sources_sameif[SCOPE6_ID_MAX];
163 + /* number of times that an address on a non-outgoing I/F is chosen */
164 + u_quad_t ip6s_sources_otherif[SCOPE6_ID_MAX];
165 + /*
166 + * number of times that an address that has the same scope
167 + * from the destination is chosen.
168 + */
169 + u_quad_t ip6s_sources_samescope[SCOPE6_ID_MAX];
170 + /*
171 + * number of times that an address that has a different scope
172 + * from the destination is chosen.
173 + */
174 + u_quad_t ip6s_sources_otherscope[SCOPE6_ID_MAX];
175 + /* number of times that a deprecated address is chosen */
176 + u_quad_t ip6s_sources_deprecated[SCOPE6_ID_MAX];
177 +
178 + u_quad_t ip6s_forward_cachehit;
179 + u_quad_t ip6s_forward_cachemiss;
180 +
181 + /* number of times that each rule of source selection is applied. */
182 + u_quad_t ip6s_sources_rule[IP6S_SRCRULE_COUNT];
183 +
184 + /* number of times we ignored address on expensive secondary interfaces */
185 + u_quad_t ip6s_sources_skip_expensive_secondary_if;
186 +
187 + /* pkt dropped, no mbufs for control data */
188 + u_quad_t ip6s_pktdropcntrl;
189 +
190 + /* total packets trimmed/adjusted */
191 + u_quad_t ip6s_adj;
192 + /* hwcksum info discarded during adjustment */
193 + u_quad_t ip6s_adj_hwcsum_clr;
194 +
195 + /* duplicate address detection collisions */
196 + u_quad_t ip6s_dad_collide;
197 +
198 + /* DAD NS looped back */
199 + u_quad_t ip6s_dad_loopcount;
200 + } ip6stat;
201 +
202 + // NEEDED BY: do_icmp6...
203 + struct icmp6stat icmp6stat;
204 + struct icmp6_total {
205 + u_long msgs_in;
206 + u_long msgs_out;
207 + } icmp6_total = {0, 0};
208 +
209 // --------------------------------------------------------------------
210
211 if (last_loadavg_usec <= dt) {
@@ -603,6 +714,357 @@ int do_macos_sysctl(int update_every, usec_t dt) {
714 }
715 }
716
717 + // --------------------------------------------------------------------
718 +
719 + if (likely(do_ip6_packets || do_ip6_fragsout || do_ip6_fragsin || do_ip6_errors)) {
720 + if (unlikely(GETSYSCTL("net.inet6.ip6.stats", ip6stat))) {
721 + do_ip6_packets = 0;
722 + error("DISABLED: ipv6.packets");
723 + do_ip6_fragsout = 0;
724 + error("DISABLED: ipv6.fragsout");
725 + do_ip6_fragsin = 0;
726 + error("DISABLED: ipv6.fragsin");
727 + do_ip6_errors = 0;
728 + error("DISABLED: ipv6.errors");
729 + } else {
730 + if (do_ip6_packets == CONFIG_ONDEMAND_YES || (do_ip6_packets == CONFIG_ONDEMAND_ONDEMAND &&
731 + (ip6stat.ip6s_localout || ip6stat.ip6s_total ||
732 + ip6stat.ip6s_forward || ip6stat.ip6s_delivered))) {
733 + do_ip6_packets = CONFIG_ONDEMAND_YES;
734 + st = rrdset_find("ipv6.packets");
735 + if (unlikely(!st)) {
736 + st = rrdset_create("ipv6", "packets", NULL, "packets", NULL, "IPv6 Packets", "packets/s", 3000,
737 + update_every, RRDSET_TYPE_LINE);
738 +
739 + rrddim_add(st, "received", NULL, 1, 1, RRDDIM_INCREMENTAL);
740 + rrddim_add(st, "sent", NULL, -1, 1, RRDDIM_INCREMENTAL);
741 + rrddim_add(st, "forwarded", NULL, 1, 1, RRDDIM_INCREMENTAL);
742 + rrddim_add(st, "delivers", NULL, -1, 1, RRDDIM_INCREMENTAL);
743 + } else
744 + rrdset_next(st);
745 +
746 + rrddim_set(st, "sent", ip6stat.ip6s_localout);
747 + rrddim_set(st, "received", ip6stat.ip6s_total);
748 + rrddim_set(st, "forwarded", ip6stat.ip6s_forward);
749 + rrddim_set(st, "delivers", ip6stat.ip6s_delivered);
750 + rrdset_done(st);
751 + }
752 +
753 + // --------------------------------------------------------------------
754 +
755 + if (do_ip6_fragsout == CONFIG_ONDEMAND_YES || (do_ip6_fragsout == CONFIG_ONDEMAND_ONDEMAND &&
756 + (ip6stat.ip6s_fragmented || ip6stat.ip6s_cantfrag ||
757 + ip6stat.ip6s_ofragments))) {
758 + do_ip6_fragsout = CONFIG_ONDEMAND_YES;
759 + st = rrdset_find("ipv6.fragsout");
760 + if (unlikely(!st)) {
761 + st = rrdset_create("ipv6", "fragsout", NULL, "fragments", NULL, "IPv6 Fragments Sent",
762 + "packets/s", 3010, update_every, RRDSET_TYPE_LINE);
763 + st->isdetail = 1;
764 +
765 + rrddim_add(st, "ok", NULL, 1, 1, RRDDIM_INCREMENTAL);
766 + rrddim_add(st, "failed", NULL, -1, 1, RRDDIM_INCREMENTAL);
767 + rrddim_add(st, "all", NULL, 1, 1, RRDDIM_INCREMENTAL);
768 + } else
769 + rrdset_next(st);
770 +
771 + rrddim_set(st, "ok", ip6stat.ip6s_fragmented);
772 + rrddim_set(st, "failed", ip6stat.ip6s_cantfrag);
773 + rrddim_set(st, "all", ip6stat.ip6s_ofragments);
774 + rrdset_done(st);
775 + }
776 +
777 + // --------------------------------------------------------------------
778 +
779 + if (do_ip6_fragsin == CONFIG_ONDEMAND_YES || (do_ip6_fragsin == CONFIG_ONDEMAND_ONDEMAND &&
780 + (ip6stat.ip6s_reassembled || ip6stat.ip6s_fragdropped ||
781 + ip6stat.ip6s_fragtimeout || ip6stat.ip6s_fragments))) {
782 + do_ip6_fragsin = CONFIG_ONDEMAND_YES;
783 + st = rrdset_find("ipv6.fragsin");
784 + if (unlikely(!st)) {
785 + st = rrdset_create("ipv6", "fragsin", NULL, "fragments", NULL, "IPv6 Fragments Reassembly",
786 + "packets/s", 3011, update_every, RRDSET_TYPE_LINE);
787 + st->isdetail = 1;
788 +
789 + rrddim_add(st, "ok", NULL, 1, 1, RRDDIM_INCREMENTAL);
790 + rrddim_add(st, "failed", NULL, -1, 1, RRDDIM_INCREMENTAL);
791 + rrddim_add(st, "timeout", NULL, -1, 1, RRDDIM_INCREMENTAL);
792 + rrddim_add(st, "all", NULL, 1, 1, RRDDIM_INCREMENTAL);
793 + } else
794 + rrdset_next(st);
795 +
796 + rrddim_set(st, "ok", ip6stat.ip6s_reassembled);
797 + rrddim_set(st, "failed", ip6stat.ip6s_fragdropped);
798 + rrddim_set(st, "timeout", ip6stat.ip6s_fragtimeout);
799 + rrddim_set(st, "all", ip6stat.ip6s_fragments);
800 + rrdset_done(st);
801 + }
802 +
803 + // --------------------------------------------------------------------
804 +
805 + if (do_ip6_errors == CONFIG_ONDEMAND_YES || (do_ip6_errors == CONFIG_ONDEMAND_ONDEMAND && (
806 + ip6stat.ip6s_toosmall ||
807 + ip6stat.ip6s_odropped ||
808 + ip6stat.ip6s_badoptions ||
809 + ip6stat.ip6s_badvers ||
810 + ip6stat.ip6s_exthdrtoolong ||
811 + ip6stat.ip6s_sources_none ||
812 + ip6stat.ip6s_tooshort ||
813 + ip6stat.ip6s_cantforward ||
814 + ip6stat.ip6s_noroute))) {
815 + do_ip6_errors = CONFIG_ONDEMAND_YES;
816 + st = rrdset_find("ipv6.errors");
817 + if (unlikely(!st)) {
818 + st = rrdset_create("ipv6", "errors", NULL, "errors", NULL, "IPv6 Errors", "packets/s", 3002,
819 + update_every, RRDSET_TYPE_LINE);
820 + st->isdetail = 1;
821 +
822 + rrddim_add(st, "InDiscards", NULL, 1, 1, RRDDIM_INCREMENTAL);
823 + rrddim_add(st, "OutDiscards", NULL, -1, 1, RRDDIM_INCREMENTAL);
824 +
825 + rrddim_add(st, "InHdrErrors", NULL, 1, 1, RRDDIM_INCREMENTAL);
826 + rrddim_add(st, "InAddrErrors", NULL, 1, 1, RRDDIM_INCREMENTAL);
827 + rrddim_add(st, "InTruncatedPkts", NULL, 1, 1, RRDDIM_INCREMENTAL);
828 + rrddim_add(st, "InNoRoutes", NULL, 1, 1, RRDDIM_INCREMENTAL);
829 +
830 + rrddim_add(st, "OutNoRoutes", NULL, -1, 1, RRDDIM_INCREMENTAL);
831 + } else
832 + rrdset_next(st);
833 +
834 + rrddim_set(st, "InDiscards", ip6stat.ip6s_toosmall);
835 + rrddim_set(st, "OutDiscards", ip6stat.ip6s_odropped);
836 +
837 + rrddim_set(st, "InHdrErrors",
838 + ip6stat.ip6s_badoptions + ip6stat.ip6s_badvers + ip6stat.ip6s_exthdrtoolong);
839 + rrddim_set(st, "InAddrErrors", ip6stat.ip6s_sources_none);
840 + rrddim_set(st, "InTruncatedPkts", ip6stat.ip6s_tooshort);
841 + rrddim_set(st, "InNoRoutes", ip6stat.ip6s_cantforward);
842 +
843 + rrddim_set(st, "OutNoRoutes", ip6stat.ip6s_noroute);
844 + rrdset_done(st);
845 + }
846 + }
847 + }
848 +
849 + // --------------------------------------------------------------------
850 +
851 + if (likely(do_icmp6 || do_icmp6_redir || do_icmp6_errors || do_icmp6_echos || do_icmp6_router || do_icmp6_neighbor || do_icmp6_types)) {
852 + if (unlikely(GETSYSCTL("net.inet6.icmp6.stats", icmp6stat))) {
853 + do_icmp6 = 0;
854 + error("DISABLED: ipv6.icmp");
855 + } else {
856 + for (i = 0; i <= ICMP6_MAXTYPE; i++) {
857 + icmp6_total.msgs_in += icmp6stat.icp6s_inhist[i];
858 + icmp6_total.msgs_out += icmp6stat.icp6s_outhist[i];
859 + }
860 + icmp6_total.msgs_in += icmp6stat.icp6s_badcode + icmp6stat.icp6s_badlen + icmp6stat.icp6s_checksum + icmp6stat.icp6s_tooshort;
861 + if (do_icmp6 == CONFIG_ONDEMAND_YES || (do_icmp6 == CONFIG_ONDEMAND_ONDEMAND && (icmp6_total.msgs_in || icmp6_total.msgs_out))) {
862 + do_icmp6 = CONFIG_ONDEMAND_YES;
863 + st = rrdset_find("ipv6.icmp");
864 + if (unlikely(!st)) {
865 + st = rrdset_create("ipv6", "icmp", NULL, "icmp", NULL, "IPv6 ICMP Messages",
866 + "messages/s", 10000, update_every, RRDSET_TYPE_LINE);
867 +
868 + rrddim_add(st, "received", NULL, 1, 1, RRDDIM_INCREMENTAL);
869 + rrddim_add(st, "sent", NULL, -1, 1, RRDDIM_INCREMENTAL);
870 + } else
871 + rrdset_next(st);
872 +
873 + rrddim_set(st, "sent", icmp6_total.msgs_in);
874 + rrddim_set(st, "received", icmp6_total.msgs_out);
875 + rrdset_done(st);
876 + }
877 +
878 + // --------------------------------------------------------------------
879 +
880 + if (do_icmp6_redir == CONFIG_ONDEMAND_YES || (do_icmp6_redir == CONFIG_ONDEMAND_ONDEMAND && (icmp6stat.icp6s_inhist[ND_REDIRECT] || icmp6stat.icp6s_outhist[ND_REDIRECT]))) {
881 + do_icmp6_redir = CONFIG_ONDEMAND_YES;
882 + st = rrdset_find("ipv6.icmpredir");
883 + if (unlikely(!st)) {
884 + st = rrdset_create("ipv6", "icmpredir", NULL, "icmp", NULL, "IPv6 ICMP Redirects",
885 + "redirects/s", 10050, update_every, RRDSET_TYPE_LINE);
886 +
887 + rrddim_add(st, "received", NULL, 1, 1, RRDDIM_INCREMENTAL);
888 + rrddim_add(st, "sent", NULL, -1, 1, RRDDIM_INCREMENTAL);
889 + } else
890 + rrdset_next(st);
891 +
892 + rrddim_set(st, "sent", icmp6stat.icp6s_inhist[ND_REDIRECT]);
893 + rrddim_set(st, "received", icmp6stat.icp6s_outhist[ND_REDIRECT]);
894 + rrdset_done(st);
895 + }
896 +
897 + // --------------------------------------------------------------------
898 +
899 + if (do_icmp6_errors == CONFIG_ONDEMAND_YES || (do_icmp6_errors == CONFIG_ONDEMAND_ONDEMAND && (
900 + icmp6stat.icp6s_badcode ||
901 + icmp6stat.icp6s_badlen ||
902 + icmp6stat.icp6s_checksum ||
903 + icmp6stat.icp6s_tooshort ||
904 + icmp6stat.icp6s_error ||
905 + icmp6stat.icp6s_inhist[ICMP6_DST_UNREACH] ||
906 + icmp6stat.icp6s_inhist[ICMP6_TIME_EXCEEDED] ||
907 + icmp6stat.icp6s_inhist[ICMP6_PARAM_PROB] ||
908 + icmp6stat.icp6s_outhist[ICMP6_DST_UNREACH] ||
909 + icmp6stat.icp6s_outhist[ICMP6_TIME_EXCEEDED] ||
910 + icmp6stat.icp6s_outhist[ICMP6_PARAM_PROB]))) {
911 + do_icmp6_errors = CONFIG_ONDEMAND_YES;
912 + st = rrdset_find("ipv6.icmperrors");
913 + if (unlikely(!st)) {
914 + st = rrdset_create("ipv6", "icmperrors", NULL, "icmp", NULL, "IPv6 ICMP Errors", "errors/s", 10100, update_every, RRDSET_TYPE_LINE);
915 +
916 + rrddim_add(st, "InErrors", NULL, 1, 1, RRDDIM_INCREMENTAL);
917 + rrddim_add(st, "OutErrors", NULL, -1, 1, RRDDIM_INCREMENTAL);
918 +
919 + rrddim_add(st, "InCsumErrors", NULL, 1, 1, RRDDIM_INCREMENTAL);
920 + rrddim_add(st, "InDestUnreachs", NULL, 1, 1, RRDDIM_INCREMENTAL);
921 + rrddim_add(st, "InPktTooBigs", NULL, 1, 1, RRDDIM_INCREMENTAL);
922 + rrddim_add(st, "InTimeExcds", NULL, 1, 1, RRDDIM_INCREMENTAL);
923 + rrddim_add(st, "InParmProblems", NULL, 1, 1, RRDDIM_INCREMENTAL);
924 + rrddim_add(st, "OutDestUnreachs", NULL, -1, 1, RRDDIM_INCREMENTAL);
925 + rrddim_add(st, "OutTimeExcds", NULL, -1, 1, RRDDIM_INCREMENTAL);
926 + rrddim_add(st, "OutParmProblems", NULL, -1, 1, RRDDIM_INCREMENTAL);
927 + } else
928 + rrdset_next(st);
929 +
930 + rrddim_set(st, "InErrors", icmp6stat.icp6s_badcode + icmp6stat.icp6s_badlen + icmp6stat.icp6s_checksum + icmp6stat.icp6s_tooshort);
931 + rrddim_set(st, "OutErrors", icmp6stat.icp6s_error);
932 + rrddim_set(st, "InCsumErrors", icmp6stat.icp6s_checksum);
933 + rrddim_set(st, "InDestUnreachs", icmp6stat.icp6s_inhist[ICMP6_DST_UNREACH]);
934 + rrddim_set(st, "InPktTooBigs", icmp6stat.icp6s_badlen);
935 + rrddim_set(st, "InTimeExcds", icmp6stat.icp6s_inhist[ICMP6_TIME_EXCEEDED]);
936 + rrddim_set(st, "InParmProblems", icmp6stat.icp6s_inhist[ICMP6_PARAM_PROB]);
937 + rrddim_set(st, "OutDestUnreachs", icmp6stat.icp6s_outhist[ICMP6_DST_UNREACH]);
938 + rrddim_set(st, "OutTimeExcds", icmp6stat.icp6s_outhist[ICMP6_TIME_EXCEEDED]);
939 + rrddim_set(st, "OutParmProblems", icmp6stat.icp6s_outhist[ICMP6_PARAM_PROB]);
940 + rrdset_done(st);
941 + }
942 +
943 + // --------------------------------------------------------------------
944 +
945 + if (do_icmp6_echos == CONFIG_ONDEMAND_YES || (do_icmp6_echos == CONFIG_ONDEMAND_ONDEMAND && (
946 + icmp6stat.icp6s_inhist[ICMP6_ECHO_REQUEST] ||
947 + icmp6stat.icp6s_outhist[ICMP6_ECHO_REQUEST] ||
948 + icmp6stat.icp6s_inhist[ICMP6_ECHO_REPLY] ||
949 + icmp6stat.icp6s_outhist[ICMP6_ECHO_REPLY]))) {
950 + do_icmp6_echos = CONFIG_ONDEMAND_YES;
951 + st = rrdset_find("ipv6.icmpechos");
952 + if (unlikely(!st)) {
953 + st = rrdset_create("ipv6", "icmpechos", NULL, "icmp", NULL, "IPv6 ICMP Echo", "messages/s", 10200, update_every, RRDSET_TYPE_LINE);
954 +
955 + rrddim_add(st, "InEchos", NULL, 1, 1, RRDDIM_INCREMENTAL);
956 + rrddim_add(st, "OutEchos", NULL, -1, 1, RRDDIM_INCREMENTAL);
957 + rrddim_add(st, "InEchoReplies", NULL, 1, 1, RRDDIM_INCREMENTAL);
958 + rrddim_add(st, "OutEchoReplies", NULL, -1, 1, RRDDIM_INCREMENTAL);
959 + } else
960 + rrdset_next(st);
961 +
962 + rrddim_set(st, "InEchos", icmp6stat.icp6s_inhist[ICMP6_ECHO_REQUEST]);
963 + rrddim_set(st, "OutEchos", icmp6stat.icp6s_outhist[ICMP6_ECHO_REQUEST]);
964 + rrddim_set(st, "InEchoReplies", icmp6stat.icp6s_inhist[ICMP6_ECHO_REPLY]);
965 + rrddim_set(st, "OutEchoReplies", icmp6stat.icp6s_outhist[ICMP6_ECHO_REPLY]);
966 + rrdset_done(st);
967 + }
968 +
969 + // --------------------------------------------------------------------
970 +
971 + if (do_icmp6_router == CONFIG_ONDEMAND_YES || (do_icmp6_router == CONFIG_ONDEMAND_ONDEMAND && (
972 + icmp6stat.icp6s_inhist[ND_ROUTER_SOLICIT] ||
973 + icmp6stat.icp6s_outhist[ND_ROUTER_SOLICIT] ||
974 + icmp6stat.icp6s_inhist[ND_ROUTER_ADVERT] ||
975 + icmp6stat.icp6s_outhist[ND_ROUTER_ADVERT]))) {
976 + do_icmp6_router = CONFIG_ONDEMAND_YES;
977 + st = rrdset_find("ipv6.icmprouter");
978 + if (unlikely(!st)) {
979 + st = rrdset_create("ipv6", "icmprouter", NULL, "icmp", NULL, "IPv6 Router Messages", "messages/s", 10400, update_every, RRDSET_TYPE_LINE);
980 +
981 + rrddim_add(st, "InSolicits", NULL, 1, 1, RRDDIM_INCREMENTAL);
982 + rrddim_add(st, "OutSolicits", NULL, -1, 1, RRDDIM_INCREMENTAL);
983 + rrddim_add(st, "InAdvertisements", NULL, 1, 1, RRDDIM_INCREMENTAL);
984 + rrddim_add(st, "OutAdvertisements", NULL, -1, 1, RRDDIM_INCREMENTAL);
985 + } else
986 + rrdset_next(st);
987 +
988 + rrddim_set(st, "InSolicits", icmp6stat.icp6s_inhist[ND_ROUTER_SOLICIT]);
989 + rrddim_set(st, "OutSolicits", icmp6stat.icp6s_outhist[ND_ROUTER_SOLICIT]);
990 + rrddim_set(st, "InAdvertisements", icmp6stat.icp6s_inhist[ND_ROUTER_ADVERT]);
991 + rrddim_set(st, "OutAdvertisements", icmp6stat.icp6s_outhist[ND_ROUTER_ADVERT]);
992 + rrdset_done(st);
993 + }
994 +
995 + // --------------------------------------------------------------------
996 +
997 + if (do_icmp6_neighbor == CONFIG_ONDEMAND_YES || (do_icmp6_neighbor == CONFIG_ONDEMAND_ONDEMAND && (
998 + icmp6stat.icp6s_inhist[ND_NEIGHBOR_SOLICIT] ||
999 + icmp6stat.icp6s_outhist[ND_NEIGHBOR_SOLICIT] ||
1000 + icmp6stat.icp6s_inhist[ND_NEIGHBOR_ADVERT] ||
1001 + icmp6stat.icp6s_outhist[ND_NEIGHBOR_ADVERT]))) {
1002 + do_icmp6_neighbor = CONFIG_ONDEMAND_YES;
1003 + st = rrdset_find("ipv6.icmpneighbor");
1004 + if (unlikely(!st)) {
1005 + st = rrdset_create("ipv6", "icmpneighbor", NULL, "icmp", NULL, "IPv6 Neighbor Messages", "messages/s", 10500, update_every, RRDSET_TYPE_LINE);
1006 +
1007 + rrddim_add(st, "InSolicits", NULL, 1, 1, RRDDIM_INCREMENTAL);
1008 + rrddim_add(st, "OutSolicits", NULL, -1, 1, RRDDIM_INCREMENTAL);
1009 + rrddim_add(st, "InAdvertisements", NULL, 1, 1, RRDDIM_INCREMENTAL);
1010 + rrddim_add(st, "OutAdvertisements", NULL, -1, 1, RRDDIM_INCREMENTAL);
1011 + } else
1012 + rrdset_next(st);
1013 +
1014 + rrddim_set(st, "InSolicits", icmp6stat.icp6s_inhist[ND_NEIGHBOR_SOLICIT]);
1015 + rrddim_set(st, "OutSolicits", icmp6stat.icp6s_outhist[ND_NEIGHBOR_SOLICIT]);
1016 + rrddim_set(st, "InAdvertisements", icmp6stat.icp6s_inhist[ND_NEIGHBOR_ADVERT]);
1017 + rrddim_set(st, "OutAdvertisements", icmp6stat.icp6s_outhist[ND_NEIGHBOR_ADVERT]);
1018 + rrdset_done(st);
1019 + }
1020 +
1021 + // --------------------------------------------------------------------
1022 +
1023 + if (do_icmp6_types == CONFIG_ONDEMAND_YES || (do_icmp6_types == CONFIG_ONDEMAND_ONDEMAND && (
1024 + icmp6stat.icp6s_inhist[1] ||
1025 + icmp6stat.icp6s_inhist[128] ||
1026 + icmp6stat.icp6s_inhist[129] ||
1027 + icmp6stat.icp6s_inhist[136] ||
1028 + icmp6stat.icp6s_outhist[1] ||
1029 + icmp6stat.icp6s_outhist[128] ||
1030 + icmp6stat.icp6s_outhist[129] ||
1031 + icmp6stat.icp6s_outhist[133] ||
1032 + icmp6stat.icp6s_outhist[135] ||
1033 + icmp6stat.icp6s_outhist[136]))) {
1034 + do_icmp6_types = CONFIG_ONDEMAND_YES;
1035 + st = rrdset_find("ipv6.icmptypes");
1036 + if (unlikely(!st)) {
1037 + st = rrdset_create("ipv6", "icmptypes", NULL, "icmp", NULL, "IPv6 ICMP Types",
1038 + "messages/s", 10700, update_every, RRDSET_TYPE_LINE);
1039 +
1040 + rrddim_add(st, "InType1", NULL, 1, 1, RRDDIM_INCREMENTAL);
1041 + rrddim_add(st, "InType128", NULL, 1, 1, RRDDIM_INCREMENTAL);
1042 + rrddim_add(st, "InType129", NULL, 1, 1, RRDDIM_INCREMENTAL);
1043 + rrddim_add(st, "InType136", NULL, 1, 1, RRDDIM_INCREMENTAL);
1044 + rrddim_add(st, "OutType1", NULL, -1, 1, RRDDIM_INCREMENTAL);
1045 + rrddim_add(st, "OutType128", NULL, -1, 1, RRDDIM_INCREMENTAL);
1046 + rrddim_add(st, "OutType129", NULL, -1, 1, RRDDIM_INCREMENTAL);
1047 + rrddim_add(st, "OutType133", NULL, -1, 1, RRDDIM_INCREMENTAL);
1048 + rrddim_add(st, "OutType135", NULL, -1, 1, RRDDIM_INCREMENTAL);
1049 + rrddim_add(st, "OutType143", NULL, -1, 1, RRDDIM_INCREMENTAL);
1050 + } else
1051 + rrdset_next(st);
1052 +
1053 + rrddim_set(st, "InType1", icmp6stat.icp6s_inhist[1]);
1054 + rrddim_set(st, "InType128", icmp6stat.icp6s_inhist[128]);
1055 + rrddim_set(st, "InType129", icmp6stat.icp6s_inhist[129]);
1056 + rrddim_set(st, "InType136", icmp6stat.icp6s_inhist[136]);
1057 + rrddim_set(st, "OutType1", icmp6stat.icp6s_outhist[1]);
1058 + rrddim_set(st, "OutType128", icmp6stat.icp6s_outhist[128]);
1059 + rrddim_set(st, "OutType129", icmp6stat.icp6s_outhist[129]);
1060 + rrddim_set(st, "OutType133", icmp6stat.icp6s_outhist[133]);
1061 + rrddim_set(st, "OutType135", icmp6stat.icp6s_outhist[135]);
1062 + rrddim_set(st, "OutType143", icmp6stat.icp6s_outhist[143]);
1063 + rrdset_done(st);
1064 + }
1065 + }
1066 + }
1067 +
1068 return 0;
1069 }
1070