Article sections

    Source : https://linuxconfig.org/how-to-monitor-a-cpu-temperature-on-redhat-7-linux-system

    Here is a short config to show you how to display and monitor CPU temperature on a Linux system running Redhat 7 Linux. First we need to install lm_sensors:

    # yum install lm_sensors
    

    Next, use sensors command to display CPU temperature:

    $ sensors | grep Core
    Core 0:         +43.0°C  (high = +86.0°C, crit = +100.0°C)
    Core 1:         +43.0°C  (high = +86.0°C, crit = +100.0°C)
    

    If you prefer to convert Celsius to Fahrenheit simply add -f option:

    $ sensors -f | grep Core
    Core 0:        +111.2°F  (high = +186.8°F, crit = +212.0°F)
    Core 1:        +111.2°F  (high = +186.8°F, crit = +212.0°F)
    

    To monitor continuously CPU temperature combine the above command with watch command. The next example will update sensors output every second:

    $ watch -n 1 "sensors -f | grep Core"

    Monitor CPU temperature on Redhat 7 Linux To put all together a simple bash script can be created to act upon a preset temperature value. Combine the below script with cron eg.:

    */5 * * * * /path/to/your/script/CPU-temperature-script.sh 
    

    and it will check first CPU ( core 0 )temperature every 5 minutes and act when the CPU temperature reaches 80 and more degrees.

    #!/bin/bash
    
    TEMPERATURE=$(sensors | grep "Core 0" | cut -d + -f 2 | cut -d . -f1)
    
    if [ $TEMPERATURE -ge 80 ]; then
    	echo "Do something here"
    fi
    
    in cPanel & WHM ServerLinux Commands