While I am waiting for sensors to arrive, I wanted to check if the current pc is stable and that it is running cool enough, so I installed http://openhardwaremonitor.org which publishes all sensor data to WMI, which we can read with PHP. I've created a simple script getPcData in the system that looks like this
СпойлерПоказать
Код: Выделить всё
$wmi = new COM('winmgmts://./root/OpenHardwareMonitor');
$result = $wmi->ExecQuery("SELECT * FROM Sensor");
foreach($result as $obj){
if($obj->SensorType == 'Temperature' && strpos($obj->Parent, 'cpu') > 0){
//echo "$obj->Name ($obj->Value C)"; // output cpu core temp
sg('serverPC.temp', $obj->Value);
callMethod('serverPC.tempChanged');
say('temp is ' . $obj->Value);
}else{
// echo 'skipping ' . $obj->Identifier ;
// echo '<br />';
}
}
I've added a new menu in the system with Server %serverPC.temp% C (%serverPC.updatedTime%) and it works great, shows the PC temperature.
It updates when I call the script via http://site/objects/?script=getPcData
Now the problem is as I want to run it on for example every minute. How do I do this? Do I have to add script in ClockChime.onNewMinute or is there more elegant way to do this?
Also, even when I run the script manually every minute I do not get the graph to display history. I use this code for the graph
Код: Выделить всё
<img src="/pChart/?p=serverPC.temp&type=30m&width=280">
the graph always shows 51C +- 1C, like this
How to activate the graph? How to call the script every minute on most "correct" way? Any optimization to the setup above?
If someone has already solved this please send me the link to the topic, I do not know what to search for.
Also feel free to translate the topic in russian if you find the script useful.