1
0
mirror of https://github.com/samba-team/samba.git synced 2025-03-26 18:50:30 +03:00

Optimise 61.nfstickle to write the tickles more efficiently.

Currently the file for each IP address is reopened to append the
details of each source socket.

This optimisation puts all the logic into awk, including the matching
of output lines from netstat.  The source sockets for each for each
destination IP are written into an array entry and then each array
entry is written to the corresponding file in a single operation.

Signed-off-by: Martin Schwenke <martin@meltin.net>

(This used to be ctdb commit 6549e9b01538998d51a5f72bfc569776d232b024)
This commit is contained in:
Martin Schwenke 2010-07-26 16:22:59 +10:00 committed by Ronnie Sahlberg
parent 5027d2b8b0
commit fe64a8f87a

View File

@ -41,12 +41,17 @@ case "$1" in
mydir=$NFS_TICKLE_SHARED_DIRECTORY/`hostname`
rm -f $mydir/*
# record our connections to shared storage
netstat -tn |egrep '^tcp[[:space:]]+[0-9]+[[:space:]]+[0-9]+[[:space:]]+[0-9\.]+:2049.*ESTABLISHED' |
awk '{print $4" "$5}' |
while read dest src; do
ip=${dest%:*}
echo $src >> $mydir/$ip
done
netstat -tn |
awk -v mydir="$mydir" '
$1 == "tcp" && $6 == "ESTABLISHED" && $4 ~ /:2049$/ {
destip = gensub(/:2049$/, "", 1, $4);
c[destip] = c[destip] (c[destip] ? "\n" : "" ) $5;
}
END {
for (ip in c) {
print c[ip] > mydir "/" ip
}
}'
;;
*)