summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbin/checkswap (renamed from bin/checkswap.sh)12
1 files changed, 7 insertions, 5 deletions
diff --git a/bin/checkswap.sh b/bin/checkswap
index 82ea867..b3a9a31 100755
--- a/bin/checkswap.sh
+++ b/bin/checkswap
@@ -22,7 +22,7 @@ if [ ! -z "$1" ]; then
shift
;;
-h|--help|help)
- echo "Statistics about all running processes."
+ echo "Statistics about memory and swap usage from all running processes."
echo "Usage: $0 [OPTION]"
echo " swap sort by swap usage (default)"
echo " memory sort by memory usage"
@@ -32,12 +32,14 @@ if [ ! -z "$1" ]; then
;;
*)
echo "Unrecognized option \"$1\"" >&2
- echo "Try -h instead."
+ echo "Try \"-h\" instead."
exit 1
esac
fi
echo "Check memory and swap usage for all programs sorted by $by."
+echo "$(tput setaf 1)Attention! The reported memory usage is just the $(tput bold)virtual$(tput sgr0) $(tput setaf 1)usage, not the $(tput bold)real$(tput sgr0) $(tput setaf 1)one."
+echo "Read more about this on Wikipedia. $(tput bold)https://en.wikipedia.org/wiki/Virtual_memory$(tput sgr0)"
echo ""
# loop over all running programs
@@ -53,8 +55,8 @@ do
swap_count=$(($swap_count+$(echo $tmp | cut -d\| -f2)))
done
- # programs swap use is not null
- if [ $swap_count -gt 0 ]
+ # programs swap or memory use is not null
+ if [ $swap_count -gt 0 ] || [ $mem_count -gt 0 ]
then
case "$by" in
swap)
@@ -69,5 +71,5 @@ do
esac
fi
-# sort by swap usage
+# sorting and formatting output
done | sort -k1 -t\ -h${rev} | column -t