sar

Installation

yum install sysstat

Commands

  • Save statistics every 5 seconds for 10 minutes in the file (binary file): nohup sar -o sar-$(hostname)-$(date +%m%d%Y).bin 5 12 >/dev/null 2>&1 &
  • Set the starting and the ending time of the report: sar -f /var/log/sa/sa04 -s 03:00:00 -e 06:00:00
  • Report paging statistics: sar -B
  • Report statistics for a specific disk: sar -dp | egrep 'DEV|emcpowera'

Paging process = pgpin/s & pgpout/s
Major page = a major page cause disk I/O as the page is not present in memory and it needs to be read from disk (good sign for lacking memory if it's going to be repeatedly)
Minor page = a minor page fault is not causing disk I/O (page might be present in memory but not assigned to the process address space)

  • Find CPU %iowait > 10 : for i in `ls /var/log/sa/sa{01..30}`; do echo file $i; sar -f $i | awk '$7 > 10 {print}'; done
  • Find await times > 300: for i in `ls /var/log/sa/sa{01..30}`; do echo file $i; sar -dp -f $i | awk '$9 > 300 {print}'; done
  • The number of tps: for i in `ls /var/log/sa/sa{01..30}`; do echo file $i; sar -dp -f $i | awk '$4 > 1000 {print}'; done

pidstat

  • Report page faults and memory utilization: pidstat -r
  • Report I/O statistics: pidstat -dl 1
  • Select process for which statistics are to be reported: pidstat -d -p <pid> or pidstat -r -p <pid>

Files

  • /etc/sysconfig/sysstat
  • /etc/cron.d/sysstat

ksar

Generate the report for current day (default interval)

  • HP-UX
sar -A -o sar.out
sar -A -f sar.out > sar-ascii.out
  • Linux

LC_ALL=C sar -A -p > sar.out

  • AIX

sar -A > sar.out

Generate the report only for a specific period

  • Linux

sar -A -p -f /var/log/sa/sa10 -s 19:00:00 -e 23:00:00 > $(hostname)-$(date +%m%d%Y).out

Generate report for 24 hours every 5 seconds (custom interval)

  • Linux
nohup sar -o sar-$(hostname)-$(date +%m%d%Y).bin 5 17280 > /dev/null 2>&1 &
LC_ALL=C sar -A -p -f sar-<hostname>-<date>.bin > sar-$(hostname)-$(date +%m%d%Y).out

Links