email when configured media folders are inaccessible?

Got an idea? Missing something? Post your feature request here.

Moderator: moderators

email when configured media folders are inaccessible?

Postby gurutech » Wed Sep 26, 2012 12:47 am

Any idea if it would be possible to have SS send an email to an email address (configurable) if the configured media folders are not accessible?

I run into an occasional issue where my Linux box cannot access the folders on my Windows box (where I store my media) and this usually means the IRPStackSize on the Windows machine is set too low, and requires a reboot. I can do the reboot remotely, but if I don't know about it, my Subsonic stream could be down for several hours at a time. I'd like to be alerted in some way so I can reboot my Windows box quickly.
Image
gurutech
 
Posts: 492
Joined: Sun Jan 15, 2012 9:56 pm

Re: email when configured media folders are inaccessible?

Postby hakko » Wed Sep 26, 2012 6:12 am

I guess this is pretty unlikely to get implemented as a feature. If Subsonic can't access your folders, shouldn't it be possible to set up a simple script that polls your folders every now and then and sends an email if they're not available?
MusicCabinet developer
hakko
 
Posts: 1416
Joined: Tue Apr 17, 2012 7:05 pm
Location: Sweden

Re: email when configured media folders are inaccessible?

Postby jonnymnemo » Wed Sep 26, 2012 7:16 am

I guess a simple script in cron, with a smbtree (and a sendmail) command included should be working.
I'm not good at scripting, but I'm searching for an answer...

EDIT :
Better idea (because smbtree seems to always ask for root password, even in root):
you can use this command :

Code: Select all
ls /media | grep networkfolder


It will show only your networkfolder if available

Another way :
Code: Select all
if [ -d /media/networkfolder ]; then echo 'good'; else echo 'wrong'; fi


this will show 'good' if the directory exists, and 'wrong' if it doesn't

FINAL EDIT :

Finally a working command :

Code: Select all
if [ -d /media/networkfolder/musicfolder ]; then  echo 'good';  else  df -h | mail yourmailadress@xxx.com -s "network error";  fi


It will send you a mail (which will contain the disks usage) if your music folder inside your network share is unavailable.
Don't point to the root folder (it still exists even if the network share is off).

If you want to do this script every hour, just add it (in root) to cron.

Code: Select all
crontab -e

And you add this line :
Code: Select all
01 * * * * if [ -d /media/networkfolder/musicfolder ]; then  echo 'good';  else  df -h | mail yourmailadress@xxx.com -s "network error";  fi


It will execute the command every hour.

If you want to do it every 30 minutes, change it to :
Code: Select all
*/30 * * * * if [ -d /media/networkfolder/musicfolder ]; then  echo 'good';  else  df -h | mail yourmailadress@xxx.com -s "network error";  fi


You will need to have a working mail command, but there are a lot of tutorials for that ! :wink:
User avatar
jonnymnemo
 
Posts: 70
Joined: Thu Apr 12, 2012 8:11 am


Return to Feature Requests

Who is online

Users browsing this forum: No registered users and 1 guest