Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
linux_wiki:sar [2014/12/03 21:32] billdozor |
linux_wiki:sar [2016/03/18 23:22] billdozor [sar (system activity report)] |
||
---|---|---|---|
Line 1: | Line 1: | ||
====== sar (system activity report) ====== | ====== sar (system activity report) ====== | ||
+ | |||
+ | **General Information** | ||
+ | |||
sar is used for displaying collected activity counters of various OS stats, including CPU, memory, swap, and disk I/O. | sar is used for displaying collected activity counters of various OS stats, including CPU, memory, swap, and disk I/O. | ||
- | sar is a command provided by the sysstat package. | + | **Checklist** |
+ | * Distro(s): Any | ||
+ | * Package: | ||
+ | |||
+ | ---- | ||
===== Installation and Configuration ===== | ===== Installation and Configuration ===== | ||
Line 25: | Line 32: | ||
Look for a line like this to edit: | Look for a line like this to edit: | ||
+ | < | ||
# Activity reports every 10 minutes everyday | # Activity reports every 10 minutes everyday | ||
5-55/10 * * * * root command -v debian-sa1 > /dev/null && debian-sa1 1 1 | 5-55/10 * * * * root command -v debian-sa1 > /dev/null && debian-sa1 1 1 | ||
+ | </ | ||
4) Start the service | 4) Start the service | ||
Line 45: | Line 54: | ||
After sysstat has collected data for a while, you can start to view the information with sar. | After sysstat has collected data for a while, you can start to view the information with sar. | ||
- | === Log location === | + | ==== Log location |
Sar logs to either: | Sar logs to either: | ||
* / | * / | ||
Line 63: | Line 72: | ||
---- | ---- | ||
- | === CPU Utilization === | + | ==== CPU Utilization |
- | < | + | < |
sar -u (displays for current day until that point) | sar -u (displays for current day until that point) | ||
sar -u 1 5 (display real time CPU every 1 second, 5 times) | sar -u 1 5 (display real time CPU every 1 second, 5 times) | ||
Line 90: | Line 99: | ||
---- | ---- | ||
- | === Memory (RAM) Stats === | + | ==== Memory (RAM) Stats ==== |
- | < | + | < |
sar -r (display todays memory stats) | sar -r (display todays memory stats) | ||
sar -r 2 10 (display real time memory stats every 2 seconds, 10 times) | sar -r 2 10 (display real time memory stats every 2 seconds, 10 times) | ||
</ | </ | ||
+ | <code bash> | ||
sar -r | sar -r | ||
Linux 3.13.0-39-generic (dt-bill) 12/03/2014 _x86_64_ (4 CPU) | Linux 3.13.0-39-generic (dt-bill) 12/03/2014 _x86_64_ (4 CPU) | ||
Line 101: | Line 111: | ||
05:25:01 PM kbmemfree kbmemused | 05:25:01 PM kbmemfree kbmemused | ||
05:35:01 PM | 05:35:01 PM | ||
+ | </ | ||
Columns (probably the only ones you care about): | Columns (probably the only ones you care about): | ||
Line 109: | Line 120: | ||
---- | ---- | ||
- | === Swap Stats === | + | ==== Swap Stats ==== |
+ | < | ||
+ | sar -S (todays swap usage) | ||
+ | </ | ||
+ | <code bash> | ||
+ | sar -S | ||
+ | Linux 3.13.0-39-generic (dt-bill) 12/03/2014 _x86_64_ (4 CPU) | ||
+ | |||
+ | 05:25:01 PM kbswpfree kbswpused | ||
+ | 05:35:01 PM | ||
+ | </ | ||
+ | |||
+ | Columns: | ||
+ | * kbswpfree => Free swap space in kilobytes | ||
+ | * kbswpused => Used swap space in kilobytes | ||
+ | * %swpused => % used swap space | ||
+ | * kbswpcad => Cached swap in kilobytes. This is memory that once was swapped out, is swapped back in but still also is in the swap area (if memory is needed it doesn' | ||
+ | * **Explanation**: | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ==== Disk I/O ==== | ||
+ | < | ||
+ | sar -b (todays disk I/O and transfer rates) | ||
+ | </ | ||
+ | |||
+ | <code bash> | ||
+ | sar -b | ||
+ | Linux 3.13.0-39-generic (dt-bill) 12/03/2014 _x86_64_ (4 CPU) | ||
+ | |||
+ | 05:25:01 PM | ||
+ | 05:35:01 PM | ||
+ | </ | ||
+ | |||
+ | Columns: | ||
+ | * tps => transfers per second (both disk reads and writes) | ||
+ | * rtps => read requests per second | ||
+ | * wtps => write requests per second | ||
+ | * bread/s => blocks read per second (block = sector = 512 bytes) | ||
+ | * bwrtn/s => blocks written per second (block = sector = 512 bytes) | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ==== Network Stats ==== | ||
+ | < | ||
+ | sar -n TYPE (todays network statistics) | ||
+ | </ | ||
+ | |||
+ | TYPE can be: | ||
+ | * DEV => devices vital stats (eth0, eth1, etc) | ||
+ | * EDEV => device failure stats | ||
+ | * NFS => NFS client activity | ||
+ | * NFSD => NFS server activity | ||
+ | * IP => IPv4 network traffic | ||
+ | * TCP => TCPv4 network traffic | ||
+ | * UDP => UDPv4 network traffic | ||
+ | * ALL => All of the above (and more). Warning: this will be very long. | ||
+ | |||
+ | Example (device stats for just eth1 from 5pm to 6pm today) | ||
+ | <code bash> | ||
+ | sar -n DEV -s 17:00:00 -e 18:00:00 | grep eth1 | ||
+ | 05:25:01 PM | ||
+ | 05:35:01 PM eth1 | ||
+ | 05:45:01 PM eth1 | ||
+ | 05:55:01 PM eth1 | ||
+ | Average: | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ==== Start and End ==== | ||
+ | Report only specfic time periods | ||
+ | |||
+ | CPU stats for today, from 6pm to 6:30pm | ||
+ | <code bash> | ||
+ | sar -u -s 18:00:00 -e 18: | ||
+ | </ | ||
+ | |||
+ | Memory stats 1pm to 3pm, from the 1st day of the month | ||
+ | <code bash> | ||
+ | sar -r -s 13:00:00 -e 15:00:00 -f / | ||
+ | </ |