On Sat, Oct 08, 2011 at 12:12:06AM +0200, Erik Wenzel wrote:
> Hi,
> 
> Am 07.10.2011 um 17.03 schrieb Milan Kocian:
> […]
> > In some enviroments is better to use multiple nfcapd deamons running 
> > parallelly.
> > This diff makes easier to configure it (some docs included). I hope it is
> > acceptable :-). Comments and objections are welcome.
> > Not sure about paths in diff ... (to be applied cleanly).
> ---snip---
> $ git apply --check ~/nf.diff
> error: etc/init.d/nfdump: No such file or directory
> error: usr/share/doc/nfdump/README.Debian: No such file or directory
> error: etc/default/nfdump: No such file or directory
> ---snip---
> 
> Please get the latest release from unstable and apply your changes to the 
> source tree. Your patch creation workflow could be like this:
> git clone git://gpl.code.de/git/nfdump.git
> git checkout unstable
> edit files
> git add <files>
> git commit
> git format-patch -M origin/unstable
> 
> Email me the resulting patch file.

hi,

many thanks for manual. Here is the new patch.
I'm not sure where to add new file nfcapd.example, so I added it
to debian directory.

Best regards,

-- 
Milan Kocian
>From e513be8ba7efcac997f16dd6f9e5a5acb184fdac Mon Sep 17 00:00:00 2001
From: Milan Kocian <mi...@wq.cz>
Date: Mon, 10 Oct 2011 10:03:54 +0200
Subject: [PATCH] Possibility to run multiple nfcapd daemons.

---
 debian/README.Debian  |    5 +++++
 debian/init.d         |   43 +++++++++++++++++++++++++++++++++++++------
 debian/nfcapd.example |   10 ++++++++++
 debian/nfdump.default |    2 ++
 4 files changed, 54 insertions(+), 6 deletions(-)
 create mode 100644 debian/nfcapd.example

diff --git a/debian/README.Debian b/debian/README.Debian
index 4bfcf7e..fda4d3d 100644
--- a/debian/README.Debian
+++ b/debian/README.Debian
@@ -15,3 +15,8 @@ flow-tools: install flow-tools-dev and enable configure parameter in debian/rule
 
 The package currently contains patches that are not in upstream release:
 05_division-by-zero.patch
+
+If you want to run multiple nfcapd daemons, you need:
+- in /etc/default/nfdump set the directory for cfg files
+- upload some cfg file into this directory (see example file)
+
diff --git a/debian/init.d b/debian/init.d
index fb64ad5..6e1ef0f 100644
--- a/debian/init.d
+++ b/debian/init.d
@@ -10,6 +10,8 @@
 ### END INIT INFO
 
 # Author: Erik Wenzel <e...@debian.org>
+# Milan Kocian <mi...@wq.cz> : possibility to run multiple nfcapd daemons
+# (inspired by openvpn script)
 
 # Do NOT "set -e"
 
@@ -22,6 +24,7 @@ DATA_BASE_DIR="/var/cache/nfdump"
 PIDFILE=/var/run/$NAME.pid
 DAEMON_ARGS="-D -l $DATA_BASE_DIR -P $PIDFILE"
 SCRIPTNAME=/etc/init.d/nfdump
+ACTION=$1
 
 # Exit if the package is not installed
 [ -x "$DAEMON" ] || exit 0
@@ -102,9 +105,13 @@ do_reload() {
 	return 0
 }
 
-case "$1" in
+do_case() {
+  case "$ACTION" in
   start)
-	[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
+	[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC $PORT" "$NAME"
+	if [ ! -d $DATA_BASE_DIR ]; then
+		mkdir -p $DATA_BASE_DIR
+	fi
 	do_start
 	case "$?" in
 		0|1) [ q"$VERBOSE" != qno ] && log_end_msg 0 ;;
@@ -112,7 +119,7 @@ case "$1" in
 	esac
 	;;
   stop)
-	[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
+	[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC $PORT" "$NAME"
 	do_stop
 	case "$?" in
 		0|1) [ "r$VERBOSE" != rno ] && log_end_msg 0 ;;
@@ -133,7 +140,7 @@ case "$1" in
 	# If the "reload" option is implemented then remove the
 	# 'force-reload' alias
 	#
-	log_daemon_msg "Restarting $DESC" "$NAME"
+	log_daemon_msg "Restarting $DESC $PORT" "$NAME"
 	do_stop
 	case "$?" in
 	  0|1)
@@ -151,8 +158,32 @@ case "$1" in
 	;;
   *)
 	#echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
-	echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
+	echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload} [names_of_cfgfiles]" >&2
 	exit 3
 	;;
-esac
+  esac
+}
+## MAIN SCRIPT
+if [ -z $2 ]; then
+	# option without names_of_cfgfiles entered 
+	# if $CFGDIR doesn't exist or is empty then old behaviour is preserved
+	for SFILE in $CFGDIR/* ; do
+		if [ "$SFILE" != "$CFGDIR/*" ]; then
+			. $SFILE
+		fi
+		do_case
+	done
+else
+	# option with names_of_cfgfiles entered (suppose existence of $CFGDIR
+	# with cfg files)
+	while shift ; do
+		[ -z "$1" ] && break
+		if [ -e $CFGDIR/$1 ]; then
+			. $CFGDIR/$1
+			do_case
+		else
+			log_failure_msg " (failure: No such nfcapd config exists: $1)"
+		fi
+	done 
+fi
 exit 0
diff --git a/debian/nfcapd.example b/debian/nfcapd.example
new file mode 100644
index 0000000..cbd5a5d
--- /dev/null
+++ b/debian/nfcapd.example
@@ -0,0 +1,10 @@
+# The debian's config file for nfcapd (permit multiple running nfcapd's deamons)
+# You can adjust this file as you need. PORT, DATA_BASE_DIR, PIDFILE and DAEMON_ARGS
+# variables must be set. (They are used by init.d script)
+
+PORT=9996
+IDENTSTR=IDENTSTRING
+DATA_BASE_DIR=/tmp/$IDENTSTR
+PIDFILE=/var/run/$NAME.$PORT.pid
+DAEMON_ARGS="-D -l $DATA_BASE_DIR -P $PIDFILE -p $PORT -w -B 2097152 -I $IDENTSTR -T +4 "
+
diff --git a/debian/nfdump.default b/debian/nfdump.default
index f91b120..03b3f63 100644
--- a/debian/nfdump.default
+++ b/debian/nfdump.default
@@ -1,2 +1,4 @@
 # nfcapd is controlled by nfsen
 nfcapd_start=no
+# set it for multiple nfcapd daemons
+#CFGDIR=/etc/nfcapd
-- 
1.7.6.3

Reply via email to