Remote temperature monitoring of MyBook World Edition II

whitebox

Distinguished
Jan 15, 2010
34
0
18,530
My Western Digital MyBook World Edition II (so white lights version) is remotely located in a place that *may* prove to be a little on the warm side. Of course I can buy a cheap and cheerful wireless thermometer and rest the probe on the top of the MyBook case. This would allow me to monitor the air temperature from the comfort of my office.

What I really want to do though is take advantage of S.M.A.R.T. and monitor the temperatures of the two MyBook HDDs remotely via the network.

I cannot however find any software to do this that doesn't look like being a science project to understand and install.

If you know of something that will do this and which is free or inexpensive, please kindly share it!

Thank you!
 

whitebox

Distinguished
Jan 15, 2010
34
0
18,530
Many thanks, but like all the other applications that I've found that are not the aforementioned science kit to implement, it only detects the HDDs on my PC, not those of the MyBook hanging off the gigabit network. If I've missed a trick rather than CPU-Z Hardware Manager (nee Monitor) not doing what I need, please explain what I need to do for it to work. Cheers.
 

whitebox

Distinguished
Jan 15, 2010
34
0
18,530
The silence is deafening so it seems there isn't an easy answer. I have therefore purchased a couple of low cost digital thermometers; one placed directly on top of the MyBook and the other on the shelf next to it. For the record the former typically shows 37 deg C, so I presume the HDDs are probably in the high forties to low fifties. This is fine by me.
 

Tony_77

Distinguished
Mar 1, 2010
28
0
18,530
Here is a script to get the disk activity, disk temperature(s), and the fan speed for the Western Digitial myBook World Edition II. Enjoy!

#!/bin/sh
# Get disk drive activity, disk temperature, and fan speed
# for the WD myBook World Edition II
#
# Identify the two Disks for the WD MB WE II
DISKS="/dev/sda /dev/sdb"
# Identify the file controlling the WDC fan and speed
FAN_DEVICE=/sys/devices/platform/wdc-fan
FAN_SPEED=$FAN_DEVICE/speed
# Location of the hdparm and smartctl utilities to be used
# hdparm version 7.7 is known to work properly on the MBWE
# see http://kyyhkynen.net/stuff/mybook/spindown.php
HDPARM=/sbin/hdparm
SMARTCTL=/usr/sbin/smartctl
for D in $DISKS
do
$HDPARM -C $D
if [ $? -le 1 ] ; then
printf " %s is: %s\n" \
$($SMARTCTL -d ata -A $D\
|grep Temperature\
|cut -c 5-28,88- )
fi
done
echo ""
echo "Current fan speed (percent): `cat ${FAN_SPEED}`"
echo ""
exit
 

whitebox

Distinguished
Jan 15, 2010
34
0
18,530
So tantalisingly close I feel...

Presuming that I need to use SSH I enabled this option via MyBook admin and then connected as root/welc0me using PuTTY.

Copying the script to the clipboard, pasting it to Notepad (to strip out anything other than raw text), and then copying and pasting it again in to the PuTTY console generates the following errors:

