You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Current »

FlowScan can now be ran as a system service rather than having it to be ran as a command line process. With this is the need to be able to log the output from the associated daemons as a syslog process.

/etc/init.d/terapaths-netflow.sh
#!/bin/bash
#
# Startup script for the Terapaths Netflow Monitoring Server
#
# chkconfig: - 85 15
# description: Terapaths Netflow Monitoring uses FlowScan + JKFlow to 
#              analyse and present netflow records
# processname: flowscan
# pidfile: /var/run/flowscan.pid
# config: /opt/terapaths-monitoring/conf/{flowscan.cf|JKFlow.xml}

# Source function library.
if [ -f /etc/init.d/functions ] ; then
        . /etc/init.d/functions
elif [ -f /etc/rc.d/init.d/functions ] ; then
        . /etc/rc.d/init.d/functions
else
        exit 0
fi

# This will prevent initlog from swallowing up a pass-phrase prompt if
# mod_ssl needs a pass-phrase from the user.
INITLOG_ARGS=""

# Path to the apachectl script, server binary, and short-form for messages.
flowscan=/opt/terapaths-monitoring/bin/flowscan
prog=terapaths-monitoring
RETVAL=0

# The semantics of these two functions differ from the way apachectl does
# things -- attempting to start while running is a failure, and shutdown
# when not running is also a failure.  So we just do it the way init scripts
# are expected to behave here.
start() {
        echo -n $"Starting $prog: "
        daemon $flowscan 
        RETVAL=$?
        echo
        [ $RETVAL = 0 ] && touch /var/lock/subsys/flowscan
        return $RETVAL
}
stop() {
        echo -n $"Stopping $prog: "
        killproc $flowscan
        RETVAL=$?
        echo
        [ $RETVAL = 0 ] && rm -f /var/lock/subsys/flowscan /var/run/flowscan.pid
}
reload() {
        echo -n $"Reloading $prog: "
        killproc $flowscan -HUP
        RETVAL=$?
        echo
}

# See how we were called.
case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  status)
        status $flowscan
        RETVAL=$?
        ;;
  restart)
        stop
        start
        ;;
  condrestart)
        if [ -f /var/run/flowscan.pid ] ; then
                stop
                start
        fi
        ;;
  reload)
        reload
        ;;
  configtest)
        echo "Not yet implemented!"
        ;;
  *)
        echo $"Usage: $prog {start|stop|restart|condrestart|reload|status|help|configtest
}"
        exit 1
esac

exit $RETVAL
  • No labels