- Timestamp:
- 09/10/15 16:42:23 (5 years ago)
- 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:
- ab7e4ee
- Parents:
- 9346e4a
- Location:
- tools/tracertstats
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
tools/tracertstats/Makefile.am
r29bbef0 rd2df7c4 1 bin_PROGRAMS = tracertstats tracertstats_parallel1 bin_PROGRAMS = tracertstats 2 2 man_MANS = tracertstats.1 3 3 EXTRA_DIST = $(man_MANS) … … 16 16 tracertstats_SOURCES = tracertstats.c output.h output.c $(OUTPUT_MODULES) 17 17 tracertstats_LDADD = -ltrace $(OUTPUT_PNG_LD) 18 tracertstats_parallel_SOURCES = tracertstats_parallel.c output.h output.c $(OUTPUT_MODULES)19 tracertstats_parallel_LDADD = -ltrace $(OUTPUT_PNG_LD) -
tools/tracertstats/tracertstats.1
rd6dc0f6 rd2df7c4 6 6 [ -f | --filter bpf ] 7 7 [ -i | --interval interval ] 8 [ -t | --threads max ] 8 9 [ -c | --count count ] 9 10 [ -o | --output-format csv,txt,png,html ] … … 34 35 .TP 35 36 .PD 0 37 .BI \-t " max" 38 .TP 39 .PD 40 .BI \-\^\-threads " max" 41 Use \fImax\fR packet processing threads. The default is 4 threads, but adding 42 more or less threads may improve performance. 43 44 .TP 45 .PD 0 36 46 .BI \-c " count" 37 47 .TP 38 48 .PD 39 49 .BI \-\^\-count " count" 40 Output results every \fIcount\fR packets. 50 Stop after processing this amount of packets. Note that this is only a 51 lower bound as this is only evaluated once per thread per interval. 41 52 42 53 .TP -
tools/tracertstats/tracertstats.c
rc3cb9f9 rd2df7c4 63 63 #define DEFAULT_OUTPUT_FMT "txt" 64 64 65 struct libtrace_t *trace;66 65 char *output_format=NULL; 67 68 66 int merge_inputs = 0; 69 67 int threadcount = 4; 68 int filter_count=0; 70 69 71 70 struct filter_t { … … 75 74 uint64_t bytes; 76 75 } *filters = NULL; 77 int filter_count=0;78 uint64_t totcount;79 uint64_t totbytes;80 76 81 77 uint64_t packet_count=UINT64_MAX; 82 78 double packet_interval=UINT32_MAX; 83 84 79 85 80 struct output_data_t *output = NULL; … … 135 130 136 131 static uint64_t glob_last_ts = 0; 137 static void process_result(libtrace_t *trace UNUSED, int mesg,132 static void process_result(libtrace_t *trace, int mesg, 138 133 libtrace_generic_t data, 139 134 libtrace_thread_t *sender UNUSED) { 140 static uint64_t ts = 0; 135 uint64_t ts = 0; 136 static bool stopped = false; 137 static uint64_t packets_seen = 0; 141 138 int j; 142 139 result_t *res; 140 141 if (stopped) 142 return; 143 143 144 144 switch (mesg) { … … 157 157 } 158 158 count += res->total.count; 159 packets_seen += res->total.count; 159 160 bytes += res->total.bytes; 160 161 for (j = 0; j < filter_count; j++) { … … 164 165 free(res); 165 166 } 167 168 /* Be careful to only call pstop once from within this thread! */ 169 if (packets_seen > packet_count) { 170 trace_pstop(trace); 171 stopped = true; 172 } 166 173 } 167 174 … … 214 221 trace_publish_result(trace, t, last_key, tmp, RESULT_USER); 215 222 trace_post_reporter(trace); 216 free(results);217 223 results = NULL; 218 224 } … … 239 245 static void run_trace(char *uri) 240 246 { 247 libtrace_t *trace = NULL; 241 248 if (!merge_inputs) 242 249 create_output(uri); … … 253 260 return; 254 261 } 255 /*256 if (trace_start(trace)==-1) {257 trace_perror(trace,"trace_start");258 trace_destroy(trace);259 if (!merge_inputs)260 output_destroy(output);261 return;262 }*/263 262 trace_set_combiner(trace, &combiner_ordered, (libtrace_generic_t){0}); 264 263 trace_set_tracetime(trace, true); 265 264 trace_set_perpkt_threads(trace, threadcount); 266 267 //trace_set_hasher(trace, HASHER_CUSTOM, &bad_hash, NULL);268 265 269 266 if (trace_get_information(trace)->live) { … … 294 291 295 292 } 293 296 294 // TODO Decide what to do with -c option 297 295 static void usage(char *argv0) … … 300 298 "%s flags libtraceuri [libtraceuri...]\n" 301 299 "-i --interval=seconds Duration of reporting interval in seconds\n" 302 "-c --count=packets Exit after count packets received\n"300 "-c --count=packets Exit after count packets have been processed\n" 303 301 "-t --threads=max Create 'max' processing threads (default: 4)\n" 304 302 "-o --output-format=txt|csv|html|png Reporting output format\n" … … 350 348 break; 351 349 case 'c': 352 packet_count= atoi(optarg);350 packet_count=strtoul(optarg, NULL, 10); 353 351 break; 354 352 case 'o':
Note: See TracChangeset
for help on using the changeset viewer.