New user's registration have been closed due to high spamming and low trafic on this forum. Please contact forum admins directly if you need an account. Thanks !

Monitor bubba and downloads on your SoundBridge.

A collection of tips on howto tweak your Bubba.
6feet5
Posts: 269
Joined: 13 Apr 2007, 17:32
Location: Gnesta, Sweden
Contact:

Monitor bubba and downloads on your SoundBridge.

Post by 6feet5 »

This how to will show you how to use a SoundBridge M1001 to display statistics about hard drive usage, temperature and downloads.

Image

Image

Disclaimer
First of all, lets start with the boring stuff. This software is distributed as is, WITHOUT ANY WARRANT of any kind. You use it on your own risk. I accept no liability should your hair catch fire, girlfriend get pregnant or leave you, or any other issue you may encounter directly or indirectly due to your (miss|ab)*use of these instructions. I'm no Linux or Security expert so there may be security issues. This is software we're talking about and there will probably be bugs (maybe it is me, but I have so far never released any software that is free from bugs on the first try). The program is very naive and may lack proper error handling. If you do spot any bugs or security issues, please let me know. I'm eager to learn and will do my best to fix the problems.

Prerequisits
Still with me??? Ok, here goes nothing??!?. My bubba have packages from the Debian repositories that aren't part of Excitos repositories. Due to earlier installs, there may be dependancies that I don't know of. If you find a dependancy I haven't mentioned, let me know.
Here's what I know you need to install:
  • hddtemp. johannes has made a howto http://www.excito.org/forum/viewtopic.php?t=417. You need to run it as a deamon because the program will connect to the TCP/IP port.
    Net::Telnet (package is named "libnet-telnet-perl").
    My files Visit http://medlem.spray.se/sixfeetfive/temp/ (not much to see yet) and write down (or copy link) the version number of the latest version (but don't download it just yet, we will use wget later). I haven't had any time writing proper instructions so there isn't much to see in this tar file.
Installation
I'm not very good at writing instructions. Writing them in another language surely doesn't help, so you may have to read between the lines here and there. There are plenty of good instructions on how to do some of the tasks mentioned here, just search the forum or the internet.

Now, log in as root, install hddtemp, following johannes instructions, and while you're at it, throw in

Code: Select all

apt-get install libnet-telnet-perl
Two dependencies solved, one to go. To download and unpack my files (note where you're putting theme, I put mine in "/home/johan/scripts/BubbaMon"), type:

Code: Select all

wget http://medlem.spray.se/sixfeetfive/temp/BubbaMon-X.Y.tgz
tar xzf BubbaMon-X.Y.tgz
mkdir -p /home/johan/scripts/BubbaMon
mv BubbaMon-X.Y/* /home/johan/scripts/BubbaMon
nano /home/johan/scripts/BubbaMon/BubbaMon.pl
X.Y (in BubbaMon-X.Y) is the version number you wrote down earlier.
Examine the settings at the top of BubbaMon.pl and change them to fit your needs. Pay special attention to the "use lib ..." part, it is important that you update the path here to the folder you installed the files to.

Output from the cronjob will be captured to a file named BubbaMon.log (or what ever you name it). If you don't see anything on the SoundBridge display when you expect to, examine this file. Note that it'll be overwritten on each run. First you may have to change access rights so www-data (we will run the script as this user) can write to this file. Type

Code: Select all

touch /home/johan/scripts/BubbaMon/BubbaMon.log
chmod o+rw /home/johan/scripts/BubbaMon/BubbaMon.log
Change the paths to where your files are stored (you need this path later on when editing the crontab).

We need to communicate with the file transfer daemon over a message queue. In order to read/write on this queue, we need proper rights. Root and www-data both have read/write access, but we don't want to run the script as root, so we enter the cron job in www-datas cron table. Type

Code: Select all

crontab -e -u www-data
This will start nano, to let you enter the cronjob. Type

Code: Select all

*/10 * * * * /usr/bin/perl /home/johan/scripts/BubbaMon/BubbaMon.pl [USERNAME] &>/home/johan/scripts/BubbaMon/BubbaMon.log
Save and exit. You will of course have to change the path to where you saved the perl script, where you put the log file, and also change [USERNAME] to the user name you want. The first part (*/10) means this command will execute every ten minutes. Shouldn't be to difficult to figure out what to change if you want it to run every 5 minutes instead ;-) A word of warning though, I don't know what will happen if time is too short so that two jobs overlap, but I do know there's nothing stopping them from doing so. Bad things are bound to happen, so keep it at a safe level. I suggest you only have one or two downloads active while testing, so that you can have a smaller interval (say 2 or maybe even 1 minute) without risking an overlap. Just remember to increase this interval before starting a lot of downloads.
Crontab allows you to have even more complex rules, like only running this script during day time. Search the internet for more info on crontab.

There you have it, I think that's all there is to it. You should be able to monitor your downloads on the SoundBridge.

Have fun.... Let me know what you think of it, what could be better, features for the future......

Best regards,
Johan
Last edited by 6feet5 on 20 Dec 2007, 17:25, edited 1 time in total.
6feet5
Posts: 269
Joined: 13 Apr 2007, 17:32
Location: Gnesta, Sweden
Contact:

New version

Post by 6feet5 »

Shame on me. Turns out there was a difference in the info field that I didn't notice when testing my code against the new bubba firmware (51.1). HTML tags appeared where the download speed was supposed to show. Don't know how I could miss it, but I did. I guess this cold I'm having must be affecting my vision. Anyway, a new version is available (0.3) and instructions updated. I realize I must write a better instruction, but that'll have to wait until I get better. Hopefully there will be some kind of install script (lets see if I can figure out how to make a proper debian package, I use Archlinux and pacman so I'm not very used to apt-get and friends).

Another thing, regarding the how to above. Maybe this goes without saying, but it is wise to try to run the script outside of cron before you start editing the cron table. Putting it in a cron job will not make it work if it isn't working outside of cron. And it will be a lot easier to test. Just run

Code: Select all

/usr/bin/perl /home/johan/scripts/BubbaMon/BubbaMon.pl [USERNAME]
/Johan

PS I will make a proper page at my internet provider, so that I don't polute the forum more than necessary whenever there's an update ;-)
ian
Posts: 128
Joined: 30 Jul 2007, 09:07

Post by ian »

Hi Johan,
thanks for the HowTo. I've performed all of the steps (twice actually :? ) but am not able to get the hddtemp output to display on the Soundbridge (it just says <unavailable>). I am able to use the hddtemp /dev/hda command when logged on as myself using PuTTy, so I'm not sure where the problem lies.

If I use the "demo" option, then a temperature is displayed, but I'm not sure that it's a real temperature...

BTW, I'm a Linux/perl noob...

Cheers, Ian.
lelle
Posts: 69
Joined: 02 Jan 2007, 20:25
Location: Stockholm, Sweden

Post by lelle »

Hi Johan,

Awesome! Works like a charm! :D

Ian: Check that hddtemp is running as a daemon
6feet5
Posts: 269
Joined: 13 Apr 2007, 17:32
Location: Gnesta, Sweden
Contact:

Post by 6feet5 »

Hi Ian,

You probably need to enable it to run as a daemon. I'm not used to Debian, but i think you need to reconfigure it. There's probably a manual way, but I think it is easiest to just type:

Code: Select all

 dpkg-reconfigure hddtemp 
Be sure to select to run it as a daemon and also note what port you use, and make sure enter this port number in my script.

Hope this helps.

/Johan
ian
Posts: 128
Joined: 30 Jul 2007, 09:07

Post by ian »

Thanks for the replies. Got it working....

Cheers, Ian.
6feet5
Posts: 269
Joined: 13 Apr 2007, 17:32
Location: Gnesta, Sweden
Contact:

Post by 6feet5 »

Instructions changed once again to be more general.

Tor from excito was kind to inform me of a bug in my software due to changes in latest version. When I started to investigate this, I couldn't see the problem. Then I realized I wasn't running the latest and greatest of the bubba firmware. Upgrading it, the problem became obvious.
So, now there's a new version available (0.5), but note that this version require that you upgrade to Bubba 0.51.2-1. If you for some reason aren't going to upgrade the bubba firmware, stick with the old 0.3.

Oh, and I've done some more research on how to "debianize" the whole shebang, and it doesn't seem to be too complicated so I may have a proper debian package available soon. This should make it a whole lot easier to install for you.

I guess season's greetings are in place, so ho ho ho.... "Merry Christmas, and a Happy New Year".

Best wishes,
Johan
ian
Posts: 128
Joined: 30 Jul 2007, 09:07

Post by ian »

Hi Johan,
I have another question. Although I've got the script to run, it doesn't seem to run automatically (ie. controlled by cron). Is there a way to see if cron is actually running and/or that my crontab entry is correct?

Cheers, Ian.
6feet5
Posts: 269
Joined: 13 Apr 2007, 17:32
Location: Gnesta, Sweden
Contact:

Post by 6feet5 »

Hi Ian,

First of all, verify that you actually entered the cronjob as I wrote it (you can copy and paste that line to be sure, only replacing paths to match your install). Then verify you actually entered the right paths.

Next, there are two things I know of that you can do. Log in as root and verify in the system log that your cronjob is running. Type:

Code: Select all

su root
<enter your password>
cat /var/log/syslog
You should see a line logged every 10 minutes that look something like

Code: Select all

Dec 21 19:00:01 bubba /USR/SBIN/CRON[22320]: (www-data) CMD (/usr/bin/perl /home/johan/scripts/BubbaMon/BubbaMon.pl johan &>/home/johan/scripts/BubbaMon/BubbaMon.log)
I'm not sure what it look like if there are errors, but I guess it is safe to say it will look different.

Also verify there are no error messages in the BubbaMon log file (in my example output was redirected to /home/johan/scripts/BubbaMon/BubbaMon.log). An empty file can mean two things, either there are no errors, or it isn't run. Try put some text in it by typing:

Code: Select all

 echo "I love my bubba" >/home/johan/scripts/BubbaMon/BubbaMon.log
cat /home/johan/scripts/BubbaMon/BubbaMon.log
. Last line is only to verify you actually got something in the file. Now wait, say 15 minutes if it should run every 10 minute, then verify the file is empty. If it isn't then we know for sure your cronjob isn't running.

Also, when you run the script outside of cron, do this from a different directory. That is, your current directory shouldn't be the same path as the scriptfiles are store in. This makes it easier to find any problems with search paths.

Try these steps and get back.

/Johan
ian
Posts: 128
Joined: 30 Jul 2007, 09:07

Post by ian »

Hi Johan,
thanks for the quick reply.

I tried what you suggested, but it still wouldn't work. Eventually I downloaded your latest version, installed it in a completely new folder, redid all the editing (.pl and crontab), and now it works.

I'm not really sure what was wrong the first time, but it seems to work fine now.

Anyway, thanks for a really useful utility; it's nice to see how the little bubba is doing....

Cheers, Ian.
tor
Posts: 703
Joined: 06 Dec 2006, 12:24
Contact:

Post by tor »

Hi,

6feet5, if you get around to package your little hack. We can of course offer to add it to our repositories if you like ;)

