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 !
