2007-06-11 17:45:16 +02:00
|
|
|
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)
|
2020-02-07 14:13:37 +01:00
|
|
|
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); }')
|
2007-06-11 17:45:16 +02:00
|
|
|
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
|
|
|
|
}
|