#!/bin/sh
#
# flowcap:      Starts all processes concerning flowtool
#
# description:  This script starts up the the flowtool daemons.
#
# processname:  There is not a single process associated with these
#               actions, rather there are multiple processes. This
#               script takes care of all of them.
#
# can be restarted by using the following command:
#
# sudo /etc/init.d/flowcap restart
 
[ -x /usr/bin/flow-capture ] || exit 0
 
RETVAL=0
 
start() {
    echo -n $"Starting flowtool processes: "
 
    /usr/bin/flow-capture -p /htp/flows/pids/flowtool.pid \
    -w /htp/flows/router_1 -E4000M -S3 0/0/2070
    RETVAL=$?
 
    /usr/bin/flow-capture -p /htp/flows/pids/flowtool.pid \
    -w /htp/flows/router_2 -E2000M -S3 0/0/2071
    RETVAL=$?
 
    /usr/bin/flow-capture -p /htp/flows/pids/flowtool.pid \
    -w /htp/flows/router_3 -E2000M -S3 0/0/2072
    RETVAL=$?
 
    /usr/bin/flow-capture -p /htp/flows/pids/flowtool.pid \
    -w /htp/flows/router_4 -E2000M -S3 0/0/2073
    RETVAL=$?
 
    cd /htp/cgi-bin/FlowViewer_3.3 &&
    env PATH=$PATH:/usr/local/rrdtool-1.2.12/bin
    ./FlowTracker_Collector&
    RETVAL=$?
 
    cd /htp/cgi-bin/FlowViewer_3.3 &&
    env PATH=$PATH:/usr/local/rrdtool-1.2.12/bin
    ./FlowTracker_Grapher&
    RETVAL=$?
 
}
stop() {
    echo -n $"Stopping flowtool processes: "
    /bin/kill `cat /htp/flows/pids/flowtool.pid.*`
    RETVAL=$?
 
    /usr/bin/killall -2 FlowTracker_Collector
    /usr/bin/killall -2 FlowTracker_Grapher
}
 
# See how we were called.
 
case "$1" in
    start)
        start
        ;;
    stop)
        stop
        ;;
    restart)
        stop
        start
        ;;
    *)
        echo $"Usage: $0 {start|stop|restart}"
        ;;
esac
exit $RETVAL
