Skip to content

Commit

Permalink
swap: return "U" in case of missing swap
Browse files Browse the repository at this point in the history
The swap plugin should return "U" if no value was found.

Source: patch "310-fix-swap-output" from Opennet Firmware
  • Loading branch information
sumpfralle committed Jul 19, 2019
1 parent eb5f13e commit ab2347f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions plugins/swap
Expand Up @@ -17,8 +17,8 @@ config_swap() {
fetch_swap() {
if [ -f /proc/vmstat ]; then
SINFO=$(cat /proc/vmstat)
echo "swap_in.value" $(echo "$SINFO" | grep "^pswpin" | cut -d\ -f2)
echo "swap_out.value" $(echo "$SINFO" | grep "^pswpout" | cut -d\ -f2)
echo "swap_in.value" $(echo "$INFO" | awk 'BEGIN { result="U"; } { if ($1 == "pswpin") result=$2; } END { print(result); }')
echo "swap_out.value" $(echo "$INFO" | 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)
Expand Down

0 comments on commit ab2347f

Please sign in to comment.