2020-04-20 11:24:58 +08:00
|
|
|
#!/usr/bin/env bash
|
2020-04-22 16:00:58 +08:00
|
|
|
SARDIR=/var/log/sysstat
|
|
|
|
if [ -d /var/log/sa ]; then
|
|
|
|
SARDIR=/var/log/sa
|
|
|
|
fi
|
2020-04-22 15:59:38 +08:00
|
|
|
echo "Date CPUUsed MEMUsed IOWait" > /tmp/sar-report.txt
|
2020-04-22 16:00:58 +08:00
|
|
|
for f in $(ls $SARDIR/sa[0123]*); do
|
2020-04-22 15:59:38 +08:00
|
|
|
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
|
2020-04-20 11:24:58 +08:00
|
|
|
done
|
2020-04-22 15:59:38 +08:00
|
|
|
cat /tmp/sar-report.txt | column -t
|
|
|
|
rm -f /tmp/sar-report.txt
|