int do_proc_net_snmp(int update_every, usec_t dt) { (void)dt; static procfile *ff = NULL; static int do_ip_packets = -1, do_ip_fragsout = -1, do_ip_fragsin = -1, do_ip_errors = -1, do_tcp_sockets = -1, do_tcp_packets = -1, do_tcp_errors = -1, do_tcp_handshake = -1, do_udp_packets = -1, do_udp_errors = -1, do_icmp_packets = -1, do_icmpmsg = -1, do_udplite_packets = -1; static uint32_t hash_ip = 0, hash_icmp = 0, hash_tcp = 0, hash_udp = 0, hash_icmpmsg = 0, hash_udplite = 0; //static unsigned long long *ip_Forwarding = NULL; //static unsigned long long *ip_DefaultTTL = NULL; static unsigned long long *ip_InReceives = NULL; static unsigned long long *ip_InHdrErrors = NULL; static unsigned long long *ip_InAddrErrors = NULL; static unsigned long long *ip_ForwDatagrams = NULL; static unsigned long long *ip_InUnknownProtos = NULL; static unsigned long long *ip_InDiscards = NULL; static unsigned long long *ip_InDelivers = NULL; static unsigned long long *ip_OutRequests = NULL; static unsigned long long *ip_OutDiscards = NULL; static unsigned long long *ip_OutNoRoutes = NULL; //static unsigned long long *ip_ReasmTimeout = NULL; static unsigned long long *ip_ReasmReqds = NULL; static unsigned long long *ip_ReasmOKs = NULL; static unsigned long long *ip_ReasmFails = NULL; static unsigned long long *ip_FragOKs = NULL; static unsigned long long *ip_FragFails = NULL; static unsigned long long *ip_FragCreates = NULL; static unsigned long long *icmp_InMsgs = NULL; static unsigned long long *icmp_OutMsgs = NULL; static unsigned long long *icmp_InErrors = NULL; static unsigned long long *icmp_OutErrors = NULL; static unsigned long long *icmp_InCsumErrors = NULL; //static unsigned long long *tcp_RtoAlgorithm = NULL; //static unsigned long long *tcp_RtoMin = NULL; //static unsigned long long *tcp_RtoMax = NULL; //static unsigned long long *tcp_MaxConn = NULL; static unsigned long long *tcp_ActiveOpens = NULL; static unsigned long long *tcp_PassiveOpens = NULL; static unsigned long long *tcp_AttemptFails = NULL; static unsigned long long *tcp_EstabResets = NULL; static unsigned long long *tcp_CurrEstab = NULL; static unsigned long long *tcp_InSegs = NULL; static unsigned long long *tcp_OutSegs = NULL; static unsigned long long *tcp_RetransSegs = NULL; static unsigned long long *tcp_InErrs = NULL; static unsigned long long *tcp_OutRsts = NULL; static unsigned long long *tcp_InCsumErrors = NULL; static unsigned long long *udp_InDatagrams = NULL; static unsigned long long *udp_NoPorts = NULL; static unsigned long long *udp_InErrors = NULL; static unsigned long long *udp_OutDatagrams = NULL; static unsigned long long *udp_RcvbufErrors = NULL; static unsigned long long *udp_SndbufErrors = NULL; static unsigned long long *udp_InCsumErrors = NULL; static unsigned long long *udp_IgnoredMulti = NULL; static unsigned long long *udplite_InDatagrams = NULL; static unsigned long long *udplite_NoPorts = NULL; static unsigned long long *udplite_InErrors = NULL; static unsigned long long *udplite_OutDatagrams = NULL; static unsigned long long *udplite_RcvbufErrors = NULL; static unsigned long long *udplite_SndbufErrors = NULL; static unsigned long long *udplite_InCsumErrors = NULL; static unsigned long long *udplite_IgnoredMulti = NULL; if(unlikely(do_ip_packets == -1)) { do_ip_packets = config_get_boolean("plugin:proc:/proc/net/snmp", "ipv4 packets", 1); do_ip_fragsout = config_get_boolean("plugin:proc:/proc/net/snmp", "ipv4 fragments sent", 1); do_ip_fragsin = config_get_boolean("plugin:proc:/proc/net/snmp", "ipv4 fragments assembly", 1); do_ip_errors = config_get_boolean("plugin:proc:/proc/net/snmp", "ipv4 errors", 1); do_tcp_sockets = config_get_boolean("plugin:proc:/proc/net/snmp", "ipv4 TCP connections", 1); do_tcp_packets = config_get_boolean("plugin:proc:/proc/net/snmp", "ipv4 TCP packets", 1); do_tcp_errors = config_get_boolean("plugin:proc:/proc/net/snmp", "ipv4 TCP errors", 1); do_tcp_handshake = config_get_boolean("plugin:proc:/proc/net/snmp", "ipv4 TCP handshake issues", 1); do_udp_packets = config_get_boolean("plugin:proc:/proc/net/snmp", "ipv4 UDP packets", 1); do_udp_errors = config_get_boolean("plugin:proc:/proc/net/snmp", "ipv4 UDP errors", 1); do_icmp_packets = config_get_boolean("plugin:proc:/proc/net/snmp", "ipv4 ICMP packets", 1); do_icmpmsg = config_get_boolean("plugin:proc:/proc/net/snmp", "ipv4 ICMP messages", 1); do_udplite_packets = config_get_boolean("plugin:proc:/proc/net/snmp", "ipv4 UDPLite packets", 1); hash_ip = simple_hash("Ip"); hash_tcp = simple_hash("Tcp"); hash_udp = simple_hash("Udp"); hash_icmp = simple_hash("Icmp"); hash_icmpmsg = simple_hash("IcmpMsg"); hash_udplite = simple_hash("UdpLite"); hash_array(ip_data); hash_array(tcp_data); hash_array(udp_data); hash_array(icmp_data); hash_array(icmpmsg_data); hash_array(udplite_data); //ip_Forwarding = netstat_columns_find(ip_data, "Forwarding"); //ip_DefaultTTL = netstat_columns_find(ip_data, "DefaultTTL"); ip_InReceives = netstat_columns_find(ip_data, "InReceives"); ip_InHdrErrors = netstat_columns_find(ip_data, "InHdrErrors"); ip_InAddrErrors = netstat_columns_find(ip_data, "InAddrErrors"); ip_ForwDatagrams = netstat_columns_find(ip_data, "ForwDatagrams"); ip_InUnknownProtos = netstat_columns_find(ip_data, "InUnknownProtos"); ip_InDiscards = netstat_columns_find(ip_data, "InDiscards"); ip_InDelivers = netstat_columns_find(ip_data, "InDelivers"); ip_OutRequests = netstat_columns_find(ip_data, "OutRequests"); ip_OutDiscards = netstat_columns_find(ip_data, "OutDiscards"); ip_OutNoRoutes = netstat_columns_find(ip_data, "OutNoRoutes"); //ip_ReasmTimeout = netstat_columns_find(ip_data, "ReasmTimeout"); ip_ReasmReqds = netstat_columns_find(ip_data, "ReasmReqds"); ip_ReasmOKs = netstat_columns_find(ip_data, "ReasmOKs"); ip_ReasmFails = netstat_columns_find(ip_data, "ReasmFails"); ip_FragOKs = netstat_columns_find(ip_data, "FragOKs"); ip_FragFails = netstat_columns_find(ip_data, "FragFails"); ip_FragCreates = netstat_columns_find(ip_data, "FragCreates"); icmp_InMsgs = netstat_columns_find(icmp_data, "InMsgs"); icmp_OutMsgs = netstat_columns_find(icmp_data, "OutMsgs"); icmp_InErrors = netstat_columns_find(icmp_data, "InErrors"); icmp_OutErrors = netstat_columns_find(icmp_data, "OutErrors"); icmp_InCsumErrors = netstat_columns_find(icmp_data, "InCsumErrors"); //tcp_RtoAlgorithm = netstat_columns_find(tcp_data, "RtoAlgorithm"); //tcp_RtoMin = netstat_columns_find(tcp_data, "RtoMin"); //tcp_RtoMax = netstat_columns_find(tcp_data, "RtoMax"); //tcp_MaxConn = netstat_columns_find(tcp_data, "MaxConn"); tcp_ActiveOpens = netstat_columns_find(tcp_data, "ActiveOpens"); tcp_PassiveOpens = netstat_columns_find(tcp_data, "PassiveOpens"); tcp_AttemptFails = netstat_columns_find(tcp_data, "AttemptFails"); tcp_EstabResets = netstat_columns_find(tcp_data, "EstabResets"); tcp_CurrEstab = netstat_columns_find(tcp_data, "CurrEstab"); tcp_InSegs = netstat_columns_find(tcp_data, "InSegs"); tcp_OutSegs = netstat_columns_find(tcp_data, "OutSegs"); tcp_RetransSegs = netstat_columns_find(tcp_data, "RetransSegs"); tcp_InErrs = netstat_columns_find(tcp_data, "InErrs"); tcp_OutRsts = netstat_columns_find(tcp_data, "OutRsts"); tcp_InCsumErrors = netstat_columns_find(tcp_data, "InCsumErrors"); udp_InDatagrams = netstat_columns_find(udp_data, "InDatagrams"); udp_NoPorts = netstat_columns_find(udp_data, "NoPorts"); udp_InErrors = netstat_columns_find(udp_data, "InErrors"); udp_OutDatagrams = netstat_columns_find(udp_data, "OutDatagrams"); udp_RcvbufErrors = netstat_columns_find(udp_data, "RcvbufErrors"); udp_SndbufErrors = netstat_columns_find(udp_data, "SndbufErrors"); udp_InCsumErrors = netstat_columns_find(udp_data, "InCsumErrors"); udp_IgnoredMulti = netstat_columns_find(udp_data, "IgnoredMulti"); udplite_InDatagrams = netstat_columns_find(udplite_data, "InDatagrams"); udplite_NoPorts = netstat_columns_find(udplite_data, "NoPorts"); udplite_InErrors = netstat_columns_find(udplite_data, "InErrors"); udplite_OutDatagrams = netstat_columns_find(udplite_data, "OutDatagrams"); udplite_RcvbufErrors = netstat_columns_find(udplite_data, "RcvbufErrors"); udplite_SndbufErrors = netstat_columns_find(udplite_data, "SndbufErrors"); udplite_InCsumErrors = netstat_columns_find(udplite_data, "InCsumErrors"); udplite_IgnoredMulti = netstat_columns_find(udplite_data, "IgnoredMulti"); } if(unlikely(!ff)) { char filename[FILENAME_MAX + 1]; snprintfz(filename, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, "/proc/net/snmp"); ff = procfile_open(config_get("plugin:proc:/proc/net/snmp", "filename to monitor", filename), " \t:", PROCFILE_FLAG_DEFAULT); if(unlikely(!ff)) return 1; } ff = procfile_readall(ff); if(unlikely(!ff)) return 0; // we return 0, so that we will retry to open it next time size_t lines = procfile_lines(ff), l; size_t words; RRDSET *st; for(l = 0; l < lines ;l++) { char *key = procfile_lineword(ff, l, 0); uint32_t hash = simple_hash(key); if(unlikely(hash == hash_ip && strcmp(key, "Ip") == 0)) { size_t h = l++; if(strcmp(procfile_lineword(ff, l, 0), "Ip") != 0) { error("Cannot read Ip line from /proc/net/snmp."); break; } words = procfile_linewords(ff, l); if(words < 3) { error("Cannot read /proc/net/snmp Ip line. Expected 3+ params, read %zu.", words); continue; } // see also http://net-snmp.sourceforge.net/docs/mibs/ip.html parse_line_pair(ff, ip_data, h, l); // -------------------------------------------------------------------- if(do_ip_packets) { st = rrdset_find_localhost(RRD_TYPE_NET_SNMP ".packets"); if(!st) { st = rrdset_create_localhost(RRD_TYPE_NET_SNMP, "packets", NULL, "packets", NULL, "IPv4 Packets" , "packets/s", 3000, update_every, RRDSET_TYPE_LINE); rrddim_add(st, "InReceives", "received", 1, 1, RRD_ALGORITHM_INCREMENTAL); rrddim_add(st, "OutRequests", "sent", -1, 1, RRD_ALGORITHM_INCREMENTAL); rrddim_add(st, "ForwDatagrams", "forwarded", 1, 1, RRD_ALGORITHM_INCREMENTAL); rrddim_add(st, "InDelivers", "delivered", 1, 1, RRD_ALGORITHM_INCREMENTAL); } else rrdset_next(st); rrddim_set(st, "OutRequests", *ip_OutRequests); rrddim_set(st, "InReceives", *ip_InReceives); rrddim_set(st, "ForwDatagrams", *ip_ForwDatagrams); rrddim_set(st, "InDelivers", *ip_InDelivers); rrdset_done(st); } // -------------------------------------------------------------------- if(do_ip_fragsout) { st = rrdset_find_localhost(RRD_TYPE_NET_SNMP ".fragsout"); if(!st) { st = rrdset_create_localhost(RRD_TYPE_NET_SNMP, "fragsout", NULL, "fragments", NULL , "IPv4 Fragments Sent", "packets/s", 3010, update_every , RRDSET_TYPE_LINE); rrdset_flag_set(st, RRDSET_FLAG_DETAIL); rrddim_add(st, "FragOKs", "ok", 1, 1, RRD_ALGORITHM_INCREMENTAL); rrddim_add(st, "FragFails", "failed", -1, 1, RRD_ALGORITHM_INCREMENTAL); rrddim_add(st, "FragCreates", "created", 1, 1, RRD_ALGORITHM_INCREMENTAL); } else rrdset_next(st); rrddim_set(st, "FragOKs", *ip_FragOKs); rrddim_set(st, "FragFails", *ip_FragFails); rrddim_set(st, "FragCreates", *ip_FragCreates); rrdset_done(st); } // -------------------------------------------------------------------- if(do_ip_fragsin) { st = rrdset_find_localhost(RRD_TYPE_NET_SNMP ".fragsin"); if(!st) { st = rrdset_create_localhost(RRD_TYPE_NET_SNMP, "fragsin", NULL, "fragments", NULL , "IPv4 Fragments Reassembly", "packets/s", 3011, update_every , RRDSET_TYPE_LINE); rrdset_flag_set(st, RRDSET_FLAG_DETAIL); rrddim_add(st, "ReasmOKs", "ok", 1, 1, RRD_ALGORITHM_INCREMENTAL); rrddim_add(st, "ReasmFails", "failed", -1, 1, RRD_ALGORITHM_INCREMENTAL); rrddim_add(st, "ReasmReqds", "all", 1, 1, RRD_ALGORITHM_INCREMENTAL); } else rrdset_next(st); rrddim_set(st, "ReasmOKs", *ip_ReasmOKs); rrddim_set(st, "ReasmFails", *ip_ReasmFails); rrddim_set(st, "ReasmReqds", *ip_ReasmReqds); rrdset_done(st); } // -------------------------------------------------------------------- if(do_ip_errors) { st = rrdset_find_localhost(RRD_TYPE_NET_SNMP ".errors"); if(!st) { st = rrdset_create_localhost(RRD_TYPE_NET_SNMP, "errors", NULL, "errors", NULL, "IPv4 Errors" , "packets/s", 3002, update_every, RRDSET_TYPE_LINE); rrdset_flag_set(st, RRDSET_FLAG_DETAIL); rrddim_add(st, "InDiscards", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); rrddim_add(st, "OutDiscards", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); rrddim_add(st, "InHdrErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); rrddim_add(st, "OutNoRoutes", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); rrddim_add(st, "InAddrErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); rrddim_add(st, "InUnknownProtos", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); } else rrdset_next(st); rrddim_set(st, "InDiscards", *ip_InDiscards); rrddim_set(st, "OutDiscards", *ip_OutDiscards); rrddim_set(st, "InHdrErrors", *ip_InHdrErrors); rrddim_set(st, "InAddrErrors", *ip_InAddrErrors); rrddim_set(st, "InUnknownProtos", *ip_InUnknownProtos); rrddim_set(st, "OutNoRoutes", *ip_OutNoRoutes); rrdset_done(st); } } else if(unlikely(hash == hash_icmp && strcmp(key, "Icmp") == 0)) { size_t h = l++; if(strcmp(procfile_lineword(ff, l, 0), "Icmp") != 0) { error("Cannot read Icmp line from /proc/net/snmp."); break; } words = procfile_linewords(ff, l); if(words < 3) { error("Cannot read /proc/net/snmp Icmp line. Expected 3+ params, read %zu.", words); continue; } parse_line_pair(ff, icmp_data, h, l); // -------------------------------------------------------------------- if(do_icmp_packets) { st = rrdset_find_localhost(RRD_TYPE_NET_SNMP ".icmp"); if(!st) { st = rrdset_create_localhost(RRD_TYPE_NET_SNMP, "icmp", NULL, "icmp", NULL, "IPv4 ICMP Packets" , "packets/s", 2602, update_every, RRDSET_TYPE_LINE); rrddim_add(st, "InMsgs", "received", 1, 1, RRD_ALGORITHM_INCREMENTAL); rrddim_add(st, "OutMsgs", "sent", -1, 1, RRD_ALGORITHM_INCREMENTAL); } else rrdset_next(st); rrddim_set(st, "InMsgs", *icmp_InMsgs); rrddim_set(st, "OutMsgs", *icmp_OutMsgs); rrdset_done(st); st = rrdset_find_localhost(RRD_TYPE_NET_SNMP ".icmp_errors"); if(!st) { st = rrdset_create_localhost(RRD_TYPE_NET_SNMP, "icmp_errors", NULL, "icmp", NULL , "IPv4 ICMP Errors", "packets/s", 2603, update_every , RRDSET_TYPE_LINE); rrddim_add(st, "InErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); rrddim_add(st, "OutErrors", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); rrddim_add(st, "InCsumErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); } else rrdset_next(st); rrddim_set(st, "InErrors", *icmp_InErrors); rrddim_set(st, "OutErrors", *icmp_OutErrors); rrddim_set(st, "InCsumErrors", *icmp_InCsumErrors); rrdset_done(st); } } else if(unlikely(hash == hash_icmpmsg && strcmp(key, "IcmpMsg") == 0)) { size_t h = l++; if(strcmp(procfile_lineword(ff, l, 0), "IcmpMsg") != 0) { error("Cannot read IcmpMsg line from /proc/net/snmp."); break; } parse_line_pair(ff, icmpmsg_data, h, l); // -------------------------------------------------------------------- if(do_icmpmsg) { int i; st = rrdset_find_localhost(RRD_TYPE_NET_SNMP ".icmpmsg"); if(!st) { st = rrdset_create_localhost(RRD_TYPE_NET_SNMP, "icmpmsg", NULL, "icmp", NULL, "IPv4 ICMP Messages" , "packets/s", 2604, update_every, RRDSET_TYPE_LINE); for(i = 0; icmpmsg_data[i].name ;i++) rrddim_add(st, icmpmsg_data[i].name, icmpmsg_data[i].label, icmpmsg_data[i].multiplier, 1, RRD_ALGORITHM_INCREMENTAL); } else rrdset_next(st); for(i = 0; icmpmsg_data[i].name ;i++) rrddim_set(st, icmpmsg_data[i].name, icmpmsg_data[i].value); rrdset_done(st); } } else if(unlikely(hash == hash_tcp && strcmp(key, "Tcp") == 0)) { size_t h = l++; if(strcmp(procfile_lineword(ff, l, 0), "Tcp") != 0) { error("Cannot read Tcp line from /proc/net/snmp."); break; } words = procfile_linewords(ff, l); if(words < 3) { error("Cannot read /proc/net/snmp Tcp line. Expected 3+ params, read %zu.", words); continue; } parse_line_pair(ff, tcp_data, h, l); // -------------------------------------------------------------------- // see http://net-snmp.sourceforge.net/docs/mibs/tcp.html if(do_tcp_sockets) { st = rrdset_find_localhost(RRD_TYPE_NET_SNMP ".tcpsock"); if(!st) { st = rrdset_create_localhost(RRD_TYPE_NET_SNMP, "tcpsock", NULL, "tcp", NULL, "IPv4 TCP Connections" , "active connections", 2500, update_every, RRDSET_TYPE_LINE); rrddim_add(st, "CurrEstab", "connections", 1, 1, RRD_ALGORITHM_ABSOLUTE); } else rrdset_next(st); rrddim_set(st, "CurrEstab", *tcp_CurrEstab); rrdset_done(st); } // -------------------------------------------------------------------- if(do_tcp_packets) { st = rrdset_find_localhost(RRD_TYPE_NET_SNMP ".tcppackets"); if(!st) { st = rrdset_create_localhost(RRD_TYPE_NET_SNMP, "tcppackets", NULL, "tcp", NULL, "IPv4 TCP Packets" , "packets/s", 2600, update_every, RRDSET_TYPE_LINE); rrddim_add(st, "InSegs", "received", 1, 1, RRD_ALGORITHM_INCREMENTAL); rrddim_add(st, "OutSegs", "sent", -1, 1, RRD_ALGORITHM_INCREMENTAL); } else rrdset_next(st); rrddim_set(st, "InSegs", *tcp_InSegs); rrddim_set(st, "OutSegs", *tcp_OutSegs); rrdset_done(st); } // -------------------------------------------------------------------- if(do_tcp_errors) { st = rrdset_find_localhost(RRD_TYPE_NET_SNMP ".tcperrors"); if(!st) { st = rrdset_create_localhost(RRD_TYPE_NET_SNMP, "tcperrors", NULL, "tcp", NULL, "IPv4 TCP Errors" , "packets/s", 2700, update_every, RRDSET_TYPE_LINE); rrdset_flag_set(st, RRDSET_FLAG_DETAIL); rrddim_add(st, "InErrs", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); rrddim_add(st, "InCsumErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); rrddim_add(st, "RetransSegs", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); } else rrdset_next(st); rrddim_set(st, "InErrs", *tcp_InErrs); rrddim_set(st, "InCsumErrors", *tcp_InCsumErrors); rrddim_set(st, "RetransSegs", *tcp_RetransSegs); rrdset_done(st); } // -------------------------------------------------------------------- if(do_tcp_handshake) { st = rrdset_find_localhost(RRD_TYPE_NET_SNMP ".tcphandshake"); if(!st) { st = rrdset_create_localhost( RRD_TYPE_NET_SNMP , "tcphandshake" , NULL , "tcp" , NULL , "IPv4 TCP Handshake Issues" , "events/s" , 2900 , update_every , RRDSET_TYPE_LINE ); rrdset_flag_set(st, RRDSET_FLAG_DETAIL); rrddim_add(st, "EstabResets", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); rrddim_add(st, "OutRsts", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); rrddim_add(st, "ActiveOpens", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); rrddim_add(st, "PassiveOpens", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); rrddim_add(st, "AttemptFails", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); rrddim_add(st, "TCPSynRetrans", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); } else rrdset_next(st); rrddim_set(st, "EstabResets", *tcp_EstabResets); rrddim_set(st, "OutRsts", *tcp_OutRsts); rrddim_set(st, "ActiveOpens", *tcp_ActiveOpens); rrddim_set(st, "PassiveOpens", *tcp_PassiveOpens); rrddim_set(st, "AttemptFails", *tcp_AttemptFails); rrddim_set(st, "TCPSynRetrans", tcpext_TCPSynRetrans); rrdset_done(st); } } else if(unlikely(hash == hash_udp && strcmp(key, "Udp") == 0)) { size_t h = l++; if(strcmp(procfile_lineword(ff, l, 0), "Udp") != 0) { error("Cannot read Udp line from /proc/net/snmp."); break; } words = procfile_linewords(ff, l); if(words < 3) { error("Cannot read /proc/net/snmp Udp line. Expected 3+ params, read %zu.", words); continue; } parse_line_pair(ff, udp_data, h, l); // -------------------------------------------------------------------- // see http://net-snmp.sourceforge.net/docs/mibs/udp.html if(do_udp_packets) { st = rrdset_find_localhost(RRD_TYPE_NET_SNMP ".udppackets"); if(!st) { st = rrdset_create_localhost(RRD_TYPE_NET_SNMP, "udppackets", NULL, "udp", NULL, "IPv4 UDP Packets" , "packets/s", 2601, update_every, RRDSET_TYPE_LINE); rrddim_add(st, "InDatagrams", "received", 1, 1, RRD_ALGORITHM_INCREMENTAL); rrddim_add(st, "OutDatagrams", "sent", -1, 1, RRD_ALGORITHM_INCREMENTAL); } else rrdset_next(st); rrddim_set(st, "InDatagrams", *udp_InDatagrams); rrddim_set(st, "OutDatagrams", *udp_OutDatagrams); rrdset_done(st); } // -------------------------------------------------------------------- if(do_udp_errors) { st = rrdset_find_localhost(RRD_TYPE_NET_SNMP ".udperrors"); if(!st) { st = rrdset_create_localhost(RRD_TYPE_NET_SNMP, "udperrors", NULL, "udp", NULL, "IPv4 UDP Errors" , "events/s", 2701, update_every, RRDSET_TYPE_LINE); rrdset_flag_set(st, RRDSET_FLAG_DETAIL); rrddim_add(st, "RcvbufErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); rrddim_add(st, "SndbufErrors", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); rrddim_add(st, "InErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); rrddim_add(st, "NoPorts", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); rrddim_add(st, "InCsumErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); rrddim_add(st, "IgnoredMulti", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); } else rrdset_next(st); rrddim_set(st, "InErrors", *udp_InErrors); rrddim_set(st, "NoPorts", *udp_NoPorts); rrddim_set(st, "RcvbufErrors", *udp_RcvbufErrors); rrddim_set(st, "SndbufErrors", *udp_SndbufErrors); rrddim_set(st, "InCsumErrors", *udp_InCsumErrors); rrddim_set(st, "IgnoredMulti", *udp_IgnoredMulti); rrdset_done(st); } } else if(unlikely(hash == hash_udplite && strcmp(key, "UdpLite") == 0)) { size_t h = l++; if(strcmp(procfile_lineword(ff, l, 0), "UdpLite") != 0) { error("Cannot read UdpLite line from /proc/net/snmp."); break; } words = procfile_linewords(ff, l); if(words < 3) { error("Cannot read /proc/net/snmp UdpLite line. Expected 3+ params, read %zu.", words); continue; } parse_line_pair(ff, udplite_data, h, l); // -------------------------------------------------------------------- if(do_udplite_packets) { st = rrdset_find_localhost(RRD_TYPE_NET_SNMP ".udplite"); if(!st) { st = rrdset_create_localhost(RRD_TYPE_NET_SNMP, "udplite", NULL, "udplite", NULL , "IPv4 UDPLite Packets", "packets/s", 2603, update_every , RRDSET_TYPE_LINE); rrddim_add(st, "InDatagrams", "received", 1, 1, RRD_ALGORITHM_INCREMENTAL); rrddim_add(st, "OutDatagrams", "sent", -1, 1, RRD_ALGORITHM_INCREMENTAL); } else rrdset_next(st); rrddim_set(st, "InDatagrams", *udplite_InDatagrams); rrddim_set(st, "OutDatagrams", *udplite_OutDatagrams); rrdset_done(st); st = rrdset_find_localhost(RRD_TYPE_NET_SNMP ".udplite_errors"); if(!st) { st = rrdset_create_localhost(RRD_TYPE_NET_SNMP, "udplite_errors", NULL, "udplite", NULL , "IPv4 UDPLite Errors", "packets/s", 2604, update_every , RRDSET_TYPE_LINE); rrddim_add(st, "RcvbufErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); rrddim_add(st, "SndbufErrors", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); rrddim_add(st, "NoPorts", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); rrddim_add(st, "IgnoredMulti", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); rrddim_add(st, "InErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); rrddim_add(st, "InCsumErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); } else rrdset_next(st); rrddim_set(st, "NoPorts", *udplite_NoPorts); rrddim_set(st, "InErrors", *udplite_InErrors); rrddim_set(st, "InCsumErrors", *udplite_InCsumErrors); rrddim_set(st, "RcvbufErrors", *udplite_RcvbufErrors); rrddim_set(st, "SndbufErrors", *udplite_SndbufErrors); rrddim_set(st, "IgnoredMulti", *udplite_IgnoredMulti); rrdset_done(st); } } } return 0; }
int do_proc_net_netstat(int update_every, usec_t dt) { (void)dt; static int do_bandwidth = -1, do_inerrors = -1, do_mcast = -1, do_bcast = -1, do_mcast_p = -1, do_bcast_p = -1, do_ecn = -1, \ do_tcpext_reorder = -1, do_tcpext_syscookies = -1, do_tcpext_ofo = -1, do_tcpext_connaborts = -1, do_tcpext_memory = -1; static uint32_t hash_ipext = 0, hash_tcpext = 0; static procfile *ff = NULL; static unsigned long long *tcpext_TCPRenoReorder = NULL; static unsigned long long *tcpext_TCPFACKReorder = NULL; static unsigned long long *tcpext_TCPSACKReorder = NULL; static unsigned long long *tcpext_TCPTSReorder = NULL; static unsigned long long *tcpext_SyncookiesSent = NULL; static unsigned long long *tcpext_SyncookiesRecv = NULL; static unsigned long long *tcpext_SyncookiesFailed = NULL; static unsigned long long *tcpext_TCPOFOQueue = NULL; // Number of packets queued in OFO queue static unsigned long long *tcpext_TCPOFODrop = NULL; // Number of packets meant to be queued in OFO but dropped because socket rcvbuf limit hit. static unsigned long long *tcpext_TCPOFOMerge = NULL; // Number of packets in OFO that were merged with other packets. static unsigned long long *tcpext_OfoPruned = NULL; // packets dropped from out-of-order queue because of socket buffer overrun static unsigned long long *tcpext_TCPAbortOnData = NULL; // connections reset due to unexpected data static unsigned long long *tcpext_TCPAbortOnClose = NULL; // connections reset due to early user close static unsigned long long *tcpext_TCPAbortOnMemory = NULL; // connections aborted due to memory pressure static unsigned long long *tcpext_TCPAbortOnTimeout = NULL; // connections aborted due to timeout static unsigned long long *tcpext_TCPAbortOnLinger = NULL; // connections aborted after user close in linger timeout static unsigned long long *tcpext_TCPAbortFailed = NULL; // times unable to send RST due to no memory static unsigned long long *tcpext_TCPMemoryPressures = NULL; /* // connection rejects static unsigned long long *tcpext_PAWSActive = NULL; // active connections rejected because of time stamp static unsigned long long *tcpext_PAWSPassive = NULL; // passive connections rejected because of time stamp static unsigned long long *tcpext_TCPTimeouts = NULL; static unsigned long long *tcpext_TCPDSACKUndo = NULL; static unsigned long long *tcpext_TCPDSACKOldSent = NULL; static unsigned long long *tcpext_TCPDSACKOfoSent = NULL; static unsigned long long *tcpext_TCPDSACKRecv = NULL; static unsigned long long *tcpext_TCPDSACKOfoRecv = NULL; static unsigned long long *tcpext_TCPDSACKIgnoredOld = NULL; static unsigned long long *tcpext_TCPDSACKIgnoredNoUndo = NULL; static unsigned long long *tcpext_EmbryonicRsts = NULL; static unsigned long long *tcpext_PruneCalled = NULL; static unsigned long long *tcpext_RcvPruned = NULL; static unsigned long long *tcpext_OutOfWindowIcmps = NULL; static unsigned long long *tcpext_LockDroppedIcmps = NULL; static unsigned long long *tcpext_ArpFilter = NULL; static unsigned long long *tcpext_TW = NULL; static unsigned long long *tcpext_TWRecycled = NULL; static unsigned long long *tcpext_TWKilled = NULL; static unsigned long long *tcpext_PAWSEstab = NULL; static unsigned long long *tcpext_DelayedACKs = NULL; static unsigned long long *tcpext_DelayedACKLocked = NULL; static unsigned long long *tcpext_DelayedACKLost = NULL; static unsigned long long *tcpext_ListenOverflows = NULL; static unsigned long long *tcpext_ListenDrops = NULL; static unsigned long long *tcpext_TCPPrequeued = NULL; static unsigned long long *tcpext_TCPDirectCopyFromBacklog = NULL; static unsigned long long *tcpext_TCPDirectCopyFromPrequeue = NULL; static unsigned long long *tcpext_TCPPrequeueDropped = NULL; static unsigned long long *tcpext_TCPHPHits = NULL; static unsigned long long *tcpext_TCPHPHitsToUser = NULL; static unsigned long long *tcpext_TCPHPAcks = NULL; static unsigned long long *tcpext_TCPPureAcks = NULL; static unsigned long long *tcpext_TCPRenoRecovery = NULL; static unsigned long long *tcpext_TCPSackRecovery = NULL; static unsigned long long *tcpext_TCPSackFailures = NULL; static unsigned long long *tcpext_TCPSACKReneging = NULL; static unsigned long long *tcpext_TCPSackRecoveryFail = NULL; static unsigned long long *tcpext_TCPSACKDiscard = NULL; static unsigned long long *tcpext_TCPSackShifted = NULL; static unsigned long long *tcpext_TCPSackMerged = NULL; static unsigned long long *tcpext_TCPSackShiftFallback = NULL; static unsigned long long *tcpext_TCPFullUndo = NULL; static unsigned long long *tcpext_TCPPartialUndo = NULL; static unsigned long long *tcpext_TCPLossUndo = NULL; static unsigned long long *tcpext_TCPLostRetransmit = NULL; static unsigned long long *tcpext_TCPRenoFailures = NULL; static unsigned long long *tcpext_TCPLossFailures = NULL; static unsigned long long *tcpext_TCPFastRetrans = NULL; static unsigned long long *tcpext_TCPForwardRetrans = NULL; static unsigned long long *tcpext_TCPSlowStartRetrans = NULL; static unsigned long long *tcpext_TCPLossProbes = NULL; static unsigned long long *tcpext_TCPLossProbeRecovery = NULL; static unsigned long long *tcpext_TCPRenoRecoveryFail = NULL; static unsigned long long *tcpext_TCPSchedulerFailed = NULL; static unsigned long long *tcpext_TCPRcvCollapsed = NULL; static unsigned long long *tcpext_TCPSpuriousRTOs = NULL; static unsigned long long *tcpext_TCPMD5NotFound = NULL; static unsigned long long *tcpext_TCPMD5Unexpected = NULL; static unsigned long long *tcpext_TCPBacklogDrop = NULL; static unsigned long long *tcpext_TCPMinTTLDrop = NULL; static unsigned long long *tcpext_TCPDeferAcceptDrop = NULL; static unsigned long long *tcpext_IPReversePathFilter = NULL; static unsigned long long *tcpext_TCPTimeWaitOverflow = NULL; static unsigned long long *tcpext_TCPReqQFullDoCookies = NULL; static unsigned long long *tcpext_TCPReqQFullDrop = NULL; static unsigned long long *tcpext_TCPRetransFail = NULL; static unsigned long long *tcpext_TCPRcvCoalesce = NULL; static unsigned long long *tcpext_TCPChallengeACK = NULL; static unsigned long long *tcpext_TCPSYNChallenge = NULL; static unsigned long long *tcpext_TCPFastOpenActive = NULL; static unsigned long long *tcpext_TCPFastOpenActiveFail = NULL; static unsigned long long *tcpext_TCPFastOpenPassive = NULL; static unsigned long long *tcpext_TCPFastOpenPassiveFail = NULL; static unsigned long long *tcpext_TCPFastOpenListenOverflow = NULL; static unsigned long long *tcpext_TCPFastOpenCookieReqd = NULL; static unsigned long long *tcpext_TCPSpuriousRtxHostQueues = NULL; static unsigned long long *tcpext_BusyPollRxPackets = NULL; static unsigned long long *tcpext_TCPAutoCorking = NULL; static unsigned long long *tcpext_TCPFromZeroWindowAdv = NULL; static unsigned long long *tcpext_TCPToZeroWindowAdv = NULL; static unsigned long long *tcpext_TCPWantZeroWindowAdv = NULL; static unsigned long long *tcpext_TCPSynRetrans = NULL; static unsigned long long *tcpext_TCPOrigDataSent = NULL; static unsigned long long *tcpext_TCPHystartTrainDetect = NULL; static unsigned long long *tcpext_TCPHystartTrainCwnd = NULL; static unsigned long long *tcpext_TCPHystartDelayDetect = NULL; static unsigned long long *tcpext_TCPHystartDelayCwnd = NULL; static unsigned long long *tcpext_TCPACKSkippedSynRecv = NULL; static unsigned long long *tcpext_TCPACKSkippedPAWS = NULL; static unsigned long long *tcpext_TCPACKSkippedSeq = NULL; static unsigned long long *tcpext_TCPACKSkippedFinWait2 = NULL; static unsigned long long *tcpext_TCPACKSkippedTimeWait = NULL; static unsigned long long *tcpext_TCPACKSkippedChallenge = NULL; static unsigned long long *tcpext_TCPWinProbe = NULL; static unsigned long long *tcpext_TCPKeepAlive = NULL; static unsigned long long *tcpext_TCPMTUPFail = NULL; static unsigned long long *tcpext_TCPMTUPSuccess = NULL; */ static unsigned long long *ipext_InNoRoutes = NULL; static unsigned long long *ipext_InTruncatedPkts = NULL; static unsigned long long *ipext_InMcastPkts = NULL; static unsigned long long *ipext_OutMcastPkts = NULL; static unsigned long long *ipext_InBcastPkts = NULL; static unsigned long long *ipext_OutBcastPkts = NULL; static unsigned long long *ipext_InOctets = NULL; static unsigned long long *ipext_OutOctets = NULL; static unsigned long long *ipext_InMcastOctets = NULL; static unsigned long long *ipext_OutMcastOctets = NULL; static unsigned long long *ipext_InBcastOctets = NULL; static unsigned long long *ipext_OutBcastOctets = NULL; static unsigned long long *ipext_InCsumErrors = NULL; static unsigned long long *ipext_InNoECTPkts = NULL; static unsigned long long *ipext_InECT1Pkts = NULL; static unsigned long long *ipext_InECT0Pkts = NULL; static unsigned long long *ipext_InCEPkts = NULL; if(unlikely(do_bandwidth == -1)) { do_bandwidth = config_get_boolean_ondemand("plugin:proc:/proc/net/netstat", "bandwidth", CONFIG_ONDEMAND_ONDEMAND); do_inerrors = config_get_boolean_ondemand("plugin:proc:/proc/net/netstat", "input errors", CONFIG_ONDEMAND_ONDEMAND); do_mcast = config_get_boolean_ondemand("plugin:proc:/proc/net/netstat", "multicast bandwidth", CONFIG_ONDEMAND_ONDEMAND); do_bcast = config_get_boolean_ondemand("plugin:proc:/proc/net/netstat", "broadcast bandwidth", CONFIG_ONDEMAND_ONDEMAND); do_mcast_p = config_get_boolean_ondemand("plugin:proc:/proc/net/netstat", "multicast packets", CONFIG_ONDEMAND_ONDEMAND); do_bcast_p = config_get_boolean_ondemand("plugin:proc:/proc/net/netstat", "broadcast packets", CONFIG_ONDEMAND_ONDEMAND); do_ecn = config_get_boolean_ondemand("plugin:proc:/proc/net/netstat", "ECN packets", CONFIG_ONDEMAND_ONDEMAND); do_tcpext_reorder = config_get_boolean_ondemand("plugin:proc:/proc/net/netstat", "TCP reorders", CONFIG_ONDEMAND_ONDEMAND); do_tcpext_syscookies = config_get_boolean_ondemand("plugin:proc:/proc/net/netstat", "TCP SYN cookies", CONFIG_ONDEMAND_ONDEMAND); do_tcpext_ofo = config_get_boolean_ondemand("plugin:proc:/proc/net/netstat", "TCP out-of-order queue", CONFIG_ONDEMAND_ONDEMAND); do_tcpext_connaborts = config_get_boolean_ondemand("plugin:proc:/proc/net/netstat", "TCP connection aborts", CONFIG_ONDEMAND_ONDEMAND); do_tcpext_memory = config_get_boolean_ondemand("plugin:proc:/proc/net/netstat", "TCP memory pressures", CONFIG_ONDEMAND_ONDEMAND); hash_ipext = simple_hash("IpExt"); hash_tcpext = simple_hash("TcpExt"); hash_array(ipext_data); hash_array(tcpext_data); // Reordering tcpext_TCPFACKReorder = netstat_columns_find(tcpext_data, "TCPFACKReorder"); tcpext_TCPSACKReorder = netstat_columns_find(tcpext_data, "TCPSACKReorder"); tcpext_TCPRenoReorder = netstat_columns_find(tcpext_data, "TCPRenoReorder"); tcpext_TCPTSReorder = netstat_columns_find(tcpext_data, "TCPTSReorder"); // SYN Cookies tcpext_SyncookiesSent = netstat_columns_find(tcpext_data, "SyncookiesSent"); tcpext_SyncookiesRecv = netstat_columns_find(tcpext_data, "SyncookiesRecv"); tcpext_SyncookiesFailed = netstat_columns_find(tcpext_data, "SyncookiesFailed"); // Out Of Order Queue // http://www.spinics.net/lists/netdev/msg204696.html tcpext_TCPOFOQueue = netstat_columns_find(tcpext_data, "TCPOFOQueue"); // Number of packets queued in OFO queue tcpext_TCPOFODrop = netstat_columns_find(tcpext_data, "TCPOFODrop"); // Number of packets meant to be queued in OFO but dropped because socket rcvbuf limit hit. tcpext_TCPOFOMerge = netstat_columns_find(tcpext_data, "TCPOFOMerge"); // Number of packets in OFO that were merged with other packets. tcpext_OfoPruned = netstat_columns_find(tcpext_data, "OfoPruned"); // packets dropped from out-of-order queue because of socket buffer overrun // connection resets // https://github.com/ecki/net-tools/blob/bd8bceaed2311651710331a7f8990c3e31be9840/statistics.c tcpext_TCPAbortOnData = netstat_columns_find(tcpext_data, "TCPAbortOnData"); // connections reset due to unexpected data tcpext_TCPAbortOnClose = netstat_columns_find(tcpext_data, "TCPAbortOnClose"); // connections reset due to early user close tcpext_TCPAbortOnMemory = netstat_columns_find(tcpext_data, "TCPAbortOnMemory"); // connections aborted due to memory pressure tcpext_TCPAbortOnTimeout = netstat_columns_find(tcpext_data, "TCPAbortOnTimeout"); // connections aborted due to timeout tcpext_TCPAbortOnLinger = netstat_columns_find(tcpext_data, "TCPAbortOnLinger"); // connections aborted after user close in linger timeout tcpext_TCPAbortFailed = netstat_columns_find(tcpext_data, "TCPAbortFailed"); // times unable to send RST due to no memory tcpext_TCPMemoryPressures = netstat_columns_find(tcpext_data, "TCPMemoryPressures"); /* tcpext_EmbryonicRsts = netstat_columns_find(tcpext_data, "EmbryonicRsts"); tcpext_PruneCalled = netstat_columns_find(tcpext_data, "PruneCalled"); tcpext_RcvPruned = netstat_columns_find(tcpext_data, "RcvPruned"); tcpext_OutOfWindowIcmps = netstat_columns_find(tcpext_data, "OutOfWindowIcmps"); tcpext_LockDroppedIcmps = netstat_columns_find(tcpext_data, "LockDroppedIcmps"); tcpext_ArpFilter = netstat_columns_find(tcpext_data, "ArpFilter"); tcpext_TW = netstat_columns_find(tcpext_data, "TW"); tcpext_TWRecycled = netstat_columns_find(tcpext_data, "TWRecycled"); tcpext_TWKilled = netstat_columns_find(tcpext_data, "TWKilled"); tcpext_PAWSPassive = netstat_columns_find(tcpext_data, "PAWSPassive"); tcpext_PAWSActive = netstat_columns_find(tcpext_data, "PAWSActive"); tcpext_PAWSEstab = netstat_columns_find(tcpext_data, "PAWSEstab"); tcpext_DelayedACKs = netstat_columns_find(tcpext_data, "DelayedACKs"); tcpext_DelayedACKLocked = netstat_columns_find(tcpext_data, "DelayedACKLocked"); tcpext_DelayedACKLost = netstat_columns_find(tcpext_data, "DelayedACKLost"); tcpext_ListenOverflows = netstat_columns_find(tcpext_data, "ListenOverflows"); tcpext_ListenDrops = netstat_columns_find(tcpext_data, "ListenDrops"); tcpext_TCPPrequeued = netstat_columns_find(tcpext_data, "TCPPrequeued"); tcpext_TCPDirectCopyFromBacklog = netstat_columns_find(tcpext_data, "TCPDirectCopyFromBacklog"); tcpext_TCPDirectCopyFromPrequeue = netstat_columns_find(tcpext_data, "TCPDirectCopyFromPrequeue"); tcpext_TCPPrequeueDropped = netstat_columns_find(tcpext_data, "TCPPrequeueDropped"); tcpext_TCPHPHits = netstat_columns_find(tcpext_data, "TCPHPHits"); tcpext_TCPHPHitsToUser = netstat_columns_find(tcpext_data, "TCPHPHitsToUser"); tcpext_TCPPureAcks = netstat_columns_find(tcpext_data, "TCPPureAcks"); tcpext_TCPHPAcks = netstat_columns_find(tcpext_data, "TCPHPAcks"); tcpext_TCPRenoRecovery = netstat_columns_find(tcpext_data, "TCPRenoRecovery"); tcpext_TCPSackRecovery = netstat_columns_find(tcpext_data, "TCPSackRecovery"); tcpext_TCPSACKReneging = netstat_columns_find(tcpext_data, "TCPSACKReneging"); tcpext_TCPFullUndo = netstat_columns_find(tcpext_data, "TCPFullUndo"); tcpext_TCPPartialUndo = netstat_columns_find(tcpext_data, "TCPPartialUndo"); tcpext_TCPDSACKUndo = netstat_columns_find(tcpext_data, "TCPDSACKUndo"); tcpext_TCPLossUndo = netstat_columns_find(tcpext_data, "TCPLossUndo"); tcpext_TCPLostRetransmit = netstat_columns_find(tcpext_data, "TCPLostRetransmit"); tcpext_TCPRenoFailures = netstat_columns_find(tcpext_data, "TCPRenoFailures"); tcpext_TCPSackFailures = netstat_columns_find(tcpext_data, "TCPSackFailures"); tcpext_TCPLossFailures = netstat_columns_find(tcpext_data, "TCPLossFailures"); tcpext_TCPFastRetrans = netstat_columns_find(tcpext_data, "TCPFastRetrans"); tcpext_TCPForwardRetrans = netstat_columns_find(tcpext_data, "TCPForwardRetrans"); tcpext_TCPSlowStartRetrans = netstat_columns_find(tcpext_data, "TCPSlowStartRetrans"); tcpext_TCPTimeouts = netstat_columns_find(tcpext_data, "TCPTimeouts"); tcpext_TCPLossProbes = netstat_columns_find(tcpext_data, "TCPLossProbes"); tcpext_TCPLossProbeRecovery = netstat_columns_find(tcpext_data, "TCPLossProbeRecovery"); tcpext_TCPRenoRecoveryFail = netstat_columns_find(tcpext_data, "TCPRenoRecoveryFail"); tcpext_TCPSackRecoveryFail = netstat_columns_find(tcpext_data, "TCPSackRecoveryFail"); tcpext_TCPSchedulerFailed = netstat_columns_find(tcpext_data, "TCPSchedulerFailed"); tcpext_TCPRcvCollapsed = netstat_columns_find(tcpext_data, "TCPRcvCollapsed"); tcpext_TCPDSACKOldSent = netstat_columns_find(tcpext_data, "TCPDSACKOldSent"); tcpext_TCPDSACKOfoSent = netstat_columns_find(tcpext_data, "TCPDSACKOfoSent"); tcpext_TCPDSACKRecv = netstat_columns_find(tcpext_data, "TCPDSACKRecv"); tcpext_TCPDSACKOfoRecv = netstat_columns_find(tcpext_data, "TCPDSACKOfoRecv"); tcpext_TCPSACKDiscard = netstat_columns_find(tcpext_data, "TCPSACKDiscard"); tcpext_TCPDSACKIgnoredOld = netstat_columns_find(tcpext_data, "TCPDSACKIgnoredOld"); tcpext_TCPDSACKIgnoredNoUndo = netstat_columns_find(tcpext_data, "TCPDSACKIgnoredNoUndo"); tcpext_TCPSpuriousRTOs = netstat_columns_find(tcpext_data, "TCPSpuriousRTOs"); tcpext_TCPMD5NotFound = netstat_columns_find(tcpext_data, "TCPMD5NotFound"); tcpext_TCPMD5Unexpected = netstat_columns_find(tcpext_data, "TCPMD5Unexpected"); tcpext_TCPSackShifted = netstat_columns_find(tcpext_data, "TCPSackShifted"); tcpext_TCPSackMerged = netstat_columns_find(tcpext_data, "TCPSackMerged"); tcpext_TCPSackShiftFallback = netstat_columns_find(tcpext_data, "TCPSackShiftFallback"); tcpext_TCPBacklogDrop = netstat_columns_find(tcpext_data, "TCPBacklogDrop"); tcpext_TCPMinTTLDrop = netstat_columns_find(tcpext_data, "TCPMinTTLDrop"); tcpext_TCPDeferAcceptDrop = netstat_columns_find(tcpext_data, "TCPDeferAcceptDrop"); tcpext_IPReversePathFilter = netstat_columns_find(tcpext_data, "IPReversePathFilter"); tcpext_TCPTimeWaitOverflow = netstat_columns_find(tcpext_data, "TCPTimeWaitOverflow"); tcpext_TCPReqQFullDoCookies = netstat_columns_find(tcpext_data, "TCPReqQFullDoCookies"); tcpext_TCPReqQFullDrop = netstat_columns_find(tcpext_data, "TCPReqQFullDrop"); tcpext_TCPRetransFail = netstat_columns_find(tcpext_data, "TCPRetransFail"); tcpext_TCPRcvCoalesce = netstat_columns_find(tcpext_data, "TCPRcvCoalesce"); tcpext_TCPChallengeACK = netstat_columns_find(tcpext_data, "TCPChallengeACK"); tcpext_TCPSYNChallenge = netstat_columns_find(tcpext_data, "TCPSYNChallenge"); tcpext_TCPFastOpenActive = netstat_columns_find(tcpext_data, "TCPFastOpenActive"); tcpext_TCPFastOpenActiveFail = netstat_columns_find(tcpext_data, "TCPFastOpenActiveFail"); tcpext_TCPFastOpenPassive = netstat_columns_find(tcpext_data, "TCPFastOpenPassive"); tcpext_TCPFastOpenPassiveFail = netstat_columns_find(tcpext_data, "TCPFastOpenPassiveFail"); tcpext_TCPFastOpenListenOverflow = netstat_columns_find(tcpext_data, "TCPFastOpenListenOverflow"); tcpext_TCPFastOpenCookieReqd = netstat_columns_find(tcpext_data, "TCPFastOpenCookieReqd"); tcpext_TCPSpuriousRtxHostQueues = netstat_columns_find(tcpext_data, "TCPSpuriousRtxHostQueues"); tcpext_BusyPollRxPackets = netstat_columns_find(tcpext_data, "BusyPollRxPackets"); tcpext_TCPAutoCorking = netstat_columns_find(tcpext_data, "TCPAutoCorking"); tcpext_TCPFromZeroWindowAdv = netstat_columns_find(tcpext_data, "TCPFromZeroWindowAdv"); tcpext_TCPToZeroWindowAdv = netstat_columns_find(tcpext_data, "TCPToZeroWindowAdv"); tcpext_TCPWantZeroWindowAdv = netstat_columns_find(tcpext_data, "TCPWantZeroWindowAdv"); tcpext_TCPSynRetrans = netstat_columns_find(tcpext_data, "TCPSynRetrans"); tcpext_TCPOrigDataSent = netstat_columns_find(tcpext_data, "TCPOrigDataSent"); tcpext_TCPHystartTrainDetect = netstat_columns_find(tcpext_data, "TCPHystartTrainDetect"); tcpext_TCPHystartTrainCwnd = netstat_columns_find(tcpext_data, "TCPHystartTrainCwnd"); tcpext_TCPHystartDelayDetect = netstat_columns_find(tcpext_data, "TCPHystartDelayDetect"); tcpext_TCPHystartDelayCwnd = netstat_columns_find(tcpext_data, "TCPHystartDelayCwnd"); tcpext_TCPACKSkippedSynRecv = netstat_columns_find(tcpext_data, "TCPACKSkippedSynRecv"); tcpext_TCPACKSkippedPAWS = netstat_columns_find(tcpext_data, "TCPACKSkippedPAWS"); tcpext_TCPACKSkippedSeq = netstat_columns_find(tcpext_data, "TCPACKSkippedSeq"); tcpext_TCPACKSkippedFinWait2 = netstat_columns_find(tcpext_data, "TCPACKSkippedFinWait2"); tcpext_TCPACKSkippedTimeWait = netstat_columns_find(tcpext_data, "TCPACKSkippedTimeWait"); tcpext_TCPACKSkippedChallenge = netstat_columns_find(tcpext_data, "TCPACKSkippedChallenge"); tcpext_TCPWinProbe = netstat_columns_find(tcpext_data, "TCPWinProbe"); tcpext_TCPKeepAlive = netstat_columns_find(tcpext_data, "TCPKeepAlive"); tcpext_TCPMTUPFail = netstat_columns_find(tcpext_data, "TCPMTUPFail"); tcpext_TCPMTUPSuccess = netstat_columns_find(tcpext_data, "TCPMTUPSuccess"); */ ipext_InNoRoutes = netstat_columns_find(ipext_data, "InNoRoutes"); ipext_InTruncatedPkts = netstat_columns_find(ipext_data, "InTruncatedPkts"); ipext_InMcastPkts = netstat_columns_find(ipext_data, "InMcastPkts"); ipext_OutMcastPkts = netstat_columns_find(ipext_data, "OutMcastPkts"); ipext_InBcastPkts = netstat_columns_find(ipext_data, "InBcastPkts"); ipext_OutBcastPkts = netstat_columns_find(ipext_data, "OutBcastPkts"); ipext_InOctets = netstat_columns_find(ipext_data, "InOctets"); ipext_OutOctets = netstat_columns_find(ipext_data, "OutOctets"); ipext_InMcastOctets = netstat_columns_find(ipext_data, "InMcastOctets"); ipext_OutMcastOctets = netstat_columns_find(ipext_data, "OutMcastOctets"); ipext_InBcastOctets = netstat_columns_find(ipext_data, "InBcastOctets"); ipext_OutBcastOctets = netstat_columns_find(ipext_data, "OutBcastOctets"); ipext_InCsumErrors = netstat_columns_find(ipext_data, "InCsumErrors"); ipext_InNoECTPkts = netstat_columns_find(ipext_data, "InNoECTPkts"); ipext_InECT1Pkts = netstat_columns_find(ipext_data, "InECT1Pkts"); ipext_InECT0Pkts = netstat_columns_find(ipext_data, "InECT0Pkts"); ipext_InCEPkts = netstat_columns_find(ipext_data, "InCEPkts"); } if(unlikely(!ff)) { char filename[FILENAME_MAX + 1]; snprintfz(filename, FILENAME_MAX, "%s%s", global_host_prefix, "/proc/net/netstat"); ff = procfile_open(config_get("plugin:proc:/proc/net/netstat", "filename to monitor", filename), " \t:", PROCFILE_FLAG_DEFAULT); if(unlikely(!ff)) return 1; } ff = procfile_readall(ff); if(unlikely(!ff)) return 0; // we return 0, so that we will retry to open it next time uint32_t lines = procfile_lines(ff), l; uint32_t words; for(l = 0; l < lines ;l++) { char *key = procfile_lineword(ff, l, 0); uint32_t hash = simple_hash(key); if(unlikely(hash == hash_ipext && strcmp(key, "IpExt") == 0)) { uint32_t h = l++; if(unlikely(strcmp(procfile_lineword(ff, l, 0), "IpExt") != 0)) { error("Cannot read IpExt line from /proc/net/netstat."); break; } words = procfile_linewords(ff, l); if(unlikely(words < 2)) { error("Cannot read /proc/net/netstat IpExt line. Expected 2+ params, read %u.", words); continue; } parse_line_pair(ff, ipext_data, h, l); RRDSET *st; // -------------------------------------------------------------------- if(do_bandwidth == CONFIG_ONDEMAND_YES || (do_bandwidth == CONFIG_ONDEMAND_ONDEMAND && (*ipext_InOctets || *ipext_OutOctets))) { do_bandwidth = CONFIG_ONDEMAND_YES; st = rrdset_find("system.ipv4"); if(unlikely(!st)) { st = rrdset_create("system", "ipv4", NULL, "network", NULL, "IPv4 Bandwidth", "kilobits/s", 500, update_every, RRDSET_TYPE_AREA); rrddim_add(st, "InOctets", "received", 8, 1024, RRDDIM_INCREMENTAL); rrddim_add(st, "OutOctets", "sent", -8, 1024, RRDDIM_INCREMENTAL); } else rrdset_next(st); rrddim_set(st, "InOctets", *ipext_InOctets); rrddim_set(st, "OutOctets", *ipext_OutOctets); rrdset_done(st); } // -------------------------------------------------------------------- if(do_inerrors == CONFIG_ONDEMAND_YES || (do_inerrors == CONFIG_ONDEMAND_ONDEMAND && (*ipext_InNoRoutes || *ipext_InTruncatedPkts))) { do_inerrors = CONFIG_ONDEMAND_YES; st = rrdset_find("ipv4.inerrors"); if(unlikely(!st)) { st = rrdset_create("ipv4", "inerrors", NULL, "errors", NULL, "IPv4 Input Errors", "packets/s", 4000, update_every, RRDSET_TYPE_LINE); st->isdetail = 1; rrddim_add(st, "InNoRoutes", "noroutes", 1, 1, RRDDIM_INCREMENTAL); rrddim_add(st, "InTruncatedPkts", "truncated", 1, 1, RRDDIM_INCREMENTAL); rrddim_add(st, "InCsumErrors", "checksum", 1, 1, RRDDIM_INCREMENTAL); } else rrdset_next(st); rrddim_set(st, "InNoRoutes", *ipext_InNoRoutes); rrddim_set(st, "InTruncatedPkts", *ipext_InTruncatedPkts); rrddim_set(st, "InCsumErrors", *ipext_InCsumErrors); rrdset_done(st); } // -------------------------------------------------------------------- if(do_mcast == CONFIG_ONDEMAND_YES || (do_mcast == CONFIG_ONDEMAND_ONDEMAND && (*ipext_InMcastOctets || *ipext_OutMcastOctets))) { do_mcast = CONFIG_ONDEMAND_YES; st = rrdset_find("ipv4.mcast"); if(unlikely(!st)) { st = rrdset_create("ipv4", "mcast", NULL, "multicast", NULL, "IPv4 Multicast Bandwidth", "kilobits/s", 9000, update_every, RRDSET_TYPE_AREA); st->isdetail = 1; rrddim_add(st, "InMcastOctets", "received", 8, 1024, RRDDIM_INCREMENTAL); rrddim_add(st, "OutMcastOctets", "sent", -8, 1024, RRDDIM_INCREMENTAL); } else rrdset_next(st); rrddim_set(st, "InMcastOctets", *ipext_InMcastOctets); rrddim_set(st, "OutMcastOctets", *ipext_OutMcastOctets); rrdset_done(st); } // -------------------------------------------------------------------- if(do_bcast == CONFIG_ONDEMAND_YES || (do_bcast == CONFIG_ONDEMAND_ONDEMAND && (*ipext_InBcastOctets || *ipext_OutBcastOctets))) { do_bcast = CONFIG_ONDEMAND_YES; st = rrdset_find("ipv4.bcast"); if(unlikely(!st)) { st = rrdset_create("ipv4", "bcast", NULL, "broadcast", NULL, "IPv4 Broadcast Bandwidth", "kilobits/s", 8000, update_every, RRDSET_TYPE_AREA); st->isdetail = 1; rrddim_add(st, "InBcastOctets", "received", 8, 1024, RRDDIM_INCREMENTAL); rrddim_add(st, "OutBcastOctets", "sent", -8, 1024, RRDDIM_INCREMENTAL); } else rrdset_next(st); rrddim_set(st, "InBcastOctets", *ipext_InBcastOctets); rrddim_set(st, "OutBcastOctets", *ipext_OutBcastOctets); rrdset_done(st); } // -------------------------------------------------------------------- if(do_mcast_p == CONFIG_ONDEMAND_YES || (do_mcast_p == CONFIG_ONDEMAND_ONDEMAND && (*ipext_InMcastPkts || *ipext_OutMcastPkts))) { do_mcast_p = CONFIG_ONDEMAND_YES; st = rrdset_find("ipv4.mcastpkts"); if(unlikely(!st)) { st = rrdset_create("ipv4", "mcastpkts", NULL, "multicast", NULL, "IPv4 Multicast Packets", "packets/s", 8600, update_every, RRDSET_TYPE_LINE); st->isdetail = 1; rrddim_add(st, "InMcastPkts", "received", 1, 1, RRDDIM_INCREMENTAL); rrddim_add(st, "OutMcastPkts", "sent", -1, 1, RRDDIM_INCREMENTAL); } else rrdset_next(st); rrddim_set(st, "InMcastPkts", *ipext_InMcastPkts); rrddim_set(st, "OutMcastPkts", *ipext_OutMcastPkts); rrdset_done(st); } // -------------------------------------------------------------------- if(do_bcast_p == CONFIG_ONDEMAND_YES || (do_bcast_p == CONFIG_ONDEMAND_ONDEMAND && (*ipext_InBcastPkts || *ipext_OutBcastPkts))) { do_bcast_p = CONFIG_ONDEMAND_YES; st = rrdset_find("ipv4.bcastpkts"); if(unlikely(!st)) { st = rrdset_create("ipv4", "bcastpkts", NULL, "broadcast", NULL, "IPv4 Broadcast Packets", "packets/s", 8500, update_every, RRDSET_TYPE_LINE); st->isdetail = 1; rrddim_add(st, "InBcastPkts", "received", 1, 1, RRDDIM_INCREMENTAL); rrddim_add(st, "OutBcastPkts", "sent", -1, 1, RRDDIM_INCREMENTAL); } else rrdset_next(st); rrddim_set(st, "InBcastPkts", *ipext_InBcastPkts); rrddim_set(st, "OutBcastPkts", *ipext_OutBcastPkts); rrdset_done(st); } // -------------------------------------------------------------------- if(do_ecn == CONFIG_ONDEMAND_YES || (do_ecn == CONFIG_ONDEMAND_ONDEMAND && (*ipext_InCEPkts || *ipext_InECT0Pkts || *ipext_InECT1Pkts || *ipext_InNoECTPkts))) { do_ecn = CONFIG_ONDEMAND_YES; st = rrdset_find("ipv4.ecnpkts"); if(unlikely(!st)) { st = rrdset_create("ipv4", "ecnpkts", NULL, "ecn", NULL, "IPv4 ECN Statistics", "packets/s", 8700, update_every, RRDSET_TYPE_LINE); st->isdetail = 1; rrddim_add(st, "InCEPkts", "CEP", 1, 1, RRDDIM_INCREMENTAL); rrddim_add(st, "InNoECTPkts", "NoECTP", -1, 1, RRDDIM_INCREMENTAL); rrddim_add(st, "InECT0Pkts", "ECTP0", 1, 1, RRDDIM_INCREMENTAL); rrddim_add(st, "InECT1Pkts", "ECTP1", 1, 1, RRDDIM_INCREMENTAL); } else rrdset_next(st); rrddim_set(st, "InCEPkts", *ipext_InCEPkts); rrddim_set(st, "InNoECTPkts", *ipext_InNoECTPkts); rrddim_set(st, "InECT0Pkts", *ipext_InECT0Pkts); rrddim_set(st, "InECT1Pkts", *ipext_InECT1Pkts); rrdset_done(st); } } else if(unlikely(hash == hash_tcpext && strcmp(key, "TcpExt") == 0)) { uint32_t h = l++; if(unlikely(strcmp(procfile_lineword(ff, l, 0), "TcpExt") != 0)) { error("Cannot read TcpExt line from /proc/net/netstat."); break; } words = procfile_linewords(ff, l); if(unlikely(words < 2)) { error("Cannot read /proc/net/netstat TcpExt line. Expected 2+ params, read %u.", words); continue; } parse_line_pair(ff, tcpext_data, h, l); RRDSET *st; // -------------------------------------------------------------------- if(do_tcpext_memory == CONFIG_ONDEMAND_YES || (do_tcpext_memory == CONFIG_ONDEMAND_ONDEMAND && (*tcpext_TCPMemoryPressures))) { do_tcpext_memory = CONFIG_ONDEMAND_YES; st = rrdset_find("ipv4.tcpmemorypressures"); if(unlikely(!st)) { st = rrdset_create("ipv4", "tcpmemorypressures", NULL, "tcp", NULL, "TCP Memory Pressures", "events/s", 3000, update_every, RRDSET_TYPE_LINE); rrddim_add(st, "TCPMemoryPressures", "pressures", 1, 1, RRDDIM_INCREMENTAL); } else rrdset_next(st); rrddim_set(st, "TCPMemoryPressures", *tcpext_TCPMemoryPressures); rrdset_done(st); } // -------------------------------------------------------------------- if(do_tcpext_connaborts == CONFIG_ONDEMAND_YES || (do_tcpext_connaborts == CONFIG_ONDEMAND_ONDEMAND && (*tcpext_TCPAbortOnData || *tcpext_TCPAbortOnClose || *tcpext_TCPAbortOnMemory || *tcpext_TCPAbortOnTimeout || *tcpext_TCPAbortOnLinger || *tcpext_TCPAbortFailed))) { do_tcpext_connaborts = CONFIG_ONDEMAND_YES; st = rrdset_find("ipv4.tcpconnaborts"); if(unlikely(!st)) { st = rrdset_create("ipv4", "tcpconnaborts", NULL, "tcp", NULL, "TCP Connection Aborts", "connections/s", 3010, update_every, RRDSET_TYPE_LINE); rrddim_add(st, "TCPAbortOnData", "baddata", 1, 1, RRDDIM_INCREMENTAL); rrddim_add(st, "TCPAbortOnClose", "userclosed", 1, 1, RRDDIM_INCREMENTAL); rrddim_add(st, "TCPAbortOnMemory", "nomemory", 1, 1, RRDDIM_INCREMENTAL); rrddim_add(st, "TCPAbortOnTimeout", "timeout", 1, 1, RRDDIM_INCREMENTAL); rrddim_add(st, "TCPAbortOnLinger", "linger", 1, 1, RRDDIM_INCREMENTAL); rrddim_add(st, "TCPAbortFailed", "failed", -1, 1, RRDDIM_INCREMENTAL); } else rrdset_next(st); rrddim_set(st, "TCPAbortOnData", *tcpext_TCPAbortOnData); rrddim_set(st, "TCPAbortOnClose", *tcpext_TCPAbortOnClose); rrddim_set(st, "TCPAbortOnMemory", *tcpext_TCPAbortOnMemory); rrddim_set(st, "TCPAbortOnTimeout", *tcpext_TCPAbortOnTimeout); rrddim_set(st, "TCPAbortOnLinger", *tcpext_TCPAbortOnLinger); rrddim_set(st, "TCPAbortFailed", *tcpext_TCPAbortFailed); rrdset_done(st); } // -------------------------------------------------------------------- if(do_tcpext_reorder == CONFIG_ONDEMAND_YES || (do_tcpext_reorder == CONFIG_ONDEMAND_ONDEMAND && (*tcpext_TCPRenoReorder || *tcpext_TCPFACKReorder || *tcpext_TCPSACKReorder || *tcpext_TCPTSReorder))) { do_tcpext_reorder = CONFIG_ONDEMAND_YES; st = rrdset_find("ipv4.tcpreorders"); if(unlikely(!st)) { st = rrdset_create("ipv4", "tcpreorders", NULL, "tcp", NULL, "TCP Reordered Packets by Detection Method", "packets/s", 3020, update_every, RRDSET_TYPE_LINE); rrddim_add(st, "TCPTSReorder", "timestamp", 1, 1, RRDDIM_INCREMENTAL); rrddim_add(st, "TCPSACKReorder", "sack", 1, 1, RRDDIM_INCREMENTAL); rrddim_add(st, "TCPFACKReorder", "fack", 1, 1, RRDDIM_INCREMENTAL); rrddim_add(st, "TCPRenoReorder", "reno", 1, 1, RRDDIM_INCREMENTAL); } else rrdset_next(st); rrddim_set(st, "TCPTSReorder", *tcpext_TCPTSReorder); rrddim_set(st, "TCPSACKReorder", *tcpext_TCPSACKReorder); rrddim_set(st, "TCPFACKReorder", *tcpext_TCPFACKReorder); rrddim_set(st, "TCPRenoReorder", *tcpext_TCPRenoReorder); rrdset_done(st); } // -------------------------------------------------------------------- if(do_tcpext_ofo == CONFIG_ONDEMAND_YES || (do_tcpext_ofo == CONFIG_ONDEMAND_ONDEMAND && (*tcpext_TCPOFOQueue || *tcpext_TCPOFODrop || *tcpext_TCPOFOMerge))) { do_tcpext_ofo = CONFIG_ONDEMAND_YES; st = rrdset_find("ipv4.tcpofo"); if(unlikely(!st)) { st = rrdset_create("ipv4", "tcpofo", NULL, "tcp", NULL, "TCP Out-Of-Order Queue", "packets/s", 3050, update_every, RRDSET_TYPE_LINE); rrddim_add(st, "TCPOFOQueue", "inqueue", 1, 1, RRDDIM_INCREMENTAL); rrddim_add(st, "TCPOFODrop", "dropped", -1, 1, RRDDIM_INCREMENTAL); rrddim_add(st, "TCPOFOMerge", "merged", 1, 1, RRDDIM_INCREMENTAL); rrddim_add(st, "OfoPruned", "pruned", -1, 1, RRDDIM_INCREMENTAL); } else rrdset_next(st); rrddim_set(st, "TCPOFOQueue", *tcpext_TCPOFOQueue); rrddim_set(st, "TCPOFODrop", *tcpext_TCPOFODrop); rrddim_set(st, "TCPOFOMerge", *tcpext_TCPOFOMerge); rrddim_set(st, "OfoPruned", *tcpext_OfoPruned); rrdset_done(st); } // -------------------------------------------------------------------- if(do_tcpext_syscookies == CONFIG_ONDEMAND_YES || (do_tcpext_syscookies == CONFIG_ONDEMAND_ONDEMAND && (*tcpext_SyncookiesSent || *tcpext_SyncookiesRecv || *tcpext_SyncookiesFailed))) { do_tcpext_syscookies = CONFIG_ONDEMAND_YES; st = rrdset_find("ipv4.tcpsyncookies"); if(unlikely(!st)) { st = rrdset_create("ipv4", "tcpsyncookies", NULL, "tcp", NULL, "TCP SYN Cookies", "packets/s", 3100, update_every, RRDSET_TYPE_LINE); rrddim_add(st, "SyncookiesRecv", "received", 1, 1, RRDDIM_INCREMENTAL); rrddim_add(st, "SyncookiesSent", "sent", -1, 1, RRDDIM_INCREMENTAL); rrddim_add(st, "SyncookiesFailed", "failed", -1, 1, RRDDIM_INCREMENTAL); } else rrdset_next(st); rrddim_set(st, "SyncookiesRecv", *tcpext_SyncookiesRecv); rrddim_set(st, "SyncookiesSent", *tcpext_SyncookiesSent); rrddim_set(st, "SyncookiesFailed", *tcpext_SyncookiesFailed); rrdset_done(st); } } } return 0; }