-
Notifications
You must be signed in to change notification settings - Fork 3
/
tcp
executable file
·64 lines (61 loc) · 1.26 KB
/
tcp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/bin/sh
if [ "$1" = "autoconf" ]; then
echo 'yes'
exit 0
fi
if [ "$1" = "config" ]; then
cat <<EOF
graph_title TCP Connections
graph_category network
graph_vlabel connections
graph_args --base 1000 -l 0
graph_info This graph shows the TCP connections states of all the network interfaces combined
CLOSED.label CLOSED
CLOSED.colour COLOUR3
IDLE.label IDLE
IDLE.colour COLOUR6
BOUND.label BOUND
BOUND.colour COLOUR12
LISTEN.label LISTEN
LISTEN.colour COLOUR0
SYN_SENT.label SYN_SENT
SYN_RCVD.label SYN_RCVD
ESTABLISHED.label ESTABLISHED
ESTABLISHED.colour COLOUR1
CLOSE_WAIT.label CLOSE_WAIT
FIN_WAIT_1.label FIN_WAIT_1
CLOSING.label CLOSING
LAST_ACK.label LAST_ACK
FIN_WAIT_2.label FIN_WAIT_2
TIME_WAIT.label TIME_WAIT
TIME_WAIT.colour COLOUR2
EOF
exit 0
fi
netstat -an -P tcp -f inet -f inet6 | awk '
NF < 1 {
header = NR
}
header + 3 < NR {
states[$7]++
}
BEGIN {
states["CLOSED"] = 0
states["IDLE"] = 0
states["BOUND"] = 0
states["LISTEN"] = 0
states["SYN_SENT"] = 0
states["SYN_RCVD"] = 0
states["ESTABLISHED"]= 0
states["CLOSE_WAIT"] = 0
states["FIN_WAIT_1"] = 0
states["CLOSING"] = 0
states["LAST_ACK"] = 0
states["FIN_WAIT_2"] = 0
states["TIME_WAIT"] = 0
}
END {
for (idx in states) {
print idx ".value " states[idx]
}
}'