1
00:00:00,000 --> 00:00:12,440
In this video, you will learn about SAR, the System Activity Reporter. It shows system

2
00:00:12,440 --> 00:00:17,680
usage statistics that have been gathered over a longer period of time. And SAR is relevant

3
00:00:17,680 --> 00:00:22,280
because a utility like TOP will only show you what is happening here and now. And the

4
00:00:22,280 --> 00:00:28,639
best thing TOP can do is show you the last 1, 5 and 15 minute system usage averages.

5
00:00:28,639 --> 00:00:35,720
SAR can gather information about everything and it gives you long-term trends on the utilization

6
00:00:35,720 --> 00:00:41,919
of your computer. Now, these statistics are collected by the SA1 and SA2 programs and

7
00:00:41,919 --> 00:00:48,599
they are executed as scheduled jobs, either using CROM or system D timers. And to work

8
00:00:48,599 --> 00:00:53,599
with SAR, you need to verify that data gathering by these utilities is enabled. Let me show

9
00:00:53,599 --> 00:00:59,520
you. So to start with, I need to install the SysTat package. Here on the CentOS system,

10
00:00:59,520 --> 00:01:07,120
I'm using sudo dnf install –y systat. Next, when I'm using SAR with one of the many options

11
00:01:07,120 --> 00:01:13,160
like SAR-A, what do we see? Oh no, we see cannot open VARLOG SA-SA30, no search file

12
00:01:13,160 --> 00:01:18,519
or directory. Why is that? Well, that is because I've just installed the package, but in order

13
00:01:18,519 --> 00:01:26,839
to work with SAR, you need to do some data gathering. So let me use systemctl listunit

14
00:01:26,839 --> 00:01:32,720
files –d timers so that you can see all the system D timers and there we can see that

15
00:01:32,720 --> 00:01:38,720
there is the SysTat collect timer. And SysTat collect timer is what we need here. You can

16
00:01:38,720 --> 00:01:42,919
see it's enabled, but it's a scheduled job. And as a scheduled job, you will always need

17
00:01:42,919 --> 00:01:52,279
to wait for a little bit. But if we use systemctl cat on systat collect.service, that is the

18
00:01:52,279 --> 00:01:57,519
program that is triggered by the timer. There we can see what it is doing. So this is the

19
00:01:57,519 --> 00:02:03,720
command that it is running. So you know what I'm going to do? I'm going to run it manually

20
00:02:03,720 --> 00:02:11,080
using sudo because we need sudo privileges to do so. And here it is going to run. And

21
00:02:11,080 --> 00:02:17,360
then I'm going to wait for one minute. So the minute is over, and I'm going to run

22
00:02:17,360 --> 00:02:24,600
my data gatherer again. Now, why do I do that? Let me show you. I'm doing this because in

23
00:02:24,600 --> 00:02:32,520
the var log directory, it should have created the SA directory. And in this SA directory,

24
00:02:32,520 --> 00:02:40,160
we can see the file SA30. Why is that SA30? Well, because today is the 30th. And in the

25
00:02:40,320 --> 00:02:46,919
SA30 file, we are able to find the data that has been gathered. So this is just a one-time

26
00:02:46,919 --> 00:02:52,320
data gathering. It's only four kilobytes, but it's only just starting. And the result is that

27
00:02:52,320 --> 00:02:59,720
right now I can use SAR minus A, and SAR minus A is giving me all the information. And that

28
00:02:59,720 --> 00:03:06,240
includes CPU utilization. It includes network interface utilization. It includes storage

29
00:03:06,240 --> 00:03:12,759
device utilization, and so much more. Now, as you can see, the first time I've used my data

30
00:03:12,759 --> 00:03:18,479
gathering, it has created the header lines. It didn't really write any data. Only the second

31
00:03:18,479 --> 00:03:25,759
time, it has written any data to it. And next, when this is growing a little bit and you get

32
00:03:25,759 --> 00:03:32,679
more information, use SAR with one of the many, many commands that are available. Like, for

33
00:03:32,679 --> 00:03:40,360
instance, SAR minus R all, which is doing what? Which is giving memory utilization statistics. I

34
00:03:40,360 --> 00:03:45,679
would say knock yourself out in SAR minus minus L with all the different options that you can

35
00:03:45,720 --> 00:03:53,520
request here. Every single aspect of system utilization can be queried. And when multiple

36
00:03:53,520 --> 00:03:59,639
datasets have been gathered, you see a nice list. And the thing in this nice list is that you can

37
00:03:59,639 --> 00:04:06,039
see an average. And the average, well, based on one-time data gathering is not so very exciting.

38
00:04:06,639 --> 00:04:12,720
The exciting part is that you can see trends. So if you suspect your server to peak every night at

39
00:04:12,720 --> 00:04:19,040
2am, well, SAR is going to reveal it. And that is what makes this utility so incredibly useful.

