on our servers, typing sar show's the system load statistics for today starting at midnight, is it possible to show yesterdays statistics?
- 57,918
- 74
- 184
- 250
3 Answers
Usually, sysstat, which provides a sar command, keeps logs in /var/log/sysstat/ or /var/log/sa/ with filenames such as /var/log/sysstat/sadd where dd is a numeric value for the day of the month (starting at 01). By default, the file from the current day is used; however, you can change the file that is used with the -f command line switch. Thus for the 3rd of the month you would do something like:
sar -f /var/log/sysstat/sa03
If you want to restrict the time range, you can use the -s and -e parameters. If you want to routinely get yesterday's file and can never remember the date and have GNU date you could try
sar -f /var/log/sysstat/sa$(date +%d -d yesterday)
I highly recommend reading the manual page for sar.
- 275
- 3
- 7
- 45,310
- 13
- 119
- 114
-
13on our cPanel/CentOS systems it appears to be in `/var/log/sa` – xenoterracide Jan 10 '11 at 06:59
-
1yup, centos it's: sar -b -f /var/log/sa/sa20 for the 20th of the month. – stantonk Jan 21 '15 at 00:51
-
5/var/log/sa for Redhat as well – sweetfa Feb 03 '15 at 21:17
-
1/var/log/sa in SUSE too – Gareth Davidson Jan 29 '16 at 12:09
Try the command as follows to get historic memory utilization details.
sar -r -f /var/log/sa/sa01
The files in /var/log/sa record everything in the world.
- 66,199
- 35
- 114
- 250
- 81
- 1
- 2
There is a "magic" parameter for that: -N, e.g. the following would display the yesterday's stats:
sar -1
Collect weekly data from many servers, put it to NFS:
parallel --tag --nonall -k -j 3 -S server1,server2,server3 \
'of="/nfs-path/sar-$(hostname).out"; rm -f "${of}"; for N in {7..0}; do sar -A -$N 2> /dev/null >> "${of}"; done'
Those files can be loaded into kSar
- 161
- 1
- 2
-
this is so much better than the accepted answer, it's built into sar command, exactly what I hoped it could do! – Michael Curtis Oct 08 '21 at 16:55