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
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¶m=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);
?>
grtz