Révision cd6dafa8
Rewrite hard-to-read shell oneliner
| plugins/network/ldap_connections | ||
|---|---|---|
| 128 | 128 |
|
| 129 | 129 |
for port in $LISTENING_PORTS; do |
| 130 | 130 |
for ip in $(find_ips_bound $port); do |
| 131 |
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')"
|
|
| 131 |
|
|
| 132 |
label=$(printf "%s_%d" "$(echo $ip | tr ':.' '_')" "$port") |
|
| 133 |
connections=$( |
|
| 134 |
awk -v ip_port="${ip}:${port}" \
|
|
| 135 |
'BEGIN { counter=0 }
|
|
| 136 |
$1 ~ /tcp[46]?/ && $4 == ip_port && $6 == "ESTABLISHED" { counter++ }
|
|
| 137 |
END { print counter }' \
|
|
| 138 |
$TEMP_FILE |
|
| 139 |
) |
|
| 140 |
|
|
| 141 |
printf "%s.value %d\n" "$label" "$connections" |
|
| 132 | 142 |
done |
| 133 | 143 |
done |
| 134 | 144 |
if [ -e "$SOCKET" ]; then |
Formats disponibles : Unified diff