Mybook live monitoring

In this subforum you can show projects you have made, or you are busy with. Please create your own topic.

Moderator: leecollings

Post Reply
rfvdboom
Posts: 40
Joined: Tuesday 20 September 2016 8:32
Target OS: Raspberry Pi / ODroid
Domoticz version: 2023.2
Location: Netherlands
Contact:

Mybook live monitoring

Post by rfvdboom »

Hi,

i was trying to use SNMP on my WD Mbooklive to monitor my NAS. SNMP was not working for me, so i've used another solution.

Make a script on your mybook. I put my scipt in /shares/Public/WWW/mybook/

Code: Select all

#!/bin/sh


#
#timenow=`date +%x\ %X`
memfree=`cat /proc/meminfo | grep MemFree:`
temp=`/usr/sbin/smartctl -d ata -A /dev/sda | grep Temperature | cut -d ' ' -f37`
#upusers=`uptime`
#totalon=`/usr/sbin/smartctl -d ata -A /dev/sda | grep Power_On | cut -d ' ' -f44`
disk=`df -H | grep -vE '^Filesystem|tmpfs|cdrom'`
rm ../shares/Public/WWW/mybook/mybook.log
echo $timenow $memfree $temp $disk>>../shares/Public/WWW/mybook/mybook.log
Then use cronjob to execute the script every 15 minutes (or whatever u want).

In domoticz make virtual dummies:
1 for the memory: counter (#56 in php scripts below)
1 for the temp: temperature (#55 in php scripts below)
1 for the disc usage: counter (#58 in php scripts below)
1 for the disc space: counter% (#57 in php scripts below)
If you also use "upusers" and/or ""totalon" you have to make more sensors.

Then make a php script of your "Domoticz" device (mine is Raspberry)

Code: Select all

<?php

$i = 0;

do {

$lines = array();

foreach (file('http://login:paswoord@ipofnas:port/Public/WWW/mybook/mybook.log') as $line) {
 //the log fil on your mybook
$parts = explode(' ', $line);

$lines[] = array(

'memory' => $parts[1],
'temp' => $parts[3],
'Disc usage' => $parts[19],
'Disc space' => $parts[20]

);
}

$domoticz = "http://ipofdomoticz:port/json.htm?type=command&param=udevice&idx=";

if ($parts[1] > 0) file_get_contents($domoticz."56&nvalue=0&svalue=".ltrim($parts[1], 'MemFree: ')."");
echo date('H:i:s')." memory updated".$parts[1]."\r\n";

if ($parts[3] > 0) file_get_contents($domoticz."55&nvalue=0&svalue=".$parts[3]."");
echo date('H:i:s')." Temp updated ".$parts[3]."\r\n";

if ($parts[19] > 0) file_get_contents($domoticz."58&nvalue=0&svalue=".rtrim($parts[19], 'G')."");
echo date('H:i:s')." disc usage updated".$parts[19]."\r\n";

if ($parts[20] > 0) file_get_contents($domoticz."57&nvalue=0&svalue=".rtrim($parts[20], '%')."");
echo date('H:i:s')." disc space updated".$parts[20]."\r\n";

printf('<pre>%s</pre>', print_r($lines, true));

sleep (900);

} 
while ($i = -1);

?>
That it. It's a simple way to monitor your mybook. In domoticz you can use the notifaction funtion. Example when your NAS is to HOT.

grtz
Odroid N2+ | Raspberry P 3 ModelB | RFXcom | AEOTEC Zwave | Honeywell Lyric T6| Milight | Milighthub (NodeMCU) | SolarEdge | P1 Smart meter USB | KAKU | Wemos D1 (esphome) | Denon | Logitech Harmony
Post Reply