To see the multiple-day sar report for memory stats:
find /var/log/sa/ -type f|grep sar|xargs grep kbmem -A144
To see the CPU status, try this
find /var/log/sa/ -type f|grep sar|xargs grep "CPU %user" -A720
How it works
The directory /var/log/sa/ will have files such as sar23, sar24, sar25, sar26, sar27. The sar-suffix corresponds to the day of the month.
- First find and grep only the sar-suffix files
- Then pass the sar files as argument to the "grep keyword" command. This will give you only the header of the parameter you are interested in (kbmem for memory, or "CPU %user" for cpu status)
- But you would also like the next 144 lines after the header for memory details (or 720 lines for CPU). So include the -A144 or -A720 options to the grep command.
Note:
- For memory stats, a single line is logged every 10 mins. Hence 144 lines per day.
- For CPU stats, 5 lines are logged every 10 mins, hence 720 lines per day (at least in my env). This might be different in your env, so please verify or calculate this manually at your end.
If you love aliases:
alias sarcpu='find /var/log/sa/ -type f|grep sar|xargs grep CPU %user -A720'
alias sario='find /var/log/sa/ -type f|grep sar|xargs grep bread -A144'
alias sarmem='find /var/log/sa/ -type f|grep sar|xargs grep kbmem -A144'