~ # #!/bin/sh
~ # # Get disk drive activity, disk temperature, and fan speed
~ # # for the WD myBook World Edition II
~ # #
~ # # Identify the two Disks for the WD MB WE II
~ # DISKS="/dev/sda /dev/sdb"
~ # # Identify the file controlling the WDC fan and speed
~ # FAN_DEVICE=/sys/devices/platform/wdc-fan
~ # FAN_SPEED=$FAN_DEVICE/speed
~ # # Location of the hdparm and smartctl utilities to be used
~ # # hdparm version 7.7 is known to work properly on the MBWE
~ # # see http://kyyhkynen.net/stuff/mybook/spindown.php
~ # HDPARM=/sbin/hdparm
~ # SMARTCTL=/usr/sbin/smartctl
~ # for D in $DISKS
> do
> $HDPARM -C $D
> if [ $? -le 1 ] ; then
> printf " %s is: %s\n" \
> $($SMARTCTL -d ata -A $D\
> |grep Temperature\
-sh: Syntax error: "|" unexpected
~ # |cut -c 5-28,88- )
-sh: Syntax error: "|" unexpected
~ # fi
-sh: Syntax error: "fi" unexpected
~ # done
-sh: Syntax error: "done" unexpected
~ # echo ""
echo "Current fan speed (percent): `cat ${FAN_SPEED}`"
echo ""
~ # echo "Current fan speed (percent): `cat ${FAN_SPEED}`"
cat: /sys/devices/platform/wdc-fan/speed: No such file or directory
Current fan speed (percent):
~ # echo ""


Whilst I follow some of the syntax from having seen Unix in a past life (I am not a software engineer!) I don't have enough knowledge to fix the problems myself, so if you can point me in the right direction I'd appreciate it please Tony_77.

Even better if having debugged the script I can then learn how to save it to the MyBook and re-run it on demand.

Many thanks!
 

whitebox

Distinguished
Jan 15, 2010
34
0
18,530
Guessing that the pipe symbols ( | ) are concatenators, I moved them on to the same line.

The script now runs but fails with:

-sh: /sbin/hdparm: Permission denied
 

whitebox

Distinguished
Jan 15, 2010
34
0
18,530
I have now replaced $HDPARM -C $D explicitly with hdparm -C $D having first done cd /sbin before pasting and executing the script, and also move "done" to the end :)

i.e.

cd /sbin

and then:

DISKS="/dev/sda /dev/sdb"
FAN_DEVICE=/sys/devices/platform/wdc-fan
FAN_SPEED=$FAN_DEVICE/speed
SMARTCTL=/usr/sbin/smartctl
for D in $DISKS
do
hdparm -C $D
if [ $? -le 1 ] ; then
printf " %s is: %s\n" \
$($SMARTCTL -d ata -A $D\ |grep Temperature\ |cut -c 5-28,88- )
fi
echo ""
echo "Current fan speed (percent): `cat ${FAN_SPEED}`"
echo ""
done

The script now runs but only tells me the drive state (active/idle) before then complaining that printf cannot be found and neither can wdc-fan. Sure enough, neither do exist.

Has this script actually been used before to show HDD temperatures on a MyBook WE II (WHITE lights, not blue) or is it a guess?

 

Tony_77

Distinguished
Mar 1, 2010
28
0
18,530
This script runs on my "Blue Ring" version of the WD MBWE. I needed to install hdparm version 7.7 to make this work (I had to download and compile it on the MBWE - very easy to do). This is the output I get on my MBWE: (I call the macro mbstat.sh)

MyBook01 login: root
Password:
[root@MyBook01 ~]# sh mbstat.sh

/dev/sda:
drive state is: active/idle
Temperature_Celsius is: 47

/dev/sdb:
drive state is: active/idle
Temperature_Celsius is: 50

Current fan speed (percent): 50

[root@MyBook01 ~]# exit

Sorry about the confusion regarding the macro. I simply cut/paste it into this blog and the blog messed up the formatting. Looks like you figured it out.
 

Tony_77

Distinguished
Mar 1, 2010
28
0
18,530
BTW the "|" symbols are "pipes" - used to splice output of one program to the input of another. The "\" are for continuation lines and need to be removed when combining lines together.

... Tony
 

Tony_77

Distinguished
Mar 1, 2010
28
0
18,530
BTW: If you have the WD "White Lights" edition or applied the latest firmware upgrade for the Blue Ring edition, you will need to download and install the components that WD has choosen to lobotomize.

See: http://mybookworld.wikidot.com/

... Tony
 

Tony_77

Distinguished
Mar 1, 2010
28
0
18,530
A couple of other hints:

