User Tools

Site Tools


sar_commands

Common Sar Commands

sar -u 
sar -q
sar -b
sar -B
sar -d (device)
sar -n DEV
sar -n SOCK



Show all statistics for current day:
sar -<option>
Show statistics 3 times with 1 second interval
sar -<option> 1 3


Show CPU statistics 3 times with 1 second interval, (focus on the last field “%idle” to see the cpu load):

sar 1 3

CPU usage of ALL CPUs

sar -u 1 3

Load average

sar -q

Swap Space

sar -S

Viewing specific time and date

Select a specific time during the day:

sar -<option> -s 10:30:00

sar -q -f /var/log/sa/sa23 -s 10:00:01
sar -p | grep -A5 "07:45"

Change the value 4 to the number of CPUs you have

sar -q | awk '$5 > 4'

Summary of logs

RAM

for i in $(ls -tr /var/log/sa/sa[0-9][0-9]); do echo $(ls -l $i); sar -r -f $i | awk '$4 > 98.8'; done | awk '!/Average|Linux/'

CPU

for i in $(ls -tr /var/log/sa/sa[0-9][0-9]); do echo $(ls -l $i); sar -u -f $i | awk '$8 > 20'; done | awk '!/Average|Linux/'

load

load=$(grep -ic 'model name' /proc/cpuinfo ); for i in $(ls -1tr /var/log/sa/sa[0-3]*| grep -v '.bz2'); do echo "$(stat --printf='%.16y...' $i)"; sar -q -f $i | awk ' $6 > '"$load"' {print $0}' | grep -v 'Average\|x86'; echo ''; done
for i in $(ls -tr /var/log/sa/sa[0-9][0-9]); do echo $(ls -l $i); sar -q -f $i | awk '$5 > 1'; done | awk '!/Average|Linux/'

Block Device I/O Activities

for i in $( ls -tr /var/log/sa/sa[0-9][0-9]); do echo $(ls -l $i ); sar -p -d | awk '$11 > 80'; done | awk '!/Average|Linux/'

sar_commands.txt · Last modified: 2024/05/23 07:26 by 127.0.0.1

Except where otherwise noted, content on this wiki is licensed under the following license: Public Domain
Public Domain Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki