Just to clarify for the people, before someone says it's not working.
sensors outputs something like this, depending on the motherboard and settings:
it8712-isa-0290 Adapter: ISA adapter VCore 1: +1.52 V (min = +1.42 V, max = +1.57 V) VCore 2: +2.54 V (min = +2.40 V, max = +2.61 V) +3.3V: +3.23 V (min = +3.14 V, max = +3.47 V) +5V: +4.11 V (min = +4.76 V, max = +5.24 V) ALARM +12V: +12.29 V (min = +11.39 V, max = +12.61 V) -12V: -16.19 V (min = -12.63 V, max = -11.41 V) ALARM -5V: -8.17 V (min = -5.26 V, max = -4.77 V) ALARM Stdby: +3.95 V (min = +4.76 V, max = +5.24 V) ALARM VBat: +4.08 V M/B Temp1: +25 C (low = +15 C, high = +40 C) sensor = thermistor M/B Temp2: +26 C (low = +15 C, high = +45 C) sensor = thermistor CPU Temp: +34 C (low = +15 C, high = +65 C) sensor = diode
The line in bold is what we need, so for this example above, the code must be changed like this:
Code: Select all
function getTemperature()
{
$te = shell_exec( 'sensors' );
$tem = explode("CPU Temp:",$te);
$tempe = explode("C",$tem[1]);
return( $tempe[0] );
}
So one has to find the words before the reported cpu temperature and replace them in the code above. lm_sensors configuration file offers a lot of nice things also.