Overview: Let me share a hard disk monitoring done on a certain server before. It was mainly implemented through the smartctl tool. The following is a test process.

2024/02/2403:54:32 hotcomm 1312

Overview

shared a hard disk monitoring of a server that was done before. It was mainly implemented through the SMARTctl tool. The following is a test process.


XX server disk space

[root@localhost media]# df -hFilesystem Size Used Avail Use% Mounted on/dev/mapper/VolGroup-lv_root 99G 70G 24G 75% /tmpfs 48G 76K 48G 1% /dev/shm/dev/sdb2 485M 42M 418M 10% /boot/dev/sdb1 500M 156M 345M 32% /boot/efi/dev/mapper/VolGroup-lv_home 77G 5.7G 68G 8% /home

Here you can see that the sdb hard disk is used

Attachment: Introduction to smartmontools

smartmontools It is an open source disk control and monitoring tool that can run on Linux, Unix, BSD, Solaris, Mac OS, OS/2, Cygwin and Windows. It can also be run from a boot CD or boot floppy disk and supports ata/ATAPI /SATA-3 (to -8) hard disk and SCSI hard disk , and also supports tape devices. Its home is smartmontools.sourceforge.NET. In fact, it is a software package that includes two utilities: smartctl and smatd. The hard drive it monitors must have the S.M.A.R.T feature. Currently, all hard drives have this feature, but this feature is usually not turned on by default. There are two ways to turn on this feature: 1) through the BIOS setting option 2) through the smartctl command. Use it to test the health of your hard drive and provide early warning before failure occurs.


Test whether the hard disk supports S.M.A.R.T

[root@localhost media]# smartctl -i -d scsi /dev/sda[root@localhost media]# smartctl -i -d scsi /dev/sdb

Overview: Let me share a hard disk monitoring done on a certain server before. It was mainly implemented through the smartctl tool. The following is a test process. - DayDayNews

Description: Parameter -i indicates the display device information , -d indicates the device type , some specified device types are ata, if it is a SCSI hard disk, scsi is specified, and the last /dev/sda is the device (the df command queries the device).

From the returned information, you can see the hard disk manufacturer, model, serial number, capacity, whether it supports SMART, and whether SMART is currently enabled. The last two lines of the result are the information we need. It can be seen from here that the /dev/sdb hard disk supports SMART technology and has been enabled. The /dev/sda hard disk prompts the message "Device does not support SMART", which means that the target hard disk does not support SMART, and this software package cannot be used for testing and monitoring.


Turn on the SMART feature

#smartctl -s on -d ata /dev/sda

The parameter -s is used to switch the SMART feature on and off. If the parameter value is added, it means it is turned on. If the parameter value is off, it means it is turned off.


test

[root@localhost media]# smartctl -H -d scsi /dev/sdb[root@localhost media]# smartctl -H -d scsi /dev/sda

Overview: Let me share a hard disk monitoring done on a certain server before. It was mainly implemented through the smartctl tool. The following is a test process. - DayDayNews

Description: The parameter -H specifies to display the health status of the target hard disk


Some other useful parameters

-A displays supported SMART attributes. Reference command:

#smartctl -A sda

Return content:

Overview: Let me share a hard disk monitoring done on a certain server before. It was mainly implemented through the smartctl tool. The following is a test process. - DayDayNews

Description:

-a displays all SMART information of the device.

-l error lists the hard disk error log. It's best if no errors are displayed. If a large number of error messages are displayed, it's time to prepare to replace the hard drive.

-l selftest lists self-test results.


uses smartd for automatic monitoring

smartd is a utility program in the smartmontools software package. It can be run alone or registered as a system service. The registration command on Windows is:

smartd install

After registration, open services.msc and you will see a name Call the "SmartD Service" service and set it to start "automatically".

can be added to /etc/rc.d/init.d by adding the smartd script on non-Windows platforms. In fact, when installing the smartmontools package, it is usually installed in this location. You only need to make a soft link at the corresponding startup level. That's it.The configuration file of

smartd is smartd.conf (both Windows and non-Windows platforms are called this name. The Windows platform and smartd.exe are in the same directory, and the non-Windows platform is in the /etc directory). Many types of configuration files have been built into this configuration file. Monitoring method and parameter description:

[root@localhost ~]# locate smartd.conf/etc/smartd.conf/usr/share/doc/smartmontools-5.43/smartd.conf/usr/share/man/man5/smartd.conf .5.gz

Regarding smartctl, there is actually a -m parameter. We can use it to send monitoring reports to the specified E-mail address in the form of emails, so that the device administrator can control all hard disk devices while sitting in front of the computer. of health.

The editor will share more Linux content later. If you are interested, please follow us~

Overview: Let me share a hard disk monitoring done on a certain server before. It was mainly implemented through the smartctl tool. The following is a test process. - DayDayNews

hotcomm Category Latest News