@cryptotaxi247 / netdata-1 / commits / 0f9cc9f04

re-wrote /proc/net/snmp using ARL; added alarm for max TCP connections

Costa Tsaousis (ktsaou) committed Nov 7, 2017 at 23:28 UTC 0f9cc9f04fd8b49f17c8bf620d05c6b4c3633b60
7 files changed +398 -422
conf.d/Makefile.am
+1
@@ -102,6 +102,7 @@ dist_healthconfig_DATA = \
102 health.d/softnet.conf \
103 health.d/squid.conf \
104 health.d/swap.conf \
105 + health.d/tcp_conn.conf \
106 health.d/tcp_listen.conf \
107 health.d/tcp_orphans.conf \
108 health.d/tcp_resets.conf \
conf.d/health.d/tcp_conn.conf new
+19
@@ -0,0 +1,19 @@
1 +
2 +#
3 +# ${tcp_max_connections} may be nan or -1 if the system
4 +# supports dynamic threshold for TCP connections.
5 +# In this case, the alarm will always be zero.
6 +#
7 +
8 + alarm: tcp_connections
9 + on: ipv4.tcpsock
10 + os: linux
11 + hosts: *
12 + calc: (${tcp_max_connections} > 0) ? ( ${connections} * 100 / ${tcp_max_connections} ) : 0
13 + units: %
14 + every: 10s
15 + warn: $this > (($status >= $WARNING ) ? ( 60 ) : ( 80 ))
16 + crit: $this > (($status >= $CRITICAL) ? ( 80 ) : ( 90 ))
17 + delay: up 0 down 5m multiplier 1.5 max 1h
18 + info: the percentage of IPv4 TCP connections over the max allowed
19 + to: sysadmin
conf.d/health.d/tcp_orphans.conf
+2 -2
@@ -7,7 +7,7 @@
7 # so we alarm warning at 25% and critical at 50%
8 #
9
10 - alarm: tcp_orphans_percentage
10 + alarm: tcp_orphans
11 on: ipv4.sockstat_tcp_sockets
12 os: linux
13 hosts: *
@@ -17,5 +17,5 @@
17 warn: $this > (($status >= $WARNING ) ? ( 20 ) : ( 25 ))
18 crit: $this > (($status >= $CRITICAL) ? ( 25 ) : ( 50 ))
19 delay: up 0 down 5m multiplier 1.5 max 1h
20 - info: the percentage of orphan IPv4 TCP sockets over the max allowed (this may lead to out-of-socket-memory errors)
20 + info: the percentage of orphan IPv4 TCP sockets over the max allowed (this may lead to too-many-orphans errors)
21 to: sysadmin
src/adaptive_resortable_list.c
+10 -1
@@ -2,7 +2,7 @@
2
3 // the default processor() of the ARL
4 // can be overwritten at arl_create()
5 -static inline void arl_callback_str2ull(const char *name, uint32_t hash, const char *value, void *dst) {
5 +inline void arl_callback_str2ull(const char *name, uint32_t hash, const char *value, void *dst) {
6 (void)name;
7 (void)hash;
8
@@ -11,6 +11,15 @@ static inline void arl_callback_str2ull(const char *name, uint32_t hash, const c
11 // fprintf(stderr, "name '%s' with hash %u and value '%s' is %llu\n", name, hash, value, *d);
12 }
13
14 +inline void arl_callback_str2kernel_uint_t(const char *name, uint32_t hash, const char *value, void *dst) {
15 + (void)name;
16 + (void)hash;
17 +
18 + register kernel_uint_t *d = dst;
19 + *d = str2kernel_uint_t(value);
20 + // fprintf(stderr, "name '%s' with hash %u and value '%s' is %llu\n", name, hash, value, (unsigned long long)*d);
21 +}
22 +
23 // create a new ARL
24 ARL_BASE *arl_create(const char *name, void (*processor)(const char *, uint32_t, const char *, void *), size_t rechecks) {
25 ARL_BASE *base = callocz(1, sizeof(ARL_BASE));
src/adaptive_resortable_list.h
+3
@@ -110,6 +110,9 @@ extern int arl_find_or_create_and_relink(ARL_BASE *base, const char *s, const ch
110 // begin an ARL iteration
111 extern void arl_begin(ARL_BASE *base);
112
113 +extern void arl_callback_str2ull(const char *name, uint32_t hash, const char *value, void *dst);
114 +extern void arl_callback_str2kernel_uint_t(const char *name, uint32_t hash, const char *value, void *dst);
115 +
116 // check a keyword against the ARL
117 // this is to be called for each keyword read from source data
118 // s = the keyword, as collected
src/proc_net_snmp.c
+343 -391
@@ -2,198 +2,88 @@
2
3 #define RRD_TYPE_NET_SNMP "ipv4"
4
5 -struct netstat_columns {
6 - char *name;
7 - uint32_t hash;
8 - unsigned long long value;
9 - int multiplier; // not needed everywhere
10 - char *label; // not needed everywhere
11 - RRDDIM *rd; // not needed everywhere
12 -};
13 -
14 -static struct netstat_columns ip_data[] = {
15 -// { "Forwarding", 0, 0, 1, NULL, NULL },
16 -// { "DefaultTTL", 0, 0, 1, NULL, NULL },
17 - { "InReceives", 0, 0, 1, NULL, NULL },
18 - { "InHdrErrors", 0, 0, 1, NULL, NULL },
19 - { "InAddrErrors", 0, 0, 1, NULL, NULL },
20 - { "ForwDatagrams", 0, 0, 1, NULL, NULL },
21 - { "InUnknownProtos", 0, 0, 1, NULL, NULL },
22 - { "InDiscards", 0, 0, 1, NULL, NULL },
23 - { "InDelivers", 0, 0, 1, NULL, NULL },
24 - { "OutRequests", 0, 0, 1, NULL, NULL },
25 - { "OutDiscards", 0, 0, 1, NULL, NULL },
26 - { "OutNoRoutes", 0, 0, 1, NULL, NULL },
27 -// { "ReasmTimeout", 0, 0, 1, NULL, NULL },
28 - { "ReasmReqds", 0, 0, 1, NULL, NULL },
29 - { "ReasmOKs", 0, 0, 1, NULL, NULL },
30 - { "ReasmFails", 0, 0, 1, NULL, NULL },
31 - { "FragOKs", 0, 0, 1, NULL, NULL },
32 - { "FragFails", 0, 0, 1, NULL, NULL },
33 - { "FragCreates", 0, 0, 1, NULL, NULL },
34 - { NULL, 0, 0, 0, NULL, NULL }
35 -};
36 -
37 -static struct netstat_columns icmp_data[] = {
38 - { "InMsgs", 0, 0, 1, NULL, NULL },
39 - { "OutMsgs", 0, 0, -1, NULL, NULL },
40 - { "InErrors", 0, 0, 1, NULL, NULL },
41 - { "OutErrors", 0, 0, -1, NULL, NULL },
42 - { "InCsumErrors", 0, 0, 1, NULL, NULL },
43 -
44 - // all these are available in icmpmsg
45 -// { "InDestUnreachs", 0, 0, 1, NULL, NULL },
46 -// { "OutDestUnreachs", 0, 0, -1, NULL, NULL },
47 -// { "InTimeExcds", 0, 0, 1, NULL, NULL },
48 -// { "OutTimeExcds", 0, 0, -1, NULL, NULL },
49 -// { "InParmProbs", 0, 0, 1, NULL, NULL },
50 -// { "OutParmProbs", 0, 0, -1, NULL, NULL },
51 -// { "InSrcQuenchs", 0, 0, 1, NULL, NULL },
52 -// { "OutSrcQuenchs", 0, 0, -1, NULL, NULL },
53 -// { "InRedirects", 0, 0, 1, NULL, NULL },
54 -// { "OutRedirects", 0, 0, -1, NULL, NULL },
55 -// { "InEchos", 0, 0, 1, NULL, NULL },
56 -// { "OutEchos", 0, 0, -1, NULL, NULL },
57 -// { "InEchoReps", 0, 0, 1, NULL, NULL },
58 -// { "OutEchoReps", 0, 0, -1, NULL, NULL },
59 -// { "InTimestamps", 0, 0, 1, NULL, NULL },
60 -// { "OutTimestamps", 0, 0, -1, NULL, NULL },
61 -// { "InTimestampReps", 0, 0, 1, NULL, NULL },
62 -// { "OutTimestampReps", 0, 0, -1, NULL, NULL },
63 -// { "InAddrMasks", 0, 0, 1, NULL, NULL },
64 -// { "OutAddrMasks", 0, 0, -1, NULL, NULL },
65 -// { "InAddrMaskReps", 0, 0, 1, NULL, NULL },
66 -// { "OutAddrMaskReps", 0, 0, -1, NULL, NULL },
67 -
68 - { NULL, 0, 0, 0, NULL, NULL }
69 -};
70 -
71 -static struct netstat_columns icmpmsg_data[] = {
72 - { "InType0", 0, 0, 1, "InEchoReps", NULL },
73 - { "OutType0", 0, 0, -1, "OutEchoReps", NULL },
74 -// { "InType1", 0, 0, 1, NULL, NULL }, // unassigned
75 -// { "OutType1", 0, 0, -1, NULL, NULL }, // unassigned
76 -// { "InType2", 0, 0, 1, NULL, NULL }, // unassigned
77 -// { "OutType2", 0, 0, -1, NULL, NULL }, // unassigned
78 - { "InType3", 0, 0, 1, "InDestUnreachs", NULL },
79 - { "OutType3", 0, 0, -1, "OutDestUnreachs", NULL },
80 -// { "InType4", 0, 0, 1, "InSrcQuenchs", NULL }, // deprecated
81 -// { "OutType4", 0, 0, -1, "OutSrcQuenchs", NULL }, // deprecated
82 - { "InType5", 0, 0, 1, "InRedirects", NULL },
83 - { "OutType5", 0, 0, -1, "OutRedirects", NULL },
84 -// { "InType6", 0, 0, 1, "InAlterHostAddr", NULL }, // deprecated
85 -// { "OutType6", 0, 0, -1, "OutAlterHostAddr", NULL }, // deprecated
86 -// { "InType7", 0, 0, 1, NULL, NULL }, // unassigned
87 -// { "OutType7", 0, 0, -1, NULL, NULL }, // unassigned
88 - { "InType8", 0, 0, 1, "InEchos", NULL },
89 - { "OutType8", 0, 0, -1, "OutEchos", NULL },
90 - { "InType9", 0, 0, 1, "InRouterAdvert", NULL },
91 - { "OutType9", 0, 0, -1, "OutRouterAdvert", NULL },
92 - { "InType10", 0, 0, 1, "InRouterSelect", NULL },
93 - { "OutType10", 0, 0, -1, "OutRouterSelect", NULL },
94 - { "InType11", 0, 0, 1, "InTimeExcds", NULL },
95 - { "OutType11", 0, 0, -1, "OutTimeExcds", NULL },
96 - { "InType12", 0, 0, 1, "InParmProbs", NULL },
97 - { "OutType12", 0, 0, -1, "OutParmProbs", NULL },
98 - { "InType13", 0, 0, 1, "InTimestamps", NULL },
99 - { "OutType13", 0, 0, -1, "OutTimestamps", NULL },
100 - { "InType14", 0, 0, 1, "InTimestampReps", NULL },
101 - { "OutType14", 0, 0, -1, "OutTimestampReps", NULL },
102 -// { "InType15", 0, 0, 1, "InInfos", NULL }, // deprecated
103 -// { "OutType15", 0, 0, -1, "OutInfos", NULL }, // deprecated
104 -// { "InType16", 0, 0, 1, "InInfoReps", NULL }, // deprecated
105 -// { "OutType16", 0, 0, -1, "OutInfoReps", NULL }, // deprecated
106 -// { "InType17", 0, 0, 1, "InAddrMasks", NULL }, // deprecated
107 -// { "OutType17", 0, 0, -1, "OutAddrMasks", NULL }, // deprecated
108 -// { "InType18", 0, 0, 1, "InAddrMaskReps", NULL }, // deprecated
109 -// { "OutType18", 0, 0, -1, "OutAddrMaskReps", NULL }, // deprecated
110 -// { "InType30", 0, 0, 1, "InTraceroute", NULL }, // deprecated
111 -// { "OutType30", 0, 0, -1, "OutTraceroute", NULL }, // deprecated
112 - { NULL, 0, 0, 0, NULL, NULL }
113 -};
114 -
115 -static struct netstat_columns tcp_data[] = {
116 -// { "RtoAlgorithm", 0, 0, 1, NULL, NULL },
117 -// { "RtoMin", 0, 0, 1, NULL, NULL },
118 -// { "RtoMax", 0, 0, 1, NULL, NULL },
119 -// { "MaxConn", 0, 0, 1, NULL, NULL },
120 - { "ActiveOpens", 0, 0, 1, NULL, NULL },
121 - { "PassiveOpens", 0, 0, 1, NULL, NULL },
122 - { "AttemptFails", 0, 0, 1, NULL, NULL },
123 - { "EstabResets", 0, 0, 1, NULL, NULL },
124 - { "CurrEstab", 0, 0, 1, NULL, NULL },
125 - { "InSegs", 0, 0, 1, NULL, NULL },
126 - { "OutSegs", 0, 0, 1, NULL, NULL },
127 - { "RetransSegs", 0, 0, 1, NULL, NULL },
128 - { "InErrs", 0, 0, 1, NULL, NULL },
129 - { "OutRsts", 0, 0, 1, NULL, NULL },
130 - { "InCsumErrors", 0, 0, 1, NULL, NULL },
131 - { NULL, 0, 0, 0, NULL, NULL }
132 -};
133 -
134 -static struct netstat_columns udp_data[] = {
135 - { "InDatagrams", 0, 0, 1, NULL, NULL },
136 - { "NoPorts", 0, 0, 1, NULL, NULL },
137 - { "InErrors", 0, 0, 1, NULL, NULL },
138 - { "OutDatagrams", 0, 0, 1, NULL, NULL },
139 - { "RcvbufErrors", 0, 0, 1, NULL, NULL },
140 - { "SndbufErrors", 0, 0, 1, NULL, NULL },
141 - { "InCsumErrors", 0, 0, 1, NULL, NULL },
142 - { "IgnoredMulti", 0, 0, 1, NULL, NULL },
143 - { NULL, 0, 0, 0, NULL, NULL }
144 -};
145 -
146 -static struct netstat_columns udplite_data[] = {
147 - { "InDatagrams", 0, 0, 1, NULL, NULL },
148 - { "NoPorts", 0, 0, 1, NULL, NULL },
149 - { "InErrors", 0, 0, 1, NULL, NULL },
150 - { "OutDatagrams", 0, 0, 1, NULL, NULL },
151 - { "RcvbufErrors", 0, 0, 1, NULL, NULL },
152 - { "SndbufErrors", 0, 0, 1, NULL, NULL },
153 - { "InCsumErrors", 0, 0, 1, NULL, NULL },
154 - { "IgnoredMulti", 0, 0, 1, NULL, NULL },
155 - { NULL, 0, 0, 0, NULL, NULL }
156 -};
157 -
158 -static void hash_array(struct netstat_columns *nc) {
159 - int i;
160 -
161 - for(i = 0; nc[i].name ;i++)
162 - nc[i].hash = simple_hash(nc[i].name);
163 -}
164 -
165 -static unsigned long long *netstat_columns_find(struct netstat_columns *nc, const char *name) {
166 - uint32_t i, hash = simple_hash(name);
167 -
168 - for(i = 0; nc[i].name ;i++)
169 - if(unlikely(nc[i].hash == hash && !strcmp(nc[i].name, name)))
170 - return &nc[i].value;
171 -
172 - fatal("Cannot find key '%s' in /proc/net/snmp internal array.", name);
173 -}
174 -
175 -static void parse_line_pair(procfile *ff, struct netstat_columns *nc, size_t header_line, size_t values_line) {
176 - size_t hwords = procfile_linewords(ff, header_line);
177 - size_t vwords = procfile_linewords(ff, values_line);
178 - size_t w, i;
179 -
180 - if(unlikely(vwords > hwords)) {
181 - error("File /proc/net/snmp on header line %zu has %zu words, but on value line %zu has %zu words.", header_line, hwords, values_line, vwords);
182 - vwords = hwords;
183 - }
184 -
185 - for(w = 1; w < vwords ;w++) {
186 - char *key = procfile_lineword(ff, header_line, w);
187 - uint32_t hash = simple_hash(key);
188 -
189 - for(i = 0 ; nc[i].name ;i++) {
190 - if(unlikely(hash == nc[i].hash && !strcmp(key, nc[i].name))) {
191 - nc[i].value = str2ull(procfile_lineword(ff, values_line, w));
192 - break;
193 - }
194 - }
195 - }
196 -}
5 +static struct proc_net_snmp {
6 + // kernel_uint_t ip_Forwarding;
7 + kernel_uint_t ip_DefaultTTL;
8 + kernel_uint_t ip_InReceives;
9 + kernel_uint_t ip_InHdrErrors;
10 + kernel_uint_t ip_InAddrErrors;
11 + kernel_uint_t ip_ForwDatagrams;
12 + kernel_uint_t ip_InUnknownProtos;
13 + kernel_uint_t ip_InDiscards;
14 + kernel_uint_t ip_InDelivers;
15 + kernel_uint_t ip_OutRequests;
16 + kernel_uint_t ip_OutDiscards;
17 + kernel_uint_t ip_OutNoRoutes;
18 + kernel_uint_t ip_ReasmTimeout;
19 + kernel_uint_t ip_ReasmReqds;
20 + kernel_uint_t ip_ReasmOKs;
21 + kernel_uint_t ip_ReasmFails;
22 + kernel_uint_t ip_FragOKs;
23 + kernel_uint_t ip_FragFails;
24 + kernel_uint_t ip_FragCreates;
25 +
26 + kernel_uint_t icmp_InMsgs;
27 + kernel_uint_t icmp_OutMsgs;
28 + kernel_uint_t icmp_InErrors;
29 + kernel_uint_t icmp_OutErrors;
30 + kernel_uint_t icmp_InCsumErrors;
31 +
32 + kernel_uint_t icmpmsg_InEchoReps;
33 + kernel_uint_t icmpmsg_OutEchoReps;
34 + kernel_uint_t icmpmsg_InDestUnreachs;
35 + kernel_uint_t icmpmsg_OutDestUnreachs;
36 + kernel_uint_t icmpmsg_InRedirects;
37 + kernel_uint_t icmpmsg_OutRedirects;
38 + kernel_uint_t icmpmsg_InEchos;
39 + kernel_uint_t icmpmsg_OutEchos;
40 + kernel_uint_t icmpmsg_InRouterAdvert;
41 + kernel_uint_t icmpmsg_OutRouterAdvert;
42 + kernel_uint_t icmpmsg_InRouterSelect;
43 + kernel_uint_t icmpmsg_OutRouterSelect;
44 + kernel_uint_t icmpmsg_InTimeExcds;
45 + kernel_uint_t icmpmsg_OutTimeExcds;
46 + kernel_uint_t icmpmsg_InParmProbs;
47 + kernel_uint_t icmpmsg_OutParmProbs;
48 + kernel_uint_t icmpmsg_InTimestamps;
49 + kernel_uint_t icmpmsg_OutTimestamps;
50 + kernel_uint_t icmpmsg_InTimestampReps;
51 + kernel_uint_t icmpmsg_OutTimestampReps;
52 +
53 + //kernel_uint_t tcp_RtoAlgorithm;
54 + //kernel_uint_t tcp_RtoMin;
55 + //kernel_uint_t tcp_RtoMax;
56 + ssize_t tcp_MaxConn;
57 + kernel_uint_t tcp_ActiveOpens;
58 + kernel_uint_t tcp_PassiveOpens;
59 + kernel_uint_t tcp_AttemptFails;
60 + kernel_uint_t tcp_EstabResets;
61 + kernel_uint_t tcp_CurrEstab;
62 + kernel_uint_t tcp_InSegs;
63 + kernel_uint_t tcp_OutSegs;
64 + kernel_uint_t tcp_RetransSegs;
65 + kernel_uint_t tcp_InErrs;
66 + kernel_uint_t tcp_OutRsts;
67 + kernel_uint_t tcp_InCsumErrors;
68 +
69 + kernel_uint_t udp_InDatagrams;
70 + kernel_uint_t udp_NoPorts;
71 + kernel_uint_t udp_InErrors;
72 + kernel_uint_t udp_OutDatagrams;
73 + kernel_uint_t udp_RcvbufErrors;
74 + kernel_uint_t udp_SndbufErrors;
75 + kernel_uint_t udp_InCsumErrors;
76 + kernel_uint_t udp_IgnoredMulti;
77 +
78 + kernel_uint_t udplite_InDatagrams;
79 + kernel_uint_t udplite_NoPorts;
80 + kernel_uint_t udplite_InErrors;
81 + kernel_uint_t udplite_OutDatagrams;
82 + kernel_uint_t udplite_RcvbufErrors;
83 + kernel_uint_t udplite_SndbufErrors;
84 + kernel_uint_t udplite_InCsumErrors;
85 + kernel_uint_t udplite_IgnoredMulti;
86 +} snmp_root = { 0 };
87
88 int do_proc_net_snmp(int update_every, usec_t dt) {
89 (void)dt;
@@ -204,67 +94,17 @@ int do_proc_net_snmp(int update_every, usec_t dt) {
94 do_udp_packets = -1, do_udp_errors = -1, do_icmp_packets = -1, do_icmpmsg = -1, do_udplite_packets = -1;
95 static uint32_t hash_ip = 0, hash_icmp = 0, hash_tcp = 0, hash_udp = 0, hash_icmpmsg = 0, hash_udplite = 0;
96
207 - //static unsigned long long *ip_Forwarding = NULL;
208 - //static unsigned long long *ip_DefaultTTL = NULL;
209 - static unsigned long long *ip_InReceives = NULL;
210 - static unsigned long long *ip_InHdrErrors = NULL;
211 - static unsigned long long *ip_InAddrErrors = NULL;
212 - static unsigned long long *ip_ForwDatagrams = NULL;
213 - static unsigned long long *ip_InUnknownProtos = NULL;
214 - static unsigned long long *ip_InDiscards = NULL;
215 - static unsigned long long *ip_InDelivers = NULL;
216 - static unsigned long long *ip_OutRequests = NULL;
217 - static unsigned long long *ip_OutDiscards = NULL;
218 - static unsigned long long *ip_OutNoRoutes = NULL;
219 - //static unsigned long long *ip_ReasmTimeout = NULL;
220 - static unsigned long long *ip_ReasmReqds = NULL;
221 - static unsigned long long *ip_ReasmOKs = NULL;
222 - static unsigned long long *ip_ReasmFails = NULL;
223 - static unsigned long long *ip_FragOKs = NULL;
224 - static unsigned long long *ip_FragFails = NULL;
225 - static unsigned long long *ip_FragCreates = NULL;
226 -
227 - static unsigned long long *icmp_InMsgs = NULL;
228 - static unsigned long long *icmp_OutMsgs = NULL;
229 - static unsigned long long *icmp_InErrors = NULL;
230 - static unsigned long long *icmp_OutErrors = NULL;
231 - static unsigned long long *icmp_InCsumErrors = NULL;
232 -
233 - //static unsigned long long *tcp_RtoAlgorithm = NULL;
234 - //static unsigned long long *tcp_RtoMin = NULL;
235 - //static unsigned long long *tcp_RtoMax = NULL;
236 - //static unsigned long long *tcp_MaxConn = NULL;
237 - static unsigned long long *tcp_ActiveOpens = NULL;
238 - static unsigned long long *tcp_PassiveOpens = NULL;
239 - static unsigned long long *tcp_AttemptFails = NULL;
240 - static unsigned long long *tcp_EstabResets = NULL;
241 - static unsigned long long *tcp_CurrEstab = NULL;
242 - static unsigned long long *tcp_InSegs = NULL;
243 - static unsigned long long *tcp_OutSegs = NULL;
244 - static unsigned long long *tcp_RetransSegs = NULL;
245 - static unsigned long long *tcp_InErrs = NULL;
246 - static unsigned long long *tcp_OutRsts = NULL;
247 - static unsigned long long *tcp_InCsumErrors = NULL;
248 -
249 - static unsigned long long *udp_InDatagrams = NULL;
250 - static unsigned long long *udp_NoPorts = NULL;
251 - static unsigned long long *udp_InErrors = NULL;
252 - static unsigned long long *udp_OutDatagrams = NULL;
253 - static unsigned long long *udp_RcvbufErrors = NULL;
254 - static unsigned long long *udp_SndbufErrors = NULL;
255 - static unsigned long long *udp_InCsumErrors = NULL;
256 - static unsigned long long *udp_IgnoredMulti = NULL;
257 -
258 - static unsigned long long *udplite_InDatagrams = NULL;
259 - static unsigned long long *udplite_NoPorts = NULL;
260 - static unsigned long long *udplite_InErrors = NULL;
261 - static unsigned long long *udplite_OutDatagrams = NULL;
262 - static unsigned long long *udplite_RcvbufErrors = NULL;
263 - static unsigned long long *udplite_SndbufErrors = NULL;
264 - static unsigned long long *udplite_InCsumErrors = NULL;
265 - static unsigned long long *udplite_IgnoredMulti = NULL;
266 -
267 - if(unlikely(do_ip_packets == -1)) {
97 + ARL_BASE *arl_ip = NULL,
98 + *arl_icmp = NULL,
99 + *arl_icmpmsg = NULL,
100 + *arl_tcp = NULL,
101 + *arl_udp = NULL,
102 + *arl_udplite = NULL;
103 +
104 + static RRDVAR *tcp_max_connections_var = NULL;
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);
@@ -286,72 +126,94 @@ int do_proc_net_snmp(int update_every, usec_t dt) {
126 hash_icmpmsg = simple_hash("IcmpMsg");
127 hash_udplite = simple_hash("UdpLite");
128
289 - hash_array(ip_data);
290 - hash_array(tcp_data);
291 - hash_array(udp_data);
292 - hash_array(icmp_data);
293 - hash_array(icmpmsg_data);
294 - hash_array(udplite_data);
295 -
296 - //ip_Forwarding = netstat_columns_find(ip_data, "Forwarding");
297 - //ip_DefaultTTL = netstat_columns_find(ip_data, "DefaultTTL");
298 - ip_InReceives = netstat_columns_find(ip_data, "InReceives");
299 - ip_InHdrErrors = netstat_columns_find(ip_data, "InHdrErrors");
300 - ip_InAddrErrors = netstat_columns_find(ip_data, "InAddrErrors");
301 - ip_ForwDatagrams = netstat_columns_find(ip_data, "ForwDatagrams");
302 - ip_InUnknownProtos = netstat_columns_find(ip_data, "InUnknownProtos");
303 - ip_InDiscards = netstat_columns_find(ip_data, "InDiscards");
304 - ip_InDelivers = netstat_columns_find(ip_data, "InDelivers");
305 - ip_OutRequests = netstat_columns_find(ip_data, "OutRequests");
306 - ip_OutDiscards = netstat_columns_find(ip_data, "OutDiscards");
307 - ip_OutNoRoutes = netstat_columns_find(ip_data, "OutNoRoutes");
308 - //ip_ReasmTimeout = netstat_columns_find(ip_data, "ReasmTimeout");
309 - ip_ReasmReqds = netstat_columns_find(ip_data, "ReasmReqds");
310 - ip_ReasmOKs = netstat_columns_find(ip_data, "ReasmOKs");
311 - ip_ReasmFails = netstat_columns_find(ip_data, "ReasmFails");
312 - ip_FragOKs = netstat_columns_find(ip_data, "FragOKs");
313 - ip_FragFails = netstat_columns_find(ip_data, "FragFails");
314 - ip_FragCreates = netstat_columns_find(ip_data, "FragCreates");
315 -
316 - icmp_InMsgs = netstat_columns_find(icmp_data, "InMsgs");
317 - icmp_OutMsgs = netstat_columns_find(icmp_data, "OutMsgs");
318 - icmp_InErrors = netstat_columns_find(icmp_data, "InErrors");
319 - icmp_OutErrors = netstat_columns_find(icmp_data, "OutErrors");
320 - icmp_InCsumErrors = netstat_columns_find(icmp_data, "InCsumErrors");
321 -
322 - //tcp_RtoAlgorithm = netstat_columns_find(tcp_data, "RtoAlgorithm");
323 - //tcp_RtoMin = netstat_columns_find(tcp_data, "RtoMin");
324 - //tcp_RtoMax = netstat_columns_find(tcp_data, "RtoMax");
325 - //tcp_MaxConn = netstat_columns_find(tcp_data, "MaxConn");
326 - tcp_ActiveOpens = netstat_columns_find(tcp_data, "ActiveOpens");
327 - tcp_PassiveOpens = netstat_columns_find(tcp_data, "PassiveOpens");
328 - tcp_AttemptFails = netstat_columns_find(tcp_data, "AttemptFails");
329 - tcp_EstabResets = netstat_columns_find(tcp_data, "EstabResets");
330 - tcp_CurrEstab = netstat_columns_find(tcp_data, "CurrEstab");
331 - tcp_InSegs = netstat_columns_find(tcp_data, "InSegs");
332 - tcp_OutSegs = netstat_columns_find(tcp_data, "OutSegs");
333 - tcp_RetransSegs = netstat_columns_find(tcp_data, "RetransSegs");
334 - tcp_InErrs = netstat_columns_find(tcp_data, "InErrs");
335 - tcp_OutRsts = netstat_columns_find(tcp_data, "OutRsts");
336 - tcp_InCsumErrors = netstat_columns_find(tcp_data, "InCsumErrors");
337 -
338 - udp_InDatagrams = netstat_columns_find(udp_data, "InDatagrams");
339 - udp_NoPorts = netstat_columns_find(udp_data, "NoPorts");
340 - udp_InErrors = netstat_columns_find(udp_data, "InErrors");
341 - udp_OutDatagrams = netstat_columns_find(udp_data, "OutDatagrams");
342 - udp_RcvbufErrors = netstat_columns_find(udp_data, "RcvbufErrors");
343 - udp_SndbufErrors = netstat_columns_find(udp_data, "SndbufErrors");
344 - udp_InCsumErrors = netstat_columns_find(udp_data, "InCsumErrors");
345 - udp_IgnoredMulti = netstat_columns_find(udp_data, "IgnoredMulti");
346 -
347 - udplite_InDatagrams = netstat_columns_find(udplite_data, "InDatagrams");
348 - udplite_NoPorts = netstat_columns_find(udplite_data, "NoPorts");
349 - udplite_InErrors = netstat_columns_find(udplite_data, "InErrors");
350 - udplite_OutDatagrams = netstat_columns_find(udplite_data, "OutDatagrams");
351 - udplite_RcvbufErrors = netstat_columns_find(udplite_data, "RcvbufErrors");
352 - udplite_SndbufErrors = netstat_columns_find(udplite_data, "SndbufErrors");
353 - udplite_InCsumErrors = netstat_columns_find(udplite_data, "InCsumErrors");
354 - udplite_IgnoredMulti = netstat_columns_find(udplite_data, "IgnoredMulti");
129 + arl_ip = arl_create("snmp/Ip", arl_callback_str2kernel_uint_t, 60);
130 + // arl_expect(arl_ip, "Forwarding", &snmp_root.ip_Forwarding);
131 + arl_expect(arl_ip, "DefaultTTL", &snmp_root.ip_DefaultTTL);
132 + arl_expect(arl_ip, "InReceives", &snmp_root.ip_InReceives);
133 + arl_expect(arl_ip, "InHdrErrors", &snmp_root.ip_InHdrErrors);
134 + arl_expect(arl_ip, "InAddrErrors", &snmp_root.ip_InAddrErrors);
135 + arl_expect(arl_ip, "ForwDatagrams", &snmp_root.ip_ForwDatagrams);
136 + arl_expect(arl_ip, "InUnknownProtos", &snmp_root.ip_InUnknownProtos);
137 + arl_expect(arl_ip, "InDiscards", &snmp_root.ip_InDiscards);
138 + arl_expect(arl_ip, "InDelivers", &snmp_root.ip_InDelivers);
139 + arl_expect(arl_ip, "OutRequests", &snmp_root.ip_OutRequests);
140 + arl_expect(arl_ip, "OutDiscards", &snmp_root.ip_OutDiscards);
141 + arl_expect(arl_ip, "OutNoRoutes", &snmp_root.ip_OutNoRoutes);
142 + arl_expect(arl_ip, "ReasmTimeout", &snmp_root.ip_ReasmTimeout);
143 + arl_expect(arl_ip, "ReasmReqds", &snmp_root.ip_ReasmReqds);
144 + arl_expect(arl_ip, "ReasmOKs", &snmp_root.ip_ReasmOKs);
145 + arl_expect(arl_ip, "ReasmFails", &snmp_root.ip_ReasmFails);
146 + arl_expect(arl_ip, "FragOKs", &snmp_root.ip_FragOKs);
147 + arl_expect(arl_ip, "FragFails", &snmp_root.ip_FragFails);
148 + arl_expect(arl_ip, "FragCreates", &snmp_root.ip_FragCreates);
149 +
150 + arl_icmp = arl_create("snmp/Icmp", arl_callback_str2kernel_uint_t, 60);
151 + arl_expect(arl_icmp, "InMsgs", &snmp_root.icmp_InMsgs);
152 + arl_expect(arl_icmp, "OutMsgs", &snmp_root.icmp_OutMsgs);
153 + arl_expect(arl_icmp, "InErrors", &snmp_root.icmp_InErrors);
154 + arl_expect(arl_icmp, "OutErrors", &snmp_root.icmp_OutErrors);
155 + arl_expect(arl_icmp, "InCsumErrors", &snmp_root.icmp_InCsumErrors);
156 +
157 + arl_icmpmsg = arl_create("snmp/Icmpmsg", arl_callback_str2kernel_uint_t, 60);
158 + arl_expect(arl_icmpmsg, "InType0", &snmp_root.icmpmsg_InEchoReps);
159 + arl_expect(arl_icmpmsg, "OutType0", &snmp_root.icmpmsg_OutEchoReps);
160 + arl_expect(arl_icmpmsg, "InType3", &snmp_root.icmpmsg_InDestUnreachs);
161 + arl_expect(arl_icmpmsg, "OutType3", &snmp_root.icmpmsg_OutDestUnreachs);
162 + arl_expect(arl_icmpmsg, "InType5", &snmp_root.icmpmsg_InRedirects);
163 + arl_expect(arl_icmpmsg, "OutType5", &snmp_root.icmpmsg_OutRedirects);
164 + arl_expect(arl_icmpmsg, "InType8", &snmp_root.icmpmsg_InEchos);
165 + arl_expect(arl_icmpmsg, "OutType8", &snmp_root.icmpmsg_OutEchos);
166 + arl_expect(arl_icmpmsg, "InType9", &snmp_root.icmpmsg_InRouterAdvert);
167 + arl_expect(arl_icmpmsg, "OutType9", &snmp_root.icmpmsg_OutRouterAdvert);
168 + arl_expect(arl_icmpmsg, "InType10", &snmp_root.icmpmsg_InRouterSelect);
169 + arl_expect(arl_icmpmsg, "OutType10", &snmp_root.icmpmsg_OutRouterSelect);
170 + arl_expect(arl_icmpmsg, "InType11", &snmp_root.icmpmsg_InTimeExcds);
171 + arl_expect(arl_icmpmsg, "OutType11", &snmp_root.icmpmsg_OutTimeExcds);
172 + arl_expect(arl_icmpmsg, "InType12", &snmp_root.icmpmsg_InParmProbs);
173 + arl_expect(arl_icmpmsg, "OutType12", &snmp_root.icmpmsg_OutParmProbs);
174 + arl_expect(arl_icmpmsg, "InType13", &snmp_root.icmpmsg_InTimestamps);
175 + arl_expect(arl_icmpmsg, "OutType13", &snmp_root.icmpmsg_OutTimestamps);
176 + arl_expect(arl_icmpmsg, "InType14", &snmp_root.icmpmsg_InTimestampReps);
177 + arl_expect(arl_icmpmsg, "OutType14", &snmp_root.icmpmsg_OutTimestampReps);
178 +
179 + arl_tcp = arl_create("snmp/Tcp", arl_callback_str2kernel_uint_t, 60);
180 + // arl_expect(arl_tcp, "RtoAlgorithm", &snmp_root.tcp_RtoAlgorithm);
181 + // arl_expect(arl_tcp, "RtoMin", &snmp_root.tcp_RtoMin);
182 + // arl_expect(arl_tcp, "RtoMax", &snmp_root.tcp_RtoMax);
183 + arl_expect(arl_tcp, "MaxConn", &snmp_root.tcp_MaxConn);
184 + arl_expect(arl_tcp, "ActiveOpens", &snmp_root.tcp_ActiveOpens);
185 + arl_expect(arl_tcp, "PassiveOpens", &snmp_root.tcp_PassiveOpens);
186 + arl_expect(arl_tcp, "AttemptFails", &snmp_root.tcp_AttemptFails);
187 + arl_expect(arl_tcp, "EstabResets", &snmp_root.tcp_EstabResets);
188 + arl_expect(arl_tcp, "CurrEstab", &snmp_root.tcp_CurrEstab);
189 + arl_expect(arl_tcp, "InSegs", &snmp_root.tcp_InSegs);
190 + arl_expect(arl_tcp, "OutSegs", &snmp_root.tcp_OutSegs);
191 + arl_expect(arl_tcp, "RetransSegs", &snmp_root.tcp_RetransSegs);
192 + arl_expect(arl_tcp, "InErrs", &snmp_root.tcp_InErrs);
193 + arl_expect(arl_tcp, "OutRsts", &snmp_root.tcp_OutRsts);
194 + arl_expect(arl_tcp, "InCsumErrors", &snmp_root.tcp_InCsumErrors);
195 +
196 + arl_udp = arl_create("snmp/Udp", arl_callback_str2kernel_uint_t, 60);
197 + arl_expect(arl_udp, "InDatagrams", &snmp_root.udp_InDatagrams);
198 + arl_expect(arl_udp, "NoPorts", &snmp_root.udp_NoPorts);
199 + arl_expect(arl_udp, "InErrors", &snmp_root.udp_InErrors);
200 + arl_expect(arl_udp, "OutDatagrams", &snmp_root.udp_OutDatagrams);
201 + arl_expect(arl_udp, "RcvbufErrors", &snmp_root.udp_RcvbufErrors);
202 + arl_expect(arl_udp, "SndbufErrors", &snmp_root.udp_SndbufErrors);
203 + arl_expect(arl_udp, "InCsumErrors", &snmp_root.udp_InCsumErrors);
204 + arl_expect(arl_udp, "IgnoredMulti", &snmp_root.udp_IgnoredMulti);
205 +
206 + arl_udplite = arl_create("snmp/Udplite", arl_callback_str2kernel_uint_t, 60);
207 + arl_expect(arl_udplite, "InDatagrams", &snmp_root.udplite_InDatagrams);
208 + arl_expect(arl_udplite, "NoPorts", &snmp_root.udplite_NoPorts);
209 + arl_expect(arl_udplite, "InErrors", &snmp_root.udplite_InErrors);
210 + arl_expect(arl_udplite, "OutDatagrams", &snmp_root.udplite_OutDatagrams);
211 + arl_expect(arl_udplite, "RcvbufErrors", &snmp_root.udplite_RcvbufErrors);
212 + arl_expect(arl_udplite, "SndbufErrors", &snmp_root.udplite_SndbufErrors);
213 + arl_expect(arl_udplite, "InCsumErrors", &snmp_root.udplite_InCsumErrors);
214 + arl_expect(arl_udplite, "IgnoredMulti", &snmp_root.udplite_IgnoredMulti);
215 +
216 + tcp_max_connections_var = rrdvar_custom_host_variable_create(localhost, "tcp_max_connections");
217 }
218
219 if(unlikely(!ff)) {
@@ -365,7 +227,7 @@ int do_proc_net_snmp(int update_every, usec_t dt) {
227 if(unlikely(!ff)) return 0; // we return 0, so that we will retry to open it next time
228
229 size_t lines = procfile_lines(ff), l;
368 - size_t words;
230 + size_t words, w;
231
232 for(l = 0; l < lines ;l++) {
233 char *key = procfile_lineword(ff, l, 0);
@@ -385,8 +247,11 @@ int do_proc_net_snmp(int update_every, usec_t dt) {
247 continue;
248 }
249
388 - // see also http://net-snmp.sourceforge.net/docs/mibs/ip.html
389 - parse_line_pair(ff, ip_data, h, l);
250 + arl_begin(arl_ip);
251 + for(w = 1; w < words ; w++) {
252 + if (unlikely(arl_check(arl_ip, procfile_lineword(ff, h, w), procfile_lineword(ff, l, w)) != 0))
253 + break;
254 + }
255
256 // --------------------------------------------------------------------
257
@@ -408,7 +273,7 @@ int do_proc_net_snmp(int update_every, usec_t dt) {
273 , "packets/s"
274 , "proc"
275 , "net/snmp"
411 - , 3000
276 + , 2450
277 , update_every
278 , RRDSET_TYPE_LINE
279 );
@@ -420,10 +285,10 @@ int do_proc_net_snmp(int update_every, usec_t dt) {
285 }
286 else rrdset_next(st);
287
423 - rrddim_set_by_pointer(st, rd_OutRequests, *ip_OutRequests);
424 - rrddim_set_by_pointer(st, rd_InReceives, *ip_InReceives);
425 - rrddim_set_by_pointer(st, rd_ForwDatagrams, *ip_ForwDatagrams);
426 - rrddim_set_by_pointer(st, rd_InDelivers, *ip_InDelivers);
288 + rrddim_set_by_pointer(st, rd_OutRequests, (collected_number)snmp_root.ip_OutRequests);
289 + rrddim_set_by_pointer(st, rd_InReceives, (collected_number)snmp_root.ip_InReceives);
290 + rrddim_set_by_pointer(st, rd_ForwDatagrams, (collected_number)snmp_root.ip_ForwDatagrams);
291 + rrddim_set_by_pointer(st, rd_InDelivers, (collected_number)snmp_root.ip_InDelivers);
292 rrdset_done(st);
293 }
294
@@ -446,7 +311,7 @@ int do_proc_net_snmp(int update_every, usec_t dt) {
311 , "packets/s"
312 , "proc"
313 , "net/snmp"
449 - , 3010
314 + , 3020
315 , update_every
316 , RRDSET_TYPE_LINE
317 );
@@ -458,9 +323,9 @@ int do_proc_net_snmp(int update_every, usec_t dt) {
323 }
324 else rrdset_next(st);
325
461 - rrddim_set_by_pointer(st, rd_FragOKs, *ip_FragOKs);
462 - rrddim_set_by_pointer(st, rd_FragFails, *ip_FragFails);
463 - rrddim_set_by_pointer(st, rd_FragCreates, *ip_FragCreates);
326 + rrddim_set_by_pointer(st, rd_FragOKs, (collected_number)snmp_root.ip_FragOKs);
327 + rrddim_set_by_pointer(st, rd_FragFails, (collected_number)snmp_root.ip_FragFails);
328 + rrddim_set_by_pointer(st, rd_FragCreates, (collected_number)snmp_root.ip_FragCreates);
329 rrdset_done(st);
330 }
331
@@ -483,7 +348,7 @@ int do_proc_net_snmp(int update_every, usec_t dt) {
348 , "packets/s"
349 , "proc"
350 , "net/snmp"
486 - , 3011
351 + , 3030
352 , update_every
353 , RRDSET_TYPE_LINE
354 );
@@ -495,9 +360,9 @@ int do_proc_net_snmp(int update_every, usec_t dt) {
360 }
361 else rrdset_next(st);
362
498 - rrddim_set_by_pointer(st, rd_ReasmOKs, *ip_ReasmOKs);
499 - rrddim_set_by_pointer(st, rd_ReasmFails, *ip_ReasmFails);
500 - rrddim_set_by_pointer(st, rd_ReasmReqds, *ip_ReasmReqds);
363 + rrddim_set_by_pointer(st, rd_ReasmOKs, (collected_number)snmp_root.ip_ReasmOKs);
364 + rrddim_set_by_pointer(st, rd_ReasmFails, (collected_number)snmp_root.ip_ReasmFails);
365 + rrddim_set_by_pointer(st, rd_ReasmReqds, (collected_number)snmp_root.ip_ReasmReqds);
366 rrdset_done(st);
367 }
368
@@ -523,7 +388,7 @@ int do_proc_net_snmp(int update_every, usec_t dt) {
388 , "packets/s"
389 , "proc"
390 , "net/snmp"
526 - , 3002
391 + , 2470
392 , update_every
393 , RRDSET_TYPE_LINE
394 );
@@ -540,12 +405,12 @@ int do_proc_net_snmp(int update_every, usec_t dt) {
405 }
406 else rrdset_next(st);
407
543 - rrddim_set_by_pointer(st, rd_InDiscards, *ip_InDiscards);
544 - rrddim_set_by_pointer(st, rd_OutDiscards, *ip_OutDiscards);
545 - rrddim_set_by_pointer(st, rd_InHdrErrors, *ip_InHdrErrors);
546 - rrddim_set_by_pointer(st, rd_InAddrErrors, *ip_InAddrErrors);
547 - rrddim_set_by_pointer(st, rd_InUnknownProtos, *ip_InUnknownProtos);
548 - rrddim_set_by_pointer(st, rd_OutNoRoutes, *ip_OutNoRoutes);
408 + rrddim_set_by_pointer(st, rd_InDiscards, (collected_number)snmp_root.ip_InDiscards);
409 + rrddim_set_by_pointer(st, rd_OutDiscards, (collected_number)snmp_root.ip_OutDiscards);
410 + rrddim_set_by_pointer(st, rd_InHdrErrors, (collected_number)snmp_root.ip_InHdrErrors);
411 + rrddim_set_by_pointer(st, rd_InAddrErrors, (collected_number)snmp_root.ip_InAddrErrors);
412 + rrddim_set_by_pointer(st, rd_InUnknownProtos, (collected_number)snmp_root.ip_InUnknownProtos);
413 + rrddim_set_by_pointer(st, rd_OutNoRoutes, (collected_number)snmp_root.ip_OutNoRoutes);
414 rrdset_done(st);
415 }
416 }
@@ -563,7 +428,11 @@ int do_proc_net_snmp(int update_every, usec_t dt) {
428 continue;
429 }
430
566 - parse_line_pair(ff, icmp_data, h, l);
431 + arl_begin(arl_icmp);
432 + for(w = 1; w < words ; w++) {
433 + if (unlikely(arl_check(arl_icmp, procfile_lineword(ff, h, w), procfile_lineword(ff, l, w)) != 0))
434 + break;
435 + }
436
437 // --------------------------------------------------------------------
438
@@ -594,8 +463,8 @@ int do_proc_net_snmp(int update_every, usec_t dt) {
463 }
464 else rrdset_next(st_packets);
465
597 - rrddim_set_by_pointer(st_packets, rd_InMsgs, *icmp_InMsgs);
598 - rrddim_set_by_pointer(st_packets, rd_OutMsgs, *icmp_OutMsgs);
466 + rrddim_set_by_pointer(st_packets, rd_InMsgs, (collected_number)snmp_root.icmp_InMsgs);
467 + rrddim_set_by_pointer(st_packets, rd_OutMsgs, (collected_number)snmp_root.icmp_OutMsgs);
468
469 rrdset_done(st_packets);
470 }
@@ -628,9 +497,9 @@ int do_proc_net_snmp(int update_every, usec_t dt) {
497 }
498 else rrdset_next(st_errors);
499
631 - rrddim_set_by_pointer(st_errors, rd_InErrors, *icmp_InErrors);
632 - rrddim_set_by_pointer(st_errors, rd_OutErrors, *icmp_OutErrors);
633 - rrddim_set_by_pointer(st_errors, rd_InCsumErrors, *icmp_InCsumErrors);
500 + rrddim_set_by_pointer(st_errors, rd_InErrors, (collected_number)snmp_root.icmp_InErrors);
501 + rrddim_set_by_pointer(st_errors, rd_OutErrors, (collected_number)snmp_root.icmp_OutErrors);
502 + rrddim_set_by_pointer(st_errors, rd_InCsumErrors, (collected_number)snmp_root.icmp_InCsumErrors);
503
504 rrdset_done(st_errors);
505 }
@@ -644,14 +513,42 @@ int do_proc_net_snmp(int update_every, usec_t dt) {
513 break;
514 }
515
647 - parse_line_pair(ff, icmpmsg_data, h, l);
516 + words = procfile_linewords(ff, l);
517 + if(words < 3) {
518 + error("Cannot read /proc/net/snmp IcmpMsg line. Expected 3+ params, read %zu.", words);
519 + continue;
520 + }
521 +
522 + arl_begin(arl_icmpmsg);
523 + for(w = 1; w < words ; w++) {
524 + if (unlikely(arl_check(arl_icmpmsg, procfile_lineword(ff, h, w), procfile_lineword(ff, l, w)) != 0))
525 + break;
526 + }
527
528 // --------------------------------------------------------------------
529
530 if(do_icmpmsg) {
652 - int i;
653 -
654 - static RRDSET *st = NULL;
531 + static RRDSET *st = NULL;
532 + static RRDDIM *rd_InEchoReps = NULL,
533 + *rd_OutEchoReps = NULL,
534 + *rd_InDestUnreachs = NULL,
535 + *rd_OutDestUnreachs = NULL,
536 + *rd_InRedirects = NULL,
537 + *rd_OutRedirects = NULL,
538 + *rd_InEchos = NULL,
539 + *rd_OutEchos = NULL,
540 + *rd_InRouterAdvert = NULL,
541 + *rd_OutRouterAdvert = NULL,
542 + *rd_InRouterSelect = NULL,
543 + *rd_OutRouterSelect = NULL,
544 + *rd_InTimeExcds = NULL,
545 + *rd_OutTimeExcds = NULL,
546 + *rd_InParmProbs = NULL,
547 + *rd_OutParmProbs = NULL,
548 + *rd_InTimestamps = NULL,
549 + *rd_OutTimestamps = NULL,
550 + *rd_InTimestampReps = NULL,
551 + *rd_OutTimestampReps = NULL;
552
553 if(unlikely(!st)) {
554 st = rrdset_create_localhost(
@@ -669,13 +566,49 @@ int do_proc_net_snmp(int update_every, usec_t dt) {
566 , RRDSET_TYPE_LINE
567 );
568
672 - for(i = 0; icmpmsg_data[i].name ;i++)
673 - icmpmsg_data[i].rd = rrddim_add(st, icmpmsg_data[i].name, icmpmsg_data[i].label, icmpmsg_data[i].multiplier, 1, RRD_ALGORITHM_INCREMENTAL);
569 + rd_InEchoReps = rrddim_add(st, "InType0", "InEchoReps", 1, 1, RRD_ALGORITHM_INCREMENTAL);
570 + rd_OutEchoReps = rrddim_add(st, "OutType0", "OutEchoReps", -1, 1, RRD_ALGORITHM_INCREMENTAL);
571 + rd_InDestUnreachs = rrddim_add(st, "InType3", "InDestUnreachs", 1, 1, RRD_ALGORITHM_INCREMENTAL);
572 + rd_OutDestUnreachs = rrddim_add(st, "OutType3", "OutDestUnreachs", -1, 1, RRD_ALGORITHM_INCREMENTAL);
573 + rd_InRedirects = rrddim_add(st, "InType5", "InRedirects", 1, 1, RRD_ALGORITHM_INCREMENTAL);
574 + rd_OutRedirects = rrddim_add(st, "OutType5", "OutRedirects", -1, 1, RRD_ALGORITHM_INCREMENTAL);
575 + rd_InEchos = rrddim_add(st, "InType8", "InEchos", 1, 1, RRD_ALGORITHM_INCREMENTAL);
576 + rd_OutEchos = rrddim_add(st, "OutType8", "OutEchos", -1, 1, RRD_ALGORITHM_INCREMENTAL);
577 + rd_InRouterAdvert = rrddim_add(st, "InType9", "InRouterAdvert", 1, 1, RRD_ALGORITHM_INCREMENTAL);
578 + rd_OutRouterAdvert = rrddim_add(st, "OutType9", "OutRouterAdvert", -1, 1, RRD_ALGORITHM_INCREMENTAL);
579 + rd_InRouterSelect = rrddim_add(st, "InType10", "InRouterSelect", 1, 1, RRD_ALGORITHM_INCREMENTAL);
580 + rd_OutRouterSelect = rrddim_add(st, "OutType10", "OutRouterSelect", -1, 1, RRD_ALGORITHM_INCREMENTAL);
581 + rd_InTimeExcds = rrddim_add(st, "InType11", "InTimeExcds", 1, 1, RRD_ALGORITHM_INCREMENTAL);
582 + rd_OutTimeExcds = rrddim_add(st, "OutType11", "OutTimeExcds", -1, 1, RRD_ALGORITHM_INCREMENTAL);
583 + rd_InParmProbs = rrddim_add(st, "InType12", "InParmProbs", 1, 1, RRD_ALGORITHM_INCREMENTAL);
584 + rd_OutParmProbs = rrddim_add(st, "OutType12", "OutParmProbs", -1, 1, RRD_ALGORITHM_INCREMENTAL);
585 + rd_InTimestamps = rrddim_add(st, "InType13", "InTimestamps", 1, 1, RRD_ALGORITHM_INCREMENTAL);
586 + rd_OutTimestamps = rrddim_add(st, "OutType13", "OutTimestamps", -1, 1, RRD_ALGORITHM_INCREMENTAL);
587 + rd_InTimestampReps = rrddim_add(st, "InType14", "InTimestampReps", 1, 1, RRD_ALGORITHM_INCREMENTAL);
588 + rd_OutTimestampReps = rrddim_add(st, "OutType14", "OutTimestampReps", -1, 1, RRD_ALGORITHM_INCREMENTAL);
589 }
590 else rrdset_next(st);
591
677 - for(i = 0; icmpmsg_data[i].name ;i++)
678 - rrddim_set_by_pointer(st, icmpmsg_data[i].rd, icmpmsg_data[i].value);
592 + rrddim_set_by_pointer(st, rd_InEchoReps, (collected_number)snmp_root.icmpmsg_InEchoReps);
593 + rrddim_set_by_pointer(st, rd_OutEchoReps, (collected_number)snmp_root.icmpmsg_OutEchoReps);
594 + rrddim_set_by_pointer(st, rd_InDestUnreachs, (collected_number)snmp_root.icmpmsg_InDestUnreachs);
595 + rrddim_set_by_pointer(st, rd_OutDestUnreachs, (collected_number)snmp_root.icmpmsg_OutDestUnreachs);
596 + rrddim_set_by_pointer(st, rd_InRedirects, (collected_number)snmp_root.icmpmsg_InRedirects);
597 + rrddim_set_by_pointer(st, rd_OutRedirects, (collected_number)snmp_root.icmpmsg_OutRedirects);
598 + rrddim_set_by_pointer(st, rd_InEchos, (collected_number)snmp_root.icmpmsg_InEchos);
599 + rrddim_set_by_pointer(st, rd_OutEchos, (collected_number)snmp_root.icmpmsg_OutEchos);
600 + rrddim_set_by_pointer(st, rd_InRouterAdvert, (collected_number)snmp_root.icmpmsg_InRouterAdvert);
601 + rrddim_set_by_pointer(st, rd_OutRouterAdvert, (collected_number)snmp_root.icmpmsg_OutRouterAdvert);
602 + rrddim_set_by_pointer(st, rd_InRouterSelect, (collected_number)snmp_root.icmpmsg_InRouterSelect);
603 + rrddim_set_by_pointer(st, rd_OutRouterSelect, (collected_number)snmp_root.icmpmsg_OutRouterSelect);
604 + rrddim_set_by_pointer(st, rd_InTimeExcds, (collected_number)snmp_root.icmpmsg_InTimeExcds);
605 + rrddim_set_by_pointer(st, rd_OutTimeExcds, (collected_number)snmp_root.icmpmsg_OutTimeExcds);
606 + rrddim_set_by_pointer(st, rd_InParmProbs, (collected_number)snmp_root.icmpmsg_InParmProbs);
607 + rrddim_set_by_pointer(st, rd_OutParmProbs, (collected_number)snmp_root.icmpmsg_OutParmProbs);
608 + rrddim_set_by_pointer(st, rd_InTimestamps, (collected_number)snmp_root.icmpmsg_InTimestamps);
609 + rrddim_set_by_pointer(st, rd_OutTimestamps, (collected_number)snmp_root.icmpmsg_OutTimestamps);
610 + rrddim_set_by_pointer(st, rd_InTimestampReps, (collected_number)snmp_root.icmpmsg_InTimestampReps);
611 + rrddim_set_by_pointer(st, rd_OutTimestampReps, (collected_number)snmp_root.icmpmsg_OutTimestampReps);
612
613 rrdset_done(st);
614 }
@@ -694,7 +627,18 @@ int do_proc_net_snmp(int update_every, usec_t dt) {
627 continue;
628 }
629
697 - parse_line_pair(ff, tcp_data, h, l);
630 + arl_begin(arl_tcp);
631 + for(w = 1; w < words ; w++) {
632 + if (unlikely(arl_check(arl_tcp, procfile_lineword(ff, h, w), procfile_lineword(ff, l, w)) != 0))
633 + break;
634 + }
635 +
636 + // --------------------------------------------------------------------
637 +
638 + if(snmp_root.tcp_MaxConn != last_max_connections) {
639 + last_max_connections = snmp_root.tcp_MaxConn;
640 + rrdvar_custom_host_variable_set(localhost, tcp_max_connections_var, last_max_connections);
641 + }
642
643 // --------------------------------------------------------------------
644
@@ -714,7 +658,7 @@ int do_proc_net_snmp(int update_every, usec_t dt) {
658 , "active connections"
659 , "proc"
660 , "net/snmp"
717 - , 2500
661 + , 2501
662 , update_every
663 , RRDSET_TYPE_LINE
664 );
@@ -723,7 +667,7 @@ int do_proc_net_snmp(int update_every, usec_t dt) {
667 }
668 else rrdset_next(st);
669
726 - rrddim_set_by_pointer(st, rd_CurrEstab, *tcp_CurrEstab);
670 + rrddim_set_by_pointer(st, rd_CurrEstab, (collected_number)snmp_root.tcp_CurrEstab);
671 rrdset_done(st);
672 }
673
@@ -745,7 +689,7 @@ int do_proc_net_snmp(int update_every, usec_t dt) {
689 , "packets/s"
690 , "proc"
691 , "net/snmp"
748 - , 2600
692 + , 2510
693 , update_every
694 , RRDSET_TYPE_LINE
695 );
@@ -755,8 +699,8 @@ int do_proc_net_snmp(int update_every, usec_t dt) {
699 }
700 else rrdset_next(st);
701
758 - rrddim_set_by_pointer(st, rd_InSegs, *tcp_InSegs);
759 - rrddim_set_by_pointer(st, rd_OutSegs, *tcp_OutSegs);
702 + rrddim_set_by_pointer(st, rd_InSegs, (collected_number)snmp_root.tcp_InSegs);
703 + rrddim_set_by_pointer(st, rd_OutSegs, (collected_number)snmp_root.tcp_OutSegs);
704 rrdset_done(st);
705 }
706
@@ -779,7 +723,7 @@ int do_proc_net_snmp(int update_every, usec_t dt) {
723 , "packets/s"
724 , "proc"
725 , "net/snmp"
782 - , 2700
726 + , 2520
727 , update_every
728 , RRDSET_TYPE_LINE
729 );
@@ -791,9 +735,9 @@ int do_proc_net_snmp(int update_every, usec_t dt) {
735 }
736 else rrdset_next(st);
737
794 - rrddim_set_by_pointer(st, rd_InErrs, *tcp_InErrs);
795 - rrddim_set_by_pointer(st, rd_InCsumErrors, *tcp_InCsumErrors);
796 - rrddim_set_by_pointer(st, rd_RetransSegs, *tcp_RetransSegs);
738 + rrddim_set_by_pointer(st, rd_InErrs, (collected_number)snmp_root.tcp_InErrs);
739 + rrddim_set_by_pointer(st, rd_InCsumErrors, (collected_number)snmp_root.tcp_InCsumErrors);
740 + rrddim_set_by_pointer(st, rd_RetransSegs, (collected_number)snmp_root.tcp_RetransSegs);
741 rrdset_done(st);
742 }
743
@@ -819,7 +763,7 @@ int do_proc_net_snmp(int update_every, usec_t dt) {
763 , "events/s"
764 , "proc"
765 , "net/snmp"
822 - , 2900
766 + , 2530
767 , update_every
768 , RRDSET_TYPE_LINE
769 );
@@ -834,11 +778,11 @@ int do_proc_net_snmp(int update_every, usec_t dt) {
778 }
779 else rrdset_next(st);
780
837 - rrddim_set_by_pointer(st, rd_EstabResets, *tcp_EstabResets);
838 - rrddim_set_by_pointer(st, rd_OutRsts, *tcp_OutRsts);
839 - rrddim_set_by_pointer(st, rd_ActiveOpens, *tcp_ActiveOpens);
840 - rrddim_set_by_pointer(st, rd_PassiveOpens, *tcp_PassiveOpens);
841 - rrddim_set_by_pointer(st, rd_AttemptFails, *tcp_AttemptFails);
781 + rrddim_set_by_pointer(st, rd_EstabResets, (collected_number)snmp_root.tcp_EstabResets);
782 + rrddim_set_by_pointer(st, rd_OutRsts, (collected_number)snmp_root.tcp_OutRsts);
783 + rrddim_set_by_pointer(st, rd_ActiveOpens, (collected_number)snmp_root.tcp_ActiveOpens);
784 + rrddim_set_by_pointer(st, rd_PassiveOpens, (collected_number)snmp_root.tcp_PassiveOpens);
785 + rrddim_set_by_pointer(st, rd_AttemptFails, (collected_number)snmp_root.tcp_AttemptFails);
786 rrddim_set_by_pointer(st, rd_TCPSynRetrans, tcpext_TCPSynRetrans);
787 rrdset_done(st);
788 }
@@ -857,7 +801,11 @@ int do_proc_net_snmp(int update_every, usec_t dt) {
801 continue;
802 }
803
860 - parse_line_pair(ff, udp_data, h, l);
804 + arl_begin(arl_udp);
805 + for(w = 1; w < words ; w++) {
806 + if (unlikely(arl_check(arl_udp, procfile_lineword(ff, h, w), procfile_lineword(ff, l, w)) != 0))
807 + break;
808 + }
809
810 // --------------------------------------------------------------------
811
@@ -878,7 +826,7 @@ int do_proc_net_snmp(int update_every, usec_t dt) {
826 , "packets/s"
827 , "proc"
828 , "net/snmp"
881 - , 2601
829 + , 2602
830 , update_every
831 , RRDSET_TYPE_LINE
832 );
@@ -888,8 +836,8 @@ int do_proc_net_snmp(int update_every, usec_t dt) {
836 }
837 else rrdset_next(st);
838
891 - rrddim_set_by_pointer(st, rd_InDatagrams, *udp_InDatagrams);
892 - rrddim_set_by_pointer(st, rd_OutDatagrams, *udp_OutDatagrams);
839 + rrddim_set_by_pointer(st, rd_InDatagrams, (collected_number)snmp_root.udp_InDatagrams);
840 + rrddim_set_by_pointer(st, rd_OutDatagrams, (collected_number)snmp_root.udp_OutDatagrams);
841 rrdset_done(st);
842 }
843
@@ -930,12 +878,12 @@ int do_proc_net_snmp(int update_every, usec_t dt) {
878 }
879 else rrdset_next(st);
880
933 - rrddim_set_by_pointer(st, rd_InErrors, *udp_InErrors);
934 - rrddim_set_by_pointer(st, rd_NoPorts, *udp_NoPorts);
935 - rrddim_set_by_pointer(st, rd_RcvbufErrors, *udp_RcvbufErrors);
936 - rrddim_set_by_pointer(st, rd_SndbufErrors, *udp_SndbufErrors);
937 - rrddim_set_by_pointer(st, rd_InCsumErrors, *udp_InCsumErrors);
938 - rrddim_set_by_pointer(st, rd_IgnoredMulti, *udp_IgnoredMulti);
881 + rrddim_set_by_pointer(st, rd_InErrors, (collected_number)snmp_root.udp_InErrors);
882 + rrddim_set_by_pointer(st, rd_NoPorts, (collected_number)snmp_root.udp_NoPorts);
883 + rrddim_set_by_pointer(st, rd_RcvbufErrors, (collected_number)snmp_root.udp_RcvbufErrors);
884 + rrddim_set_by_pointer(st, rd_SndbufErrors, (collected_number)snmp_root.udp_SndbufErrors);
885 + rrddim_set_by_pointer(st, rd_InCsumErrors, (collected_number)snmp_root.udp_InCsumErrors);
886 + rrddim_set_by_pointer(st, rd_IgnoredMulti, (collected_number)snmp_root.udp_IgnoredMulti);
887 rrdset_done(st);
888 }
889 }
@@ -953,7 +901,11 @@ int do_proc_net_snmp(int update_every, usec_t dt) {
901 continue;
902 }
903
956 - parse_line_pair(ff, udplite_data, h, l);
904 + arl_begin(arl_udplite);
905 + for(w = 1; w < words ; w++) {
906 + if (unlikely(arl_check(arl_udplite, procfile_lineword(ff, h, w), procfile_lineword(ff, l, w)) != 0))
907 + break;
908 + }
909
910 // --------------------------------------------------------------------
911
@@ -984,8 +936,8 @@ int do_proc_net_snmp(int update_every, usec_t dt) {
936 }
937 else rrdset_next(st);
938
987 - rrddim_set_by_pointer(st, rd_InDatagrams, *udplite_InDatagrams);
988 - rrddim_set_by_pointer(st, rd_OutDatagrams, *udplite_OutDatagrams);
939 + rrddim_set_by_pointer(st, rd_InDatagrams, (collected_number)snmp_root.udplite_InDatagrams);
940 + rrddim_set_by_pointer(st, rd_OutDatagrams, (collected_number)snmp_root.udplite_OutDatagrams);
941 rrdset_done(st);
942 }
943
@@ -1022,12 +974,12 @@ int do_proc_net_snmp(int update_every, usec_t dt) {
974 }
975 else rrdset_next(st);
976
1025 - rrddim_set_by_pointer(st, rd_NoPorts, *udplite_NoPorts);
1026 - rrddim_set_by_pointer(st, rd_InErrors, *udplite_InErrors);
1027 - rrddim_set_by_pointer(st, rd_InCsumErrors, *udplite_InCsumErrors);
1028 - rrddim_set_by_pointer(st, rd_RcvbufErrors, *udplite_RcvbufErrors);
1029 - rrddim_set_by_pointer(st, rd_SndbufErrors, *udplite_SndbufErrors);
1030 - rrddim_set_by_pointer(st, rd_IgnoredMulti, *udplite_IgnoredMulti);
977 + rrddim_set_by_pointer(st, rd_NoPorts, (collected_number)snmp_root.udplite_NoPorts);
978 + rrddim_set_by_pointer(st, rd_InErrors, (collected_number)snmp_root.udplite_InErrors);
979 + rrddim_set_by_pointer(st, rd_InCsumErrors, (collected_number)snmp_root.udplite_InCsumErrors);
980 + rrddim_set_by_pointer(st, rd_RcvbufErrors, (collected_number)snmp_root.udplite_RcvbufErrors);
981 + rrddim_set_by_pointer(st, rd_SndbufErrors, (collected_number)snmp_root.udplite_SndbufErrors);
982 + rrddim_set_by_pointer(st, rd_IgnoredMulti, (collected_number)snmp_root.udplite_IgnoredMulti);
983 rrdset_done(st);
984 }
985 }
src/proc_net_sockstat.c
+20 -28
@@ -23,15 +23,6 @@ static struct proc_net_sockstat {
23 } sockstat_root = { 0 };
24
25
26 -static inline void arl_callback_str2kernel_uint_t(const char *name, uint32_t hash, const char *value, void *dst) {
27 - (void)name;
28 - (void)hash;
29 -
30 - register kernel_uint_t *d = dst;
31 - *d = str2kernel_uint_t(value);
32 - // fprintf(stderr, "name '%s' with hash %u and value '%s' is %llu\n", name, hash, value, (unsigned long long)*d);
33 -}
34 -
26 static kernel_uint_t read_tcp_max_orphans(void) {
27 static char *filename = NULL;
28 static RRDVAR *tcp_max_orphans_var = NULL;
@@ -92,6 +83,7 @@ int do_proc_net_sockstat(int update_every, usec_t dt) {
83 do_raw_sockets = config_get_boolean_ondemand("plugin:proc:/proc/net/sockstat", "ipv4 RAW sockets", CONFIG_BOOLEAN_AUTO);
84 do_frag_sockets = config_get_boolean_ondemand("plugin:proc:/proc/net/sockstat", "ipv4 FRAG sockets", CONFIG_BOOLEAN_AUTO);
85 do_frag_mem = config_get_boolean_ondemand("plugin:proc:/proc/net/sockstat", "ipv4 FRAG memory", CONFIG_BOOLEAN_AUTO);
86 +
87 update_tcp_max_orphans_every = config_get_number("plugin:proc:/proc/net/sockstat", "update tcp_max_orphans every", update_tcp_max_orphans_every);
88 update_tcp_max_orphans_count = update_tcp_max_orphans_every;
89
@@ -191,7 +183,7 @@ int do_proc_net_sockstat(int update_every, usec_t dt) {
183 , NULL
184 , "sockets"
185 , NULL
194 - , "IPv4 Sockets In Use"
186 + , "IPv4 Sockets Used"
187 , "sockets"
188 , "proc"
189 , "net/sockstat"
@@ -224,13 +216,13 @@ int do_proc_net_sockstat(int update_every, usec_t dt) {
216 "ipv4"
217 , "sockstat_tcp_sockets"
218 , NULL
227 - , "sockets"
219 + , "tcp"
220 , NULL
221 , "IPv4 TCP Sockets"
230 - , "sockets"
222 + , "tcp"
223 , "proc"
224 , "net/sockstat"
233 - , 2405
225 + , 2500
226 , update_every
227 , RRDSET_TYPE_LINE
228 );
@@ -262,13 +254,13 @@ int do_proc_net_sockstat(int update_every, usec_t dt) {
254 "ipv4"
255 , "sockstat_tcp_mem"
256 , NULL
265 - , "sockets"
257 + , "tcp"
258 , NULL
259 , "IPv4 TCP Sockets Memory"
260 , "KB"
261 , "proc"
262 , "net/sockstat"
271 - , 2406
263 + , 2540
264 , update_every
265 , RRDSET_TYPE_AREA
266 );
@@ -294,13 +286,13 @@ int do_proc_net_sockstat(int update_every, usec_t dt) {
286 "ipv4"
287 , "sockstat_udp_sockets"
288 , NULL
297 - , "sockets"
289 + , "udp"
290 , NULL
291 , "IPv4 UDP Sockets"
292 , "sockets"
293 , "proc"
294 , "net/sockstat"
303 - , 2410
295 + , 2600
296 , update_every
297 , RRDSET_TYPE_LINE
298 );
@@ -326,13 +318,13 @@ int do_proc_net_sockstat(int update_every, usec_t dt) {
318 "ipv4"
319 , "sockstat_udp_mem"
320 , NULL
329 - , "sockets"
321 + , "udp"
322 , NULL
323 , "IPv4 UDP Sockets Memory"
324 , "KB"
325 , "proc"
326 , "net/sockstat"
335 - , 2411
327 + , 2603
328 , update_every
329 , RRDSET_TYPE_AREA
330 );
@@ -358,13 +350,13 @@ int do_proc_net_sockstat(int update_every, usec_t dt) {
350 "ipv4"
351 , "sockstat_udplite_sockets"
352 , NULL
361 - , "sockets"
353 + , "udplite"
354 , NULL
355 , "IPv4 UDPLITE Sockets"
356 , "sockets"
357 , "proc"
358 , "net/sockstat"
367 - , 2420
359 + , 2602
360 , update_every
361 , RRDSET_TYPE_LINE
362 );
@@ -390,13 +382,13 @@ int do_proc_net_sockstat(int update_every, usec_t dt) {
382 "ipv4"
383 , "sockstat_raw_sockets"
384 , NULL
393 - , "sockets"
385 + , "raw"
386 , NULL
387 , "IPv4 RAW Sockets"
388 , "sockets"
389 , "proc"
390 , "net/sockstat"
399 - , 2430
391 + , 3010
392 , update_every
393 , RRDSET_TYPE_LINE
394 );
@@ -422,13 +414,13 @@ int do_proc_net_sockstat(int update_every, usec_t dt) {
414 "ipv4"
415 , "sockstat_frag_sockets"
416 , NULL
425 - , "sockets"
417 + , "fragments"
418 , NULL
419 , "IPv4 FRAG Sockets"
428 - , "sockets"
420 + , "fragments"
421 , "proc"
422 , "net/sockstat"
431 - , 2440
423 + , 3010
424 , update_every
425 , RRDSET_TYPE_LINE
426 );
@@ -454,13 +446,13 @@ int do_proc_net_sockstat(int update_every, usec_t dt) {
446 "ipv4"
447 , "sockstat_frag_mem"
448 , NULL
457 - , "sockets"
449 + , "fragments"
450 , NULL
451 , "IPv4 FRAG Sockets Memory"
452 , "KB"
453 , "proc"
454 , "net/sockstat"
463 - , 2441
455 + , 3020
456 , update_every
457 , RRDSET_TYPE_AREA
458 );