diff options
author | Stanislav Sedov <stas@FreeBSD.org> | 2006-11-22 15:44:55 +0000 |
---|---|---|
committer | Stanislav Sedov <stas@FreeBSD.org> | 2006-11-22 15:44:55 +0000 |
commit | 5497eb9b338e7e45dfe710b55cd4057be13e2021 (patch) | |
tree | 9f56c4226836e10911bc581be8bf33667f16bc4c /net-mgmt | |
parent | dd3e50223d0b2ae782f860ffe2476a0e62a3e43a (diff) | |
download | ports-5497eb9b338e7e45dfe710b55cd4057be13e2021.tar.gz ports-5497eb9b338e7e45dfe710b55cd4057be13e2021.zip |
Notes
Diffstat (limited to 'net-mgmt')
-rw-r--r-- | net-mgmt/flow-tools/Makefile | 2 | ||||
-rw-r--r-- | net-mgmt/flow-tools/files/flow_capture.in | 77 | ||||
-rw-r--r-- | net-mgmt/flow-tools/files/patch-lib-ftfile.c | 100 |
3 files changed, 169 insertions, 10 deletions
diff --git a/net-mgmt/flow-tools/Makefile b/net-mgmt/flow-tools/Makefile index d12a74f95505..eb40154a604a 100644 --- a/net-mgmt/flow-tools/Makefile +++ b/net-mgmt/flow-tools/Makefile @@ -7,7 +7,7 @@ PORTNAME= flow-tools PORTVERSION= 0.68 -PORTREVISION= 2 +PORTREVISION= 3 CATEGORIES= net-mgmt MASTER_SITES= ftp://ftp.eng.oar.net/pub/flow-tools/ diff --git a/net-mgmt/flow-tools/files/flow_capture.in b/net-mgmt/flow-tools/files/flow_capture.in index f19ebfd05f12..cfbad2a35949 100644 --- a/net-mgmt/flow-tools/files/flow_capture.in +++ b/net-mgmt/flow-tools/files/flow_capture.in @@ -13,39 +13,98 @@ # Set to "NO" by default. # flow_tools_datadir (str): Base flow data directory. # Default is "/var/db/flows" -# flow_tools_datasize (str): Maximum allowed size of the flow data on disk -# Default is "128M" # flow_capture_localip (str): IP address to bind to # Default to "0.0.0.0" # flow_capture_remoteip (str): IP address to accept flows from # Default to "0.0.0.0" or all IPs # flow_capture_port (int): Port to accept flow data on # Default is "8787" -# flow_capture_args (str): Custom additional arguments to be passed -# to flow-collector (default empty). +# flow_capture_flags (str): Custom additional arguments to be passed +# to flow-collector (default "-E 128M"). +# flow_capture_profiles (str): A list of configuration profiles to enable. +# This allows you to run several instances of +# flow-capture with different parameters. +# Consider the following example: +# flow_capture_enable="YES" +# flow_capture_localip="85.172.168.9" +# flow_capture_profiles="r1 r2" +# flow_capture_r1_datadir="/var/db/flows/r1" +# flow_capture_r1_port="4444" +# flow_capture_r1_flags="-E20G -n287 -N-2" +# flow_capture_r2_datadir="/var/db/flows/r2" +# flow_capture_r2_port="4445" +# flow_capture_r2_flags="-E5G -n287 -N-2" # +# This will run two instances of the flow-capture +# with parameters taken from appropriate +# flow_capture_PROFILENAME_xxx variables. For +# unspecified parameters flow_capture_xxx +# varialbes will be used. . /etc/rc.subr name="flow_capture" rcvar=`set_rcvar` +setup_profile_vars() +{ + name=flow_capture_$1 + eval ": \${flow_capture_${1}_datadir=${flow_capture_datadir}}" + eval ": \${flow_capture_${1}_localip=${flow_capture_localip}}" + eval ": \${flow_capture_${1}_remoteip=${flow_capture_remoteip}}" + eval ": \${flow_capture_${1}_port=${flow_capture_port}}" + eval ": \${flow_capture_${1}_user=${flow_capture_user}}" + eval ": \${flow_capture_${1}_group=${flow_capture_group}}" + eval ": \${flow_capture_${1}_flags=${flow_capture_flags}}" + eval "pidfile=${flow_capture_pid}.\${flow_capture_${1}_port}" + eval "command_args=\"-w \${flow_capture_${1}_datadir} -p ${flow_capture_pid} \${flow_capture_${1}_localip}/\${flow_capture_${1}_remoteip}/\${flow_capture_${1}_port}\"" +} + +start_profiles() +{ + unset start_cmd + for _profile in ${flow_capture_profiles}; do + setup_profile_vars $_profile + run_rc_command "${rc_arg}" + done +} + +stop_profiles() +{ + unset stop_cmd + for _profile in ${flow_capture_profiles}; do + setup_profile_vars $_profile + run_rc_command "${rc_arg}" + done +} + load_rc_config $name : ${flow_capture_enable="NO"} -: ${flow_tools_datadir="%%FLOW_CAPTURE_SPOOL%%"} -: ${flow_tools_datasize="128M"} +: ${flow_capture_datadir="%%FLOW_CAPTURE_SPOOL%%"} : ${flow_capture_localip="0.0.0.0"} : ${flow_capture_remoteip="0.0.0.0"} : ${flow_capture_port="8787"} : ${flow_capture_pid="%%FLOW_CAPTURE_PIDDIR%%/flow-capture.pid"} : ${flow_capture_user="flowtools"} : ${flow_capture_group="flowtools"} -: ${flow_capture_args=""} +: ${flow_capture_flags="-E 128M"} pidfile="${flow_capture_pid}.${flow_capture_port}" command="%%PREFIX%%/bin/flow-capture" -command_args="${flow_capture_args} -E ${flow_tools_datasize} -w ${flow_tools_datadir} -p ${flow_capture_pid} ${flow_capture_localip}/${flow_capture_remoteip}/${flow_capture_port}" +command_args="-w ${flow_capture_datadir} -p ${flow_capture_pid} ${flow_capture_localip}/${flow_capture_remoteip}/${flow_capture_port}" + +cmd="$1" +if [ $# -gt 0 ]; then + shift +fi + +[ -n "$*" ] && flow_capture_profiles="$*" + +if [ "${flow_capture_profiles}" ]; then + start_cmd="start_profiles" + stop_cmd="stop_profiles" +fi -run_rc_command "$1" +run_rc_command "$cmd" diff --git a/net-mgmt/flow-tools/files/patch-lib-ftfile.c b/net-mgmt/flow-tools/files/patch-lib-ftfile.c new file mode 100644 index 000000000000..0418caa8ac0a --- /dev/null +++ b/net-mgmt/flow-tools/files/patch-lib-ftfile.c @@ -0,0 +1,100 @@ +--- lib/ftfile.c.orig Thu Feb 13 05:38:42 2003 ++++ lib/ftfile.c Fri Feb 10 10:39:40 2006 +@@ -311,7 +311,7 @@ + int ftfile_expire (struct ftfile_entries *fte, int doit, int curbytes) + { + u_int i; +- struct ftfile_entry *n1; ++ struct ftfile_entry *n1, *n2; + u_int64 bytes; + + /* +@@ -323,15 +323,20 @@ + bytes = 0; + + if (fte->max_files && (fte->num_files > fte->max_files)) { ++ n2 = NULL; + FT_TAILQ_FOREACH(n1, &fte->head, chain) { ++ if (n2 != NULL) { ++ ftfile_entry_free(n2); ++ n2 = NULL; ++ } + fterr_info("remove/1 %s", n1->name); + bytes += n1->size; + ++i; + if (doit) { ++ n2 = n1; + FT_TAILQ_REMOVE(&fte->head, n1, chain); + if (unlink(n1->name) == -1) + fterr_warn("unlink(%s)", n1->name); +- ftfile_entry_free(n1); + } /* doit */ + if ((fte->num_files - i) <= fte->max_files) + break; +@@ -340,6 +345,10 @@ + fte->num_files -= i; + fte->num_bytes -= bytes; + } /* doit */ ++ if (n2 != NULL) { ++ ftfile_entry_free(n2); ++ n2 = NULL; ++ } + } /* if */ + + if (debug) +@@ -354,15 +363,20 @@ + */ + + if (fte->max_bytes && (fte->num_bytes+curbytes > fte->max_bytes)) { ++ n2 = NULL; + FT_TAILQ_FOREACH(n1, &fte->head, chain) { ++ if (n2 != NULL) { ++ ftfile_entry_free(n2); ++ n2 = NULL; ++ } + fterr_info("remove/2 %s", n1->name); + bytes += n1->size; + ++i; + if (doit) { ++ n2 = n1; + FT_TAILQ_REMOVE(&fte->head, n1, chain); + if (unlink(n1->name) == -1) + fterr_warn("unlink(%s)", n1->name); +- ftfile_entry_free(n1); + } /* doit */ + if ((fte->num_bytes+curbytes - bytes) <= fte->max_bytes) + break; +@@ -371,6 +385,10 @@ + fte->num_files -= i; + fte->num_bytes -= bytes; + } /* doit */ ++ if (n2 != NULL) { ++ ftfile_entry_free(n2); ++ n2 = NULL; ++ } + } /* if */ + + if (debug) +@@ -762,13 +780,19 @@ + { + struct ftfile_entry *n1, *n2; + ++ n2 = NULL; + FT_TAILQ_FOREACH(n1, &fte->head, chain) { ++ if (n2 != NULL) { ++ ftfile_entry_free(n2); ++ n2 = NULL; ++ } + FT_TAILQ_REMOVE(&fte->head, n1, chain); + n2 = n1; +- n1 = FT_TAILQ_NEXT(n1, chain); ++ } ++ ++ if (n2 != NULL) { + ftfile_entry_free(n2); +- if (!n1) +- break; ++ n2 = NULL; + } + + } /* ftfile_free */ |