Ignore:
Timestamp:
02/18/15 17:41:48 (6 years ago)
Author:
Richard Sanger <rsangerarj@…>
Branches:
4.0.1-hotfixes, cachetimestamps, develop, dpdk-ndag, etsilive, libtrace4, master, ndag_format, pfring, rc-4.0.1, rc-4.0.2, rc-4.0.3, rc-4.0.4, ringdecrementfix, ringperformance, ringtimestampfixes
Children:
e4f27d1
Parents:
8bcc925
Message:

Deprecate trace_get_filtered/accepted/recevied/dropped() in favour of a single function

Adds the single trace_get_statistics function. This allows the structure to be filled
at a point in time, rather than making multiple calls to the library during which state
might have changed.

This has been designed such that the structure can be added to in the future without
breaking old code.

The old internal get_captured_packets was removed from the formats as it was never used.
Eventually we should completely remove get_filtered and received from the formats and replace
them with get_statistics.

In additon some extra fields have added, such as error and captured and the pre-existing
fields are better defined.

The linux formats have been updated to use this new API, which combined with reading
/proc/net/dev returns a full set of statistics.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tools/tracestats/tracestats.c

    r3c54095 r5ab626a  
    8484        uint64_t count = 0;
    8585        uint64_t bytes = 0;
    86         uint64_t packets;
     86        libtrace_stat_t *stats;
    8787
    8888        fprintf(stderr,"%s:\n",uri);
     
    128128                ++count;
    129129                bytes+=wlen;
    130         }
     130        }
     131
     132        stats = trace_get_statistics(trace, NULL);
    131133
    132134        printf("%-30s\t%12s\t%12s\t%7s\n","filter","count","bytes","%");
     
    136138                filters[i].count=0;
    137139        }
    138         packets=trace_get_received_packets(trace);
    139         if (packets!=UINT64_MAX)
     140        if (stats->received_valid)
    140141                fprintf(stderr,"%30s:\t%12" PRIu64"\n",
    141                                 "Input packets", packets);
    142         packets=trace_get_filtered_packets(trace);
    143         if (packets!=UINT64_MAX)
     142                                "Input packets", stats->received);
     143        if (stats->filtered_valid)
    144144                fprintf(stderr,"%30s:\t%12" PRIu64"\n",
    145                                 "Filtered packets", packets);
    146         packets=trace_get_dropped_packets(trace);
    147         if (packets!=UINT64_MAX)
     145                                "Filtered packets", stats->filtered);
     146        if (stats->dropped_valid)
    148147                fprintf(stderr,"%30s:\t%12" PRIu64"\n",
    149                                 "Dropped packets",packets);
    150         packets=trace_get_accepted_packets(trace);
    151         if (packets!=UINT64_MAX)
     148                                "Dropped packets",stats->dropped);
     149        if (stats->accepted_valid)
    152150                fprintf(stderr,"%30s:\t%12" PRIu64 "\n",
    153                                 "Accepted Packets",packets);
     151                                "Accepted packets", stats->accepted);
     152        if (stats->errors_valid)
     153                fprintf(stderr,"%30s:\t%12" PRIu64 "\n",
     154                                "Erred packets", stats->errors);
    154155        printf("%30s:\t%12"PRIu64"\t%12" PRIu64 "\n","Total",count,bytes);
    155156        totcount+=count;
Note: See TracChangeset for help on using the changeset viewer.