mirror of
https://github.com/munin-monitoring/muninlite.git
synced 2024-12-22 05:42:13 +01:00
Add missing quoting
This commit is contained in:
parent
c2108276eb
commit
14251d6791
11 changed files with 56 additions and 60 deletions
34
muninlite.in
34
muninlite.in
|
@ -31,7 +31,7 @@ clean_fieldname() {
|
|||
|
||||
# ===== NODE CODE =====
|
||||
do_list() {
|
||||
echo $PLUGINS
|
||||
echo "$PLUGINS"
|
||||
}
|
||||
|
||||
|
||||
|
@ -42,7 +42,7 @@ do_nodes() {
|
|||
|
||||
do_config() {
|
||||
if echo "$PLUGINS" | grep -qwF "$1"; then
|
||||
config_$1
|
||||
"config_$1"
|
||||
else
|
||||
echo "# Unknown service"
|
||||
fi
|
||||
|
@ -51,7 +51,7 @@ do_config() {
|
|||
|
||||
do_fetch() {
|
||||
if echo "$PLUGINS" | grep -qwF "$1"; then
|
||||
fetch_$1
|
||||
"fetch_$1"
|
||||
else
|
||||
echo "# Unknown service"
|
||||
fi
|
||||
|
@ -73,18 +73,18 @@ 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/\-/_/')
|
||||
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 $@; };"
|
||||
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/\-/_/')
|
||||
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 $@; };"
|
||||
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
|
||||
|
@ -93,15 +93,15 @@ do
|
|||
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 -a -x $MYPLUGIN ]; then
|
||||
MYPLUGINNAME=$(basename $MYPLUGIN)
|
||||
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 ; };"
|
||||
eval "fetch_${MYPLUGINNAME}() { '$MYPLUGIN'; };"
|
||||
eval "config_${MYPLUGINNAME}() { '$MYPLUGIN' config; };"
|
||||
fi
|
||||
done
|
||||
else
|
||||
|
@ -120,10 +120,8 @@ do
|
|||
arg0=$(echo "$arg0" | xargs)
|
||||
arg1=$(echo "$arg1" | xargs)
|
||||
if ! echo "$FUNCTIONS" | grep -qwF "$arg0"; then
|
||||
echo "# Unknown command. Try" $(echo "$FUNCTIONS" | sed -e 's/\( [[:alpha:]]\{1,\}\)/,\1/g' -e 's/,\( [[:alpha:]]\{1,\}\)$/ or\1/')
|
||||
continue
|
||||
echo "# Unknown command. Try $(echo "$FUNCTIONS" | sed -e 's/\( [[:alpha:]]\{1,\}\)/,\1/g' -e 's/,\( [[:alpha:]]\{1,\}\)$/ or\1/')"
|
||||
else
|
||||
"do_$arg0" "$arg1"
|
||||
fi
|
||||
|
||||
do_$arg0 $arg1
|
||||
done
|
||||
|
||||
|
|
20
plugins/cpu
20
plugins/cpu
|
@ -11,7 +11,7 @@ config_cpu() {
|
|||
SYSCRITICAL=$(($PERCENT * 50 / 100))
|
||||
USRWARNING=$(($PERCENT * 80 / 100))
|
||||
echo "graph_title CPU usage"
|
||||
echo "graph_order system user nice idle" $extinfo
|
||||
echo "graph_order system user nice idle $extinfo" | sed 's/ $//'
|
||||
echo "graph_args --base 1000 -r --lower-limit 0 --upper-limit $graphlimit"
|
||||
echo "graph_vlabel %"
|
||||
echo "graph_scale no"
|
||||
|
@ -63,7 +63,7 @@ config_cpu() {
|
|||
echo "softirq.min 0"
|
||||
echo "softirq.max 5000"
|
||||
echo "softirq.type DERIVE"
|
||||
echo "softirq.info CPU time spent handling "batched" interrupts"
|
||||
echo "softirq.info CPU time spent handling 'batched' interrupts"
|
||||
fi
|
||||
}
|
||||
fetch_cpu() {
|
||||
|
@ -72,13 +72,13 @@ fetch_cpu() {
|
|||
extinfo="iowait irq softirq"
|
||||
fi
|
||||
CINFO=$(grep '^cpu ' /proc/stat | cut -c6-)
|
||||
echo "user.value" $(echo "$CINFO" | cut -d\ -f1)
|
||||
echo "nice.value" $(echo "$CINFO" | cut -d\ -f2)
|
||||
echo "system.value" $(echo "$CINFO" | cut -d\ -f3)
|
||||
echo "idle.value" $(echo "$CINFO" | cut -d\ -f4)
|
||||
if [ ! -z "$extinfo" ]; then
|
||||
echo "iowait.value" $(echo "$CINFO" | cut -d\ -f5)
|
||||
echo "irq.value" $(echo "$CINFO" | cut -d\ -f6)
|
||||
echo "softirq.value" $(echo "$CINFO" | cut -d\ -f7)
|
||||
echo "user.value" "$(echo "$CINFO" | cut -d " " -f 1)"
|
||||
echo "nice.value" "$(echo "$CINFO" | cut -d " " -f 2)"
|
||||
echo "system.value" "$(echo "$CINFO" | cut -d " " -f 3)"
|
||||
echo "idle.value" "$(echo "$CINFO" | cut -d " " -f 4)"
|
||||
if [ -n "$extinfo" ]; then
|
||||
echo "iowait.value" "$(echo "$CINFO" | cut -d " " -f 5)"
|
||||
echo "irq.value" "$(echo "$CINFO" | cut -d " " -f 6)"
|
||||
echo "softirq.value" "$(echo "$CINFO" | cut -d " " -f 7)"
|
||||
fi
|
||||
}
|
||||
|
|
10
plugins/df
10
plugins/df
|
@ -6,8 +6,8 @@ graph_category disk
|
|||
graph_info This graph shows disk usage on the machine."
|
||||
for PART in $(df -P | grep '^/' | sed '/\/[a-z0-9]*$/!d;s/.* \([a-z0-9\/]\{1,\}\)$/\1/g')
|
||||
do
|
||||
PINFO=$(df -P $PART | tail -1);
|
||||
PNAME=$(echo $PINFO | cut -d\ -f1 | sed 's/\//_/g')
|
||||
PINFO=$(df -P "$PART" | tail -1);
|
||||
PNAME=$(echo "$PINFO" | cut -d " " -f 1 | sed 's/\//_/g')
|
||||
echo "$PNAME.label $PART"
|
||||
echo "$PNAME.info $PNAME -> $PART"
|
||||
echo "$PNAME.warning 92"
|
||||
|
@ -17,8 +17,8 @@ graph_info This graph shows disk usage on the machine."
|
|||
fetch_df() {
|
||||
for PART in $(df -P | grep '^/' | sed '/\/[a-z0-9]*$/!d;s/.* \([a-z0-9\/]\{1,\}\)$/\1/g')
|
||||
do
|
||||
PINFO=$(df -P $PART | tail -1);
|
||||
PNAME=$(echo $PINFO | cut -d\ -f1 | sed 's/[\/.-]/_/g')
|
||||
echo "$PNAME.value" $(echo $PINFO | sed -e 's/\%//g' -e 's/ */ /g' | cut -f5 -d' ')
|
||||
PINFO=$(df -P "$PART" | tail -1);
|
||||
PNAME=$(echo "$PINFO" | cut -d " " -f 1 | sed 's/[\/.-]/_/g')
|
||||
echo "$PNAME.value" "$(echo "$PINFO" | sed -e 's/\%//g' -e 's/ */ /g' | cut -d " " -f 5)"
|
||||
done
|
||||
}
|
||||
|
|
10
plugins/if_
10
plugins/if_
|
@ -17,8 +17,8 @@ config_if() {
|
|||
echo "up.cdef up,8,*"
|
||||
if [ -n "$(which ethtool)" ]; then
|
||||
if [ -x "$(which ethtool)" ]; then
|
||||
if ethtool $1 | grep -q Speed; then
|
||||
MAX=$(($(ethtool $1 | grep Speed | sed -e 's/[[:space:]]\{1,\}/ /g' -e 's/^ //' -e 's/M.*//' | cut -d\ -f2) * 1000000))
|
||||
if ethtool "$1" | grep -q Speed; then
|
||||
MAX=$(($(ethtool "$1" | grep Speed | sed -e 's/[[:space:]]\{1,\}/ /g' -e 's/^ //' -e 's/M.*//' | cut -d " " -f 2) * 1000000))
|
||||
echo "up.max $MAX"
|
||||
echo "down.max $MAX"
|
||||
fi
|
||||
|
@ -26,7 +26,7 @@ config_if() {
|
|||
fi
|
||||
}
|
||||
fetch_if() {
|
||||
IINFO=$(grep "$1:" /proc/net/dev | cut -d: -f2 | sed -e 's/ */ /g' -e 's/^[ \t]*//')
|
||||
echo "down.value" $(echo $IINFO | cut -d\ -f1)
|
||||
echo "up.value" $(echo $IINFO | cut -d\ -f9)
|
||||
IINFO=$(grep "^ *$1:" /proc/net/dev | cut -d ":" -f 2 | sed -e 's/ */ /g' -e 's/^[ \t]*//')
|
||||
echo "down.value" "$(echo "$IINFO" | cut -d " " -f 1)"
|
||||
echo "up.value" "$(echo "$IINFO" | cut -d " " -f 9)"
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ config_if_err() {
|
|||
echo "trans.warning 1"
|
||||
}
|
||||
fetch_if_err() {
|
||||
IINFO=$(grep "$1:" /proc/net/dev | cut -d: -f2 | sed -e 's/ */ /g' -e 's/^[ \t]*//')
|
||||
echo "rcvd.value" $(echo $IINFO | cut -d\ -f3)
|
||||
echo "trans.value" $(echo $IINFO | cut -d\ -f11)
|
||||
IINFO=$(grep "^ *$1:" /proc/net/dev | cut -d ":" -f 2 | sed -e 's/ */ /g' -e 's/^[ \t]*//')
|
||||
echo "rcvd.value" "$(echo "$IINFO" | cut -d " " -f 3)"
|
||||
echo "trans.value" "$(echo "$IINFO" | cut -d " " -f 11)"
|
||||
}
|
||||
|
|
|
@ -17,6 +17,6 @@ config_interrupts() {
|
|||
}
|
||||
fetch_interrupts() {
|
||||
IINFO=$(cat /proc/stat)
|
||||
echo "ctx.value" $(echo "$IINFO" | grep "^ctxt" | cut -d\ -f2)
|
||||
echo "intr.value" $(echo "$IINFO" | grep "^intr" | cut -d\ -f2)
|
||||
echo "ctx.value" "$(echo "$IINFO" | grep "^ctxt" | cut -d " " -f 2)"
|
||||
echo "intr.value" "$(echo "$IINFO" | grep "^intr" | cut -d " " -f 2)"
|
||||
}
|
||||
|
|
|
@ -11,5 +11,5 @@ graph_info The load average of the machine describes how many processes are in t
|
|||
load.info Average load for the five minutes."
|
||||
}
|
||||
fetch_load() {
|
||||
echo "load.value" $(cut -f2 -d\ /proc/loadavg)
|
||||
echo "load.value" "$(cut -d " " -f 2 /proc/loadavg)"
|
||||
}
|
||||
|
|
|
@ -32,9 +32,9 @@ config_netstat() {
|
|||
}
|
||||
fetch_netstat() {
|
||||
NINFO=$(netstat -s | sed 's/ \{1,\}/ /g')
|
||||
echo "active.value" $(echo "$NINFO" | grep "active connections" | cut -d\ -f2)
|
||||
echo "passive.value" $(echo "$NINFO" | grep "passive connection" | cut -d\ -f2)
|
||||
echo "failed.value" $(echo "$NINFO" | grep "failed connection" | cut -d\ -f2)
|
||||
echo "resets.value" $(echo "$NINFO" | grep "connection resets" | cut -d\ -f2)
|
||||
echo "established.value" $(echo "$NINFO" | grep "connections established" | cut -d\ -f2)
|
||||
echo "active.value" "$(echo "$NINFO" | grep "active connections" | 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)"
|
||||
echo "established.value" "$(echo "$NINFO" | grep "connections established" | cut -d " " -f 2)"
|
||||
}
|
||||
|
|
|
@ -11,12 +11,10 @@ fetch_ntpdate() {
|
|||
NTPDATE="/usr/sbin/ntpdate"
|
||||
OFFSET=0
|
||||
DELAY=0
|
||||
if [ "$NTP_PEER" != "" ]; then
|
||||
if [ -x "$NTPDATE" ]; then
|
||||
DATA=$($NTPDATE -q $NTP_PEER | awk '/^server.*offset/{gsub(/,/,"");printf "%s %s", ($6*1000), ($8*1000);}')
|
||||
OFFSET=$(echo "$DATA" | cut -d\ -f1)
|
||||
DELAY=$(echo "$DATA" | cut -d\ -f2)
|
||||
fi
|
||||
if [ -n "$NTP_PEER" ] && [ -x "$NTPDATE" ]; then
|
||||
DATA=$("$NTPDATE" -q "$NTP_PEER" | awk '/^server.*offset/{gsub(/,/,""); printf "%s %s", ($6*1000), ($8*1000);}')
|
||||
OFFSET=$(echo "$DATA" | cut -d " " -f 1)
|
||||
DELAY=$(echo "$DATA" | cut -d " " -f 2)
|
||||
fi
|
||||
echo "offset.value $OFFSET"
|
||||
echo "delay.value $DELAY"
|
||||
|
|
|
@ -9,5 +9,5 @@ config_processes() {
|
|||
echo "processes.info The current number of processes."
|
||||
}
|
||||
fetch_processes() {
|
||||
echo "processes.value" $(echo /proc/[0-9]* | wc -w)
|
||||
echo "processes.value" "$(echo /proc/[0-9]* | wc -w)"
|
||||
}
|
||||
|
|
|
@ -17,11 +17,11 @@ config_swap() {
|
|||
fetch_swap() {
|
||||
if [ -f /proc/vmstat ]; then
|
||||
SINFO=$(cat /proc/vmstat)
|
||||
echo "swap_in.value" $(echo "$SINFO" | awk 'BEGIN { result="U"; } { if ($1 == "pswpin") result=$2; } END { print(result); }')
|
||||
echo "swap_out.value" $(echo "$SINFO" | awk 'BEGIN { result="U"; } { if ($1 == "pswpout") result=$2; } END { print(result); }')
|
||||
echo "swap_in.value" "$(echo "$SINFO" | awk 'BEGIN { result="U"; } { if ($1 == "pswpin") result=$2; } END { print(result); }')"
|
||||
echo "swap_out.value" "$(echo "$SINFO" | awk 'BEGIN { result="U"; } { if ($1 == "pswpout") result=$2; } END { print(result); }')"
|
||||
else
|
||||
SINFO=$(grep "^swap" /proc/stat)
|
||||
echo "swap_in.value" $(echo "$SINFO" | cut -d\ -f2)
|
||||
echo "swap_out.value" $(echo "$SINFO" | cut -d\ -f3)
|
||||
echo "swap_in.value" "$(echo "$SINFO" | cut -d " " -f 2)"
|
||||
echo "swap_out.value" "$(echo "$SINFO" | cut -d " " -f 3)"
|
||||
fi
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue