[flow-tools] memory-lack in flow-capture ?
Mark Fullmer
maf@splintered.net
Sun, 26 May 2002 15:16:24 -0400
Fix below.
Index: flow-capture.c
===================================================================
RCS file: /usr/home/djnz-cvsroot/flow-tools/src/flow-capture.c,v
retrieving revision 1.57
retrieving revision 1.58
diff -c -r1.57 -r1.58
*** flow-capture.c 23 May 2002 14:19:10 -0000 1.57
--- flow-capture.c 26 May 2002 19:10:48 -0000 1.58
***************
*** 23,29 ****
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
! * $Id: flow-capture.c,v 1.57 2002/05/23 14:19:10 maf Exp $
*/
#include <sys/time.h>
--- 23,29 ----
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
! * $Id: flow-capture.c,v 1.58 2002/05/26 19:10:48 maf Exp $
*/
#include <sys/time.h>
***************
*** 236,246 ****
--- 236,250 ----
case 'e': /* expire */
fte.max_files = atoi(optarg);
+ if (fte.max_files)
+ fte.expiring = 1;
break;
case 'E': /* expire bytes */
if ((fte.max_bytes = scan_size(optarg)) == -1)
fterr_errx(1, "scan_size(): failed");
+ if (fte.max_bytes)
+ fte.expiring = 1;
break;
case 'd': /* debug */
***************
*** 389,404 ****
/*
* load directory entries into the file ager
*/
! if (ftfile_loaddir(&fte, ".", FT_FILE_SORT|FT_FILE_INIT|FT_FILE_CHECKNAMES))
! fterr_errx(1, "ftfile_scandir(): failed");
/* debugging gets a dump of the ager */
if (debug)
ftfile_dump(&fte);
/* run the ager once now */
! if (ftfile_expire(&fte, enable_unlink, (u_int32)0))
! fterr_errx(1, "ftfile_export(): failed");
/* get hostname */
if (gethostname((char*)&ftset.hnbuf, FT_HOSTNAME_LEN-1) == -1)
--- 393,410 ----
/*
* load directory entries into the file ager
*/
! if (fte.expiring)
! if (ftfile_loaddir(&fte, ".", FT_FILE_SORT|FT_FILE_INIT|FT_FILE_CHECKNAMES))
! fterr_errx(1, "ftfile_scandir(): failed");
/* debugging gets a dump of the ager */
if (debug)
ftfile_dump(&fte);
/* run the ager once now */
! if (fte.expiring)
! if (ftfile_expire(&fte, enable_unlink, (u_int32)0))
! fterr_errx(1, "ftfile_export(): failed");
/* get hostname */
if (gethostname((char*)&ftset.hnbuf, FT_HOSTNAME_LEN-1) == -1)
***************
*** 1012,1020 ****
fterr_err(1, "rename(%s,%s)", cap_file.name, cap_file.nname);
/* add it to the ager */
! if (ftfile_add_tail(&fte, cap_file.nname, cap_file.nbytes,
! cap_file.time))
! fterr_errx(1, "ftfile_add_tail(%s): failed", cap_file.name);
/* debugging gets a dump of the ager */
if (debug)
--- 1018,1027 ----
fterr_err(1, "rename(%s,%s)", cap_file.name, cap_file.nname);
/* add it to the ager */
! if (fte.expiring)
! if (ftfile_add_tail(&fte, cap_file.nname, cap_file.nbytes,
! cap_file.time))
! fterr_errx(1, "ftfile_add_tail(%s): failed", cap_file.name);
/* debugging gets a dump of the ager */
if (debug)
***************
*** 1091,1098 ****
if (!(cap_file.hdr_nflows % 1001)) {
! if (ftfile_expire(&fte, enable_unlink, cap_file.nbytes))
! fterr_errx(1, "ftfile_expire(): failed");
} /* ager run? */
--- 1098,1106 ----
if (!(cap_file.hdr_nflows % 1001)) {
! if (fte.expiring)
! if (ftfile_expire(&fte, enable_unlink, cap_file.nbytes))
! fterr_errx(1, "ftfile_expire(): failed");
} /* ager run? */
***************
*** 1106,1112 ****
fterr_info("SIGQUIT");
/* free storage allocated to file entries */
! ftfile_free(&fte);
return 0;
--- 1114,1121 ----
fterr_info("SIGQUIT");
/* free storage allocated to file entries */
! if (fte.expiring)
! ftfile_free(&fte);
return 0;
Index: ftlib.h
===================================================================
RCS file: /usr/home/djnz-cvsroot/flow-tools/lib/ftlib.h,v
retrieving revision 1.44
retrieving revision 1.45
diff -c -r1.44 -r1.45
*** ftlib.h 20 Apr 2002 22:29:11 -0000 1.44
--- ftlib.h 26 May 2002 19:10:50 -0000 1.45
***************
*** 23,29 ****
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
! * $Id: ftlib.h,v 1.44 2002/04/20 22:29:11 maf Exp $
*/
#ifndef FTLIB_H
--- 23,29 ----
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
! * $Id: ftlib.h,v 1.45 2002/05/26 19:10:50 maf Exp $
*/
#ifndef FTLIB_H
***************
*** 1842,1847 ****
--- 1842,1848 ----
u_int64 max_bytes; /* min space before removing files 0=disable */
u_int32 max_files; /* max num of files to keep before removing 0=disable */
u_int32 num_files; /* number of files in the queue */
+ int expiring; /* expiring in use? */
};
Index: ftio.c
===================================================================
RCS file: /usr/home/djnz-cvsroot/flow-tools/lib/ftio.c,v
retrieving revision 1.37
retrieving revision 1.38
diff -c -r1.37 -r1.38
*** ftio.c 26 May 2002 17:48:56 -0000 1.37
--- ftio.c 26 May 2002 17:49:56 -0000 1.38
***************
*** 23,29 ****
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
! * $Id: ftio.c,v 1.37 2002/05/26 17:48:56 maf Exp $
*/
#include <sys/time.h>
--- 23,29 ----
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
! * $Id: ftio.c,v 1.38 2002/05/26 17:49:56 maf Exp $
*/
#include <sys/time.h>
***************
*** 770,782 ****
} /* io stream enabled for write */
- ret = close(ftio->fd);
-
- /* return bytes written if no error */
- if (ret >= 0)
- ret = nbytes;
-
- return ret;
ftio_close_out:
--- 770,775 ----
***************
*** 796,802 ****
} /* FT_IO_FLAG_WRITE */
! close(ftio->fd);
return ret;
--- 789,803 ----
} /* FT_IO_FLAG_WRITE */
! /* don't lose error condition if close() is a success */
! if (ret < 0)
! ret = close(ftio->fd);
! else
! close(ftio->fd);
!
! /* no error and writing? then return bytes written */
! if ((ftio->flags & FT_IO_FLAG_WRITE) && (ret >= 0))
! ret = nbytes;
return ret;
On Tue, May 21, 2002 at 01:54:18PM +0200, Christian Bauer wrote:
> Hi There..
>
> is it possible that there is a memory lack in the flow-capture tool ?
> i attached 2 gfx with a graph of memory and swap usage of my system.
> there are no other programs running.. and i checked the memory usage
> with ps.
>
> if i kill the flow-capture-process and restart it again, all memory will
> be freed.
>
> i start the captureing with this arguments:
>
> /path/to/bins/flow-capture -V 7 -R /path/to/scripts/script.sh -w
> /path/to/data/ -n 287 0/0/1234
>
> script.sh runs a flow-header and flow-stat and writes the output in a file.
>
> I've got 5 Version5 exporter and 2 Version7 exporter and about 30Gig of
> Flow-Data per week.
> all running on a dual PIII intel machine with linux. kernel 2.4.18.
> Flow-Tools 0.57
>
> thanx for help
> chris
>
> --
> NEFkom Telekommunikation GmbH & Co.
> Spittlertorgraben 13 Tel. 0911/1808-18
> D-90429 Nuernberg Fax. 0911/1808-409
> http://www.NEFkom.de mailto:Christian.Bauer@NEFkom.de
>
>