@cryptotaxi247 / netdata-1 / commits / f24c52598

re-factored /proc/net/netstat data collector to collect all the available metrics - work in progress

Costa Tsaousis (ktsaou) committed Sep 18, 2016 at 17:01 UTC f24c52598735a130a1c5379c596d43fee1fe53b4
1 file changed +698 -63
src/proc_net_netstat.c
+698 -63
@@ -1,175 +1,810 @@
1 #include "common.h"
2
3 +
4 +struct netstat_columns {
5 + char *name;
6 + uint32_t hash;
7 + unsigned long long value;
8 + int multiplier; // not needed everywhere
9 + char *label; // not needed everywhere
10 +};
11 +
12 +static struct netstat_columns tcpext_data[] = {
13 + { "SyncookiesSent", 0, 0, 1, NULL },
14 + { "SyncookiesRecv", 0, 0, 1, NULL },
15 + { "SyncookiesFailed", 0, 0, 1, NULL },
16 + { "EmbryonicRsts", 0, 0, 1, NULL },
17 + { "PruneCalled", 0, 0, 1, NULL },
18 + { "RcvPruned", 0, 0, 1, NULL },
19 + { "OfoPruned", 0, 0, 1, NULL },
20 + { "OutOfWindowIcmps", 0, 0, 1, NULL },
21 + { "LockDroppedIcmps", 0, 0, 1, NULL },
22 + { "ArpFilter", 0, 0, 1, NULL },
23 + { "TW", 0, 0, 1, NULL },
24 + { "TWRecycled", 0, 0, 1, NULL },
25 + { "TWKilled", 0, 0, 1, NULL },
26 + { "PAWSPassive", 0, 0, 1, NULL },
27 + { "PAWSActive", 0, 0, 1, NULL },
28 + { "PAWSEstab", 0, 0, 1, NULL },
29 + { "DelayedACKs", 0, 0, 1, NULL },
30 + { "DelayedACKLocked", 0, 0, 1, NULL },
31 + { "DelayedACKLost", 0, 0, 1, NULL },
32 + { "ListenOverflows", 0, 0, 1, NULL },
33 + { "ListenDrops", 0, 0, 1, NULL },
34 + { "TCPPrequeued", 0, 0, 1, NULL },
35 + { "TCPDirectCopyFromBacklog", 0, 0, 1, NULL },
36 + { "TCPDirectCopyFromPrequeue", 0, 0, 1, NULL },
37 + { "TCPPrequeueDropped", 0, 0, 1, NULL },
38 + { "TCPHPHits", 0, 0, 1, NULL },
39 + { "TCPHPHitsToUser", 0, 0, 1, NULL },
40 + { "TCPPureAcks", 0, 0, 1, NULL },
41 + { "TCPHPAcks", 0, 0, 1, NULL },
42 + { "TCPRenoRecovery", 0, 0, 1, NULL },
43 + { "TCPSackRecovery", 0, 0, 1, NULL },
44 + { "TCPSACKReneging", 0, 0, 1, NULL },
45 + { "TCPFACKReorder", 0, 0, 1, NULL },
46 + { "TCPSACKReorder", 0, 0, 1, NULL },
47 + { "TCPRenoReorder", 0, 0, 1, NULL },
48 + { "TCPTSReorder", 0, 0, 1, NULL },
49 + { "TCPFullUndo", 0, 0, 1, NULL },
50 + { "TCPPartialUndo", 0, 0, 1, NULL },
51 + { "TCPDSACKUndo", 0, 0, 1, NULL },
52 + { "TCPLossUndo", 0, 0, 1, NULL },
53 + { "TCPLostRetransmit", 0, 0, 1, NULL },
54 + { "TCPRenoFailures", 0, 0, 1, NULL },
55 + { "TCPSackFailures", 0, 0, 1, NULL },
56 + { "TCPLossFailures", 0, 0, 1, NULL },
57 + { "TCPFastRetrans", 0, 0, 1, NULL },
58 + { "TCPForwardRetrans", 0, 0, 1, NULL },
59 + { "TCPSlowStartRetrans", 0, 0, 1, NULL },
60 + { "TCPTimeouts", 0, 0, 1, NULL },
61 + { "TCPLossProbes", 0, 0, 1, NULL },
62 + { "TCPLossProbeRecovery", 0, 0, 1, NULL },
63 + { "TCPRenoRecoveryFail", 0, 0, 1, NULL },
64 + { "TCPSackRecoveryFail", 0, 0, 1, NULL },
65 + { "TCPSchedulerFailed", 0, 0, 1, NULL },
66 + { "TCPRcvCollapsed", 0, 0, 1, NULL },
67 + { "TCPDSACKOldSent", 0, 0, 1, NULL },
68 + { "TCPDSACKOfoSent", 0, 0, 1, NULL },
69 + { "TCPDSACKRecv", 0, 0, 1, NULL },
70 + { "TCPDSACKOfoRecv", 0, 0, 1, NULL },
71 + { "TCPAbortOnData", 0, 0, 1, NULL },
72 + { "TCPAbortOnClose", 0, 0, 1, NULL },
73 + { "TCPAbortOnMemory", 0, 0, 1, NULL },
74 + { "TCPAbortOnTimeout", 0, 0, 1, NULL },
75 + { "TCPAbortOnLinger", 0, 0, 1, NULL },
76 + { "TCPAbortFailed", 0, 0, 1, NULL },
77 + { "TCPMemoryPressures", 0, 0, 1, NULL },
78 + { "TCPSACKDiscard", 0, 0, 1, NULL },
79 + { "TCPDSACKIgnoredOld", 0, 0, 1, NULL },
80 + { "TCPDSACKIgnoredNoUndo", 0, 0, 1, NULL },
81 + { "TCPSpuriousRTOs", 0, 0, 1, NULL },
82 + { "TCPMD5NotFound", 0, 0, 1, NULL },
83 + { "TCPMD5Unexpected", 0, 0, 1, NULL },
84 + { "TCPSackShifted", 0, 0, 1, NULL },
85 + { "TCPSackMerged", 0, 0, 1, NULL },
86 + { "TCPSackShiftFallback", 0, 0, 1, NULL },
87 + { "TCPBacklogDrop", 0, 0, 1, NULL },
88 + { "TCPMinTTLDrop", 0, 0, 1, NULL },
89 + { "TCPDeferAcceptDrop", 0, 0, 1, NULL },
90 + { "IPReversePathFilter", 0, 0, 1, NULL },
91 + { "TCPTimeWaitOverflow", 0, 0, 1, NULL },
92 + { "TCPReqQFullDoCookies", 0, 0, 1, NULL },
93 + { "TCPReqQFullDrop", 0, 0, 1, NULL },
94 + { "TCPRetransFail", 0, 0, 1, NULL },
95 + { "TCPRcvCoalesce", 0, 0, 1, NULL },
96 + { "TCPOFOQueue", 0, 0, 1, NULL },
97 + { "TCPOFODrop", 0, 0, 1, NULL },
98 + { "TCPOFOMerge", 0, 0, 1, NULL },
99 + { "TCPChallengeACK", 0, 0, 1, NULL },
100 + { "TCPSYNChallenge", 0, 0, 1, NULL },
101 + { "TCPFastOpenActive", 0, 0, 1, NULL },
102 + { "TCPFastOpenActiveFail", 0, 0, 1, NULL },
103 + { "TCPFastOpenPassive", 0, 0, 1, NULL },
104 + { "TCPFastOpenPassiveFail", 0, 0, 1, NULL },
105 + { "TCPFastOpenListenOverflow", 0, 0, 1, NULL },
106 + { "TCPFastOpenCookieReqd", 0, 0, 1, NULL },
107 + { "TCPSpuriousRtxHostQueues", 0, 0, 1, NULL },
108 + { "BusyPollRxPackets", 0, 0, 1, NULL },
109 + { "TCPAutoCorking", 0, 0, 1, NULL },
110 + { "TCPFromZeroWindowAdv", 0, 0, 1, NULL },
111 + { "TCPToZeroWindowAdv", 0, 0, 1, NULL },
112 + { "TCPWantZeroWindowAdv", 0, 0, 1, NULL },
113 + { "TCPSynRetrans", 0, 0, 1, NULL },
114 + { "TCPOrigDataSent", 0, 0, 1, NULL },
115 + { "TCPHystartTrainDetect", 0, 0, 1, NULL },
116 + { "TCPHystartTrainCwnd", 0, 0, 1, NULL },
117 + { "TCPHystartDelayDetect", 0, 0, 1, NULL },
118 + { "TCPHystartDelayCwnd", 0, 0, 1, NULL },
119 + { "TCPACKSkippedSynRecv", 0, 0, 1, NULL },
120 + { "TCPACKSkippedPAWS", 0, 0, 1, NULL },
121 + { "TCPACKSkippedSeq", 0, 0, 1, NULL },
122 + { "TCPACKSkippedFinWait2", 0, 0, 1, NULL },
123 + { "TCPACKSkippedTimeWait", 0, 0, 1, NULL },
124 + { "TCPACKSkippedChallenge", 0, 0, 1, NULL },
125 + { "TCPWinProbe", 0, 0, 1, NULL },
126 + { "TCPKeepAlive", 0, 0, 1, NULL },
127 + { "TCPMTUPFail", 0, 0, 1, NULL },
128 + { "TCPMTUPSuccess", 0, 0, 1, NULL },
129 + { NULL, 0, 0, 0, NULL }
130 +};
131 +
132 +static struct netstat_columns ipext_data[] = {
133 + { "InNoRoutes", 0, 0, 1, NULL },
134 + { "InTruncatedPkts", 0, 0, 1, NULL },
135 + { "InMcastPkts", 0, 0, 1, NULL },
136 + { "OutMcastPkts", 0, 0, 1, NULL },
137 + { "InBcastPkts", 0, 0, 1, NULL },
138 + { "OutBcastPkts", 0, 0, 1, NULL },
139 + { "InOctets", 0, 0, 1, NULL },
140 + { "OutOctets", 0, 0, 1, NULL },
141 + { "InMcastOctets", 0, 0, 1, NULL },
142 + { "OutMcastOctets", 0, 0, 1, NULL },
143 + { "InBcastOctets", 0, 0, 1, NULL },
144 + { "OutBcastOctets", 0, 0, 1, NULL },
145 + { "InCsumErrors", 0, 0, 1, NULL },
146 + { "InNoECTPkts", 0, 0, 1, NULL },
147 + { "InECT1Pkts", 0, 0, 1, NULL },
148 + { "InECT0Pkts", 0, 0, 1, NULL },
149 + { "InCEPkts", 0, 0, 1, NULL },
150 + { NULL, 0, 0, 0, NULL }
151 +};
152 +
153 +static void hash_array(struct netstat_columns *nc) {
154 + int i;
155 +
156 + for(i = 0; nc[i].name ;i++)
157 + nc[i].hash = simple_hash(nc[i].name);
158 +}
159 +
160 +static unsigned long long *netstat_columns_find(struct netstat_columns *nc, const char *name) {
161 + uint32_t i, hash = simple_hash(name);
162 +
163 + for(i = 0; nc[i].name ;i++)
164 + if(unlikely(nc[i].hash == hash && !strcmp(nc[i].name, name)))
165 + return &nc[i].value;
166 +
167 + fatal("Cannot find key '%s' in /proc/net/netstat internal array.", name);
168 +}
169 +
170 +static void parse_line_pair(procfile *ff, struct netstat_columns *nc, uint32_t header_line, uint32_t values_line) {
171 + uint32_t hwords = procfile_linewords(ff, header_line);
172 + uint32_t vwords = procfile_linewords(ff, values_line);
173 + uint32_t w, i;
174 +
175 + if(unlikely(vwords > hwords)) {
176 + error("File /proc/net/netstat on header line %u has %u words, but on value line %u has %u words.", header_line, hwords, values_line, vwords);
177 + vwords = hwords;
178 + }
179 +
180 + for(w = 1; w < vwords ;w++) {
181 + char *key = procfile_lineword(ff, header_line, w);
182 + uint32_t hash = simple_hash(key);
183 +
184 + for(i = 0 ; nc[i].name ;i++) {
185 + if(unlikely(hash == nc[i].hash && !strcmp(key, nc[i].name))) {
186 + nc[i].value = strtoull(procfile_lineword(ff, values_line, w), NULL, 10);
187 + break;
188 + }
189 + }
190 + }
191 +}
192 +
193 +
194 int do_proc_net_netstat(int update_every, unsigned long long dt) {
4 - static int do_bandwidth = -1, do_inerrors = -1, do_mcast = -1, do_bcast = -1, do_mcast_p = -1, do_bcast_p = -1;
195 + (void)dt;
196 +
197 + 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, \
198 + do_tcpext_reorder = -1, do_tcpext_syscookies = -1, do_tcpext_ofo = -1, do_tcpext_connaborts = -1;
199 + static uint32_t hash_ipext = 0, hash_tcpext = 0;
200 static procfile *ff = NULL;
201
7 - if(do_bandwidth == -1) do_bandwidth = config_get_boolean_ondemand("plugin:proc:/proc/net/netstat", "bandwidth", CONFIG_ONDEMAND_ONDEMAND);
8 - if(do_inerrors == -1) do_inerrors = config_get_boolean_ondemand("plugin:proc:/proc/net/netstat", "input errors", CONFIG_ONDEMAND_ONDEMAND);
9 - if(do_mcast == -1) do_mcast = config_get_boolean_ondemand("plugin:proc:/proc/net/netstat", "multicast bandwidth", CONFIG_ONDEMAND_ONDEMAND);
10 - if(do_bcast == -1) do_bcast = config_get_boolean_ondemand("plugin:proc:/proc/net/netstat", "broadcast bandwidth", CONFIG_ONDEMAND_ONDEMAND);
11 - if(do_mcast_p == -1) do_mcast_p = config_get_boolean_ondemand("plugin:proc:/proc/net/netstat", "multicast packets", CONFIG_ONDEMAND_ONDEMAND);
12 - if(do_bcast_p == -1) do_bcast_p = config_get_boolean_ondemand("plugin:proc:/proc/net/netstat", "broadcast packets", CONFIG_ONDEMAND_ONDEMAND);
202 + // https://github.com/ecki/net-tools/blob/bd8bceaed2311651710331a7f8990c3e31be9840/statistics.c
203
14 - if(dt) {};
204 + // Reordering
205 + static unsigned long long *tcpext_TCPRenoReorder = NULL;
206 + static unsigned long long *tcpext_TCPFACKReorder = NULL;
207 + static unsigned long long *tcpext_TCPSACKReorder = NULL;
208 + static unsigned long long *tcpext_TCPTSReorder = NULL;
209 +
210 + // SYN Cookies
211 + static unsigned long long *tcpext_SyncookiesSent = NULL;
212 + static unsigned long long *tcpext_SyncookiesRecv = NULL;
213 + static unsigned long long *tcpext_SyncookiesFailed = NULL;
214 +
215 + // Out Of Order Queue
216 + // http://www.spinics.net/lists/netdev/msg204696.html
217 + static unsigned long long *tcpext_TCPOFOQueue = NULL; // Number of packets queued in OFO queue
218 + static unsigned long long *tcpext_TCPOFODrop = NULL; // Number of packets meant to be queued in OFO but dropped because socket rcvbuf limit hit.
219 + static unsigned long long *tcpext_TCPOFOMerge = NULL; // Number of packets in OFO that were merged with other packets.
220 + static unsigned long long *tcpext_OfoPruned = NULL; // packets dropped from out-of-order queue because of socket buffer overrun
221 +
222 + // connection rejects
223 + static unsigned long long *tcpext_PAWSActive = NULL; // active connections rejected because of time stamp
224 + static unsigned long long *tcpext_PAWSPassive = NULL; // passive connections rejected because of time stamp
225 +
226 + // connection resets
227 + static unsigned long long *tcpext_TCPAbortOnData = NULL; // connections reset due to unexpected data
228 + static unsigned long long *tcpext_TCPAbortOnClose = NULL; // connections reset due to early user close
229 + static unsigned long long *tcpext_TCPAbortOnMemory = NULL; // connections aborted due to memory pressure
230 + static unsigned long long *tcpext_TCPAbortOnTimeout = NULL; // connections aborted due to timeout
231 + static unsigned long long *tcpext_TCPAbortOnLinger = NULL; // connections aborted after user close in linger timeout
232 + static unsigned long long *tcpext_TCPAbortFailed = NULL; // times unable to send RST due to no memory
233 +
234 + static unsigned long long *tcpext_TCPTimeouts = NULL;
235 +
236 + static unsigned long long *tcpext_TCPDSACKUndo = NULL;
237 + static unsigned long long *tcpext_TCPDSACKOldSent = NULL;
238 + static unsigned long long *tcpext_TCPDSACKOfoSent = NULL;
239 + static unsigned long long *tcpext_TCPDSACKRecv = NULL;
240 + static unsigned long long *tcpext_TCPDSACKOfoRecv = NULL;
241 + static unsigned long long *tcpext_TCPDSACKIgnoredOld = NULL;
242 + static unsigned long long *tcpext_TCPDSACKIgnoredNoUndo = NULL;
243 +
244 +
245 + static unsigned long long *tcpext_EmbryonicRsts = NULL;
246 +
247 + static unsigned long long *tcpext_PruneCalled = NULL;
248 + static unsigned long long *tcpext_RcvPruned = NULL;
249 + static unsigned long long *tcpext_OutOfWindowIcmps = NULL;
250 + static unsigned long long *tcpext_LockDroppedIcmps = NULL;
251 + static unsigned long long *tcpext_ArpFilter = NULL;
252 +
253 + static unsigned long long *tcpext_TW = NULL;
254 + static unsigned long long *tcpext_TWRecycled = NULL;
255 + static unsigned long long *tcpext_TWKilled = NULL;
256 +
257 + static unsigned long long *tcpext_PAWSEstab = NULL;
258 +
259 + static unsigned long long *tcpext_DelayedACKs = NULL;
260 + static unsigned long long *tcpext_DelayedACKLocked = NULL;
261 + static unsigned long long *tcpext_DelayedACKLost = NULL;
262 +
263 + static unsigned long long *tcpext_ListenOverflows = NULL;
264 + static unsigned long long *tcpext_ListenDrops = NULL;
265 +
266 + static unsigned long long *tcpext_TCPPrequeued = NULL;
267 +
268 + static unsigned long long *tcpext_TCPDirectCopyFromBacklog = NULL;
269 + static unsigned long long *tcpext_TCPDirectCopyFromPrequeue = NULL;
270 + static unsigned long long *tcpext_TCPPrequeueDropped = NULL;
271 +
272 + static unsigned long long *tcpext_TCPHPHits = NULL;
273 + static unsigned long long *tcpext_TCPHPHitsToUser = NULL;
274 + static unsigned long long *tcpext_TCPHPAcks = NULL;
275 +
276 + static unsigned long long *tcpext_TCPPureAcks = NULL;
277 + static unsigned long long *tcpext_TCPRenoRecovery = NULL;
278 +
279 + static unsigned long long *tcpext_TCPSackRecovery = NULL;
280 + static unsigned long long *tcpext_TCPSackFailures = NULL;
281 + static unsigned long long *tcpext_TCPSACKReneging = NULL;
282 + static unsigned long long *tcpext_TCPSackRecoveryFail = NULL;
283 + static unsigned long long *tcpext_TCPSACKDiscard = NULL;
284 + static unsigned long long *tcpext_TCPSackShifted = NULL;
285 + static unsigned long long *tcpext_TCPSackMerged = NULL;
286 + static unsigned long long *tcpext_TCPSackShiftFallback = NULL;
287 +
288 +
289 + static unsigned long long *tcpext_TCPFullUndo = NULL;
290 + static unsigned long long *tcpext_TCPPartialUndo = NULL;
291 +
292 + static unsigned long long *tcpext_TCPLossUndo = NULL;
293 + static unsigned long long *tcpext_TCPLostRetransmit = NULL;
294 +
295 + static unsigned long long *tcpext_TCPRenoFailures = NULL;
296 +
297 + static unsigned long long *tcpext_TCPLossFailures = NULL;
298 + static unsigned long long *tcpext_TCPFastRetrans = NULL;
299 + static unsigned long long *tcpext_TCPForwardRetrans = NULL;
300 + static unsigned long long *tcpext_TCPSlowStartRetrans = NULL;
301 + static unsigned long long *tcpext_TCPLossProbes = NULL;
302 + static unsigned long long *tcpext_TCPLossProbeRecovery = NULL;
303 + static unsigned long long *tcpext_TCPRenoRecoveryFail = NULL;
304 + static unsigned long long *tcpext_TCPSchedulerFailed = NULL;
305 + static unsigned long long *tcpext_TCPRcvCollapsed = NULL;
306 +
307 + static unsigned long long *tcpext_TCPMemoryPressures = NULL;
308 + static unsigned long long *tcpext_TCPSpuriousRTOs = NULL;
309 + static unsigned long long *tcpext_TCPMD5NotFound = NULL;
310 + static unsigned long long *tcpext_TCPMD5Unexpected = NULL;
311 +
312 + static unsigned long long *tcpext_TCPBacklogDrop = NULL;
313 + static unsigned long long *tcpext_TCPMinTTLDrop = NULL;
314 + static unsigned long long *tcpext_TCPDeferAcceptDrop = NULL;
315 + static unsigned long long *tcpext_IPReversePathFilter = NULL;
316 + static unsigned long long *tcpext_TCPTimeWaitOverflow = NULL;
317 + static unsigned long long *tcpext_TCPReqQFullDoCookies = NULL;
318 + static unsigned long long *tcpext_TCPReqQFullDrop = NULL;
319 + static unsigned long long *tcpext_TCPRetransFail = NULL;
320 + static unsigned long long *tcpext_TCPRcvCoalesce = NULL;
321 +
322 + static unsigned long long *tcpext_TCPChallengeACK = NULL;
323 + static unsigned long long *tcpext_TCPSYNChallenge = NULL;
324 +
325 + static unsigned long long *tcpext_TCPFastOpenActive = NULL;
326 + static unsigned long long *tcpext_TCPFastOpenActiveFail = NULL;
327 + static unsigned long long *tcpext_TCPFastOpenPassive = NULL;
328 + static unsigned long long *tcpext_TCPFastOpenPassiveFail = NULL;
329 + static unsigned long long *tcpext_TCPFastOpenListenOverflow = NULL;
330 + static unsigned long long *tcpext_TCPFastOpenCookieReqd = NULL;
331 +
332 + static unsigned long long *tcpext_TCPSpuriousRtxHostQueues = NULL;
333 + static unsigned long long *tcpext_BusyPollRxPackets = NULL;
334 + static unsigned long long *tcpext_TCPAutoCorking = NULL;
335 + static unsigned long long *tcpext_TCPFromZeroWindowAdv = NULL;
336 + static unsigned long long *tcpext_TCPToZeroWindowAdv = NULL;
337 + static unsigned long long *tcpext_TCPWantZeroWindowAdv = NULL;
338 + static unsigned long long *tcpext_TCPSynRetrans = NULL;
339 + static unsigned long long *tcpext_TCPOrigDataSent = NULL;
340 +
341 + static unsigned long long *tcpext_TCPHystartTrainDetect = NULL;
342 + static unsigned long long *tcpext_TCPHystartTrainCwnd = NULL;
343 + static unsigned long long *tcpext_TCPHystartDelayDetect = NULL;
344 + static unsigned long long *tcpext_TCPHystartDelayCwnd = NULL;
345 +
346 + static unsigned long long *tcpext_TCPACKSkippedSynRecv = NULL;
347 + static unsigned long long *tcpext_TCPACKSkippedPAWS = NULL;
348 + static unsigned long long *tcpext_TCPACKSkippedSeq = NULL;
349 + static unsigned long long *tcpext_TCPACKSkippedFinWait2 = NULL;
350 + static unsigned long long *tcpext_TCPACKSkippedTimeWait = NULL;
351 + static unsigned long long *tcpext_TCPACKSkippedChallenge = NULL;
352 +
353 + static unsigned long long *tcpext_TCPWinProbe = NULL;
354 + static unsigned long long *tcpext_TCPKeepAlive = NULL;
355 +
356 + static unsigned long long *tcpext_TCPMTUPFail = NULL;
357 + static unsigned long long *tcpext_TCPMTUPSuccess = NULL;
358 +
359 + static unsigned long long *ipext_InNoRoutes = NULL;
360 + static unsigned long long *ipext_InTruncatedPkts = NULL;
361 + static unsigned long long *ipext_InMcastPkts = NULL;
362 + static unsigned long long *ipext_OutMcastPkts = NULL;
363 + static unsigned long long *ipext_InBcastPkts = NULL;
364 + static unsigned long long *ipext_OutBcastPkts = NULL;
365 + static unsigned long long *ipext_InOctets = NULL;
366 + static unsigned long long *ipext_OutOctets = NULL;
367 + static unsigned long long *ipext_InMcastOctets = NULL;
368 + static unsigned long long *ipext_OutMcastOctets = NULL;
369 + static unsigned long long *ipext_InBcastOctets = NULL;
370 + static unsigned long long *ipext_OutBcastOctets = NULL;
371 + static unsigned long long *ipext_InCsumErrors = NULL;
372 + static unsigned long long *ipext_InNoECTPkts = NULL;
373 + static unsigned long long *ipext_InECT1Pkts = NULL;
374 + static unsigned long long *ipext_InECT0Pkts = NULL;
375 + static unsigned long long *ipext_InCEPkts = NULL;
376 +
377 + if(unlikely(do_bandwidth == -1)) {
378 + do_bandwidth = config_get_boolean_ondemand("plugin:proc:/proc/net/netstat", "bandwidth", CONFIG_ONDEMAND_ONDEMAND);
379 + do_inerrors = config_get_boolean_ondemand("plugin:proc:/proc/net/netstat", "input errors", CONFIG_ONDEMAND_ONDEMAND);
380 + do_mcast = config_get_boolean_ondemand("plugin:proc:/proc/net/netstat", "multicast bandwidth", CONFIG_ONDEMAND_ONDEMAND);
381 + do_bcast = config_get_boolean_ondemand("plugin:proc:/proc/net/netstat", "broadcast bandwidth", CONFIG_ONDEMAND_ONDEMAND);
382 + do_mcast_p = config_get_boolean_ondemand("plugin:proc:/proc/net/netstat", "multicast packets", CONFIG_ONDEMAND_ONDEMAND);
383 + do_bcast_p = config_get_boolean_ondemand("plugin:proc:/proc/net/netstat", "broadcast packets", CONFIG_ONDEMAND_ONDEMAND);
384 + do_ecn = config_get_boolean_ondemand("plugin:proc:/proc/net/netstat", "ECN packets", CONFIG_ONDEMAND_ONDEMAND);
385 +
386 + do_tcpext_reorder = config_get_boolean_ondemand("plugin:proc:/proc/net/netstat", "TCP reorders", CONFIG_ONDEMAND_ONDEMAND);
387 + do_tcpext_syscookies = config_get_boolean_ondemand("plugin:proc:/proc/net/netstat", "TCP SYN cookies", CONFIG_ONDEMAND_ONDEMAND);
388 + do_tcpext_ofo = config_get_boolean_ondemand("plugin:proc:/proc/net/netstat", "TCP out-of-order queue", CONFIG_ONDEMAND_ONDEMAND);
389 + do_tcpext_connaborts = config_get_boolean_ondemand("plugin:proc:/proc/net/netstat", "TCP connection aborts", CONFIG_ONDEMAND_ONDEMAND);
390 +
391 + hash_ipext = simple_hash("IpExt");
392 + hash_tcpext = simple_hash("TcpExt");
393 +
394 + hash_array(ipext_data);
395 + hash_array(tcpext_data);
396 +
397 + tcpext_SyncookiesSent = netstat_columns_find(tcpext_data, "SyncookiesSent");
398 + tcpext_SyncookiesRecv = netstat_columns_find(tcpext_data, "SyncookiesRecv");
399 + tcpext_SyncookiesFailed = netstat_columns_find(tcpext_data, "SyncookiesFailed");
400 + tcpext_EmbryonicRsts = netstat_columns_find(tcpext_data, "EmbryonicRsts");
401 + tcpext_PruneCalled = netstat_columns_find(tcpext_data, "PruneCalled");
402 + tcpext_RcvPruned = netstat_columns_find(tcpext_data, "RcvPruned");
403 + tcpext_OfoPruned = netstat_columns_find(tcpext_data, "OfoPruned");
404 + tcpext_OutOfWindowIcmps = netstat_columns_find(tcpext_data, "OutOfWindowIcmps");
405 + tcpext_LockDroppedIcmps = netstat_columns_find(tcpext_data, "LockDroppedIcmps");
406 + tcpext_ArpFilter = netstat_columns_find(tcpext_data, "ArpFilter");
407 + tcpext_TW = netstat_columns_find(tcpext_data, "TW");
408 + tcpext_TWRecycled = netstat_columns_find(tcpext_data, "TWRecycled");
409 + tcpext_TWKilled = netstat_columns_find(tcpext_data, "TWKilled");
410 + tcpext_PAWSPassive = netstat_columns_find(tcpext_data, "PAWSPassive");
411 + tcpext_PAWSActive = netstat_columns_find(tcpext_data, "PAWSActive");
412 + tcpext_PAWSEstab = netstat_columns_find(tcpext_data, "PAWSEstab");
413 + tcpext_DelayedACKs = netstat_columns_find(tcpext_data, "DelayedACKs");
414 + tcpext_DelayedACKLocked = netstat_columns_find(tcpext_data, "DelayedACKLocked");
415 + tcpext_DelayedACKLost = netstat_columns_find(tcpext_data, "DelayedACKLost");
416 + tcpext_ListenOverflows = netstat_columns_find(tcpext_data, "ListenOverflows");
417 + tcpext_ListenDrops = netstat_columns_find(tcpext_data, "ListenDrops");
418 + tcpext_TCPPrequeued = netstat_columns_find(tcpext_data, "TCPPrequeued");
419 + tcpext_TCPDirectCopyFromBacklog = netstat_columns_find(tcpext_data, "TCPDirectCopyFromBacklog");
420 + tcpext_TCPDirectCopyFromPrequeue = netstat_columns_find(tcpext_data, "TCPDirectCopyFromPrequeue");
421 + tcpext_TCPPrequeueDropped = netstat_columns_find(tcpext_data, "TCPPrequeueDropped");
422 + tcpext_TCPHPHits = netstat_columns_find(tcpext_data, "TCPHPHits");
423 + tcpext_TCPHPHitsToUser = netstat_columns_find(tcpext_data, "TCPHPHitsToUser");
424 + tcpext_TCPPureAcks = netstat_columns_find(tcpext_data, "TCPPureAcks");
425 + tcpext_TCPHPAcks = netstat_columns_find(tcpext_data, "TCPHPAcks");
426 + tcpext_TCPRenoRecovery = netstat_columns_find(tcpext_data, "TCPRenoRecovery");
427 + tcpext_TCPSackRecovery = netstat_columns_find(tcpext_data, "TCPSackRecovery");
428 + tcpext_TCPSACKReneging = netstat_columns_find(tcpext_data, "TCPSACKReneging");
429 + tcpext_TCPFACKReorder = netstat_columns_find(tcpext_data, "TCPFACKReorder");
430 + tcpext_TCPSACKReorder = netstat_columns_find(tcpext_data, "TCPSACKReorder");
431 + tcpext_TCPRenoReorder = netstat_columns_find(tcpext_data, "TCPRenoReorder");
432 + tcpext_TCPTSReorder = netstat_columns_find(tcpext_data, "TCPTSReorder");
433 + tcpext_TCPFullUndo = netstat_columns_find(tcpext_data, "TCPFullUndo");
434 + tcpext_TCPPartialUndo = netstat_columns_find(tcpext_data, "TCPPartialUndo");
435 + tcpext_TCPDSACKUndo = netstat_columns_find(tcpext_data, "TCPDSACKUndo");
436 + tcpext_TCPLossUndo = netstat_columns_find(tcpext_data, "TCPLossUndo");
437 + tcpext_TCPLostRetransmit = netstat_columns_find(tcpext_data, "TCPLostRetransmit");
438 + tcpext_TCPRenoFailures = netstat_columns_find(tcpext_data, "TCPRenoFailures");
439 + tcpext_TCPSackFailures = netstat_columns_find(tcpext_data, "TCPSackFailures");
440 + tcpext_TCPLossFailures = netstat_columns_find(tcpext_data, "TCPLossFailures");
441 + tcpext_TCPFastRetrans = netstat_columns_find(tcpext_data, "TCPFastRetrans");
442 + tcpext_TCPForwardRetrans = netstat_columns_find(tcpext_data, "TCPForwardRetrans");
443 + tcpext_TCPSlowStartRetrans = netstat_columns_find(tcpext_data, "TCPSlowStartRetrans");
444 + tcpext_TCPTimeouts = netstat_columns_find(tcpext_data, "TCPTimeouts");
445 + tcpext_TCPLossProbes = netstat_columns_find(tcpext_data, "TCPLossProbes");
446 + tcpext_TCPLossProbeRecovery = netstat_columns_find(tcpext_data, "TCPLossProbeRecovery");
447 + tcpext_TCPRenoRecoveryFail = netstat_columns_find(tcpext_data, "TCPRenoRecoveryFail");
448 + tcpext_TCPSackRecoveryFail = netstat_columns_find(tcpext_data, "TCPSackRecoveryFail");
449 + tcpext_TCPSchedulerFailed = netstat_columns_find(tcpext_data, "TCPSchedulerFailed");
450 + tcpext_TCPRcvCollapsed = netstat_columns_find(tcpext_data, "TCPRcvCollapsed");
451 + tcpext_TCPDSACKOldSent = netstat_columns_find(tcpext_data, "TCPDSACKOldSent");
452 + tcpext_TCPDSACKOfoSent = netstat_columns_find(tcpext_data, "TCPDSACKOfoSent");
453 + tcpext_TCPDSACKRecv = netstat_columns_find(tcpext_data, "TCPDSACKRecv");
454 + tcpext_TCPDSACKOfoRecv = netstat_columns_find(tcpext_data, "TCPDSACKOfoRecv");
455 + tcpext_TCPAbortOnData = netstat_columns_find(tcpext_data, "TCPAbortOnData");
456 + tcpext_TCPAbortOnClose = netstat_columns_find(tcpext_data, "TCPAbortOnClose");
457 + tcpext_TCPAbortOnMemory = netstat_columns_find(tcpext_data, "TCPAbortOnMemory");
458 + tcpext_TCPAbortOnTimeout = netstat_columns_find(tcpext_data, "TCPAbortOnTimeout");
459 + tcpext_TCPAbortOnLinger = netstat_columns_find(tcpext_data, "TCPAbortOnLinger");
460 + tcpext_TCPAbortFailed = netstat_columns_find(tcpext_data, "TCPAbortFailed");
461 + tcpext_TCPMemoryPressures = netstat_columns_find(tcpext_data, "TCPMemoryPressures");
462 + tcpext_TCPSACKDiscard = netstat_columns_find(tcpext_data, "TCPSACKDiscard");
463 + tcpext_TCPDSACKIgnoredOld = netstat_columns_find(tcpext_data, "TCPDSACKIgnoredOld");
464 + tcpext_TCPDSACKIgnoredNoUndo = netstat_columns_find(tcpext_data, "TCPDSACKIgnoredNoUndo");
465 + tcpext_TCPSpuriousRTOs = netstat_columns_find(tcpext_data, "TCPSpuriousRTOs");
466 + tcpext_TCPMD5NotFound = netstat_columns_find(tcpext_data, "TCPMD5NotFound");
467 + tcpext_TCPMD5Unexpected = netstat_columns_find(tcpext_data, "TCPMD5Unexpected");
468 + tcpext_TCPSackShifted = netstat_columns_find(tcpext_data, "TCPSackShifted");
469 + tcpext_TCPSackMerged = netstat_columns_find(tcpext_data, "TCPSackMerged");
470 + tcpext_TCPSackShiftFallback = netstat_columns_find(tcpext_data, "TCPSackShiftFallback");
471 + tcpext_TCPBacklogDrop = netstat_columns_find(tcpext_data, "TCPBacklogDrop");
472 + tcpext_TCPMinTTLDrop = netstat_columns_find(tcpext_data, "TCPMinTTLDrop");
473 + tcpext_TCPDeferAcceptDrop = netstat_columns_find(tcpext_data, "TCPDeferAcceptDrop");
474 + tcpext_IPReversePathFilter = netstat_columns_find(tcpext_data, "IPReversePathFilter");
475 + tcpext_TCPTimeWaitOverflow = netstat_columns_find(tcpext_data, "TCPTimeWaitOverflow");
476 + tcpext_TCPReqQFullDoCookies = netstat_columns_find(tcpext_data, "TCPReqQFullDoCookies");
477 + tcpext_TCPReqQFullDrop = netstat_columns_find(tcpext_data, "TCPReqQFullDrop");
478 + tcpext_TCPRetransFail = netstat_columns_find(tcpext_data, "TCPRetransFail");
479 + tcpext_TCPRcvCoalesce = netstat_columns_find(tcpext_data, "TCPRcvCoalesce");
480 + tcpext_TCPOFOQueue = netstat_columns_find(tcpext_data, "TCPOFOQueue");
481 + tcpext_TCPOFODrop = netstat_columns_find(tcpext_data, "TCPOFODrop");
482 + tcpext_TCPOFOMerge = netstat_columns_find(tcpext_data, "TCPOFOMerge");
483 + tcpext_TCPChallengeACK = netstat_columns_find(tcpext_data, "TCPChallengeACK");
484 + tcpext_TCPSYNChallenge = netstat_columns_find(tcpext_data, "TCPSYNChallenge");
485 + tcpext_TCPFastOpenActive = netstat_columns_find(tcpext_data, "TCPFastOpenActive");
486 + tcpext_TCPFastOpenActiveFail = netstat_columns_find(tcpext_data, "TCPFastOpenActiveFail");
487 + tcpext_TCPFastOpenPassive = netstat_columns_find(tcpext_data, "TCPFastOpenPassive");
488 + tcpext_TCPFastOpenPassiveFail = netstat_columns_find(tcpext_data, "TCPFastOpenPassiveFail");
489 + tcpext_TCPFastOpenListenOverflow = netstat_columns_find(tcpext_data, "TCPFastOpenListenOverflow");
490 + tcpext_TCPFastOpenCookieReqd = netstat_columns_find(tcpext_data, "TCPFastOpenCookieReqd");
491 + tcpext_TCPSpuriousRtxHostQueues = netstat_columns_find(tcpext_data, "TCPSpuriousRtxHostQueues");
492 + tcpext_BusyPollRxPackets = netstat_columns_find(tcpext_data, "BusyPollRxPackets");
493 + tcpext_TCPAutoCorking = netstat_columns_find(tcpext_data, "TCPAutoCorking");
494 + tcpext_TCPFromZeroWindowAdv = netstat_columns_find(tcpext_data, "TCPFromZeroWindowAdv");
495 + tcpext_TCPToZeroWindowAdv = netstat_columns_find(tcpext_data, "TCPToZeroWindowAdv");
496 + tcpext_TCPWantZeroWindowAdv = netstat_columns_find(tcpext_data, "TCPWantZeroWindowAdv");
497 + tcpext_TCPSynRetrans = netstat_columns_find(tcpext_data, "TCPSynRetrans");
498 + tcpext_TCPOrigDataSent = netstat_columns_find(tcpext_data, "TCPOrigDataSent");
499 + tcpext_TCPHystartTrainDetect = netstat_columns_find(tcpext_data, "TCPHystartTrainDetect");
500 + tcpext_TCPHystartTrainCwnd = netstat_columns_find(tcpext_data, "TCPHystartTrainCwnd");
501 + tcpext_TCPHystartDelayDetect = netstat_columns_find(tcpext_data, "TCPHystartDelayDetect");
502 + tcpext_TCPHystartDelayCwnd = netstat_columns_find(tcpext_data, "TCPHystartDelayCwnd");
503 + tcpext_TCPACKSkippedSynRecv = netstat_columns_find(tcpext_data, "TCPACKSkippedSynRecv");
504 + tcpext_TCPACKSkippedPAWS = netstat_columns_find(tcpext_data, "TCPACKSkippedPAWS");
505 + tcpext_TCPACKSkippedSeq = netstat_columns_find(tcpext_data, "TCPACKSkippedSeq");
506 + tcpext_TCPACKSkippedFinWait2 = netstat_columns_find(tcpext_data, "TCPACKSkippedFinWait2");
507 + tcpext_TCPACKSkippedTimeWait = netstat_columns_find(tcpext_data, "TCPACKSkippedTimeWait");
508 + tcpext_TCPACKSkippedChallenge = netstat_columns_find(tcpext_data, "TCPACKSkippedChallenge");
509 + tcpext_TCPWinProbe = netstat_columns_find(tcpext_data, "TCPWinProbe");
510 + tcpext_TCPKeepAlive = netstat_columns_find(tcpext_data, "TCPKeepAlive");
511 + tcpext_TCPMTUPFail = netstat_columns_find(tcpext_data, "TCPMTUPFail");
512 + tcpext_TCPMTUPSuccess = netstat_columns_find(tcpext_data, "TCPMTUPSuccess");
513 +
514 + ipext_InNoRoutes = netstat_columns_find(ipext_data, "InNoRoutes");
515 + ipext_InTruncatedPkts = netstat_columns_find(ipext_data, "InTruncatedPkts");
516 + ipext_InMcastPkts = netstat_columns_find(ipext_data, "InMcastPkts");
517 + ipext_OutMcastPkts = netstat_columns_find(ipext_data, "OutMcastPkts");
518 + ipext_InBcastPkts = netstat_columns_find(ipext_data, "InBcastPkts");
519 + ipext_OutBcastPkts = netstat_columns_find(ipext_data, "OutBcastPkts");
520 + ipext_InOctets = netstat_columns_find(ipext_data, "InOctets");
521 + ipext_OutOctets = netstat_columns_find(ipext_data, "OutOctets");
522 + ipext_InMcastOctets = netstat_columns_find(ipext_data, "InMcastOctets");
523 + ipext_OutMcastOctets = netstat_columns_find(ipext_data, "OutMcastOctets");
524 + ipext_InBcastOctets = netstat_columns_find(ipext_data, "InBcastOctets");
525 + ipext_OutBcastOctets = netstat_columns_find(ipext_data, "OutBcastOctets");
526 + ipext_InCsumErrors = netstat_columns_find(ipext_data, "InCsumErrors");
527 + ipext_InNoECTPkts = netstat_columns_find(ipext_data, "InNoECTPkts");
528 + ipext_InECT1Pkts = netstat_columns_find(ipext_data, "InECT1Pkts");
529 + ipext_InECT0Pkts = netstat_columns_find(ipext_data, "InECT0Pkts");
530 + ipext_InCEPkts = netstat_columns_find(ipext_data, "InCEPkts");
531 + }
532
16 - if(!ff) {
533 + if(unlikely(!ff)) {
534 char filename[FILENAME_MAX + 1];
535 snprintfz(filename, FILENAME_MAX, "%s%s", global_host_prefix, "/proc/net/netstat");
536 ff = procfile_open(config_get("plugin:proc:/proc/net/netstat", "filename to monitor", filename), " \t:", PROCFILE_FLAG_DEFAULT);
537 }
21 - if(!ff) return 1;
538 + if(unlikely(!ff)) return 1;
539
540 ff = procfile_readall(ff);
24 - if(!ff) return 0; // we return 0, so that we will retry to open it next time
541 + if(unlikely(!ff)) return 0; // we return 0, so that we will retry to open it next time
542
543 uint32_t lines = procfile_lines(ff), l;
544 uint32_t words;
545
546 for(l = 0; l < lines ;l++) {
30 - if(strcmp(procfile_lineword(ff, l, 0), "IpExt") == 0) {
31 - l++; // we need the next line
547 + char *key = procfile_lineword(ff, l, 0);
548 + uint32_t hash = simple_hash(key);
549 +
550 + if(unlikely(hash == hash_ipext && strcmp(key, "IpExt") == 0)) {
551 + uint32_t h = l++;
552
553 if(strcmp(procfile_lineword(ff, l, 0), "IpExt") != 0) {
554 error("Cannot read IpExt line from /proc/net/netstat.");
555 break;
556 }
557 words = procfile_linewords(ff, l);
38 - if(words < 12) {
39 - error("Cannot read /proc/net/netstat IpExt line. Expected 12 params, read %u.", words);
558 + if(words < 2) {
559 + error("Cannot read /proc/net/netstat IpExt line. Expected 2+ params, read %u.", words);
560 continue;
561 }
562
43 - unsigned long long
44 - InNoRoutes = 0, InTruncatedPkts = 0,
45 - InOctets = 0, InMcastPkts = 0, InBcastPkts = 0, InMcastOctets = 0, InBcastOctets = 0,
46 - OutOctets = 0, OutMcastPkts = 0, OutBcastPkts = 0, OutMcastOctets = 0, OutBcastOctets = 0;
47 -
48 - InNoRoutes = strtoull(procfile_lineword(ff, l, 1), NULL, 10);
49 - InTruncatedPkts = strtoull(procfile_lineword(ff, l, 2), NULL, 10);
50 - InMcastPkts = strtoull(procfile_lineword(ff, l, 3), NULL, 10);
51 - OutMcastPkts = strtoull(procfile_lineword(ff, l, 4), NULL, 10);
52 - InBcastPkts = strtoull(procfile_lineword(ff, l, 5), NULL, 10);
53 - OutBcastPkts = strtoull(procfile_lineword(ff, l, 6), NULL, 10);
54 - InOctets = strtoull(procfile_lineword(ff, l, 7), NULL, 10);
55 - OutOctets = strtoull(procfile_lineword(ff, l, 8), NULL, 10);
56 - InMcastOctets = strtoull(procfile_lineword(ff, l, 9), NULL, 10);
57 - OutMcastOctets = strtoull(procfile_lineword(ff, l, 10), NULL, 10);
58 - InBcastOctets = strtoull(procfile_lineword(ff, l, 11), NULL, 10);
59 - OutBcastOctets = strtoull(procfile_lineword(ff, l, 12), NULL, 10);
563 + parse_line_pair(ff, ipext_data, h, l);
564
565 RRDSET *st;
566
567 // --------------------------------------------------------------------
568
65 - if(do_bandwidth == CONFIG_ONDEMAND_YES || (do_bandwidth == CONFIG_ONDEMAND_ONDEMAND && (InOctets || OutOctets))) {
569 + if(do_bandwidth == CONFIG_ONDEMAND_YES || (do_bandwidth == CONFIG_ONDEMAND_ONDEMAND && (*ipext_InOctets || *ipext_OutOctets))) {
570 do_bandwidth = CONFIG_ONDEMAND_YES;
571 st = rrdset_find("system.ipv4");
572 if(!st) {
573 st = rrdset_create("system", "ipv4", NULL, "network", NULL, "IPv4 Bandwidth", "kilobits/s", 500, update_every, RRDSET_TYPE_AREA);
574
71 - rrddim_add(st, "received", NULL, 8, 1024, RRDDIM_INCREMENTAL);
72 - rrddim_add(st, "sent", NULL, -8, 1024, RRDDIM_INCREMENTAL);
575 + rrddim_add(st, "InOctets", "received", 8, 1024, RRDDIM_INCREMENTAL);
576 + rrddim_add(st, "OutOctets", "sent", -8, 1024, RRDDIM_INCREMENTAL);
577 }
578 else rrdset_next(st);
579
76 - rrddim_set(st, "sent", OutOctets);
77 - rrddim_set(st, "received", InOctets);
580 + rrddim_set(st, "InOctets", *ipext_InOctets);
581 + rrddim_set(st, "OutOctets", *ipext_OutOctets);
582 rrdset_done(st);
583 }
584
585 // --------------------------------------------------------------------
586
83 - if(do_inerrors == CONFIG_ONDEMAND_YES || (do_inerrors == CONFIG_ONDEMAND_ONDEMAND && (InNoRoutes || InTruncatedPkts))) {
587 + if(do_inerrors == CONFIG_ONDEMAND_YES || (do_inerrors == CONFIG_ONDEMAND_ONDEMAND && (*ipext_InNoRoutes || *ipext_InTruncatedPkts))) {
588 do_inerrors = CONFIG_ONDEMAND_YES;
589 st = rrdset_find("ipv4.inerrors");
590 if(!st) {
591 st = rrdset_create("ipv4", "inerrors", NULL, "errors", NULL, "IPv4 Input Errors", "packets/s", 4000, update_every, RRDSET_TYPE_LINE);
592 st->isdetail = 1;
593
90 - rrddim_add(st, "noroutes", NULL, 1, 1, RRDDIM_INCREMENTAL);
91 - rrddim_add(st, "truncated", NULL, 1, 1, RRDDIM_INCREMENTAL);
594 + rrddim_add(st, "InNoRoutes", "noroutes", 1, 1, RRDDIM_INCREMENTAL);
595 + rrddim_add(st, "InTruncatedPkts", "truncated", 1, 1, RRDDIM_INCREMENTAL);
596 + rrddim_add(st, "InCsumErrors", "checksum", 1, 1, RRDDIM_INCREMENTAL);
597 }
598 else rrdset_next(st);
599
95 - rrddim_set(st, "noroutes", InNoRoutes);
96 - rrddim_set(st, "truncated", InTruncatedPkts);
600 + rrddim_set(st, "InNoRoutes", *ipext_InNoRoutes);
601 + rrddim_set(st, "InTruncatedPkts", *ipext_InTruncatedPkts);
602 + rrddim_set(st, "InCsumErrors", *ipext_InCsumErrors);
603 rrdset_done(st);
604 }
605
606 // --------------------------------------------------------------------
607
102 - if(do_mcast == CONFIG_ONDEMAND_YES || (do_mcast == CONFIG_ONDEMAND_ONDEMAND && (InMcastOctets || OutMcastOctets))) {
608 + if(do_mcast == CONFIG_ONDEMAND_YES || (do_mcast == CONFIG_ONDEMAND_ONDEMAND && (*ipext_InMcastOctets || *ipext_OutMcastOctets))) {
609 do_mcast = CONFIG_ONDEMAND_YES;
610 st = rrdset_find("ipv4.mcast");
611 if(!st) {
612 st = rrdset_create("ipv4", "mcast", NULL, "multicast", NULL, "IPv4 Multicast Bandwidth", "kilobits/s", 9000, update_every, RRDSET_TYPE_AREA);
613 st->isdetail = 1;
614
109 - rrddim_add(st, "received", NULL, 8, 1024, RRDDIM_INCREMENTAL);
110 - rrddim_add(st, "sent", NULL, -8, 1024, RRDDIM_INCREMENTAL);
615 + rrddim_add(st, "InMcastOctets", "received", 8, 1024, RRDDIM_INCREMENTAL);
616 + rrddim_add(st, "OutMcastOctets", "sent", -8, 1024, RRDDIM_INCREMENTAL);
617 }
618 else rrdset_next(st);
619
114 - rrddim_set(st, "sent", OutMcastOctets);
115 - rrddim_set(st, "received", InMcastOctets);
620 + rrddim_set(st, "InMcastOctets", *ipext_InMcastOctets);
621 + rrddim_set(st, "OutMcastOctets", *ipext_OutMcastOctets);
622 rrdset_done(st);
623 }
624
625 // --------------------------------------------------------------------
626
121 - if(do_bcast == CONFIG_ONDEMAND_YES || (do_bcast == CONFIG_ONDEMAND_ONDEMAND && (InBcastOctets || OutBcastOctets))) {
627 + if(do_bcast == CONFIG_ONDEMAND_YES || (do_bcast == CONFIG_ONDEMAND_ONDEMAND && (*ipext_InBcastOctets || *ipext_OutBcastOctets))) {
628 do_bcast = CONFIG_ONDEMAND_YES;
629 st = rrdset_find("ipv4.bcast");
630 if(!st) {
631 st = rrdset_create("ipv4", "bcast", NULL, "broadcast", NULL, "IPv4 Broadcast Bandwidth", "kilobits/s", 8000, update_every, RRDSET_TYPE_AREA);
632 st->isdetail = 1;
633
128 - rrddim_add(st, "received", NULL, 8, 1024, RRDDIM_INCREMENTAL);
129 - rrddim_add(st, "sent", NULL, -8, 1024, RRDDIM_INCREMENTAL);
634 + rrddim_add(st, "InBcastOctets", "received", 8, 1024, RRDDIM_INCREMENTAL);
635 + rrddim_add(st, "OutBcastOctets", "sent", -8, 1024, RRDDIM_INCREMENTAL);
636 }
637 else rrdset_next(st);
638
133 - rrddim_set(st, "sent", OutBcastOctets);
134 - rrddim_set(st, "received", InBcastOctets);
639 + rrddim_set(st, "InBcastOctets", *ipext_InBcastOctets);
640 + rrddim_set(st, "OutBcastOctets", *ipext_OutBcastOctets);
641 rrdset_done(st);
642 }
643
644 // --------------------------------------------------------------------
645
140 - if(do_mcast_p == CONFIG_ONDEMAND_YES || (do_mcast_p == CONFIG_ONDEMAND_ONDEMAND && (InMcastPkts || OutMcastPkts))) {
646 + if(do_mcast_p == CONFIG_ONDEMAND_YES || (do_mcast_p == CONFIG_ONDEMAND_ONDEMAND && (*ipext_InMcastPkts || *ipext_OutMcastPkts))) {
647 do_mcast_p = CONFIG_ONDEMAND_YES;
648 st = rrdset_find("ipv4.mcastpkts");
649 if(!st) {
144 - st = rrdset_create("ipv4", "mcastpkts", NULL, "multicast", NULL, "IPv4 Multicast Packets", "packets/s", 9500, update_every, RRDSET_TYPE_LINE);
650 + st = rrdset_create("ipv4", "mcastpkts", NULL, "multicast", NULL, "IPv4 Multicast Packets", "packets/s", 8600, update_every, RRDSET_TYPE_LINE);
651 st->isdetail = 1;
652
147 - rrddim_add(st, "received", NULL, 1, 1, RRDDIM_INCREMENTAL);
148 - rrddim_add(st, "sent", NULL, -1, 1, RRDDIM_INCREMENTAL);
653 + rrddim_add(st, "InMcastPkts", "received", 1, 1, RRDDIM_INCREMENTAL);
654 + rrddim_add(st, "OutMcastPkts", "sent", -1, 1, RRDDIM_INCREMENTAL);
655 }
656 else rrdset_next(st);
657
152 - rrddim_set(st, "sent", OutMcastPkts);
153 - rrddim_set(st, "received", InMcastPkts);
658 + rrddim_set(st, "InMcastPkts", *ipext_InMcastPkts);
659 + rrddim_set(st, "OutMcastPkts", *ipext_OutMcastPkts);
660 rrdset_done(st);
661 }
662
663 // --------------------------------------------------------------------
664
159 - if(do_bcast_p == CONFIG_ONDEMAND_YES || (do_bcast_p == CONFIG_ONDEMAND_ONDEMAND && (InBcastPkts || OutBcastPkts))) {
665 + if(do_bcast_p == CONFIG_ONDEMAND_YES || (do_bcast_p == CONFIG_ONDEMAND_ONDEMAND && (*ipext_InBcastPkts || *ipext_OutBcastPkts))) {
666 do_bcast_p = CONFIG_ONDEMAND_YES;
667 st = rrdset_find("ipv4.bcastpkts");
668 if(!st) {
669 st = rrdset_create("ipv4", "bcastpkts", NULL, "broadcast", NULL, "IPv4 Broadcast Packets", "packets/s", 8500, update_every, RRDSET_TYPE_LINE);
670 st->isdetail = 1;
671
166 - rrddim_add(st, "received", NULL, 1, 1, RRDDIM_INCREMENTAL);
167 - rrddim_add(st, "sent", NULL, -1, 1, RRDDIM_INCREMENTAL);
672 + rrddim_add(st, "InBcastPkts", "received", 1, 1, RRDDIM_INCREMENTAL);
673 + rrddim_add(st, "OutBcastPkts", "sent", -1, 1, RRDDIM_INCREMENTAL);
674 + }
675 + else rrdset_next(st);
676 +
677 + rrddim_set(st, "InBcastPkts", *ipext_InBcastPkts);
678 + rrddim_set(st, "OutBcastPkts", *ipext_OutBcastPkts);
679 + rrdset_done(st);
680 + }
681 +
682 + // --------------------------------------------------------------------
683 +
684 + if(do_ecn == CONFIG_ONDEMAND_YES || (do_ecn == CONFIG_ONDEMAND_ONDEMAND && (*ipext_InCEPkts || *ipext_InECT0Pkts || *ipext_InECT1Pkts || *ipext_InNoECTPkts))) {
685 + do_ecn = CONFIG_ONDEMAND_YES;
686 + st = rrdset_find("ipv4.ecnpkts");
687 + if(!st) {
688 + st = rrdset_create("ipv4", "ecnpkts", NULL, "ecn", NULL, "IPv4 ECN Statistics", "packets/s", 8700, update_every, RRDSET_TYPE_LINE);
689 + st->isdetail = 1;
690 +
691 + rrddim_add(st, "InCEPkts", "CEP", 1, 1, RRDDIM_INCREMENTAL);
692 + rrddim_add(st, "InNoECTPkts", "NoECTP", -1, 1, RRDDIM_INCREMENTAL);
693 + rrddim_add(st, "InECT0Pkts", "ECTP0", 1, 1, RRDDIM_INCREMENTAL);
694 + rrddim_add(st, "InECT1Pkts", "ECTP1", 1, 1, RRDDIM_INCREMENTAL);
695 + }
696 + else rrdset_next(st);
697 +
698 + rrddim_set(st, "InCEPkts", *ipext_InCEPkts);
699 + rrddim_set(st, "InNoECTPkts", *ipext_InNoECTPkts);
700 + rrddim_set(st, "InECT0Pkts", *ipext_InECT0Pkts);
701 + rrddim_set(st, "InECT1Pkts", *ipext_InECT1Pkts);
702 + rrdset_done(st);
703 + }
704 + }
705 + else if(unlikely(hash == hash_tcpext && strcmp(key, "TcpExt") == 0)) {
706 + uint32_t h = l++;
707 +
708 + if(strcmp(procfile_lineword(ff, l, 0), "TcpExt") != 0) {
709 + error("Cannot read TcpExt line from /proc/net/netstat.");
710 + break;
711 + }
712 + words = procfile_linewords(ff, l);
713 + if(words < 2) {
714 + error("Cannot read /proc/net/netstat TcpExt line. Expected 2+ params, read %u.", words);
715 + continue;
716 + }
717 +
718 + parse_line_pair(ff, tcpext_data, h, l);
719 +
720 + RRDSET *st;
721 +
722 + // --------------------------------------------------------------------
723 +
724 + 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))) {
725 + do_tcpext_connaborts = CONFIG_ONDEMAND_YES;
726 + st = rrdset_find("ipv4.tcpconnaborts");
727 + if(!st) {
728 + st = rrdset_create("ipv4", "tcpconnaborts", NULL, "tcp", NULL, "TCP Connection Aborts", "connections/s", 3000, update_every, RRDSET_TYPE_LINE);
729 +
730 + rrddim_add(st, "TCPAbortOnData", "baddata", 1, 1, RRDDIM_INCREMENTAL);
731 + rrddim_add(st, "TCPAbortOnClose", "userclosed", 1, 1, RRDDIM_INCREMENTAL);
732 + rrddim_add(st, "TCPAbortOnMemory", "nomemory", 1, 1, RRDDIM_INCREMENTAL);
733 + rrddim_add(st, "TCPAbortOnTimeout", "timeout", 1, 1, RRDDIM_INCREMENTAL);
734 + rrddim_add(st, "TCPAbortOnLinger", "linger", 1, 1, RRDDIM_INCREMENTAL);
735 + rrddim_add(st, "TCPAbortFailed", "failed", -1, 1, RRDDIM_INCREMENTAL);
736 + }
737 + else rrdset_next(st);
738 +
739 + rrddim_set(st, "TCPAbortOnData", *tcpext_TCPAbortOnData);
740 + rrddim_set(st, "TCPAbortOnClose", *tcpext_TCPAbortOnClose);
741 + rrddim_set(st, "TCPAbortOnMemory", *tcpext_TCPAbortOnMemory);
742 + rrddim_set(st, "TCPAbortOnTimeout", *tcpext_TCPAbortOnTimeout);
743 + rrddim_set(st, "TCPAbortOnLinger", *tcpext_TCPAbortOnLinger);
744 + rrddim_set(st, "TCPAbortFailed", *tcpext_TCPAbortFailed);
745 + rrdset_done(st);
746 + }
747 + // --------------------------------------------------------------------
748 +
749 + if(do_tcpext_reorder == CONFIG_ONDEMAND_YES || (do_tcpext_reorder == CONFIG_ONDEMAND_ONDEMAND && (*tcpext_TCPRenoReorder || *tcpext_TCPFACKReorder || *tcpext_TCPSACKReorder || *tcpext_TCPTSReorder))) {
750 + do_tcpext_reorder = CONFIG_ONDEMAND_YES;
751 + st = rrdset_find("ipv4.tcpreorders");
752 + if(!st) {
753 + st = rrdset_create("ipv4", "tcpreorders", NULL, "tcp", NULL, "TCP Reordered Packets by Detection Method", "packets/s", 3020, update_every, RRDSET_TYPE_LINE);
754 +
755 + rrddim_add(st, "TCPTSReorder", "timestamp", 1, 1, RRDDIM_INCREMENTAL);
756 + rrddim_add(st, "TCPSACKReorder", "sack", 1, 1, RRDDIM_INCREMENTAL);
757 + rrddim_add(st, "TCPFACKReorder", "fack", 1, 1, RRDDIM_INCREMENTAL);
758 + rrddim_add(st, "TCPRenoReorder", "reno", 1, 1, RRDDIM_INCREMENTAL);
759 + }
760 + else rrdset_next(st);
761 +
762 + rrddim_set(st, "TCPTSReorder", *tcpext_TCPTSReorder);
763 + rrddim_set(st, "TCPSACKReorder", *tcpext_TCPSACKReorder);
764 + rrddim_set(st, "TCPFACKReorder", *tcpext_TCPFACKReorder);
765 + rrddim_set(st, "TCPRenoReorder", *tcpext_TCPRenoReorder);
766 + rrdset_done(st);
767 + }
768 +
769 + // --------------------------------------------------------------------
770 +
771 + if(do_tcpext_ofo == CONFIG_ONDEMAND_YES || (do_tcpext_ofo == CONFIG_ONDEMAND_ONDEMAND && (*tcpext_TCPOFOQueue || *tcpext_TCPOFODrop || *tcpext_TCPOFOMerge))) {
772 + do_tcpext_ofo = CONFIG_ONDEMAND_YES;
773 + st = rrdset_find("ipv4.tcpofo");
774 + if(!st) {
775 + st = rrdset_create("ipv4", "tcpofo", NULL, "tcp", NULL, "TCP Out-Of-Order Queue", "packets/s", 3050, update_every, RRDSET_TYPE_LINE);
776 +
777 + rrddim_add(st, "TCPOFOQueue", "inqueue", 1, 1, RRDDIM_INCREMENTAL);
778 + rrddim_add(st, "TCPOFODrop", "dropped", -1, 1, RRDDIM_INCREMENTAL);
779 + rrddim_add(st, "TCPOFOMerge", "merged", 1, 1, RRDDIM_INCREMENTAL);
780 + rrddim_add(st, "OfoPruned", "pruned", -1, 1, RRDDIM_INCREMENTAL);
781 + }
782 + else rrdset_next(st);
783 +
784 + rrddim_set(st, "TCPOFOQueue", *tcpext_TCPOFOQueue);
785 + rrddim_set(st, "TCPOFODrop", *tcpext_TCPOFODrop);
786 + rrddim_set(st, "TCPOFOMerge", *tcpext_TCPOFOMerge);
787 + rrddim_set(st, "OfoPruned", *tcpext_OfoPruned);
788 + rrdset_done(st);
789 + }
790 +
791 + // --------------------------------------------------------------------
792 +
793 + if(do_tcpext_syscookies == CONFIG_ONDEMAND_YES || (do_tcpext_syscookies == CONFIG_ONDEMAND_ONDEMAND && (*tcpext_SyncookiesSent || *tcpext_SyncookiesRecv || *tcpext_SyncookiesFailed))) {
794 + do_tcpext_syscookies = CONFIG_ONDEMAND_YES;
795 + st = rrdset_find("ipv4.tcpsyncookies");
796 + if(!st) {
797 + st = rrdset_create("ipv4", "tcpsyncookies", NULL, "tcp", NULL, "TCP SYN Cookies", "packets/s", 3100, update_every, RRDSET_TYPE_LINE);
798 +
799 + rrddim_add(st, "SyncookiesRecv", "received", 1, 1, RRDDIM_INCREMENTAL);
800 + rrddim_add(st, "SyncookiesSent", "sent", -1, 1, RRDDIM_INCREMENTAL);
801 + rrddim_add(st, "SyncookiesFailed", "failed", -1, 1, RRDDIM_INCREMENTAL);
802 }
803 else rrdset_next(st);
804
171 - rrddim_set(st, "sent", OutBcastPkts);
172 - rrddim_set(st, "received", InBcastPkts);
805 + rrddim_set(st, "SyncookiesRecv", *tcpext_SyncookiesRecv);
806 + rrddim_set(st, "SyncookiesSent", *tcpext_SyncookiesSent);
807 + rrddim_set(st, "SyncookiesFailed", *tcpext_SyncookiesFailed);
808 rrdset_done(st);
809 }
810 }