Here's a script to start/restart your cflowd binaries when they die
and log it. runs via crontab. tested on openbsd 2.7
available at http://c3w.org/source/cflowd/ and I've attached it below-
Chas. <c3w@ISP.NET>
ISP Networks, Inc.
#!/bin/ksh
###
## FileNAME : `flowstart`
## Requires : `ksh` `sed` `ps` `grep` `cflowdmux` `cflowd` `cfdcollect`
##
## Author : Chas Wareing <c3w@isp.net>
## URL : http://c3w.org/source/cflowd/
## CreateDATE : 22OCT2000
## ModifyDATE : never
##
## Purpose : starts non-running cflowd processes
## (or anything you want) and logs startups to
## flowstart.log. free, no warranty, etc etc.
##
## Use With : crontab per-minute: * * * * * flowstart > /dev/null
###
## Init VARs
##
SED_BIN="/usr/bin/sed"
PS_BIN="/bin/ps"
GREP_BIN="/usr/bin/grep"
CFLOWD_DIR="/usr/local/arts/sbin"
LOG_DIR="/usr/local/arts/sbin"
function initOnce {
## harvest PID from given program arguments
myPID=$(\
${PS_BIN} auxw |\
${GREP_BIN} -e "[0-9] ${1}" |\
${SED_BIN} -e "s/root[ ]*\([0-9]*\).*/\1/" \
)
## if no PID, restart cflowd/cfdcollect
if [ "${myPID}x" == "x" ]; then {
echo $(date) Starting ${@}
echo $(date) Starting ${@} >> ${LOG_DIR}/flowstart.log
${@}
} else {
echo ${@} already running as pid ${myPID}
}; fi
}
###
## RUNTIME START HERE
##
## trailing whitespace on args simulates cmdline execution
cd ${CFLOWD_DIR}
initOnce "./cflowdmux "
initOnce "./cflowd -s300 -O0 -m " ## DJP patch args
initOnce "./cfdcollect ../etc/cfdcollect.conf "
-- cflowd mailing list cflowd@caida.org
This archive was generated by hypermail 2b29 : Sun Oct 22 2000 - 20:43:51 PDT