/Tor
Co-founder OpenProducts and Ex Excito Developer
6feet5
Posts: 269
Joined: 13 Apr 2007, 17:32
Location: Gnesta, Sweden
Contact:

Post by 6feet5 »

Hi Tor,

That sounds good.

I have managed to make a test package that at least appears to be fully debian compatible, but it need some more testing.

The next release will hopefully be a proper debian package (with a couple of new features).

/Johan
6feet5
Posts: 269
Joined: 13 Apr 2007, 17:32
Location: Gnesta, Sweden
Contact:

Post by 6feet5 »

Hi,

A new version of bubbamon is available. Note that bubbamon now is packaged as a debian package, so installation instruction differ.

If you have an old version (0.5 or older), please remove it first:
Remove cronjob by typing:

Code: Select all

crontab -u www-data -r
Then remove all scriptfiles.

Installation (0.6 or newer)
Download bubbamon package and install it:

Code: Select all

wget http://medlem.spray.se/sixfeetfive/temp/bubbamon_X.Y_all.deb
dpkg -i bubbamon_X.Y_all.deb
Replace X.Y with the version you want to install.

And that's it. You will be asked a couple of questions during installation. User settings are stored in /etc/default/bubbamon. You can reconfigure it with:

Code: Select all

dpkg-reconfigure bubbamon
or edit the file manually.

Here are the highlights for this new version:
  • Daemon mode You can now run bubbamon as a daemon (running in the background). This will let you get the information when ever you like. Just press MENU key (a house on my remote) three times in a row. The menu will light up and is now ready for navigation (Cron mode is still available as in the old version).
  • Menu navigation You may now use the remote control to navigate through the screens. Use UP/DOWN keys to select previous/next screen when script is running. It will roll-over when reaching top/bottom. Press MENU to get to first screen. Press EXIT to close menu and return to previous state.
  • Cancel download Downloads may be canceled with remote. Navigate to the download you want to cancel (or wait until it is showing), then press SELECT (a check mark on my remote) and select Yes/No with LEFT/RIGHT keys when asked if you want to cancel download (press SELECT to confirm choice). If no key is pressed within 30 seconds the action is cancelled (that is, the download is NOT canceled, no matter what was selected). You can also press EXIT to leave cancellation, leaving the download unchanged.

Will the daemon turn into a demon?
A few notes on the daemon mode. When the program is run as a daemon, it means it will always be running in the background. A cron job on the other hand is run as a finite job: it is started, hopefully does its job and then quit. Cron will restart it next time it is scheduled to run. I can think of one good reason to run as a cron job and not as a daemon. Any program that quits will return all memory to the system, even memory that has been lost due to memory leaks in program. Since the program will quit every time in cron mode, it will return lost memory to the system. A daemon with a memory leak on the other hand will continue to consume memory and eventually run out of memory. This means that if there are any memory leaks in my program, you are probably better off running it as a cron job. I run it as a daemon and I have so far not seen any problem, but then, I restart it from time to time to test changes I make to the program.
If you spot memory problems, let me know and I'll try to track them down. Even better if you can pin point it and maybe provide me with a solution ;-)

Best regards,
Johan Stenarson
tor
Posts: 703
Joined: 06 Dec 2006, 12:24
Contact:

Post by tor »

Nice work 6feet5 :)

I have only browsed it briefly but it surely seems like you have done a great job.

/Tor
Co-founder OpenProducts and Ex Excito Developer
marcel23
Posts: 20
Joined: 15 Dec 2007, 07:43

Post by marcel23 »

Hi,

Is there a way to change the type of font on the bubbamonitor using soundbridge ? On my soundbridge, the font is to big, so i can't see all the info....

Perfect functionality by the way...
Post Reply