@cryptotaxi247 / netdata-1 / commits / 3af05bcbb

do not create ipv4 charts with just zero values; fixes #3706

Costa Tsaousis (ktsaou) committed May 10, 2018 at 16:42 UTC 3af05bcbb2aa196f97abf6f9ce9f8c7c20dbee5c
2 files changed +113 -45
src/common.h
+4 -1
@@ -163,7 +163,10 @@
163
164 #define NETDATA_CHART_PRIO_IPV4 3000
165 #define NETDATA_CHART_PRIO_IPV4_SOCKETS 3000
166 -#define NETDATA_CHART_PRIO_IPV4_ERRORS 3120
166 +#define NETDATA_CHART_PRIO_IPV4_PACKETS 3050
167 +#define NETDATA_CHART_PRIO_IPV4_ERRORS 3100
168 +
169 +#define NETDATA_CHART_PRIO_IPV4_ICMP 3150
170
171 #define NETDATA_CHART_PRIO_IPV4_TCP 3200
172 #define NETDATA_CHART_PRIO_IPV4_TCP_MEM 3290
src/proc_net_snmp.c
+109 -44
@@ -105,20 +105,20 @@ int do_proc_net_snmp(int update_every, usec_t dt) {
105 static ssize_t last_max_connections = 0;
106
107 if(unlikely(!arl_ip)) {
108 - do_ip_packets = config_get_boolean("plugin:proc:/proc/net/snmp", "ipv4 packets", 1);
109 - do_ip_fragsout = config_get_boolean("plugin:proc:/proc/net/snmp", "ipv4 fragments sent", 1);
110 - do_ip_fragsin = config_get_boolean("plugin:proc:/proc/net/snmp", "ipv4 fragments assembly", 1);
111 - do_ip_errors = config_get_boolean("plugin:proc:/proc/net/snmp", "ipv4 errors", 1);
112 - do_tcp_sockets = config_get_boolean("plugin:proc:/proc/net/snmp", "ipv4 TCP connections", 1);
113 - do_tcp_packets = config_get_boolean("plugin:proc:/proc/net/snmp", "ipv4 TCP packets", 1);
114 - do_tcp_errors = config_get_boolean("plugin:proc:/proc/net/snmp", "ipv4 TCP errors", 1);
115 - do_tcp_opens = config_get_boolean("plugin:proc:/proc/net/snmp", "ipv4 TCP opens", 1);
116 - do_tcp_handshake = config_get_boolean("plugin:proc:/proc/net/snmp", "ipv4 TCP handshake issues", 1);
117 - do_udp_packets = config_get_boolean("plugin:proc:/proc/net/snmp", "ipv4 UDP packets", 1);
118 - do_udp_errors = config_get_boolean("plugin:proc:/proc/net/snmp", "ipv4 UDP errors", 1);
119 - do_icmp_packets = config_get_boolean("plugin:proc:/proc/net/snmp", "ipv4 ICMP packets", 1);
120 - do_icmpmsg = config_get_boolean("plugin:proc:/proc/net/snmp", "ipv4 ICMP messages", 1);
121 - do_udplite_packets = config_get_boolean("plugin:proc:/proc/net/snmp", "ipv4 UDPLite packets", 1);
108 + do_ip_packets = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp", "ipv4 packets", CONFIG_BOOLEAN_AUTO);
109 + do_ip_fragsout = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp", "ipv4 fragments sent", CONFIG_BOOLEAN_AUTO);
110 + do_ip_fragsin = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp", "ipv4 fragments assembly", CONFIG_BOOLEAN_AUTO);
111 + do_ip_errors = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp", "ipv4 errors", CONFIG_BOOLEAN_AUTO);
112 + do_tcp_sockets = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp", "ipv4 TCP connections", CONFIG_BOOLEAN_AUTO);
113 + do_tcp_packets = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp", "ipv4 TCP packets", CONFIG_BOOLEAN_AUTO);
114 + do_tcp_errors = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp", "ipv4 TCP errors", CONFIG_BOOLEAN_AUTO);
115 + do_tcp_opens = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp", "ipv4 TCP opens", CONFIG_BOOLEAN_AUTO);
116 + do_tcp_handshake = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp", "ipv4 TCP handshake issues", CONFIG_BOOLEAN_AUTO);
117 + do_udp_packets = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp", "ipv4 UDP packets", CONFIG_BOOLEAN_AUTO);
118 + do_udp_errors = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp", "ipv4 UDP errors", CONFIG_BOOLEAN_AUTO);
119 + do_icmp_packets = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp", "ipv4 ICMP packets", CONFIG_BOOLEAN_AUTO);
120 + do_icmpmsg = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp", "ipv4 ICMP messages", CONFIG_BOOLEAN_AUTO);
121 + do_udplite_packets = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp", "ipv4 UDPLite packets", CONFIG_BOOLEAN_AUTO);
122
123 hash_ip = simple_hash("Ip");
124 hash_tcp = simple_hash("Tcp");
@@ -256,7 +256,9 @@ int do_proc_net_snmp(int update_every, usec_t dt) {
256
257 // --------------------------------------------------------------------
258
259 - if(do_ip_packets) {
259 + if(do_ip_packets == CONFIG_BOOLEAN_YES || (do_ip_packets == CONFIG_BOOLEAN_AUTO && (snmp_root.ip_OutRequests || snmp_root.ip_InReceives || snmp_root.ip_ForwDatagrams || snmp_root.ip_InDelivers))) {
260 + do_ip_packets = CONFIG_BOOLEAN_YES;
261 +
262 static RRDSET *st = NULL;
263 static RRDDIM *rd_InReceives = NULL,
264 *rd_OutRequests = NULL,
@@ -274,7 +276,7 @@ int do_proc_net_snmp(int update_every, usec_t dt) {
276 , "packets/s"
277 , "proc"
278 , "net/snmp"
277 - , 2450
279 + , NETDATA_CHART_PRIO_IPV4_PACKETS
280 , update_every
281 , RRDSET_TYPE_LINE
282 );
@@ -295,7 +297,9 @@ int do_proc_net_snmp(int update_every, usec_t dt) {
297
298 // --------------------------------------------------------------------
299
298 - if(do_ip_fragsout) {
300 + if(do_ip_fragsout == CONFIG_BOOLEAN_YES || (do_ip_fragsout == CONFIG_BOOLEAN_AUTO && (snmp_root.ip_FragOKs || snmp_root.ip_FragFails || snmp_root.ip_FragCreates))) {
301 + do_ip_fragsout = CONFIG_BOOLEAN_YES;
302 +
303 static RRDSET *st = NULL;
304 static RRDDIM *rd_FragOKs = NULL,
305 *rd_FragFails = NULL,
@@ -312,7 +316,7 @@ int do_proc_net_snmp(int update_every, usec_t dt) {
316 , "packets/s"
317 , "proc"
318 , "net/snmp"
315 - , 3020
319 + , NETDATA_CHART_PRIO_IPV4_FRAGMENTS
320 , update_every
321 , RRDSET_TYPE_LINE
322 );
@@ -332,7 +336,9 @@ int do_proc_net_snmp(int update_every, usec_t dt) {
336
337 // --------------------------------------------------------------------
338
335 - if(do_ip_fragsin) {
339 + if(do_ip_fragsin == CONFIG_BOOLEAN_YES || (do_ip_fragsin == CONFIG_BOOLEAN_AUTO && (snmp_root.ip_ReasmOKs || snmp_root.ip_ReasmFails || snmp_root.ip_ReasmReqds))) {
340 + do_ip_fragsin = CONFIG_BOOLEAN_YES;
341 +
342 static RRDSET *st = NULL;
343 static RRDDIM *rd_ReasmOKs = NULL,
344 *rd_ReasmFails = NULL,
@@ -349,7 +355,7 @@ int do_proc_net_snmp(int update_every, usec_t dt) {
355 , "packets/s"
356 , "proc"
357 , "net/snmp"
352 - , 3030
358 + , NETDATA_CHART_PRIO_IPV4_FRAGMENTS + 1
359 , update_every
360 , RRDSET_TYPE_LINE
361 );
@@ -369,7 +375,9 @@ int do_proc_net_snmp(int update_every, usec_t dt) {
375
376 // --------------------------------------------------------------------
377
372 - if(do_ip_errors) {
378 + if(do_ip_errors == CONFIG_BOOLEAN_YES || (do_ip_errors == CONFIG_BOOLEAN_AUTO && (snmp_root.ip_InDiscards || snmp_root.ip_OutDiscards || snmp_root.ip_InHdrErrors || snmp_root.ip_InAddrErrors || snmp_root.ip_InUnknownProtos || snmp_root.ip_OutNoRoutes))) {
379 + do_ip_errors = CONFIG_BOOLEAN_YES;
380 +
381 static RRDSET *st = NULL;
382 static RRDDIM *rd_InDiscards = NULL,
383 *rd_OutDiscards = NULL,
@@ -389,7 +397,7 @@ int do_proc_net_snmp(int update_every, usec_t dt) {
397 , "packets/s"
398 , "proc"
399 , "net/snmp"
392 - , 2470
400 + , NETDATA_CHART_PRIO_IPV4_ERRORS
401 , update_every
402 , RRDSET_TYPE_LINE
403 );
@@ -437,7 +445,9 @@ int do_proc_net_snmp(int update_every, usec_t dt) {
445
446 // --------------------------------------------------------------------
447
440 - if(do_icmp_packets) {
448 + if(do_icmp_packets == CONFIG_BOOLEAN_YES || (do_icmp_packets == CONFIG_BOOLEAN_AUTO && (snmp_root.icmp_InMsgs || snmp_root.icmp_OutMsgs || snmp_root.icmp_InErrors || snmp_root.icmp_OutErrors || snmp_root.icmp_InCsumErrors))) {
449 + do_icmp_packets = CONFIG_BOOLEAN_YES;
450 +
451 {
452 static RRDSET *st_packets = NULL;
453 static RRDDIM *rd_InMsgs = NULL,
@@ -454,7 +464,7 @@ int do_proc_net_snmp(int update_every, usec_t dt) {
464 , "packets/s"
465 , "proc"
466 , "net/snmp"
457 - , 2602
467 + , NETDATA_CHART_PRIO_IPV4_ICMP
468 , update_every
469 , RRDSET_TYPE_LINE
470 );
@@ -487,7 +497,7 @@ int do_proc_net_snmp(int update_every, usec_t dt) {
497 , "packets/s"
498 , "proc"
499 , "net/snmp"
490 - , 2603
500 + , NETDATA_CHART_PRIO_IPV4_ICMP + 1
501 , update_every
502 , RRDSET_TYPE_LINE
503 );
@@ -528,7 +538,30 @@ int do_proc_net_snmp(int update_every, usec_t dt) {
538
539 // --------------------------------------------------------------------
540
531 - if(do_icmpmsg) {
541 + if(do_icmpmsg == CONFIG_BOOLEAN_YES || (do_icmpmsg == CONFIG_BOOLEAN_AUTO && (
542 + snmp_root.icmpmsg_InEchoReps
543 + || snmp_root.icmpmsg_OutEchoReps
544 + || snmp_root.icmpmsg_InDestUnreachs
545 + || snmp_root.icmpmsg_OutDestUnreachs
546 + || snmp_root.icmpmsg_InRedirects
547 + || snmp_root.icmpmsg_OutRedirects
548 + || snmp_root.icmpmsg_InEchos
549 + || snmp_root.icmpmsg_OutEchos
550 + || snmp_root.icmpmsg_InRouterAdvert
551 + || snmp_root.icmpmsg_OutRouterAdvert
552 + || snmp_root.icmpmsg_InRouterSelect
553 + || snmp_root.icmpmsg_OutRouterSelect
554 + || snmp_root.icmpmsg_InTimeExcds
555 + || snmp_root.icmpmsg_OutTimeExcds
556 + || snmp_root.icmpmsg_InParmProbs
557 + || snmp_root.icmpmsg_OutParmProbs
558 + || snmp_root.icmpmsg_InTimestamps
559 + || snmp_root.icmpmsg_OutTimestamps
560 + || snmp_root.icmpmsg_InTimestampReps
561 + || snmp_root.icmpmsg_OutTimestampReps
562 + ))) {
563 + do_icmpmsg = CONFIG_BOOLEAN_YES;
564 +
565 static RRDSET *st = NULL;
566 static RRDDIM *rd_InEchoReps = NULL,
567 *rd_OutEchoReps = NULL,
@@ -562,7 +595,7 @@ int do_proc_net_snmp(int update_every, usec_t dt) {
595 , "packets/s"
596 , "proc"
597 , "net/snmp"
565 - , 2604
598 + , NETDATA_CHART_PRIO_IPV4_ICMP + 2
599 , update_every
600 , RRDSET_TYPE_LINE
601 );
@@ -644,7 +677,9 @@ int do_proc_net_snmp(int update_every, usec_t dt) {
677 // --------------------------------------------------------------------
678
679 // see http://net-snmp.sourceforge.net/docs/mibs/tcp.html
647 - if(do_tcp_sockets) {
680 + if(do_tcp_sockets == CONFIG_BOOLEAN_YES || (do_tcp_sockets == CONFIG_BOOLEAN_AUTO && snmp_root.tcp_CurrEstab)) {
681 + do_tcp_sockets = CONFIG_BOOLEAN_YES;
682 +
683 static RRDSET *st = NULL;
684 static RRDDIM *rd_CurrEstab = NULL;
685
@@ -659,7 +694,7 @@ int do_proc_net_snmp(int update_every, usec_t dt) {
694 , "active connections"
695 , "proc"
696 , "net/snmp"
662 - , 2501
697 + , NETDATA_CHART_PRIO_IPV4_TCP
698 , update_every
699 , RRDSET_TYPE_LINE
700 );
@@ -674,7 +709,9 @@ int do_proc_net_snmp(int update_every, usec_t dt) {
709
710 // --------------------------------------------------------------------
711
677 - if(do_tcp_packets) {
712 + if(do_tcp_packets == CONFIG_BOOLEAN_YES || (do_tcp_packets == CONFIG_BOOLEAN_AUTO && (snmp_root.tcp_InSegs || snmp_root.tcp_OutSegs))) {
713 + do_tcp_packets = CONFIG_BOOLEAN_YES;
714 +
715 static RRDSET *st = NULL;
716 static RRDDIM *rd_InSegs = NULL,
717 *rd_OutSegs = NULL;
@@ -690,7 +727,7 @@ int do_proc_net_snmp(int update_every, usec_t dt) {
727 , "packets/s"
728 , "proc"
729 , "net/snmp"
693 - , 2510
730 + , NETDATA_CHART_PRIO_IPV4_TCP + 10
731 , update_every
732 , RRDSET_TYPE_LINE
733 );
@@ -707,7 +744,9 @@ int do_proc_net_snmp(int update_every, usec_t dt) {
744
745 // --------------------------------------------------------------------
746
710 - if(do_tcp_errors) {
747 + if(do_tcp_errors == CONFIG_BOOLEAN_YES || (do_tcp_errors == CONFIG_BOOLEAN_AUTO && (snmp_root.tcp_InErrs || snmp_root.tcp_InCsumErrors || snmp_root.tcp_RetransSegs))) {
748 + do_tcp_errors = CONFIG_BOOLEAN_YES;
749 +
750 static RRDSET *st = NULL;
751 static RRDDIM *rd_InErrs = NULL,
752 *rd_InCsumErrors = NULL,
@@ -724,7 +763,7 @@ int do_proc_net_snmp(int update_every, usec_t dt) {
763 , "packets/s"
764 , "proc"
765 , "net/snmp"
727 - , 2525
766 + , NETDATA_CHART_PRIO_IPV4_TCP + 20
767 , update_every
768 , RRDSET_TYPE_LINE
769 );
@@ -744,7 +783,9 @@ int do_proc_net_snmp(int update_every, usec_t dt) {
783
784 // --------------------------------------------------------------------
785
747 - if(do_tcp_opens) {
786 + if(do_tcp_opens == CONFIG_BOOLEAN_YES || (do_tcp_opens == CONFIG_BOOLEAN_AUTO && (snmp_root.tcp_ActiveOpens || snmp_root.tcp_PassiveOpens))) {
787 + do_tcp_opens = CONFIG_BOOLEAN_YES;
788 +
789 static RRDSET *st = NULL;
790 static RRDDIM *rd_ActiveOpens = NULL,
791 *rd_PassiveOpens = NULL;
@@ -760,7 +801,7 @@ int do_proc_net_snmp(int update_every, usec_t dt) {
801 , "connections/s"
802 , "proc"
803 , "net/snmp"
763 - , 2502
804 + , NETDATA_CHART_PRIO_IPV4_TCP + 5
805 , update_every
806 , RRDSET_TYPE_LINE
807 );
@@ -778,7 +819,9 @@ int do_proc_net_snmp(int update_every, usec_t dt) {
819
820 // --------------------------------------------------------------------
821
781 - if(do_tcp_handshake) {
822 + if(do_tcp_handshake == CONFIG_BOOLEAN_YES || (do_tcp_handshake == CONFIG_BOOLEAN_AUTO && (snmp_root.tcp_EstabResets || snmp_root.tcp_OutRsts || snmp_root.tcp_AttemptFails))) {
823 + do_tcp_handshake = CONFIG_BOOLEAN_YES;
824 +
825 static RRDSET *st = NULL;
826 static RRDDIM *rd_EstabResets = NULL,
827 *rd_OutRsts = NULL,
@@ -796,7 +839,7 @@ int do_proc_net_snmp(int update_every, usec_t dt) {
839 , "events/s"
840 , "proc"
841 , "net/snmp"
799 - , 2530
842 + , NETDATA_CHART_PRIO_IPV4_TCP + 30
843 , update_every
844 , RRDSET_TYPE_LINE
845 );
@@ -839,7 +882,9 @@ int do_proc_net_snmp(int update_every, usec_t dt) {
882 // --------------------------------------------------------------------
883
884 // see http://net-snmp.sourceforge.net/docs/mibs/udp.html
842 - if(do_udp_packets) {
885 + if(do_udp_packets == CONFIG_BOOLEAN_YES || (do_udp_packets == CONFIG_BOOLEAN_AUTO && (snmp_root.udp_InDatagrams || snmp_root.udp_OutDatagrams))) {
886 + do_udp_packets = CONFIG_BOOLEAN_YES;
887 +
888 static RRDSET *st = NULL;
889 static RRDDIM *rd_InDatagrams = NULL,
890 *rd_OutDatagrams = NULL;
@@ -855,7 +900,7 @@ int do_proc_net_snmp(int update_every, usec_t dt) {
900 , "packets/s"
901 , "proc"
902 , "net/snmp"
858 - , 2602
903 + , NETDATA_CHART_PRIO_IPV4_UDP
904 , update_every
905 , RRDSET_TYPE_LINE
906 );
@@ -872,7 +917,16 @@ int do_proc_net_snmp(int update_every, usec_t dt) {
917
918 // --------------------------------------------------------------------
919
875 - if(do_udp_errors) {
920 + if(do_udp_errors == CONFIG_BOOLEAN_YES || (do_udp_errors == CONFIG_BOOLEAN_AUTO && (
921 + snmp_root.udp_InErrors
922 + || snmp_root.udp_NoPorts
923 + || snmp_root.udp_RcvbufErrors
924 + || snmp_root.udp_SndbufErrors
925 + || snmp_root.udp_InCsumErrors
926 + || snmp_root.udp_IgnoredMulti
927 + ))) {
928 + do_udp_errors = CONFIG_BOOLEAN_YES;
929 +
930 static RRDSET *st = NULL;
931 static RRDDIM *rd_RcvbufErrors = NULL,
932 *rd_SndbufErrors = NULL,
@@ -892,7 +946,7 @@ int do_proc_net_snmp(int update_every, usec_t dt) {
946 , "events/s"
947 , "proc"
948 , "net/snmp"
895 - , 2701
949 + , NETDATA_CHART_PRIO_IPV4_UDP + 10
950 , update_every
951 , RRDSET_TYPE_LINE
952 );
@@ -938,7 +992,18 @@ int do_proc_net_snmp(int update_every, usec_t dt) {
992
993 // --------------------------------------------------------------------
994
941 - if(do_udplite_packets) {
995 + if(do_udplite_packets == CONFIG_BOOLEAN_YES || (do_udplite_packets == CONFIG_BOOLEAN_AUTO && (
996 + snmp_root.udplite_InDatagrams
997 + || snmp_root.udplite_OutDatagrams
998 + || snmp_root.udplite_NoPorts
999 + || snmp_root.udplite_InErrors
1000 + || snmp_root.udplite_InCsumErrors
1001 + || snmp_root.udplite_RcvbufErrors
1002 + || snmp_root.udplite_SndbufErrors
1003 + || snmp_root.udplite_IgnoredMulti
1004 + ))) {
1005 + do_udplite_packets = CONFIG_BOOLEAN_YES;
1006 +
1007 {
1008 static RRDSET *st = NULL;
1009 static RRDDIM *rd_InDatagrams = NULL,
@@ -955,7 +1020,7 @@ int do_proc_net_snmp(int update_every, usec_t dt) {
1020 , "packets/s"
1021 , "proc"
1022 , "net/snmp"
958 - , 2603
1023 + , NETDATA_CHART_PRIO_IPV4_UDPLITE
1024 , update_every
1025 , RRDSET_TYPE_LINE
1026 );
@@ -990,7 +1055,7 @@ int do_proc_net_snmp(int update_every, usec_t dt) {
1055 , "packets/s"
1056 , "proc"
1057 , "net/snmp"
993 - , 2604
1058 + , NETDATA_CHART_PRIO_IPV4_UDPLITE + 10
1059 , update_every
1060 , RRDSET_TYPE_LINE);
1061