Last active
January 5, 2017 13:06
-
-
Save wwng2333/069a5efa267df95e1c4c34580ed912e6 to your computer and use it in GitHub Desktop.
获取CPU温度
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$cmd = 'sensors'; | |
exec($cmd,$result); | |
$arr = array(); | |
for($i=0;$i<count($result);$i++) { | |
$linenow = $result[$i]; | |
while(strstr($linenow,' ')) { | |
$linenow = str_replace(' ','',$linenow); //去空格 | |
} | |
if(strstr($linenow,'Core')) { | |
$temp = explode('(',$linenow); | |
$temp = explode(': ',$temp[0]); | |
$name = $temp[0]; | |
$val = $temp[1]; | |
$arr[$name] = $val; | |
} else { | |
continue; | |
} | |
echo json_encode($arr); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment