muninlite/plugins/swap
Lars Kruse 5de3df252e Plugin swap: fix evaluation of swap usage
The variable name was misspelled.
2020-02-08 23:39:44 +01:00

27 lines
970 B
Text

config_swap() {
echo "graph_title Swap in/out"
echo "graph_args -l 0 --base 1000"
echo "graph_vlabel pages per \${graph_period} in (-) / out (+)"
echo "graph_category system"
echo "swap_in.label swap"
echo "swap_in.type DERIVE"
echo "swap_in.max 100000"
echo "swap_in.min 0"
echo "swap_in.graph no"
echo "swap_out.label swap"
echo "swap_out.type DERIVE"
echo "swap_out.max 100000"
echo "swap_out.min 0"
echo "swap_out.negative swap_in"
}
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); }')
else
SINFO=$(grep "^swap" /proc/stat)
echo "swap_in.value" $(echo "$SINFO" | cut -d\ -f2)
echo "swap_out.value" $(echo "$SINFO" | cut -d\ -f3)
fi
}