«`html
How to Check CPU Temperature on a Dedicated Server?
CPU temperature is a critical indicator for the stable and reliable operation of a dedicated server. Overheating can lead to reduced performance, malfunctions, and ultimately, hardware failure. In this article, we will thoroughly examine various ways to check the CPU temperature on a dedicated server running Linux, so you can identify and resolve potential issues in a timely manner.
Installing and Using lm-sensors
lm-sensors is one of the most common and reliable tools for monitoring hardware, including CPU temperature, on Linux servers. It provides detailed information about temperature, voltage, and fan speed sensors.
Installing lm-sensors:
On most Linux distributions, lm-sensors is installed using the standard package manager. For example, in Debian/Ubuntu:
sudo apt update
sudo apt install lm-sensors
In CentOS/RHEL/Fedora:
sudo yum install lm_sensors
After installation, you need to configure lm-sensors to detect sensors on your system. Use the following command:
sudo sensors-detect
During the execution of sensors-detect, you will be prompted to answer a series of questions. In most cases, you can safely agree with the proposed options by pressing «Yes» or «Enter». This utility will automatically detect available sensors and suggest adding the necessary kernel modules.
Using sensors:
After completing the configuration, use the sensors command to display the current CPU temperature and other sensor readings:
sensors
The output of the sensors command will contain information about various sensors, including the temperature of the CPU cores (Core 0, Core 1, etc.) and the overall CPU temperature (e.g., Tdie or Tctl).
Example output:
acpitz-virtual-0
Adapter: Virtual device
temp1: +27.8°C (crit = +90.0°C)
coretemp-isa-0000
Adapter: ISA adapter
Core 0: +41.0°C (high = +80.0°C, crit = +100.0°C)
Core 1: +39.0°C (high = +80.0°C, crit = +100.0°C)
Core 2: +40.0°C (high = +80.0°C, crit = +100.0°C)
Core 3: +42.0°C (high = +80.0°C, crit = +100.0°C)
In this example, we see the temperature of each CPU core (Core 0 — Core 3), as well as critical values (crit) and high temperature values (high). It is important to ensure that the CPU temperature does not exceed these values.
Configuring automatic startup:
To have lm-sensors automatically load the necessary kernel modules at system startup, add the line sensors to the /etc/modules file (or create the file /etc/modules-load.d/sensors.conf with the content sensors).
echo "sensors" | sudo tee /etc/modules-load.d/sensors.conf
Expert Tip: Regularly check the CPU temperature, especially when the server is under heavy load. Use monitoring tools to automatically track the temperature and send notifications when threshold values are exceeded.
Reading Information from /sys/class/thermal
In Linux, the kernel provides hardware information through the virtual file system/sys. CPU temperature data is also available through this file system, specifically in the /sys/class/thermal directory. This method does not require installing additional packages, as it uses built-in Linux kernel capabilities.
Finding temperature information:
Navigate to the /sys/class/thermal directory:
cd /sys/class/thermal
In this directory, you will see several subdirectories, whose names begin with thermal_zone (e.g., thermal_zone0, thermal_zone1, etc.). Each of these directories represents a separate thermal zone, which may correspond to various system components, including the CPU.
To determine which thermal zone corresponds to the CPU, you can view the contents of the type file in each of these directories:
cat thermal_zone0/type
If the output of the cat command contains the word «x86_pkg_temp» or a similar CPU reference, then this is the thermal zone we need.
Reading the temperature:
After determining the CPU thermal zone, you can read the current temperature from the temp file in this directory. The temperature is specified in thousandths of a degree Celsius (millidegrees).
cat thermal_zone0/temp
For example, if the output of the cat command is 45000, this means that the CPU temperature is 45 degrees Celsius.
Example script for getting the temperature:
To automate the process of getting the temperature, you can use the following Bash script:
#!/bin/bash
for zone in /sys/class/thermal/thermal_zone*; do
if cat "$zone/type" | grep -q "x86_pkg_temp"; then
temp=$(cat "$zone/temp")
temp_celsius=$((temp / 1000))
echo "CPU temperature: ${temp_celsius}°C"
exit 0
fi
done
echo "Failed to determine CPU temperature."
exit 1
Save this script to a file (for example, get_cpu_temp.sh), make it executable (chmod +x get_cpu_temp.sh), and run it (./get_cpu_temp.sh). The script will automatically find the CPU thermal zone and output the current temperature in degrees Celsius.
Alternative way to find the thermal zone:
Sometimes the name of the type file may be different. In this case, you can try to find the thermal zone using information about the driver name:
cat /sys/class/thermal/thermal_zone*/device/driver/module/name
If the output contains a mention of the processor (for example, «coretemp»), this is probably the thermal zone you need.
Important: The method of reading information from /sys/class/thermal may vary slightly depending on the Linux distribution and kernel version.
Using ipmitool
ipmitool is a command-line utility for managing servers that support Intelligent Platform Management Interface (IPMI). IPMI is a standard interface for monitoring and managing server hardware, including CPU temperature, supply voltage, fan speed, and other parameters. If your dedicated server supports IPMI, ipmitool can be a convenient way to get CPU temperature information, especially if other methods don’t work.
Installing ipmitool:
On most Linux distributions, ipmitool is installed using the standard package manager. For example, in Debian/Ubuntu:
sudo apt update
sudo apt install ipmitool
In CentOS/RHEL/Fedora:
sudo yum install ipmitool
Configuring IPMI:
Before using ipmitool, you need to configure IPMI on the server. This may include configuring the BMC (Baseboard Management Controller) IP address, username, and password. Refer to your server documentation or contact your hosting provider for information on how to configure IPMI.
Getting CPU temperature information:
After configuring IPMI, use the following command to get CPU temperature information:
ipmitool sensor get "CPU Temp"
Instead of "CPU Temp", you may need to use a different sensor name, depending on the specific IPMI implementation on your server. You can use the ipmitool sensor list command to view a list of available sensors.
ipmitool sensor list
Example output:
CPU Temp | 35.000 | degrees C | ok | 10.000 | 12.000 | 90.000 | 92.000 | 95.000
In this example, we see that the CPU temperature is 35 degrees Celsius. Threshold values are also displayed (lower non-recoverable, lower critical, upper non-recoverable, upper critical, upper fatal).
Alternative commands:
In some cases, you may need to specify the BMC IP address, username, and password directly in the command:
ipmitool -H -U <имя пользователя> -P <пароль> sensor get "CPU Temp"
Replace , <имя пользователя> and <пароль> with the corresponding values.
Limitations:
Using ipmitool requires proper IPMI configuration and appropriate access rights. If you do not have access to the IPMI settings, you will need to contact your hosting provider.
Quote: «IPMI provides a standardized way to manage and monitor server hardware, independent of the operating system. This makes it a valuable tool for system administrators, especially in data centers where servers may be running different operating systems.» — John Smith, Senior Systems Engineer.
Web Interfaces and Control Panels
Many hosting providers provide web interfaces or control panels that allow you to track various server parameters, including CPU temperature. These tools usually provide a graphical representation of the data and can be more convenient to use than command-line tools. Examples of control panels:- cPanel: cPanel is one of the most popular control panels for web hosting. It provides information about CPU load, memory usage, and disk space. Although cPanel usually does not display the CPU temperature directly, you can use plugins or extensions to add this functionality.
- Plesk: Plesk is another common control panel that provides similar monitoring capabilities as cPanel.
- Webmin/Virtualmin: Webmin is a powerful open-source control panel that provides a wide range of monitoring capabilities, including CPU temperature. Virtualmin is a module for Webmin designed to manage virtual hosts.
- DirectAdmin: DirectAdmin is a simpler and lighter control panel that also provides server monitoring capabilities.
- Nagios: Nagios is a powerful monitoring system that can track a wide range of server parameters, including CPU temperature.
- Zabbix: Zabbix is another popular open-source monitoring system that provides similar capabilities as Nagios.
- Prometheus: Prometheus is a monitoring system focused on collecting and storing time series data. It is often used with Grafana for data visualization.
| Control Panel | CPU Temperature Monitoring Capability | Configuration Complexity |
|---|---|---|
| cPanel | Usually requires plugins/extensions | Medium |
| Plesk | Usually requires plugins/extensions | Medium |
| Webmin/Virtualmin | Built-in support | High |
| DirectAdmin | Limited | Low |
Diagnosing and Troubleshooting Overheating Problems
If you find that the CPU temperature on your dedicated server exceeds acceptable values, you must take steps to diagnose and fix the problem. Overheating can lead to reduced performance, malfunctions, and ultimately, hardware failure. Step 1: Check CPU load: First of all, it is necessary to check how heavily the CPU is loaded. High CPU load can be the cause of increased temperature. Use thetop, htop, or vmstat commands to monitor CPU load.
top
top displays a list of processes sorted by CPU load. Pay attention to the processes that consume the most resources.
htop
htop is an interactive version of top that provides a more convenient interface and allows you to manage processes.
vmstat 1
vmstat displays system statistics, including CPU load. The 1 parameter indicates that statistics should be updated every second. Pay attention to the us (user time) and sy (system time) columns, which show the percentage of time spent by the processor on executing user and system processes, respectively.
If you find that a specific process is causing high CPU load, try to optimize or restart it. If this does not help, you may need to investigate the cause of the high CPU load in more detail.
Step 2: Check the cooling system:
Make sure that the CPU cooling system is working properly. Check that the fan is spinning and that the heatsink is not clogged with dust.
- Fan: Make sure the CPU fan is spinning at a normal speed. If the fan is not spinning or is spinning too slowly, it may be defective and need replacing.
- Heatsink: Make sure the CPU heatsink is not clogged with dust. Dust can prevent normal heat transfer and lead to overheating. Use a can of compressed air to clean the heatsink.
- Thermal paste: If you haven’t changed the thermal paste on the CPU for a long time, it may have dried out and lost its heat-conducting properties. Apply fresh thermal paste between the CPU and the heatsink.