2

I want to monitor the network traffic and save the results to a file under Debian Linux. I am using iftop to achieve this.

Following command does the job:

iftop -tnNBP -s 3600 -o destination > output.txt 2>&1

My problem is: if more than 10 connections are present during the monitoring time (1 hour), only the first 10 is saved to the output.txt file. The rest of the connections are not shown.

How can I configure the iftop to display all of the connection (regardless how much they are/were).

A.V.
  • 55
  • 6

1 Answers1

3

I couldn't find it in iftop's configuration file documentation but I did find it in the source:

167    options.num_lines = 10;

[...]

587     options_config_get_int("num-lines", &options.num_lines);

[...]

297            case 'L':
298                 config_set_string("num-lines", optarg);
299                 break;
  • UPDATE: but actually, as @GAD3R kindly told me, this information is also available in the command's built-in help:

    # iftop --usage
    [...]
       The following options are only available in combination with -t
       -s num              print one single text output afer num seconds, then quit
       -L num              number of lines to print
    

The option is thus -L. Values 0 or -1 won't help (no result displayed):

iftop -L 2000000000 -tnNBP -s 3600 -o destination > output.txt 2>&1

should do what you're looking for (up to 2000000000 lines). Or alternatively, you can use this configuration option in the ~/.iftoprc file:

num-lines:2000000000

which will be used only if the command is run with -t or the other configuration option no-curses:true is also present.

and run as usual:

iftop -tnNBP -s 3600 -o destination > output.txt 2>&1
A.B
  • 31,762
  • 2
  • 62
  • 101