1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
if (isset($_GET['cmd']))
$cmd = $_GET['cmd'];
else
$cmd = "t";
if ($cmd=="t"){
$t_cpu = file_get_contents("/tmp/core_temp");
$t_10389 = "";
$t_sda = "";
$t_sdb = "";
$temp1_input = "/sys/devices/soc0/amba@0/e0004000.ps7-i2c/i2c-0/0-001a/hwmon/hwmon0/temp1_input";
if (is_file($temp1_input)){
$t_10389 = trim(file_get_contents($temp1_input));
$t_10389 = intval($t_10389)/1000;
}
$t_sda = exec("smartctl -A /dev/sda | egrep ^194 | awk '{print $10}'");
if ($t_sda=="") $t_sda = "-";
else $t_sda = intval($t_sda);
$t_sdb = exec("smartctl -A /dev/sdb | egrep ^194 | awk '{print $10}'");
if ($t_sdb=="") $t_sdb = "-";
else $t_sdb = intval($t_sdb);
echo "$t_cpu $t_10389 $t_sda $t_sdb";
}
if ($cmd=="read"){
echo file_get_contents("/tmp/core_temp_params");
}
if ($cmd=="write"){
$cstr = "";
foreach($_GET as $key => $val){
if(strpos($key,"temp")===0){
$cstr .= "$key:$val\n";
}
}
file_put_contents("/tmp/core_temp_params",$cstr);
echo "$cstr";
}
?>