[icecast] Re: keeping liveice running

Robin P. Blanchard robin at gactr.uga.edu
Sat Dec 15 04:16:39 UTC 2001



Matt --

I actually came up with a much more elegant script. On FreeBSD there is a 
command 'fstat' (I'm sure this could be modified to use 'lsof' or something of 
the like).

First of all, while liveice and icecast are running properly,

# fstat -m | grep liveice |wc -l

for me yeilds 56 or 57. I let liveice die and checked again, and that number 
went significantly down. Thus, I built this script (which works great) and put 
it into an hourly cronjob. I think you'll find this much cleaner/better. Let me 
know how it works out for you.

#!/bin/sh

NUMBER=$(fstat -m | grep liveice | wc -l)
DIR=/usr/local
PIDS=$(ps axw |grep ice |awk '{print $1}')

if [ $NUMBER -lt 50 ] ; then
        echo "Killing rogue processes..."
        echo "pid(s): $PIDS"
        for i in $PIDS ; do kill -9 $i ; done
        sleep 5
        $DIR/sbin/icecast -c $DIR/etc/icecast/conf/icecast.conf
        sleep 5
        $DIR/bin/liveice -F $DIR/etc/liveice.cfg >/dev/null 2>/dev/null &
        echo "Radio restarted at `date`."
else
        echo "Radio (supposedly) still running"
fi

> I'm getting ready to use this script that you created.  Just wondering
> how it is working for you or if you had to modify it any.  Thanks for
> making this available...
> 
> Matt Mencel
> Technician
> Computer Masters
> 
> 
> >>>>>
> ok...based on William's shoutcast-based suggestion, i've come up with
> the following. i haven't had time to really test the thing
> yet...suggestions are greatly appreciated.
> 
> i based this on the fact that icecast's stats.log tells what sources
> are
> connected (in my case 0 and 1) and that log is updated frequently (per
> icecast.conf)
> 
> 
> 
> #!/bin/sh
> 
> DIR=/usr/local
> LOG=$DIR/var/icecast/log/stats.log
> SOURCE=`cat $LOG |grep Source\ [0-1] |awk '{print $1" "$2}'|sort
> |uniq`
> PIDS=`ps ax |grep $DIR/bin/liveice |awk '{print $1}' ; ps ax |grep
> $DIR/bin/lame |awk '{print $1}'`
> 
> if [ "$SOURCE" ] ; then
>         echo "LiveIce still connected to icecast server."
> else    
>         if [ "$PIDS" ] ; then 
>                 echo "Killing rogue processes..."
>                 echo "pid(s): $PIDS"
>                 kill -9 $PIDS
>                 $DIR/bin/liveice -F $DIR/etc/liveice/liveice.cfg
> >/dev/null 2>/dev/null &
>                 echo "LiveIce restarted at `date`."
>         else
>         $DIR/bin/liveice -F $DIR/etc/liveice/liveice.cfg >/dev/null
> 2>/dev/null &
>         echo "LiveIce restarted at `date`."
>         fi
> fi
> 

------------------------------------
Robin P. Blanchard
IT Program Specialist
Georgia Center for Continuing Ed.
fon: 706.542.2404 fax: 706.542.6546
email: Robin_Blanchard at gactr.uga.edu
------------------------------------

-------------------------------------------------
This mail sent through IMP: www.gactr.uga.edu

--- >8 ----
List archives:  http://www.xiph.org/archives/
icecast project homepage: http://www.icecast.org/
To unsubscribe from this list, send a message to 'icecast-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the Icecast mailing list