![]() ![]() Once you run the script, you will get an output like the one below. # vi /opt/scripts/sar-cpu-avg.shĮcho "+-+"Įcho "|Average: CPU %user %nice %system %iowait %steal %idle |"įor file in `ls -tr /var/log/sa/sa* | grep -v sar`ĭat=`sar -f $file | head -n 1 | awk '' Since this is a month end, it shows 28 days data for August 2019. ![]() This bash script collects the CPU average from each data file and display it on one page. Script-1: Bash Script to Get Average CPU Utilization from SAR Reports The configuration file can be found in “/etc/sysstat/config”. Make a note, Debian-based users should replace the “/var/log/sysstat/sa” path instead. You can modify other performance metrics in the script to suit your needs. For testing purposes, we have included only two performance metrics, namely CPU and memory. These scripts are simple and straightforward. How to automate daily operations using shell script.If you want to check out that collection, go to the link below. The task’s share of the elapsed CPU time since the last screen update, expressed as a percentage of total CPU time. We have added many useful shell scripts in the past. Top command to check Linux CPU usage or utilization Type the top command: top Fig.01: top command in action (click to enlarge) You can see Linux CPU utilization under CPU statistics. ![]() ![]() In this article we have added three bash scripts that will help you to easily view each data file averages in one place. To extend the coverage period to 28 days, make the following change to the “/etc/sysconfig/sysstat” file.Įdit the sysstat file and change HISTORY=7 to HISTORY=28. If the value exceeds 28, the log files are placed in multiple directories, one for each month. Most Linux administrator monitor system performance with SAR report because it collects performance data for a week.īut you can easily extend this to four weeks by making changes to the “/etc/sysconfig/sysstat” file.Īlso, this period can be extended beyond one month. ![]()
0 Comments
Leave a Reply. |