Skip to content

Instantly share code, notes, and snippets.

@marcoemorais
Created November 14, 2014 01:48
Show Gist options
  • Save marcoemorais/23926d8517414b158d23 to your computer and use it in GitHub Desktop.
Save marcoemorais/23926d8517414b158d23 to your computer and use it in GitHub Desktop.
useful sar counters
# canonical sar command invocation
sar -f [FILE] [flags] [interval] [count]
# general purpose flags
# -f [FILE] refers to a file in /var/log/sa/saXX where XX is the day of month
# -o [FILE] capture all performance data in a binary file to be read with sar later
# Note: *all* performance counters are captured by default
# -p flag will pretty print device names rather than using dev{m}-{n} format
# when [interval] is 0 sar will report statistics for time since boot
# when [count] is omitted sar will loop indefinitely
# table of sar flags along with some of the most useful counters
-u cpu utilization
%user : % CPU utilization in user land
%system : % CPU utilization in kernel land
%iowait : % CPU idle during which system waiting on IO
%idle : % CPU idle during which system was *not* waiting on IO
%steal : % of time system waiting while hypervisor servicing another tenant
-q run queue & load average
runq-sz : number of tasks waiting for run time
ldavg-(X) : system load average over X interval
-B paging statistics
fault/s : major & minor faults / sec
majflt/s : major faults / sec (require read from disk)
-H huge pages
-r memory utilization
%memused : % of used memory
%commit : % of memory needed by workload relative to RAM+swap
-R memory statistics
-S swap utilization
-W swap statistics
-v kernel tables
-d disk statistics per block device
tps : number of read & write ops / sec
rd_sec/s : number of 512b sectors read / sec
wr_sec/s : number of 512b sectors write / sec
await : average wait + service time (ms)
svctm : average service time (ms)
%util : % of cpu time during which device busy
-b io rates to all physical devices
tps : number of read & write ops / second
rtps : read ops / second
wtps : write ops / second
-w task creation & context switch
cswch/s : number of context switches / sec
# examples of flags
# display run queue length and load average
sar -f [FILE] -q
sar -q [interval] [count]
# display memory utilization counters
sar -f [FILE] -r
sar -r [interval] [count]
# display all cpu utilization counters
sar -u ALL
# display per-cpu utilization counter
sar -P [0|1|...|ALL]
# display disk statistics with pretty printed device names
sar -dp [interval] [count]
# display per-device (-n) counter
# table of supported arguments to (-n)
DEV nic stats
EDEV nic errors
IP ip stats
EIP ip errors
TCP tcp stats
ETCP tcp errors
SOCK socket stats
# display number of ipv4 tcp and udp sockets open
sar -f [FILE] -n SOCK
# use LC_TIME environment variable to have sar print dates in 24h time
env LC_TIME=POSIX sar -u 1
# use S_TIME_FORMAT environment variable to have sar print date in YYYY-MM-DD format
env S_TIME_FORMAT=ISO sar -u 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment