From c22d6c8ed767842ca151f83174160ead01e5a24e Mon Sep 17 00:00:00 2001 From: x p k Date: Wed, 22 Apr 2020 15:59:38 +0800 Subject: [PATCH] UPD: changed to column format --- sh/sar-weekly.sh | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) mode change 100644 => 100755 sh/sar-weekly.sh diff --git a/sh/sar-weekly.sh b/sh/sar-weekly.sh old mode 100644 new mode 100755 index 00e6992..46ab9a3 --- a/sh/sar-weekly.sh +++ b/sh/sar-weekly.sh @@ -1,8 +1,11 @@ #!/usr/bin/env bash +echo "Date CPUUsed MEMUsed IOWait" > /tmp/sar-report.txt for f in $(ls /var/log/sysstat/sa[0123]*); do -echo -n "Date: "; stat $f | grep Modify | awk '{print $2}' -sar -f $f | tail -1 | awk '{print "CPU Used: ", 100-$NF}' -sar -r -f $f | tail -1 | awk '{print "Memused: "$5}' -sar -f $f | tail -1 | awk '{print "iowait: "$6}' -echo "- - -" +SARDate=$(stat $f | grep Modify | awk '{print $2}') +CPUUsed=$(sar -f $f | tail -1 | awk '{print 100-$NF}') +MEMUsed=$(sar -r -f $f | tail -1 | awk '{print $5}') +IOWait=$(sar -f $f | tail -1 | awk '{print $6}') +echo "$SARDate $CPUUsed $MEMUsed $IOWait" >> /tmp/sar-report.txt done +cat /tmp/sar-report.txt | column -t +rm -f /tmp/sar-report.txt