In Linux server management, monitoring the hardware status of the system is a crucial task, particularly for CPU temperature, which directly affects the stability and performance of the server. As one of the widely used Linux distributions, CentOS provides various tools to help administrators monitor CPU temperature. This article will detail how to check the CPU temperature in CentOS, ensuring that your server operates at its best.
1. Install the lm_sensors Tool
First, you need to install the lm_sensors
package, a powerful hardware monitoring tool that can read CPU temperature, fan speeds, and other related information.
Open a terminal and run the following command to install lm_sensors
:
|
|
For CentOS versions that use dnf
, use the command:
|
|
2. Configure the Sensors
After installation, run the sensors-detect
command to configure the sensors. During this process, the system will ask several questions, and you can typically answer “yes” to complete the configuration:
|
|
To automatically confirm all prompts, you can use:
|
|
3. Check CPU Temperature
Once the configuration is complete, you can use the sensors
command to view the CPU temperature and other hardware status:
|
|
Sample Output
|
|
4. Real-Time Monitoring of CPU Temperature
If you need to monitor CPU temperature in real-time, you can use the watch
command in combination with sensors
to regularly update the temperature information. For example, the following command updates the temperature data every 2 seconds:
|
|
Important Notes
- Ensure that your CPU and motherboard support temperature monitoring functionality.
- If
lm_sensors
is unable to read the temperature information, it may be due to missing sensor hardware or driver support. In such cases, refer to the documentation related to your CPU and motherboard, or consider updating the BIOS and kernel to the latest versions.
By following the steps above, you can easily monitor the CPU temperature in your CentOS system, ensuring the stable operation of your server. Regularly checking the hardware status is key to preventing failures and improving system performance. If you encounter any issues, consider consulting relevant documentation or seeking help from the community.