1
00:00:00,360 --> 00:00:02,370
In this lesson, you're going to learn how

2
00:00:02,370 --> 00:00:04,710
to monitor devices and explore tools

3
00:00:04,710 --> 00:00:07,020
for spotting possible hard drive failures,

4
00:00:07,020 --> 00:00:08,640
displaying hardware information

5
00:00:08,640 --> 00:00:11,730
and checking if the hardware is functioning as expected.

6
00:00:11,730 --> 00:00:15,330
Needless to say, Linux is a very robust operating system,

7
00:00:15,330 --> 00:00:17,610
and it has a large number of excellent utilities

8
00:00:17,610 --> 00:00:20,370
for discovering hardware and monitoring hardware health

9
00:00:20,370 --> 00:00:22,500
that's connected to that computer.

10
00:00:22,500 --> 00:00:25,800
As a Linux administrator, after you set up your devices,

11
00:00:25,800 --> 00:00:28,200
you need to be able to track those devices that are used

12
00:00:28,200 --> 00:00:31,050
on all the computers on the network and maintain a list

13
00:00:31,050 --> 00:00:33,360
of the hardware resources in use.

14
00:00:33,360 --> 00:00:35,550
To do this, one of the most valuable commands

15
00:00:35,550 --> 00:00:37,980
we'll use is lsdev.

16
00:00:37,980 --> 00:00:40,140
lsdev will display information

17
00:00:40,140 --> 00:00:42,210
about your computer's installed hardware

18
00:00:42,210 --> 00:00:44,730
from the interrupts, also the IO ports

19
00:00:44,730 --> 00:00:48,390
and the DMA files inside the /proc directory.

20
00:00:48,390 --> 00:00:50,220
This will give you a quick overview

21
00:00:50,220 --> 00:00:53,280
of which hardware is using which input output addresses

22
00:00:53,280 --> 00:00:57,120
and what IRQs, or interrupts, and DM channels are in use.

23
00:00:57,120 --> 00:00:59,400
This program only shows the kernel's idea

24
00:00:59,400 --> 00:01:01,170
of what hardware is present though,

25
00:01:01,170 --> 00:01:03,780
not what's actually physically available.

26
00:01:03,780 --> 00:01:08,070
The /proc/interrupts file will list each logical CPU core

27
00:01:08,070 --> 00:01:10,230
and its associate interrupt requests.

28
00:01:10,230 --> 00:01:12,930
An IRQ, or interrupt, is simply a signal

29
00:01:12,930 --> 00:01:15,090
that's sent by device to the processor,

30
00:01:15,090 --> 00:01:17,100
so the processor can stop what it's doing

31
00:01:17,100 --> 00:01:20,160
and handle some task that that hardware needs to perform,

32
00:01:20,160 --> 00:01:22,890
like if you pressed a keystroke, or you moved the mouse.

33
00:01:22,890 --> 00:01:24,510
The processor needs to know that,

34
00:01:24,510 --> 00:01:26,250
so it can take action on it.

35
00:01:26,250 --> 00:01:29,310
There are multiple IRQ addresses, or interrupt addresses,

36
00:01:29,310 --> 00:01:31,350
that can signal and be sent along

37
00:01:31,350 --> 00:01:32,880
and for each of those addresses,

38
00:01:32,880 --> 00:01:35,280
the file is going to list how many signals were sent

39
00:01:35,280 --> 00:01:38,550
to each CPU core along with that address.

40
00:01:38,550 --> 00:01:42,840
Another list you need to look at is /proc/ioports.

41
00:01:42,840 --> 00:01:46,020
This is a file that's going to list input and output ports

42
00:01:46,020 --> 00:01:48,810
and the hardware devices that are mapped to those.

43
00:01:48,810 --> 00:01:52,410
On the other hand, we also have /proc/dma.

44
00:01:52,410 --> 00:01:55,950
This is a file that lists all the ISA direct memory

45
00:01:55,950 --> 00:01:59,310
access channels that are going to be used on that system.

46
00:01:59,310 --> 00:02:02,940
ISA DMA is a hardware controller that typically supports

47
00:02:02,940 --> 00:02:06,720
legacy technologies like old-school floppy discs.

48
00:02:06,720 --> 00:02:10,229
Another command we're going to use is lsusb.

49
00:02:10,229 --> 00:02:13,470
The lsusb command is used to display information

50
00:02:13,470 --> 00:02:17,550
about what devices are connected to the system's USB buses.

51
00:02:17,550 --> 00:02:22,350
This command will scan the /dev/bus/usb directory

52
00:02:22,350 --> 00:02:24,150
for all of its information.

53
00:02:24,150 --> 00:02:27,060
By default, the command will print the number of the bus

54
00:02:27,060 --> 00:02:28,770
and the connected device as well

55
00:02:28,770 --> 00:02:31,290
as the ID of the device and the name of the vendor

56
00:02:31,290 --> 00:02:33,600
and product that matches that device.

57
00:02:33,600 --> 00:02:35,940
If you use the -v flag with this command,

