report snippets

How to install sar on Debian

Tagged linux, debian, io, cpu, sar, usage, report  Languages bash

First install the sysstat package which includes sar:

apt-get install sysstat

Then run crontab -e and add the following to collect stats:

# Collect measurements at 10-minute intervals
0,10,20,30,40,50   * * * *   /usr/lib/sa/sa1
# Create daily reports and purge old files
0                  0 * * *   /usr/lib/sa/sa2 -A

You now have access to IO and CPU usage history.

Use this command see the data for the 5th day of the current month:

sar -f /var/log/sysstat/sa05

And remember to enable collection of statistics:

sudo vim /etc/default/sysstat