Shoutcast servers which are running on shared hosts usually get shut down quite frequently by procwatch. While it is important to stay within system limits it is also important to have those servers running till you shift to dedicated hosting 😀
Here’s a quick and dirty shell script to monitor and restart shoutcast services. Drop it in cron to run every 15 minutes and you will never have to worry about your shoutcast going down.
### Script to restart shoutcast server/transcoder when it's down
### Imtiaz a Khan http://blog.netbrix.net on 21 May 2007
prcs=`ps -ef | grep “sc_serv\|sc_trans” | grep -v grep > /tmp/monitor.log && cat /tmp/monitor.log | tr -s ” ” | cut -d” ” -f2,8 | grep -v grep | wc -l`
if [ ! $prcs ] || [ $prcs -lt 4 ]
nohup sc_serv &
nohup sc_serv sc_serv_low.conf &
nohup sc_trans_linux &
nohup sc_trans_linux sc_trans_low.conf &
###Send out the mails to inform
echo “shoutcast services restarted at `date`”| mail -s “ALARM: shoutcast services on `hostname`” [email protected]
#echo “shoutcast services restarted at `date`”| mail -s “ALARM: shoutcast services on `hostname`” youremailid
echo “shoutcast services running fine on `date`”| mail -s “OK: shoutcast services on `hostname`” [email protected]
#echo “shoutcast services running fine on `date`”| mail -s “OK: shoutcast services on `hostname`” youremailid
Make sure you replace the paths to the binaries and email ids. Also after a point getting a “everything OK” mail every 15 minutes gets irritating so just comment out the lines in the else portion when you’re happy with the script.
This script can be modified to monitor many other services that you’re running and facing problems with. Please Contact us for implementation on your server or for modifications.