8000 add script counting network connections (#6754) · davinash/arangodb@94805aa · GitHub
[go: up one dir, main page]

Skip to content

Commit 94805aa

Browse files
dothebartneunhoef
authored andcommitted
add script counting network connections (arangodb#6754)
This was added (and is currently not being used) to find a problem where a server in shutdown would hammer the agency with new connections. It was decided to implement a corresponding monitoring directly in the monitoring system (ganglia) rather than in the context of `testing.js`. Nevertheless, the script is retained for posteriority here.
1 parent 66d04a1 commit 94805aa

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

scripts/analyzeNetworkSocketUsage.sh

+30Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/bash
2+
# we first count open sockets in total on the system:
3+
echo "open sockets: "
4+
F="/tmp/$$_netstat.log"
5+
# we store it in a temporary file, since gatherng this information may become expensive if
6+
# its more then some thousand connections:
7+
netstat -n |grep ^tcp > $F
8+
C=$(wc -l < "$F")
9+
echo $C
10+
# if this outdoes a sane number, lets go into detail.
11+
if test "$C" -gt 1024; then
12+
# we use lsof to find all tcp sockets and which processes own them.
13+
LF="/tmp/$$_lsof.log"
14+
lsof -n -iTCP > "$LF"
15+
# we group all sockets by target ip:port
16+
for sockets in $(grep ^tcp $F | sed -e "s; *; ;g" |cut -d ' ' -f 5 |sort -u ) ; do
17+
# count the connections to one ip:port
18+
SC=$(grep "$sockets" $F |wc -l)
19+
if test "$SC" -gt "16"; then
20+
# if the connection outoes a sane figure, we want to count & output them:
21+
echo "$sockets - $SC"
22+
# and here we want to know which processes are attached to them.
23+
# this will output one line per active connection, so this may become much:
24+
grep "$sockets" "$LF"
25+
fi
26+
done
27+
rm "$LF"
28+
fi
29+
rm "$F"
30+

0 commit comments

Comments
 (0)
0