mirror of
https://github.com/munin-monitoring/muninlite.git
synced 2024-12-22 13:52:13 +01:00
Plugin netstat: adjust filter to newer netstat version
Newer versions of netstat use "active connection openings" instead of "active connections".
This commit is contained in:
parent
e439fd79a1
commit
60b16f4121
2 changed files with 34 additions and 39 deletions
71
muninlite.in
71
muninlite.in
|
@ -68,45 +68,40 @@ do_quit() {
|
|||
|
||||
# ===== Runtime config =====
|
||||
RES=""
|
||||
for PLUG in $PLUGINS
|
||||
do
|
||||
if [ "$PLUG" = "if_" ]; then
|
||||
for INTER in $(grep -E '^ *(ppp|eth|wlan|ath|ra|ipsec|tap|br-)[^:]{1,}:' /proc/net/dev | cut -f1 -d: | sed 's/ //g');
|
||||
do
|
||||
INTERRES=$(echo "$INTER" | sed -e 's/\./VLAN/' -e 's/\-/_/')
|
||||
RES="$RES if_$INTERRES"
|
||||
eval 'fetch_if_'"$INTERRES"'() { fetch_if "'"$INTER"'" "$@"; };'
|
||||
eval 'config_if_'"$INTERRES"'() { config_if "'"$INTER"'" "$@"; };'
|
||||
done
|
||||
elif [ "$PLUG" = "if_err_" ]; then
|
||||
for INTER in $(grep -E '^ *(ppp|eth|wlan|ath|ra|ipsec|tap|br-)[^:]{1,}:' /proc/net/dev | cut -f1 -d: | sed 's/ //g');
|
||||
do
|
||||
INTERRES=$(echo "$INTER" | sed -e 's/\./VLAN/' -e 's/\-/_/')
|
||||
RES="$RES if_err_$INTERRES"
|
||||
eval 'fetch_if_err_'"$INTERRES"'() { fetch_if_err "'"$INTER"'" "$@"; };'
|
||||
eval 'config_if_err_'"$INTERRES"'() { config_if_err "'"$INTER"'" "$@"; };'
|
||||
done
|
||||
elif [ "$PLUG" = "netstat" ]; then
|
||||
if netstat -s >/dev/null 2>&1; then
|
||||
RES="$RES netstat"
|
||||
fi
|
||||
elif [ "$PLUG" = "plugindir_" ]; then
|
||||
for MYPLUGIN in $(if [ -d "$PLUGIN_DIRECTORY" ]; then find -L "$PLUGIN_DIRECTORY" -type f -name "$PLUGINPATTERN"; fi);
|
||||
do
|
||||
if [ -f "$MYPLUGIN" ] && [ -x "$MYPLUGIN" ]; then
|
||||
MYPLUGINNAME=$(basename "$MYPLUGIN")
|
||||
#ensure we don't have name collision
|
||||
if echo "$RES" | grep -qwF "$MYPLUGINNAME"; then
|
||||
MYPLUGINNAME="plugindir_$MYPLUGINNAME"
|
||||
fi
|
||||
RES="$RES $MYPLUGINNAME"
|
||||
eval "fetch_${MYPLUGINNAME}() { '$MYPLUGIN'; };"
|
||||
eval "config_${MYPLUGINNAME}() { '$MYPLUGIN' config; };"
|
||||
for PLUG in $PLUGINS; do
|
||||
case "$PLUG" in
|
||||
if_|if_err_)
|
||||
interface_names=$(grep -E '^ *(ppp|eth|wlan|ath|ra|ipsec|tap|br-)[^:]{1,}:' /proc/net/dev | sed 's/^ *//; s/:.*$//')
|
||||
for INTER in $interface_names; do
|
||||
INTERRES=$(echo "$INTER" | sed -e 's/\./VLAN/' -e 's/\-/_/')
|
||||
RES="$RES ${PLUG}${INTERRES}"
|
||||
eval "fetch_${PLUG}${INTERRES}() { 'fetch_${PLUG%_}' '$INTER'; }"
|
||||
eval "config_${PLUG}${INTERRES}() { 'config_${PLUG%_}' '$INTER'; }"
|
||||
done
|
||||
;;
|
||||
netstat)
|
||||
if netstat -s >/dev/null 2>&1; then
|
||||
RES="$RES netstat"
|
||||
fi
|
||||
done
|
||||
else
|
||||
RES="$RES $PLUG"
|
||||
fi
|
||||
;;
|
||||
plugindir_)
|
||||
for MYPLUGIN in $(if [ -d "$PLUGIN_DIRECTORY" ]; then find -L "$PLUGIN_DIRECTORY" -type f -name "$PLUGINPATTERN"; fi); do
|
||||
if [ -f "$MYPLUGIN" ] && [ -x "$MYPLUGIN" ]; then
|
||||
MYPLUGINNAME=$(basename "$MYPLUGIN")
|
||||
# detect and avoid name collision
|
||||
if echo "$RES" | grep -qwF "$MYPLUGINNAME"; then
|
||||
MYPLUGINNAME="plugindir_$MYPLUGINNAME"
|
||||
fi
|
||||
RES="$RES $MYPLUGINNAME"
|
||||
eval "fetch_${MYPLUGINNAME}() { '$MYPLUGIN'; }"
|
||||
eval "config_${MYPLUGINNAME}() { '$MYPLUGIN' config; }"
|
||||
fi
|
||||
done
|
||||
;;
|
||||
*)
|
||||
RES="$RES $PLUG"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
# sort plugin names and remove surrounding whitespace
|
||||
PLUGINS=$(echo "$RES" | xargs -r -n 1 echo | sort | xargs echo)
|
||||
|
|
|
@ -32,7 +32,7 @@ config_netstat() {
|
|||
}
|
||||
fetch_netstat() {
|
||||
NINFO=$(netstat -s | sed 's/ \{1,\}/ /g')
|
||||
echo "active.value" "$(echo "$NINFO" | grep "active connections" | cut -d " " -f 2)"
|
||||
echo "active.value" "$(echo "$NINFO" | grep "active connection" | cut -d " " -f 2)"
|
||||
echo "passive.value" "$(echo "$NINFO" | grep "passive connection" | cut -d " " -f 2)"
|
||||
echo "failed.value" "$(echo "$NINFO" | grep "failed connection" | cut -d " " -f 2)"
|
||||
echo "resets.value" "$(echo "$NINFO" | grep "connection resets" | cut -d " " -f 2)"
|
||||
|
|
Loading…
Reference in a new issue