Monitor a WD ShareSpace using XYMon on any remote network

On June 4, 2011, in How-to, by Cubert aka (Cube Dweller)

Do you happen to be a systems support guy who needs a method of getting the basic stats of a WD ShareSpace into your XYmon or MAG monitor? If you are like me then you are a systems admin responsible for many different networks spread across the Internet. You then may have deployed a few NAS systems including the WD ShareSpace that runs a version of BusyBox Linux. This is good news because WD provides access to the shell over SSH if you enable it via the web admin (advanced section). So now go enable SSH access and then puttythe system using the username “root” and a password of “welc0me”  where the 0 in welc0me is a zero.

With shell access we can do many things, one of which is getting the stats from the system.  Currently we have only 1 method to get the stats to XYmon but we are exploring some custom XYmon client binaries we can distribute in future versions of this article.  That may make this article a mute point so check back every so often for updates.

Today we have to do monitoring in 2 parts,

#1 Have a script on WD ShareSpace running on a regular intervals, that executes  the basic commands to produce the files we need to stat the system in XYmon.

#2 Have a Windows system grab the stat files from WD ShareSpace and process them before sending them on to the XYMon server.

First script is the WD Sharespace script which is a very simple shell script that does nothing more then cat to several text files ( meminfo, df, du, uptime and load) and saves them to a share on the WD ShareSpace called Public. You can modify the script to place files on any share you want. The script should then be executed with the following command while SSHed in to the WD ShareSpace

The first time you run the script you will need to make it executible. To do so type:

chmod 0755 ./Report.sh

The to run the shell script type:

Report.sh &

This will place the script in the background as a process and release your shell so you can logout without stopping the script. The script will run then sleep for 5 minutes then run again replacing files with updated files every 5 minutes until you stop it(which should be never).  You will need to change the permissions on the files the first time you run script so that the report files are world readable. To do this use the following command.

chmod 0777 ./*report.txt

We now have stat files on a share that we want to “FTP” off. The key word here is FTP so we will want to allow anonymous FTP to the WD ShareSpace. Login to the web admin of the WD ShareSpace and enable FTP on the device. This allows the Perl script we use next to grab the stat files, process them and then send them on to the XYmon sever via a proxy connection.

WDShareSpace Scripts

The next step is to setup the Windows system to proxy the stats to the remote XYMon server. I normally use one of the Windows server we monitor via XYMon but if this is the only thing you monitor then a windows desktop can be used as well. Either way you will need a Active State Perl set up on a Windows box to be the proxy.

Today the script is Perl, tomorrow it could be a Powershell or some other language suitable for Windows but for today it’s Perl. Perl is not native to Windows so you will need to add it’s language to Windows by the way of Active State Perl for Windows. To install ASP go to Active State Perl.  Install Perl and make sure you select to place Perl in the PATH variables with in Windows during install process. Now download our Perl script and place it in  a directory on your Windows server.

You should edit the script variables so that it reflects your setups, (Share to look for files in, the name of the WDShareSpace as seen on XYMon server ).  The run the Windows Scheduler and create a new daily schedule to run the perl script “WdShareSpace.pl”. After creating the daily schedule go back in and edit the schedule and select the advanced section. Find the “run every” and set it to 5 minutes and the in the “run for” place in 24 for 24 hours a day. This will get the script running every 5 minutes which is the same schedule as the shell script running on the NAS so you will get updates every 5 minutes.

So to summarize:

We have 2 scripts (Report.sh and WDSharespace.pl) Report.sh runs on the NAS and after permissions are changed it is executed with the (&) symbol after it so it drops to the background and keeps running when you close the ssh window. This script creates a set of report text files in the same directory as the script. The WDShareSpace.pl runs on Windows with Active State Perl installed and it has several varibles in script that need to be edited to point it to the NAS and XYMon servers and it is scheduled to run inside of Windows Scheduler(AT) on a 5 minute interval.

If all is successful you should get some thing like the following in your XYmon server if you configured the BBHOST for the WDShareSpace HOST.

Disk view:

Tagged with:
 

Leave a Reply

*



%d bloggers like this: