Temperature of the MajorDoMo server

Project discussion/ideas in English
Ответить
dakipro
Сообщения: 8
Зарегистрирован: Вс ноя 08, 2015 8:07 pm
Благодарил (а): 1 раз
Поблагодарили: 0

Temperature of the MajorDoMo server

Сообщение dakipro » Вс ноя 15, 2015 2:48 am

Hi,
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 also added a new object named serverPC under the temp sensors, and it is updated fine by the script.
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"> 
Type: HTML
the graph always shows 51C +- 1C, like this
Skjermbilde 2015-11-15 00.44.13.png
Temp Graph
Skjermbilde 2015-11-15 00.44.13.png (82.37 КБ) 11808 просмотров

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.
Аватара пользователя
nick7zmail
Сообщения: 7573
Зарегистрирован: Пн окт 28, 2013 8:14 am
Откуда: Екатеринбург
Благодарил (а): 121 раз
Поблагодарили: 2010 раз

Re: Temperature of the MajorDoMo server

Сообщение nick7zmail » Вс ноя 15, 2015 11:28 am

Set the properties of the class - save history.
Вложения
111.jpg
111.jpg (31.73 КБ) 11784 просмотра
За это сообщение автора nick7zmail поблагодарил:
dakipro (Вс ноя 15, 2015 12:06 pm)
Рейтинг: 1.16%
Raspberry Pi3+Broadlink+esp8266 (blynk)+AMS
Если вам помогло какое-либо сообщение - не забывайте пользоваться кнопкой "СПАСИБО".
:arrow: Услуги в профиле коннект
>>>>>Мой новый канал на ютутбе, подписывайтесь!<<<<<
dakipro
Сообщения: 8
Зарегистрирован: Вс ноя 08, 2015 8:07 pm
Благодарил (а): 1 раз
Поблагодарили: 0

Re: Temperature of the MajorDoMo server

Сообщение dakipro » Вс ноя 15, 2015 11:59 am

Than you for reply, it is already set to 7 by default on the master class
Skjermbilde 2015-11-15 09.58.40.png
Skjermbilde 2015-11-15 09.58.40.png (19.52 КБ) 11781 просмотр
Аватара пользователя
nick7zmail
Сообщения: 7573
Зарегистрирован: Пн окт 28, 2013 8:14 am
Откуда: Екатеринбург
Благодарил (а): 121 раз
Поблагодарили: 2010 раз

Re: Temperature of the MajorDoMo server

Сообщение nick7zmail » Вс ноя 15, 2015 12:18 pm

dakipro писал(а):

Код: Выделить всё

<img src="/pChart/?p=serverPC.temp&type=30m&width=280"> 
Try something like this

Код: Выделить всё

<img src="/pChart/?p=serverPC.temp&unit=°C&type=8d&width=250&height=150&gcolor=blue&scale=zero&px=10&title=serverPC"> 
That's code is working.
Raspberry Pi3+Broadlink+esp8266 (blynk)+AMS
Если вам помогло какое-либо сообщение - не забывайте пользоваться кнопкой "СПАСИБО".
:arrow: Услуги в профиле коннект
>>>>>Мой новый канал на ютутбе, подписывайтесь!<<<<<
dakipro
Сообщения: 8
Зарегистрирован: Вс ноя 08, 2015 8:07 pm
Благодарил (а): 1 раз
Поблагодарили: 0

Re: Temperature of the MajorDoMo server

Сообщение dakipro » Вс ноя 15, 2015 12:28 pm

It looks better now, but still no history of the data.
Screenshot 2015-11-15 10.27.01.png
Screenshot 2015-11-15 10.27.01.png (89.91 КБ) 11772 просмотра

I am suspecting that code in the script is not quite right, is this the right way to store temperature?

Код: Выделить всё

sg('serverPC.temp', $obj->Value);
callMethod('serverPC.tempChanged'); 
I tried looking at the demo, I see now that it is temporarily disabled. Is there some detailed API documentation/cheatsheet?
I see examples on the website and forum, but is there one centralized technical documentation on how to do things?
dakipro
Сообщения: 8
Зарегистрирован: Вс ноя 08, 2015 8:07 pm
Благодарил (а): 1 раз
Поблагодарили: 0

Re: Temperature of the MajorDoMo server

Сообщение dakipro » Вс ноя 15, 2015 5:14 pm

I've changed type=8d to type=8h and now data appears nice (I also removed &scale=zero).
I've also called the script inside the onNewMinute for now, until i figure out better way to schedule a script

Thanks for the help!
Аватара пользователя
nick7zmail
Сообщения: 7573
Зарегистрирован: Пн окт 28, 2013 8:14 am
Откуда: Екатеринбург
Благодарил (а): 121 раз
Поблагодарили: 2010 раз

Re: Temperature of the MajorDoMo server

Сообщение nick7zmail » Вс ноя 15, 2015 6:58 pm

dakipro писал(а):I've changed type=8d to type=8h
its time period 8d - 8 days, 8h - 8 hours
Raspberry Pi3+Broadlink+esp8266 (blynk)+AMS
Если вам помогло какое-либо сообщение - не забывайте пользоваться кнопкой "СПАСИБО".
:arrow: Услуги в профиле коннект
>>>>>Мой новый канал на ютутбе, подписывайтесь!<<<<<
Ответить