Computer systems are constructed by software systems and hardware systems. Detecting hardware status is very important to ensure the stability of the entire system. Whether the operating system uses Linux, or Windows, once the hardware fails, the security of the entire system is serious. Here we mainly detect the CPU, hard disk and memory of the computer system running Linux.
Central processor status detection
The central processor is the core hardware of the Linux host. Let's take a look at the Linux root directory: / proc directory content. The files in this directory are actually not stored on the disk. The file system of this directory is called the Proc file system, which is an image of the system kernel. That is to say that the file in this directory is stored in the system memory. It provides an interface to the operation of accessing system kernel data in a file system. User and applications can get system information through / proc, and change certain parameters of the kernel. Since the system information (such as a process) is dynamically changed, the Proc file system is dynamically generated and submitted by dynamic nucleation from the system.
The information of the CPU is stored in the "CPUInfo" file. We can also use the following command to view:
#cat / proc / cpuinfo
The following author's AMD Athlon 1100 is used as an example:
Processor: 0
Vendor_ID: Authentic AMD
CPU Family: 6
MODEL: 7
Model Name: AMD Athlon (TM) Processor
STEpping: 0
CPU MHz: 1100.046
Cache Size: 64 KB # Cache Capacity #
FDIV_BUG: No # No bug #
HLT_BUG: No # No bug #
F00f_bug: no # No bug #
Coma_bug: no # No bug #
FPU: YES
FPU_EXCEPTION: YES
CPUID Level: 1
WP: YES
Flags: FPU VME DE PSE TSC MSR PAE MCE CX8 APIC SEP MTRR PGE MCA CMOV
PAT PSE36 MMX FXSR SSE SYSCALL MMXEXT 3DNOWEXT 3DNOW
BOGOMIPS: 2195.45
Be sure to ensure that the CPU hardware does not have bugs, and the specific model is applied by the system. The above is just the basic situation of the CPU, and we use MBMON software to detect CPUs for real-time conditions.
The central processor temperature is 42.1, the power supply temperature is 33.0, the main board temperature is 24.2; the CPU fan speed is 5357 rpm; the CPU core voltage is 1.78 volts, the input voltage is 12.19 volts, 3.41 volts, 4.93 volts. By default, the above is updated for five seconds.
MBMON runs under the X window, and the results are shown in Figure 1.
./xmbmon
Figure 1 MBMON runs under the X window
4. Remote monitoring
The latest version of MBMON also provides remote monitoring features:
./MBMON-P 22
Where "-P 22" indicates open port 22 so you can use Telnet, SSH and other remote tools to connect Linux hosts to detect the CPU status.
Hard disk track detection
Hard disk physics bad track is the most headache in all Linux hardware failures of the hard drive. It lightly makes your Linux computer frequently crafted, and all of you have all the data into a dark. Now the factory hard disk (after 1993) basically supports the automatic detection analysis and reporting technology of Smart (Self Monitoring Analysis and Reporting Technology). SMART technology can monitor the head unit of the hard disk, the disc motor drive system, the hard disk internal circuit, and the disc surface dielectric material. When SMART monitors and analyzes the hard disk, the user will be alarmed to the user to avoid loss of computer data. SMART technology must only take effects on board support, and SMART technology does not guarantee the possible hard disk failure. Smart (SFF-8035i) is an industrial standard established by hard disk manufacturers. This standard is a table that saves a attribute such as execution, reliability, read error rate, etc. on the hard disk. All attributes have a standardized value of 1 Ibyte (size range 1-253), and also contains another 1byte key phase value. If a data in the property table is close to less than or reaches a critical stage value, it indicates that the hard disk is not working properly.
Smartmontools is a hard disk detection tool in Linux. Home is http://smartmontools.sourceforge.net, download link: ftp: //fr2.rpmfind.net/linux/sources/smartmontools/smartmontools-5.1-18.i386.rpm.
1. Software Installation:
RPM-IVH / Smartmontools-5.1-18.i386.rpm
After the software is installed, the program will be generated in the / usr / local / directory: SmartCTL, first detect whether the hard disk and the motherboard support SMART technology (see Figure 2). Smartctl -i / dev / hda7
Figure 2 detects whether the hard disk supports SMART
Figure 2 shows the author's hard drive support Smart, model: ST320414A (Seagate's cool fish III, 72000 rpm, 2 megabyge caokes).
2. Comprehensive detection hard disk
Run the following hard drive detection command:
Smartctl -a / dev / hda7
Figure 3 Hard disk physical logic status
Figure 3 is the detected hard disk information, which is displayed differently depending on your hard drive vendor, where 1-202 lines represent different physical properties of the hard disk, and the column represents the logical status of the hard disk.
FLAG is a tag, the standard value (Value) should be less than or equal to the key value (Thresh). When_failed represents the error message, the WHEN_FAILED line in Figure 3 is blank, indicating that the hard disk is not faulty. If the WHEN_FAILD displays a number, it indicates that the hard disk track may have a relatively large bad track.
Smartctl has more than a dozen parameters, detailed, the following commands are viewed:
Smartctl --help
3. Advanced application
We can use the crontab command to implement a scheduled scan:
(1) Build a file first, the file name is Linuxect (name yourself):
#Crontab -e
(2) File content:
05 16 * * 5 smartctl -a / dev / hda7
Use the VI editor to exit. Add the crontab command to the task list:
#Crontab linuxect
This allows all users in the system to automatically scan at 16:00 on each Friday.
Memory detection
Usually we will feel that the inclination of the wrong damage is not large, and it is considered that if it is broken, it is impossible to start self-test by the motherboard BIOS. In fact, this self-test program has little features, but only detects the capacity speed, many internal existence errors do not detect. If you have a program when you run the program, you will not lose your response from time to time;
1. Use Linux command to detect
(1) Use the "free" command in the command line to monitor memory usage
#Free
Total Used Free Shared Buffers Cached
MEM: 256024 192284 63740 0 10676 101004
- / buffers / cache: 80604 175420
SWAP: 522072 0 522072
The system of 256MB of RAM and 512MB swappable space is given above.
(2) Make the VMSTAT command to monitor virtual memory usage:
The VMSTAT () command is a general monitor, an abbreviation for Virtual Meomory Statistics (virtual memory statistics). If you use the vmstat command, you will receive a one-time report when using the vmstat command. The vmstat commands the main activity type of activity (procs), memory (in kilobytes), swap partition (in kilobytes), input and output from block devices (hard drives), system interrupt (The number of occurrences per second), the central processing unit (CPU) is allocated to the user system and the ratio of the proportion. 2. Tool software detection
Memtest86 is a free memory test software with high test accuracy, and the implicit problem of memory can also be checked. You can download its latest version 3.0 version by http://www.memtest86.com/ page.
Then, insert a 3.5-inch blank disk into the floppy drive and enter:
# make install
You can also download http://www.memtest86.com/memtest86-3.0.iso.gz file, decompressed is an iOS file, burn to the disc, then start the computer.
Restart your computer, set with a floppic drive in the BIOS, as shown in Figure 4.
Figure 4 MEMTEST86 software run interface
Figure 4 can be seen by the processor model used in the current system: AMD-DURON and frequency: 1056, and CPU level cache (128K) and secondary cache (64K), the capacity of physical memory (64) and speed (315Mb / s). Finally, the chipset type used by the motherboard is displayed. The right side of the system information is displayed is the progress of the test. "Pass" shows the progress of the main test process. "TEST" shows the progress of the current test item. "Test # 1" shows the current test item. "WallTime" Displays the time that has been spent, in the "ECC" column in this row, is displayed whether the current memory supports opening the ECC check function. "TEST" is displayed by the test mode, with "standard" and "complete" mode to choose from. "
Set Detection Option: We can click the "C" button to open the MEMTEST86 setting menu, then click the Test Selection option, then click the Number button "3" to select the "All Test" option to open Test mode (shown in Figure 5).
Figure 5 Set Detection Options
The main memory burst (such as "death" bits) will be detected in a few seconds. If it is a fault triggered by a particular bit mode, a long time test is required to detect it. If your memory capacity is relatively large, you need to wait for the test results. The memory capacity used by the author is 64MB, PC133. The time used in full detection mode is 24 minutes.
summary
Central processor, hard disk, memory is the core of the Linux system. Linux has a prestigious feature of its extraordinary stability. If your hardware is defective or configured correctly, the security within the system is dangerous, so it is important to detect their status in real time.