From 4d11822bc606f046aa8a50c5dfcacfb73907fbfa Mon Sep 17 00:00:00 2001 From: Filippo Squillace Date: Wed, 4 Sep 2019 19:16:48 +1000 Subject: [PATCH 1/4] Fix bug when checking whether `vmstat` exists --- scripts/cpu_collect.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/cpu_collect.sh b/scripts/cpu_collect.sh index 768caba..a37148f 100755 --- a/scripts/cpu_collect.sh +++ b/scripts/cpu_collect.sh @@ -22,7 +22,7 @@ get_cpu_usage() { | sed -u -nr '/CPU usage/s/.*,[[:space:]]*([0-9]+[.,][0-9]*)%[[:space:]]*idle.*/\1/p' \ | stdbuf -o0 awk '{ print 100-$0 }' fi - elif ! command_exists "vmstat"; then + elif command_exists "vmstat"; then if is_freebsd; then vmstat -n "$refresh_interval" -c "$samples_count" \ | stdbuf -o0 awk 'NR>2 {print 100-$(NF-0)}' From ca7d495b67ec6f34de8b186eae87ac937ad5741c Mon Sep 17 00:00:00 2001 From: Aamir Khan Date: Mon, 23 Sep 2019 02:07:15 -0500 Subject: [PATCH 2/4] Report CPU percent as a whole number (3 places) --- scripts/cpu.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/cpu.sh b/scripts/cpu.sh index adc2223..4a46cc5 100755 --- a/scripts/cpu.sh +++ b/scripts/cpu.sh @@ -36,7 +36,7 @@ print_cpu_usage() { local cpu_color=$(get_cpu_color "$cpu_pused") local cpu_view="$cpu_view_tmpl" - cpu_view="${cpu_view//'#{cpu.pused}'/$(printf "%.1f%%" "$cpu_pused")}" + cpu_view="${cpu_view//'#{cpu.pused}'/$(printf "%3.0f%%" "$cpu_pused")}" cpu_view="${cpu_view//'#{cpu.color}'/$(echo "$cpu_color" | awk '{ print $1 }')}" cpu_view="${cpu_view//'#{cpu.color2}'/$(echo "$cpu_color" | awk '{ print $2 }')}" cpu_view="${cpu_view//'#{cpu.color3}'/$(echo "$cpu_color" | awk '{ print $3 }')}" From 94697ce9e06803a8ac46747a6591cd4442854f37 Mon Sep 17 00:00:00 2001 From: Aamir Khan Date: Mon, 23 Sep 2019 12:35:59 -0500 Subject: [PATCH 3/4] Report CPU percent as a whole number (2 places) For example: " 5%", "81%", or "100%" --- scripts/cpu.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/cpu.sh b/scripts/cpu.sh index 4a46cc5..b604156 100755 --- a/scripts/cpu.sh +++ b/scripts/cpu.sh @@ -36,7 +36,7 @@ print_cpu_usage() { local cpu_color=$(get_cpu_color "$cpu_pused") local cpu_view="$cpu_view_tmpl" - cpu_view="${cpu_view//'#{cpu.pused}'/$(printf "%3.0f%%" "$cpu_pused")}" + cpu_view="${cpu_view//'#{cpu.pused}'/$(printf "%2.0f%%" "$cpu_pused")}" cpu_view="${cpu_view//'#{cpu.color}'/$(echo "$cpu_color" | awk '{ print $1 }')}" cpu_view="${cpu_view//'#{cpu.color2}'/$(echo "$cpu_color" | awk '{ print $2 }')}" cpu_view="${cpu_view//'#{cpu.color3}'/$(echo "$cpu_color" | awk '{ print $3 }')}" From 22e57cda67e1fc52627aa12dfc62ca01c251538b Mon Sep 17 00:00:00 2001 From: Aamir Khan Date: Mon, 23 Sep 2019 13:58:54 -0500 Subject: [PATCH 4/4] Report RAM percent as a whole number (2 places) --- scripts/mem.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/mem.sh b/scripts/mem.sh index 6a032bf..93e6311 100755 --- a/scripts/mem.sh +++ b/scripts/mem.sh @@ -59,9 +59,9 @@ print_mem() { local mem_view="$mem_view_tmpl" mem_view="${mem_view//'#{mem.used}'/$(printf "$size_format" "$mem_used" "$size_unit")}" - mem_view="${mem_view//'#{mem.pused}'/$(printf "%.0f%%" "$mem_pused")}" + mem_view="${mem_view//'#{mem.pused}'/$(printf "%2.0f%%" "$mem_pused")}" mem_view="${mem_view//'#{mem.free}'/$(printf "$size_format" "$mem_free" "$size_unit")}" - mem_view="${mem_view//'#{mem.pfree}'/$(printf "%.0f%%" "$mem_pfree")}" + mem_view="${mem_view//'#{mem.pfree}'/$(printf "%2.0f%%" "$mem_pfree")}" mem_view="${mem_view//'#{mem.total}'/$(printf "$size_format" "$mem_total" "$size_unit")}" mem_view="${mem_view//'#{mem.color}'/$(echo "$mem_color" | awk '{ print $1 }')}" mem_view="${mem_view//'#{mem.color2}'/$(echo "$mem_color" | awk '{ print $2 }')}"