diff options
Diffstat (limited to 'hm/soispha/conf/yambar/scripts/old/meminfo')
-rwxr-xr-x | hm/soispha/conf/yambar/scripts/old/meminfo | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/hm/soispha/conf/yambar/scripts/old/meminfo b/hm/soispha/conf/yambar/scripts/old/meminfo new file mode 100755 index 00000000..0156e94c --- /dev/null +++ b/hm/soispha/conf/yambar/scripts/old/meminfo @@ -0,0 +1,37 @@ +#!/bin/sh +# Checks memory usage + +# Number of seconds to retest +timer=5 + +# Main loop +while true; do + + mem_total=$(LANG=C free -b|awk '/^Mem:/{print $2}') + mem_used=$(LANG=C free -b|awk '/^Mem:/{print $3}') + swap_total=$(LANG=C free -b|awk '/^Swap:/{print $2}') + swap_used=$(LANG=C free -b|awk '/^Swap:/{print $3}') + + + memperc=$(echo "$mem_used" "$mem_total" | awk '{ div = 100 * ($1 / $2)} { printf "%.0f ", div }' | tr -d ' ' ) + swapperc=$(echo "$swap_used" "$swap_total" | awk '{ + if ( $1 == 0 || $2 == 0 ) { + print "%" + } else { + div = 100 * ($1 / $2); + printf "%.0f ", div +} +}' | tr -d ' ' ) + + +echo "memperc|string|$memperc" +if [ "$swapperc" = "%" ];then + echo "swapstate|bool|false" +else + echo "swapperc|string|$swapperc" + echo "swapstate|bool|true" +fi +echo "" +sleep "$timer" + +done |