58
00:02:35,940 --> 00:02:39,120
you'll see more detailed information about each device.

59
00:02:39,120 --> 00:02:42,570
You can also filter out your results by using -s,

60
00:02:42,570 --> 00:02:45,750
which will show you it by bus, or by using -d,

61
00:02:45,750 --> 00:02:48,360
which will then filter it by the vendor or product.

62
00:02:48,360 --> 00:02:53,310
To run this command, type in lsusb and the options you want.

63
00:02:53,310 --> 00:02:56,550
Another command we have is lspci,

64
00:02:56,550 --> 00:02:58,920
and this one is going to be used to display information

65
00:02:58,920 --> 00:03:00,600
about devices that are connected

66
00:03:00,600 --> 00:03:04,710
through your system's PCI buses or PCI Express buses.

67
00:03:04,710 --> 00:03:07,380
By default, the output of this list will show you

68
00:03:07,380 --> 00:03:09,750
all the logical slot addresses that are typically

69
00:03:09,750 --> 00:03:13,650
in the format of Bus:Device.Function.

70
00:03:13,650 --> 00:03:15,780
It's also going to have the device's class,

71
00:03:15,780 --> 00:03:18,600
such as a network controller, a storage controller,

72
00:03:18,600 --> 00:03:20,820
an input device or a bridge device.

73
00:03:20,820 --> 00:03:23,550
It'll also have the vendor name and the device name.

74
00:03:23,550 --> 00:03:28,530
To run this command, simply type in lspci and the options.

75
00:03:28,530 --> 00:03:30,450
The next command we have is going to allow us

76
00:03:30,450 --> 00:03:32,070
to see what's in the print queue,

77
00:03:32,070 --> 00:03:35,310
and we do this by typing in lpq.

78
00:03:35,310 --> 00:03:38,490
Now, lpq is the list print queue command.

79
00:03:38,490 --> 00:03:40,620
It's going to show the status of your print queue

80
00:03:40,620 --> 00:03:43,620
and by default, it's going to report each print job's rank

81
00:03:43,620 --> 00:03:47,070
in the queue, who owns that job, the job number,

82
00:03:47,070 --> 00:03:50,160
the files in that job and the size of the job.

83
00:03:50,160 --> 00:03:52,830
You can also have the report update every few seconds,

84
00:03:52,830 --> 00:03:56,670
if you want, by specifying this with the +interval option

85
00:03:56,670 --> 00:03:58,740
until that queue becomes empty.

86
00:03:58,740 --> 00:04:01,110
If you don't want to specify the printer to monitor,

87
00:04:01,110 --> 00:04:04,440
the lpq command will monitor your default printer.

88
00:04:04,440 --> 00:04:05,430
To run this command,

89
00:04:05,430 --> 00:04:08,970
simply type in lpq and then the options.

90
00:04:08,970 --> 00:04:10,980
Now, there's some other tools we need to talk about,

91
00:04:10,980 --> 00:04:12,720
and some of these are ones we've already talked

92
00:04:12,720 --> 00:04:14,940
about in the course, but they're also useful

93
00:04:14,940 --> 00:04:17,010
for monitoring hardware devices.

94
00:04:17,010 --> 00:04:20,100
For example, if you want to identify block storage devices

95
00:04:20,100 --> 00:04:21,600
that are connected to your system,

96
00:04:21,600 --> 00:04:26,370
you can use the lsbk command or list block devices.

97
00:04:26,370 --> 00:04:28,680
The output of this command will help you ensure

98
00:04:28,680 --> 00:04:30,540
that you understand what storage devices

99
00:04:30,540 --> 00:04:33,120
are being recognized and used on your system

100
00:04:33,120 --> 00:04:36,180
as well as if they're correctly partitioned and mounted.

101
00:04:36,180 --> 00:04:39,660
Another example of this would be the dmesg command

102
00:04:39,660 --> 00:04:41,490
or D-message command.

103
00:04:41,490 --> 00:04:44,280
If you remember, this is going to print out all the messages

104
00:04:44,280 --> 00:04:46,320
that were sent to the kernel's message buffer

105
00:04:46,320 --> 00:04:48,840
after the system boot, including messages

106
00:04:48,840 --> 00:04:50,700
that were sent by the device drivers.

107
00:04:50,700 --> 00:04:53,340
So it can be very helpful in doing troubleshooting.

108
00:04:53,340 --> 00:04:55,590
If you have a hardware device that encounters errors

109
00:04:55,590 --> 00:04:57,240
in its operation, or they're not able

110
00:04:57,240 --> 00:04:59,670
to load up the expected modules to the kernel,

111
00:04:59,670 --> 00:05:03,120
the output of the D-message might help you figure this out.

112
00:05:03,120 --> 00:05:05,580
Also, you can use this output to monitor

113
00:05:05,580 --> 00:05:07,470
for issues related to device drivers

114
00:05:07,470 --> 00:05:09,770
and the underlying hardware that they control.

