metrics.sh/metrics/swap.sh

17 lines
343 B
Bash
Raw Permalink Normal View History

2015-02-19 14:15:38 -05:00
#!/bin/sh
2015-02-21 12:18:27 -05:00
if is_osx; then
2015-02-22 12:36:04 -05:00
collect () {
report $(sysctl -n vm.swapusage |
awk '{ if (int($3) == 0) exit; printf "%.1f", $6 / $3 * 100.0 }')
2015-02-22 12:36:04 -05:00
}
else
collect () {
report $(free |
awk '/Swap/{ if (int($2) == 0) exit; printf "%.1f", $3 / $2 * 100.0 }')
2015-02-22 12:36:04 -05:00
}
fi
docs () {
echo "Percentage of used swap space."
}