In this lesson, you're going to learn how
to monitor devices and explore tools
for spotting possible hard drive failures,
displaying hardware information
and checking if the hardware is functioning as expected.
Needless to say, Linux is a very robust operating system,
and it has a large number of excellent utilities
for discovering hardware and monitoring hardware health
that's connected to that computer.
As a Linux administrator, after you set up your devices,
you need to be able to track those devices that are used
on all the computers on the network and maintain a list
of the hardware resources in use.
To do this, one of the most valuable commands
we'll use is lsdev.
lsdev will display information
about your computer's installed hardware
from the interrupts, also the IO ports
and the DMA files inside the /proc directory.
This will give you a quick overview
of which hardware is using which input output addresses
and what IRQs, or interrupts, and DM channels are in use.
This program only shows the kernel's idea
of what hardware is present though,
not what's actually physically available.
The /proc/interrupts file will list each logical CPU core
and its associate interrupt requests.
An IRQ, or interrupt, is simply a signal
that's sent by device to the processor,
so the processor can stop what it's doing
and handle some task that that hardware needs to perform,
like if you pressed a keystroke, or you moved the mouse.
The processor needs to know that,
so it can take action on it.
There are multiple IRQ addresses, or interrupt addresses,
that can signal and be sent along
and for each of those addresses,
the file is going to list how many signals were sent
to each CPU core along with that address.
Another list you need to look at is /proc/ioports.
This is a file that's going to list input and output ports
and the hardware devices that are mapped to those.
On the other hand, we also have /proc/dma.
This is a file that lists all the ISA direct memory
access channels that are going to be used on that system.
ISA DMA is a hardware controller that typically supports
legacy technologies like old-school floppy discs.
Another command we're going to use is lsusb.
The lsusb command is used to display information
about what devices are connected to the system's USB buses.
This command will scan the /dev/bus/usb directory
for all of its information.
By default, the command will print the number of the bus
and the connected device as well
as the ID of the device and the name of the vendor
and product that matches that device.
If you use the -v flag with this command,
you'll see more detailed information about each device.
You can also filter out your results by using -s,
which will show you it by bus, or by using -d,
which will then filter it by the vendor or product.
To run this command, type in lsusb and the options you want.
Another command we have is lspci,
and this one is going to be used to display information
about devices that are connected
through your system's PCI buses or PCI Express buses.
By default, the output of this list will show you
all the logical slot addresses that are typically
in the format of Bus:Device.Function.
It's also going to have the device's class,
such as a network controller, a storage controller,
an input device or a bridge device.
It'll also have the vendor name and the device name.
To run this command, simply type in lspci and the options.
The next command we have is going to allow us
to see what's in the print queue,
and we do this by typing in lpq.
Now, lpq is the list print queue command.
It's going to show the status of your print queue
and by default, it's going to report each print job's rank
in the queue, who owns that job, the job number,
the files in that job and the size of the job.
You can also have the report update every few seconds,
if you want, by specifying this with the +interval option
until that queue becomes empty.
If you don't want to specify the printer to monitor,
the lpq command will monitor your default printer.
To run this command,
simply type in lpq and then the options.
Now, there's some other tools we need to talk about,
and some of these are ones we've already talked
about in the course, but they're also useful
for monitoring hardware devices.
For example, if you want to identify block storage devices
that are connected to your system,
you can use the lsbk command or list block devices.
The output of this command will help you ensure
that you understand what storage devices
are being recognized and used on your system
as well as if they're correctly partitioned and mounted.
Another example of this would be the dmesg command
or D-message command.
If you remember, this is going to print out all the messages
that were sent to the kernel's message buffer
after the system boot, including messages
that were sent by the device drivers.
So it can be very helpful in doing troubleshooting.
If you have a hardware device that encounters errors
in its operation, or they're not able
to load up the expected modules to the kernel,
the output of the D-message might help you figure this out.
Also, you can use this output to monitor
for issues related to device drivers
and the underlying hardware that they control.