mirror of https://gitee.com/bigwinds/arangodb
add script counting network connections (#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.
This commit is contained in:
parent
66d04a10bc
commit
94805aad7c
|
@ -0,0 +1,30 @@
|
|||
#!/bin/bash
|
||||
# we first count open sockets in total on the system:
|
||||
echo "open sockets: "
|
||||
F="/tmp/$$_netstat.log"
|
||||
# we store it in a temporary file, since gatherng this information may become expensive if
|
||||
# its more then some thousand connections:
|
||||
netstat -n |grep ^tcp > $F
|
||||
C=$(wc -l < "$F")
|
||||
echo $C
|
||||
# if this outdoes a sane number, lets go into detail.
|
||||
if test "$C" -gt 1024; then
|
||||
# we use lsof to find all tcp sockets and which processes own them.
|
||||
LF="/tmp/$$_lsof.log"
|
||||
lsof -n -iTCP > "$LF"
|
||||
# we group all sockets by target ip:port
|
||||
for sockets in $(grep ^tcp $F | sed -e "s; *; ;g" |cut -d ' ' -f 5 |sort -u ) ; do
|
||||
# count the connections to one ip:port
|
||||
SC=$(grep "$sockets" $F |wc -l)
|
||||
if test "$SC" -gt "16"; then
|
||||
# if the connection outoes a sane figure, we want to count & output them:
|
||||
echo "$sockets - $SC"
|
||||
# and here we want to know which processes are attached to them.
|
||||
# this will output one line per active connection, so this may become much:
|
||||
grep "$sockets" "$LF"
|
||||
fi
|
||||
done
|
||||
rm "$LF"
|
||||
fi
|
||||
rm "$F"
|
||||
|
Loading…
Reference in New Issue