In this article, we're going to take a look at the System Activity Reporter, also known as the
sar command. This command will help us with seeing a historical view of the performance of our server. You'll see examples of installing it, running it manually, and more. Let's get started!
Before we do get started, there's a few quick things to mention. If your server is a production server, then I hope you've already installed all available updates. There's already articles within Linode's documentation when it comes to updating packages.
To get started, we'll first need to install the
sar command, which is available in the
sudo apt update
sudo apt install sysstat
Installation of the
sysstat package should be fairly fast.
However, having the
sysstat package installed by itself isn't enough - we'll need to configure its defaults. We can use the
nano text editor, for example, to edit the
sudo nano /etc/default/sysstat
The first change to make within this file, is to enable stat collection:
Save the file, and then we're all set with that file in particular.
Optionally, you could consider editing other configuration files that configure
The first configures how often stats are collected, the second example will give you even more options to fine-tun
sar, which might be useful. Feel free to take a look at it.
The data file
List the storage of the
ls -l /var/log/sysstat/
sar will run every ten minutes by default, so if ten minutes hasn't passed since you've enabled stat collecting, then wait a bit, and it should be present.
Here's an example of
sar in action:
sudo sar -u -f /var/log/sysstat/saNUM
NUM in the example is a placeholder for the number next to your data file, which will actually be the same as the date, specifically the day of the month (for example,
sa22 corresponds to the 22nd of the current month). The output will give you the overall performance for your server at a given time.
Continuing, let's look at a simpler example:
This should give you the same output as before, but without waiting for the data file to be updated.
Yet enother example to show you, is the