diff --git a/contrib/debian/etc/default/netflow-asstatsd b/contrib/debian/etc/default/netflow-asstatsd new file mode 100755 index 0000000..b015be0 --- /dev/null +++ b/contrib/debian/etc/default/netflow-asstatsd @@ -0,0 +1,3 @@ +RRD_DIR=/tmp +CONF_FILE=/etc/as-stats/netflow-links +EXTRA_ARGS="" diff --git a/contrib/debian/etc/default/sflow-asstatsd b/contrib/debian/etc/default/sflow-asstatsd new file mode 100755 index 0000000..9d32cda --- /dev/null +++ b/contrib/debian/etc/default/sflow-asstatsd @@ -0,0 +1,4 @@ +RRD_DIR=/tmp +CONF_FILE=/etc/as-stats/sflow-links +ASN=65534 +EXTRA_ARGS="" diff --git a/contrib/debian/etc/init.d/netflow-asstatsd b/contrib/debian/etc/init.d/netflow-asstatsd new file mode 100755 index 0000000..183dcba --- /dev/null +++ b/contrib/debian/etc/init.d/netflow-asstatsd @@ -0,0 +1,97 @@ +#! /bin/sh +### BEGIN INIT INFO +# Provides: netflow-asstatsd +# Required-Start: $remote_fs $syslog +# Required-Stop: $remote_fs $syslog +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: netflow as-stats collection daemon +# Description: as-stats is a program that collects NetFlow data +# and process it in order to show the different +# sourced / destinated IP traffic AS. +### END INIT INFO + +PATH=/sbin:/usr/sbin:/bin:/usr/bin +DESC="as-stats collection daemon" +NAME=netflow-asstatd +DAEMON=/usr/bin/netflow-asstatd.pl +PIDFILE=/var/run/$NAME.pid +SCRIPTNAME=/etc/init.d/$NAME + +RRD_DIR=/tmp +CONF_FILE=/etc/as-stats/netflow-links +EXTRA_ARGS="" + +[ -r /etc/default/$NAME ] && . /etc/default/$NAME + +DAEMON_ARGS="-r $RRD_DIR -k $CONF_FILE $EXTRA_ARGS" + +[ -x "$DAEMON" ] || exit 0 + +. /lib/init/vars.sh +. /lib/lsb/init-functions + +do_start() +{ + start-stop-daemon -v --start --quiet --make-pidfile --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \ + || return 1 + start-stop-daemon -v --start --quiet --background --make-pidfile --pidfile $PIDFILE --exec $DAEMON -- $DAEMON_ARGS \ + || return 2 +} + +do_stop() +{ + start-stop-daemon -v --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME + RETVAL="$?" + [ "$RETVAL" = 2 ] && return 2 + start-stop-daemon -v --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON + [ "$?" = 2 ] && return 2 + rm -f $PIDFILE + return "$RETVAL" +} + +case "$1" in + start) + [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME" + do_start + case "$?" in + 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; + 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; + esac + ;; + stop) + [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME" + do_stop + case "$?" in + 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; + 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; + esac + ;; + status) + status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $? + ;; + restart|force-reload) + log_daemon_msg "Restarting $DESC" "$NAME" + do_stop + case "$?" in + 0|1) + do_start + case "$?" in + 0) log_end_msg 0 ;; + 1) log_end_msg 1 ;; # Old process is still running + *) log_end_msg 1 ;; # Failed to start + esac + ;; + *) + # Failed to stop + log_end_msg 1 + ;; + esac + ;; + *) + echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2 + exit 3 + ;; +esac + +: diff --git a/contrib/debian/etc/init.d/sflow-asstatsd b/contrib/debian/etc/init.d/sflow-asstatsd new file mode 100755 index 0000000..9870bf4 --- /dev/null +++ b/contrib/debian/etc/init.d/sflow-asstatsd @@ -0,0 +1,98 @@ +#! /bin/sh +### BEGIN INIT INFO +# Provides: sflow-asstatsd +# Required-Start: $remote_fs $syslog +# Required-Stop: $remote_fs $syslog +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: sFlow as-stats collection daemon +# Description: as-stats is a program that collects sFlow data +# and process it in order to show the different +# sourced / destinated IP traffic AS. +### END INIT INFO + +PATH=/sbin:/usr/sbin:/bin:/usr/bin +DESC="as-stats collection daemon" +NAME=sflow-asstatd +DAEMON=/usr/bin/sflow-asstatd.pl +PIDFILE=/var/run/$NAME.pid +SCRIPTNAME=/etc/init.d/$NAME + +RRD_DIR=/tmp +CONF_FILE=/etc/as-stats/sflow-links +ASN=65534 +EXTRA_ARGS="" + +[ -r /etc/default/$NAME ] && . /etc/default/$NAME + +DAEMON_ARGS="-r $RRD_DIR -k $CONF_FILE -a $ASN $EXTRA_ARGS" + +[ -x "$DAEMON" ] || exit 0 + +. /lib/init/vars.sh +. /lib/lsb/init-functions + +do_start() +{ + start-stop-daemon -v --start --quiet --make-pidfile --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \ + || return 1 + start-stop-daemon -v --start --quiet --background --make-pidfile --pidfile $PIDFILE --exec $DAEMON -- $DAEMON_ARGS \ + || return 2 +} + +do_stop() +{ + start-stop-daemon -v --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME + RETVAL="$?" + [ "$RETVAL" = 2 ] && return 2 + start-stop-daemon -v --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON + [ "$?" = 2 ] && return 2 + rm -f $PIDFILE + return "$RETVAL" +} + +case "$1" in + start) + [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME" + do_start + case "$?" in + 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; + 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; + esac + ;; + stop) + [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME" + do_stop + case "$?" in + 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; + 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; + esac + ;; + status) + status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $? + ;; + restart|force-reload) + log_daemon_msg "Restarting $DESC" "$NAME" + do_stop + case "$?" in + 0|1) + do_start + case "$?" in + 0) log_end_msg 0 ;; + 1) log_end_msg 1 ;; # Old process is still running + *) log_end_msg 1 ;; # Failed to start + esac + ;; + *) + # Failed to stop + log_end_msg 1 + ;; + esac + ;; + *) + echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2 + exit 3 + ;; +esac + +: