mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-22 02:51:03 +00:00
Rewrite hard-to-read shell oneliner
This commit is contained in:
parent
6281364b67
commit
cd6dafa842
1 changed files with 11 additions and 1 deletions
|
@ -128,7 +128,17 @@ fi
|
||||||
|
|
||||||
for port in $LISTENING_PORTS; do
|
for port in $LISTENING_PORTS; do
|
||||||
for ip in $(find_ips_bound $port); do
|
for ip in $(find_ips_bound $port); do
|
||||||
echo "$(echo $ip | sed 's/\./_/g')_${port}.value $(grep "^tcp[46]\{0,1\}\([[:space:]]\{1,\}[[:digit:]]\{1,\}\)\{2\}[[:space:]]\{1,\}$ip[\.:]$port[[:space:]].*ESTABLISHED$" $TEMP_FILE | wc -l | sed 's/[[:space:]]*//g')"
|
|
||||||
|
label=$(printf "%s_%d" "$(echo $ip | tr ':.' '_')" "$port")
|
||||||
|
connections=$(
|
||||||
|
awk -v ip_port="${ip}:${port}" \
|
||||||
|
'BEGIN { counter=0 }
|
||||||
|
$1 ~ /tcp[46]?/ && $4 == ip_port && $6 == "ESTABLISHED" { counter++ }
|
||||||
|
END { print counter }' \
|
||||||
|
$TEMP_FILE
|
||||||
|
)
|
||||||
|
|
||||||
|
printf "%s.value %d\n" "$label" "$connections"
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
if [ -e "$SOCKET" ]; then
|
if [ -e "$SOCKET" ]; then
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue