1
00:00:00,000 --> 00:00:12,360
Okay, so this is top, the performance dashboard for Linux. When I tell people about top, there's

2
00:00:12,360 --> 00:00:17,120
always people asking me, Hey, standard, have you heard of H top? Yes, of course, I've heard

3
00:00:17,120 --> 00:00:23,320
of H top. And there are other top like utilities as well. The reason I'm showing you top and

4
00:00:23,320 --> 00:00:28,480
nothing else is simple to explain. Top will always be present on your system. Because

5
00:00:28,480 --> 00:00:35,240
top is a standard Linux utility. H top is a fancy version of top, it's showing you colors,

6
00:00:35,240 --> 00:00:40,360
it's showing you much more details. But it also has a much larger system overhead. And

7
00:00:40,360 --> 00:00:46,160
for that reason, you won't find H top by default installed on most systems. You can see it

8
00:00:46,160 --> 00:00:53,360
right here in bold typeface. Top is using a CPU percentage of about 0.3%. I have seen

9
00:00:53,360 --> 00:00:59,880
H top systems that are using about 4% just for H top. And let's face it, you are using

10
00:00:59,880 --> 00:01:04,279
utilities like this. If you have an issue with your performance, then you don't want

11
00:01:04,279 --> 00:01:10,959
to earn a utility. That's a performance hit itself. Also notice that in many cases, it

12
00:01:10,959 --> 00:01:16,400
will not be allowed to install different utilities anyway. Imagine that you're a consultant and

13
00:01:16,400 --> 00:01:21,040
you want to help a customer with their performance problems. And then you are going to tell them,

14
00:01:21,080 --> 00:01:27,360
hey, can you install H top for me? Most likely they are going to tell you no, because installing

15
00:01:27,400 --> 00:01:34,400
unauthorized software is not something that is easily done in many Linux installations. Now

16
00:01:34,400 --> 00:01:40,440
the top interface right here is a little bit boring. I'm using Q to quit. And I'm going to

17
00:01:40,480 --> 00:01:49,800
give us some action using DDIF is dev 0, OF is dev null. And I'm making it background job. And

18
00:01:49,800 --> 00:01:54,680
then I'm running top again, so that at least we have one process that is creating some

19
00:01:54,680 --> 00:02:00,879
action. First thing I would look at in the top interface is the load average. Load average is

20
00:02:00,879 --> 00:02:08,119
giving the total amount of runnable processes over the last 1, 5 and 15 minutes. A runnable

21
00:02:08,119 --> 00:02:14,279
process is a process that is currently active, but also a process that wants to be served. So

22
00:02:14,279 --> 00:02:19,960
if you see six runnable processes, it doesn't mean that these are always active at the same

23
00:02:19,960 --> 00:02:26,360
time, because that is determined by the number of CPUs that you have. One CPU can only have one

24
00:02:26,360 --> 00:02:34,279
process active at any moment in time. So on a four CPU system, if you have a load average of six,

25
00:02:34,360 --> 00:02:39,279
that indicates that you have more processes than your system can handle. And you need to further

26
00:02:39,279 --> 00:02:45,279
investigate what is going on. So for the proper identification of what is going on, it's important

27
00:02:45,279 --> 00:02:51,639
that you know how many CPUs you have. Now here, you can almost guess, look, we have the DD process

28
00:02:51,639 --> 00:03:00,360
causing 100%. And we have my system, the CPUs line, and the parameter I'm looking at is ID for

29
00:03:00,360 --> 00:03:07,479
the idle loop. Idle loop is the amount of time my CPU is doing nothing. So for 50% of its time, my

30
00:03:07,479 --> 00:03:14,520
CPU is doing nothing. That means that this must be a two CPU system. You want to know it for sure,

31
00:03:14,559 --> 00:03:20,240
just press one from the top interface. And there you can see that yes, indeed, this is a two CPU

32
00:03:20,240 --> 00:03:28,520
system. Now CPUs is the next item that I'm interested in. You can see my active CPU is busy

33
00:03:28,520 --> 00:03:36,199
in user and in system space. User and system space are the areas of your operating system, where

34
00:03:36,199 --> 00:03:44,800
system space relates to kernel work, and user space relates to user processes. So here, the usage

35
00:03:44,800 --> 00:03:50,919
is mainly happening in kernel space. That is surprising in most cases, because in most cases,

36
00:03:50,919 --> 00:03:56,720
you will see a higher level of activity in user space. And if you see a high level of activity in

37
00:03:56,720 --> 00:04:03,479
kernel space, that indicates that you have very busy drivers. Now knowing what is going on in my

38
00:04:03,479 --> 00:04:10,119
command, the DD, IF and OF is, I know that I'm going from one driver to another driver. So that does

39
00:04:10,119 --> 00:04:17,559
make sense. The other parameter I'm interested in is ID. ID is the idle loop, the percentage of time

40
00:04:17,559 --> 00:04:23,040
that your system is doing nothing. And I want the idle loop to be as high as possible. The other

41
00:04:23,040 --> 00:04:29,279
parameters are not so interesting. In the past, when disks were still slow, instead of all being SSD,

42
00:04:30,079 --> 00:04:37,920
you would be interested in WA. WA is waiting for IO. And waiting for IO is what you get if your

43
00:04:37,920 --> 00:04:43,600
system is waiting for your disk to process the files. But nowadays, disks are fast enough, and

44
00:04:43,600 --> 00:04:50,000
for that reason, you don't see waiting for IO anymore. Now we have the memory usage. And in the

45
00:04:50,000 --> 00:04:56,160
memory usage, we have this line indicating that we have about four gigabytes in total, of which three

46
00:04:56,160 --> 00:05:04,799
gigabytes is free, and only 530 megabytes is used. And we also have 554 in buffers and cache.

47
00:05:05,839 --> 00:05:11,440
Buffers and cache is an area that your Linux system is using to speed up a little bit. And by keeping

48
00:05:11,440 --> 00:05:16,720
more files in buffers and cache, the next time you read the same file, you can serve it from the cache,

49
00:05:16,720 --> 00:05:23,040
and that will make your system faster. In the end, buffers and cache is not required, and that is why

50
00:05:23,040 --> 00:05:29,600
available memory is showing even more than what you see in free. And that is because your operating

51
00:05:29,600 --> 00:05:35,519
system is considering everything in cache, and it knows if the data in cache is actively being

52
00:05:35,519 --> 00:05:41,920
used or not. And if it's not actively being used, the Linux kernel knows that it can be dropped if

53
00:05:41,920 --> 00:05:48,720
more memory is needed. And in the last column, we can see the actual activity. By default, it's

54
00:05:48,720 --> 00:05:55,279
sort on CPU usage. You can also sort it on other things, and the easy way to do so is by using

55
00:05:55,279 --> 00:06:00,640
greater than or smaller than. Greater than is bringing you to the right, so right now I'm

56
00:06:00,640 --> 00:06:08,559
sorting on memory usage, and smaller than is bringing you to the left. So if I do that a couple of times

57
00:06:08,559 --> 00:06:15,839
right now, it is sorting on virtual memory usage. The virtual memory is not memory that is really in

58
00:06:15,839 --> 00:06:21,600
use. If you want to check memory that is really in use, go for a resident memory. So I'm using my

59
00:06:21,600 --> 00:06:29,279
uppercase arrow to the right once more. Now top is awesome, because apart from this overview,

60
00:06:29,279 --> 00:06:35,040
you can reanalyze and kill processes, and you can also reorganize the top interface.

61
00:06:36,160 --> 00:06:42,720
If you press F, then you get all the fields that you could be seeing in top. And if there is anything

62
00:06:42,720 --> 00:06:48,799
that you would like to see, you just use your arrow key to go over the option that you want to see.

63
00:06:48,799 --> 00:06:55,440
Here I see last used CPU. Well, that's what I want to see, so I'm using spacebar to select it, Q to

64
00:06:55,440 --> 00:07:01,839
get back to top, and look at that. We now have an additional column for the last CPU. And if you want

65
00:07:01,839 --> 00:07:09,839
to write your modifications to a persistent configuration file, use uppercase W. Uppercase W

66
00:07:09,920 --> 00:07:14,399
will write a file with the name toprc to make your setting persistent.

67
00:07:14,399 --> 00:07:19,920
So when I quit and I start top again, I can see my CPU column is listed again.

