From c59eb7db01a92b61d4994fd3fa52a173f06dadb4 Mon Sep 17 00:00:00 2001 From: taradiddles Date: Wed, 4 Apr 2018 22:26:59 +0300 Subject: [PATCH] use only awk to display the result --- code/monitoring/ls-qubes.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/code/monitoring/ls-qubes.sh b/code/monitoring/ls-qubes.sh index dab90ff..29ba940 100644 --- a/code/monitoring/ls-qubes.sh +++ b/code/monitoring/ls-qubes.sh @@ -15,7 +15,7 @@ # # Initial version 03.04.18 by https://github.com/one7two99 # -ram_sum="("$(xl list | awk '{print $3}' | tail -n +2 | paste -s -d+ -)")/1000" -ram_sum=$(bc <<< "scale=1;$ram_sum") -qubes_sum=$(xl list 2> /dev/null | tail -n +2 | wc -l) -echo $qubes_sum"Q|"$ram_sum"G" +xl list | awk ' + BEGIN { mem=0; qubes=0; } + / [0-9]+ +[0-9]+ +[0-9]+ / { mem+=$3; qubes++; } + END { printf("%dQ|%.1fG\n", qubes, mem/1000); }'