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_parallel.c

    rd994324 r5ab626a  
    132132                        case MESSAGE_STOPPING:
    133133                                trace_publish_result(trace, t, 0, (libtrace_generic_types_t){.ptr = results}, RESULT_NORMAL); // Only ever using a single key 0
    134                                 fprintf(stderr, "Thread published resuslts WOWW\n");
     134                                //fprintf(stderr, "tracestats_parallel:\t Stopping thread - publishing results\n");
    135135                                break;
    136136                        case MESSAGE_STARTING:
     
    138138                                break;
    139139                        case MESSAGE_DO_PAUSE:
    140                                 fprintf(stderr, "GOT Asked to pause ahh\n");
     140                                assert(!"GOT Asked to pause!!!\n");
    141141                                break;
    142142                        case MESSAGE_PAUSING:
    143                                 fprintf(stderr, "Thread is pausing\n");
     143                                //fprintf(stderr, "tracestats_parallel:\t pausing thread\n");
    144144                                break;
    145145                        case MESSAGE_RESUMING:
    146                                 fprintf(stderr, "Thread has paused\n");
     146                                //fprintf(stderr, "tracestats_parallel:\t resuming thread\n");
    147147                                break;
    148148                }
     
    168168                free(res);
    169169        } else switch (mesg->code) {
     170                libtrace_stat_t *stats;
    170171                case MESSAGE_STOPPING:
     172                        stats = trace_get_statistics(trace, NULL);
    171173                        printf("%-30s\t%12s\t%12s\t%7s\n","filter","count","bytes","%");
    172174                        for(i=0;i<filter_count;++i) {
     
    175177                                filters[i].count=0;
    176178                        }
    177                         packets=trace_get_received_packets(trace);
    178                         if (packets!=UINT64_MAX)
     179                        if (stats->received_valid)
    179180                                fprintf(stderr,"%30s:\t%12" PRIu64"\n",
    180                                                 "Input packets", packets);
    181                         packets=trace_get_filtered_packets(trace);
    182                         if (packets!=UINT64_MAX)
     181                                                "Input packets", stats->received);
     182                        if (stats->filtered_valid)
    183183                                fprintf(stderr,"%30s:\t%12" PRIu64"\n",
    184                                                 "Filtered packets", packets);
    185                         packets=trace_get_dropped_packets(trace);
    186                         if (packets!=UINT64_MAX)
     184                                                "Filtered packets", stats->filtered);
     185                        if (stats->dropped_valid)
    187186                                fprintf(stderr,"%30s:\t%12" PRIu64"\n",
    188                                                 "Dropped packets",packets);
    189                         packets=trace_get_accepted_packets(trace);
    190                         if (packets!=UINT64_MAX)
     187                                                "Dropped packets",stats->dropped);
     188                        if (stats->accepted_valid)
    191189                                fprintf(stderr,"%30s:\t%12" PRIu64 "\n",
    192                                                 "Accepted Packets",packets);
     190                                                "Accepted packets", stats->accepted);
     191                        if (stats->errors_valid)
     192                                fprintf(stderr,"%30s:\t%12" PRIu64 "\n",
     193                                                "Erred packets", stats->errors);
    193194                        printf("%30s:\t%12"PRIu64"\t%12" PRIu64 "\n","Total",count,bytes);
    194195                        totcount+=count;
Note: See TracChangeset for help on using the changeset viewer.