1. Install WinSCP onto your PC (see: http://sourceforge.net/projects/winscp/ for the free download). This makes getting around the MBWE file system a lot easier and will allow you to do SCP "secure" uploads and downloads - albeit fairly slow (the MBWE uses a fairly slow processor so the encryption really slows file transfers when you use SCP).

2. Browse (look but don't touch unless you really know linux shell scripting) the startup script files in the \etc\init.d directory. These will show you where WD has hidden things like hdparm and smartdrv and the wdc fan controller etc...

3. Have fun. I have installed things like VSFTPD onto my MBWE, enabled the secure FTP, and integrated this with the Windows (Samba) share areas. I can use things like FileZilla ( see: http://filezilla-project.org/ ) to do secure FTP uploads and downloads from anywhere anywhere in the world. Great way to send digital pictures from your camera to your now secure filer and to download media (things like digitized movies .avi, .wmv. mp4. etc ) to your netbook or pocket PC when you are travelling (remember that MIONET doesn't allow .jpeg,s, avi's, .mp3's, .mp4's, .wmv's, etc.).
 

whitebox

Distinguished
Jan 15, 2010
34
0
18,530
Thanks very much Tony.
Much appreciated.

It's late and I've had a enough beers to screw things up if I dabble now, so I'll do so over the weekend instead if the kids give me some breathing space.

Stay tuned!
 

Tony_77

Distinguished
Mar 1, 2010
28
0
18,530
I did a little more testing of the temp monitor script I posted to this blog, so I cut the temp monitor script from this blog and pasted it back into my WD MBWE (Blue Rings) as a file under the \root directory calling it mbstat2.sh

I then executed the script file using the command "sh mbstat2.sh" and things worked perfectly - so this blog's version of the script is really OK other than the non-indented formatting. This script is meant to be saved as a file and "executed" by the Linux shell via the "sh" command in order to run it.

If you so choose, you can make the script file executable using the "chmod +x" command and place the script somewhere into the PATH. Then you won't need to use the "sh" command - you can just run the script directly.

My WD MBWE II is the Blue Rings edition and I am running firmware 02.00.19 - the most recent for this edition. When I applied this latest firmware update, I discovered that WD had lobotomized the Linux that was installed on the MBWE and I had to recover what they removed. There are tutorials on http://mybookworld.wikidot.com/ on how to do this.

Unfortunately, I don't have access to a "White Lights" version of the MBWE. Wish I did, it's processor is twice as fast as the "Blue Rings" and it has four times the internal memory. I would be able to do a lot more neat stuff with it. So I can't give you much help with how to configure the script for "White Lights".

Having said this, I suspect that both the hdparm program and the smartdrv program are installed somewhere on the White Lights edition. All you should have to do is set the FAN_DEVICE, FAN_SPEED, HDPARM, and SMARTCTL script variables to the appropriate locations and you would be good to go! By examining the startup files in the /etc/init.d directory, you should be able to find out where WD "hid" these things in the "White Lights" version.

The Linux command "type" can be used to locate files in the search PATH. ie: "type hdparm" to locate hdparm ... etc. I have attached an example of how to do this.

The printf, grep, and cut programs are very standard Linux programs and I can't imagine that WD lobotomized those on the "White Lights" edition. It just could be that the PATH variable is not being set properly for the root account and that the shell simply can't find these very standard Linux programs. You need to do a little research on this. Try a command like "printf --help" to see if the shell can find it, "usage" information should be returned.

Example follows:

MyBook01 login: root
Password:
[root@MyBook01 ~]# type printf
printf is a shell builtin
[root@MyBook01 ~]# type grep
grep is /bin/grep
[root@MyBook01 ~]# type cut
cut is /usr/bin/cut
[root@MyBook01 ~]# type hdparm
hdparm is /sbin/hdparm
[root@MyBook01 ~]# type smartctl
smartctl is /usr/sbin/smartctl
[root@MyBook01 ~]# exit
logout

Hope this helps. I wish WD wouldn't be so anal-retentive when it comes to the MBWE. This NAS has real possibilities.

... Tony
 

Tony_77

Distinguished
Mar 1, 2010
28
0
18,530
More tips:

1. To get files into the your directory (such as the temp monitor script) you can use the command "cat >filename" where filename is the name of the file you want to create. You need to "cd" into the directory you want first. You "cut/paste" the text from notepad into your PuTTY terminal session and the lines will be written to the file. When the paste is finished, type a CONTROL-D to indicate end-of-file and the "cat" program will exit. If you mess up you can remove the file with a "rm filename".

2. Better yet install WinSCP on your PC. You can drag and drop files wherever you want onto your MBWE. WinSCP has a built-in editor so you can edit directly on the MBWE. You can also quickly look at the startup script files in the \etc\init.d directory. WinSCP also handles the Linux <-> Windows text conversions for end-of-line control characters.

3. WinSCP has a very handy Terminal Window built-in where you can run a single command and get the answer back. This is a great place to execute the temp monitor script. The output fits very nicely into the WinSCP Terminal Window and there is no other clutter. WinSCP can also hand-off to PuTTY.

4. Because the MBWE is a filer, you can simply open your MBWE folder in Windows and drag files to it (even Linux script files). The files end up in this directory: \shares\internal\<your user name>\<your folder> where "<your user name>" is your userid on the MBWE and "<your folder>" is where you dragged the file to. You can use the "cp" command (the Linux copy command) or the "mv" command (the Linux move command) to move the files where you want them to end up.

Hope this helps.

... Tony
 

whitebox

Distinguished
Jan 15, 2010
34
0
18,530
The kids are in bed so I've made a faster start than I expected to. Thanks for the tip, Tony: WinSCP is brilliant! :) So much faster than navigating around in a command console and using clunky old vi (which is how I previously edited /usr/mionet/monitorCVM.sh to stop Mionet restarting every 15 minutes despite being disabled in the admin console)

Turning to my missing applets, this is what I found:

/$ cd /
/$ type wdc-fan
wdc-fan: not found
/$ wdc-fan --help
-sh: wdc-fan: not found
/$ type printf
printf: not found
/$ printf --help
-sh: printf: not found

I am therefore sure they are not installed rather than installed but in an obscure place.
I took a long walk around http://mybookworld.wikidot.com/ but cannot find the tutorial you refer to for me to install them, probably because I am searching on inappropriate guesses. If you can point me a little more closely that would be great, thank you!

 

Tony_77

Distinguished
Mar 1, 2010
28
0
18,530
I assume you were able to verify the existence of the hdparm, smartctl, grep, and cut program.

Now that you have WinSCP, if you haven't discovered it yet - WinSCP has a "Find Files" function on the toolbar which can scan the entire disk farm if need be. You can search for "printf" this way.

Now on my Blue Rings MBWE the printf program is built into the shell.
It is also installed in \usr\bin .

We should find out if printf is built into the white lights version of the MBWE. Use the command "sh - c help" to find out what is built-in.

Use the WinSCP "Find Files" function to see if it exists anywhere.

Use the command "echo $PATH" to see if \usr\bin (or where-ever the white-lights version of printf is located) is indeed on the search path for programs.

Let us know what you find, and we'll go from there.

On my MBWE (Blue Rings), I get: (you can see printf in the list of programs)

MyBook01 login: root
Password:
[root@MyBook01 ~]# sh -c help
GNU bash, version 3.1.17(1)-release (arm-unknown-linux-gnu)
These shell commands are defined internally. Type `help' to see this lis
Type `help name' to find out more about the function `name'.
Use `info bash' to find out more about the shell in general.
Use `man -k' or `info' to find out more about commands not in this list.

A star (*) next to a name means that the command is disabled.

JOB_SPEC [&] (( expression ))
. filename [arguments] :
[ arg... ] [[ expression ]]
alias [-p] [name[=value] ... ] bind [-lpvsPVS] [-m keymap] [-f fi
break [n] builtin [shell-builtin [arg ...]]
caller [EXPR] case WORD in [PATTERN [| PATTERN].
cd [-L|-P] [dir] command [-pVv] command [arg ...]
compgen [-abcdefgjksuv] [-o option complete [-abcdefgjksuv] [-pr] [-o
continue [n] declare [-afFirtx] [-p] [name[=val
dirs [-clpv] [+N] [-N] echo [-neE] [arg ...]
enable [-pnds] [-a] [-f filename] eval [arg ...]
exec [-cl] [-a name] file [redirec exit [n]
export [-nf] [name[=value] ...] or false
fc [-e ename] [-nlr] [first] [last for NAME [in WORDS ... ;] do COMMA
for (( exp1; exp2; exp3 )); do COM function NAME { COMMANDS ; } or NA
getopts optstring name [arg] hash [-lr] [-p pathname] [-dt] [na
help [-s] [pattern ...] history [-c] [-d offset] [n] or hi
if COMMANDS; then COMMANDS; [ elif kill [-s sigspec | -n signum | -si
let arg [arg ...] local name[=value] ...
logout popd [+N | -N] [-n]
printf [-v var] format [arguments] pushd [dir | +N | -N] [-n]
pwd [-LP] read [-ers] [-u fd] [-t timeout] [
readonly [-af] [name[=value] ...] return [n]
select NAME [in WORDS ... ;] do CO set [--abefhkmnptuvxBCHP] [-o opti
shift [n] shopt [-pqsu] [-o long-option] opt
source filename [arguments] test [expr]
time [-p] PIPELINE times
trap [-lp] [arg signal_spec ...] true
type [-afptP] name [name ...] typeset [-afFirtx] [-p] name[=valu
ulimit [-SHacdfilmnpqstuvx] [limit umask [-p] [-S] [mode]
unalias [-a] name [name ...] unset [-f] [-v] [name ...]
until COMMANDS; do COMMANDS; done variables - Some variable names an
wait [n] while COMMANDS; do COMMANDS; done
{ COMMANDS ; }


[root@MyBook01 ~]#


AND on my MBWE (Blue Rings), I get: (you can see :/usr/bin: in the list)


[root@MyBook01 ~]# echo $PATH
/bin:/sbin:/usr/bin:/usr/sbin:/usr/bin/X11:/usr/local/bin:/opt/bin:.
[root@MyBook01 ~]#


 

whitebox

Distinguished
Jan 15, 2010
34
0
18,530
Hi Tony,

Thanks for such commitment to helping me.
I am amazed!

This is what "echo $PATH" returns: /usr/bin:/bin:/usr/sbin:/sbin
Unfortunately "sh - c help" fails with "Can't open c"
Using "find files" on the root folder, printf is nowhere to be found

Off to bed now before I get shot! :)

Cheers!
 

Tony_77

Distinguished
Mar 1, 2010
28
0
18,530
Wow! I can't believe how much lobotomy WD has done to the MBWE since the initial release of the Blue Rings edition. I guess they figured that folks were just having to much fun adding functionality to it. My blessings to WD: "May the front lawns of the WD headquarters be fertilized by the dung from one million North American Bison - every other day."

I checked http://mybookworld.wikidot.com/ on how to recover programs lobotomized by WD. Turns out the recovery is only for the Blue Rings edition and I wouldn't recommend trying it on the White Lights edition.

But, I am still undaunted. We have a couple of choices here:

1. I can make the printf program from the Blue Rings edition of the WD MBWE available to you and you can simply FTP it onto your MBWE. Since both editions of the MBWE use the processor from Oxford Semiconductor, that should work.

2. If WD hasn't removed gcc (the "C" compiler), you can download the printf source and make files and compile it back onto your MBWE by using your MBWE - the poetic justice solution. Use the command "type gcc" to see if the MBWE shell can find gcc? (But I suspect WD lobotimized that as well. Did I say 1 million Bison, I meant 2 million Bison and every day!)

3. Use the reworked script that follows. I have removed the requirement for printf - the whole thing relies on using the echo command - not very elegant but what the hey! The script now checks to see if the wdc-fan device can be found where expected. The fan speed only displays if it can be found. You will need to update the HDPARM and the SMARTCTL variables to the location of where these programs are installed on your MBWE white lights edition. The "type hdparm" and "type smartdrv" commands should give you this information. Remember that Linux is case-sensitive.

I have called the reworked script mbstat.sh and copied it into the /root directory of my MBWE from where I run it from the root account as follows:

[root@MyBook01 ~]# sh mbstat.sh

Date: Fri Mar 12 23:10:47 PDT 2010
uptime: 13 days, 23:47 hours
load average: 0.00, 0.00, 0.00

/dev/sda:
drive state is: active/idle
Temperature_Celsius is: 52

/dev/sdb:
drive state is: active/idle
Temperature_Celsius is: 54

Current fan speed (percent): 0

[root@MyBook01 ~]#

(I added the Date:, uptime:, and load average. You will need to check for the existence of the date and uptime programs by using the "type" command (ie: "type date" and "type uptime"). If they have been lobotomized by WD, just comment out the corresponding echo commands in the script.)

The reworked script (mbstat.sh) follows:

#!/bin/sh
# Get disk drive activity, disk temperature, and fan speed
# for the WD myBook World Edition II (Blue Rings)
#
# Identify the two Disks for the WD MB WE II:
DISKS="/dev/sda /dev/sdb"
# Identify the file controlling the WDC fan and speed:
FAN_DEVICE=/sys/devices/platform/wdc-fan
FAN_SPEED=$FAN_DEVICE/speed
# Location of the hdparm and smartctl utilities to be used:
HDPARM=/sbin/hdparm
SMARTCTL=/usr/sbin/smartctl
# note: hdparm version 7.7 is known to work properly on the MBWE
# see http://kyyhkynen.net/stuff/mybook/spindown.php
# The following tag is used to identify the line within
# the attributes returned by SMARTCTL in order to get
# the internal HD temperature readings.
THE_TEMP="Temperature_Celsius"
echo ""
echo "Date: `date`"
echo " uptime:`uptime | cut -d, -f1-2 | cut -c13-` hours"
echo "`uptime | cut -d, -f4-6`"
for D in $DISKS
do
$HDPARM -C $D
if [ $? -le 1 ] ; then
echo " $THE_TEMP is: `$SMARTCTL -d ata -A $D \
|grep "$THE_TEMP" | cut -c88-`"
fi
done
if test -r "$FAN_SPEED" ; then
echo ""
echo "Current fan speed (percent): `cat ${FAN_SPEED}`"
fi
echo ""
exit

 

Tony_77

Distinguished
Mar 1, 2010
28
0
18,530
A couple of places to look for things:

On my WD MBWE Blue Rings, the variables HDPARM and SMARTCTL that located the corresponding programs were found in the file: /etc/init.d/S15wdc-heat-monitor

On my WD MBWE Blue Rings, the variables FAN_DEVICE and FAN_SPEED that located the corresponding devices were found in the file: /etc/init.d/S20wdc-fan-test

You can use WinSCP to edit these files if they or something similar exists on the MBWE White Lights (these are simple shell script files).

I think the MBWE White Lights edition has a thermistor temperature sensor on the processor board as well. Since I have the Blue Rings edition, I can't be sure. However do look at: http://hacksomethingtonight.blogspot.com/2010/02/wd-mybook-hacks-temperature-readings.html There maybe something of interest there.

If you would like to replace missing programs, let me know which ones and I'll put the Blue Rings version up onto a public FTP share somewhere. The Linux command for downloading programs from an http: site or and ftp: site is "wget". Hopefully that has not been lobotomized as well. Try "type wget" to see if the MBWE shell can find it.

Let me know.

CIAO - Think Open Source

... Tony
 

Tony_77

Distinguished
Mar 1, 2010
28
0
18,530
If you are looking for something to do, the mbstat.sh script can be called from another script that loops around - say every 10 minutes or so and the output of mbstat.sh can be written to the "PUBLIC" share as a text file where you can use MS WORDPAD to look at it whenever you want. Hint - to get mbstat.sh to output to the public share, the command would be:

sh mbstat.sh >/shares/internal/PUBLIC/mbstat.txt

Enjoy!

... Tony
 

whitebox

Distinguished
Jan 15, 2010
34
0
18,530
Thanks again Tony, and for the output syntax for when we get the basic script running A very nice idea.

You were correct - gcc does not exist.

I ran the script and this is the outcome:

Date: Sat Mar 13 13:16:54 GMT 2010
mbstat.sh: mbstat.sh: 30: /sbin/hdparm: Permission denied
uptime: 1 day, 12:15 hours
2.06, 2.01
mbstat.sh: mbstat.sh: 30: /sbin/hdparm: Permission denied

Using WinSCP I see that although hdparm both exists and does so in the expected /sbin folder, it has zero byte size.