diff options
| author | root | 2014-12-16 19:13:53 +0100 |
|---|---|---|
| committer | root | 2014-12-16 19:13:53 +0100 |
| commit | b1ebf046fb4780fdb90a30b670dc13b5f62b37d1 (patch) | |
| tree | 77eae7f6eeff759f4e9cff2fd14739eba2f6c629 | |
| parent | 564e1f1ef4d3770c396c9f1630facc3387495cf2 (diff) | |
| download | dotfiles-b1ebf046fb4780fdb90a30b670dc13b5f62b37d1.tar.gz | |
Fixed some minor bugs and added warning about virtual memory.
| -rwxr-xr-x | bin/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 |
