diff options
author | sake <sake@f5534014-38df-0310-8fa8-9805f1628bb7> | 2009-03-12 22:44:58 +0000 |
---|---|---|
committer | sake <sake@f5534014-38df-0310-8fa8-9805f1628bb7> | 2009-03-12 22:44:58 +0000 |
commit | 84975cea9b3384cba69a286b36f38ade6328a67f (patch) | |
tree | 2a6ce42b08212f28d8c5c692c4783aae7019bb3b | |
parent | d3d369614c50a0d215a6ed127bad31daad0b809f (diff) |
As suggested on wireshark-users, when using io,stat in tshark, make an
interval of 0 signify "all packets".
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@27715 f5534014-38df-0310-8fa8-9805f1628bb7
-rw-r--r-- | doc/tshark.pod | 1 | ||||
-rw-r--r-- | tap-iostat.c | 27 |
2 files changed, 21 insertions, 7 deletions
diff --git a/doc/tshark.pod b/doc/tshark.pod index 8732b2aafc..c09a415c77 100644 --- a/doc/tshark.pod +++ b/doc/tshark.pod @@ -539,6 +539,7 @@ B<-z> io,stat,I<interval>[,I<filter>][,I<filter>][,I<filter>]... Collect packet/bytes statistics for the capture in intervals of I<interval> seconds. I<Intervals> can be specified either as whole or fractional seconds. Interval can be specified in ms resolution. +If Interval is 0, the statistics will be calculated over all packets. If no I<filter> is specified the statistics will be calculated for all packets. If one or more I<filters> are specified statistics will be calculated for diff --git a/tap-iostat.c b/tap-iostat.c index 456b5cdf5b..df4a1a1490 100644 --- a/tap-iostat.c +++ b/tap-iostat.c @@ -284,7 +284,8 @@ iostat_draw(void *arg) printf("\n"); printf("===================================================================\n"); printf("IO Statistics\n"); - printf("Interval: %d.%03d secs\n", iot->interval/1000, iot->interval%1000); + if(iot->interval!=G_MAXINT32) + printf("Interval: %d.%03d secs\n", iot->interval/1000, iot->interval%1000); for(i=0;i<iot->num_items;i++){ printf("Column #%d: %s\n",i,iot->filters[i]?iot->filters[i]:""); } @@ -353,9 +354,14 @@ iostat_draw(void *arg) } if(more_items){ - printf("%03d.%03d-%03d.%03d ", - t/1000,t%1000, - (t+iot->interval)/1000,(t+iot->interval)%1000); + if(iot->interval==G_MAXINT32) { + printf("000.000- "); + } else { + printf("%03d.%03d-%03d.%03d ", + t/1000,t%1000, + (t+iot->interval)/1000, + (t+iot->interval)%1000); + } for(i=0;i<iot->num_items;i++){ switch(iot->items[i].calc_type){ case CALC_TYPE_BYTES: @@ -625,11 +631,18 @@ iostat_init(const char *optarg, void* userdata _U_) exit(1); } + /* if interval is 0, calculate statistics over the whole file + * by setting the interval to G_MAXINT32 + */ + if(interval_float==0) { + interval=G_MAXINT32; + } else { + /* make interval be number of ms */ + interval=(gint32)(interval_float*1000.0+0.9); + } - /* make interval be number of ms */ - interval=(gint32)(interval_float*1000.0+0.9); if(interval<1){ - fprintf(stderr, "tshark: \"-z\" interval must be >=0.001 seconds.\n"); + fprintf(stderr, "tshark: \"-z\" interval must be >=0.001 seconds or 0.\n"); exit(10); } |