As suggested on wireshark-users, when using io,stat in tshark, make an
authorSake Blok <sake@euronet.nl>
Thu, 12 Mar 2009 22:44:58 +0000 (22:44 -0000)
committerSake Blok <sake@euronet.nl>
Thu, 12 Mar 2009 22:44:58 +0000 (22:44 -0000)
interval of 0 signify "all packets".

svn path=/trunk/; revision=27715

doc/tshark.pod
tap-iostat.c

index 8732b2aafc61fbf34ff3fc65b0fc9b6af4e80b6c..c09a415c772ed0abe338f5b73a8a2f90f5ddf85a 100644 (file)
@@ -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
index 456b5cdf5b119e92f341655645bed9c181c90164..df4a1a149089afb5d38d3b209950913c67d6c6ce 100644 (file)
@@ -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);
        }