Changeset 1800ee3
- Timestamp:
- 11/28/18 11:44:35 (2 years ago)
- Branches:
- develop
- Children:
- 54642da
- Parents:
- 8a12a49
- git-author:
- Shane Alcock <salcock@…> (11/28/18 11:43:25)
- git-committer:
- Shane Alcock <salcock@…> (11/28/18 11:44:35)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tools/tracertstats/tracertstats.c
r02d13cb r1800ee3 66 66 int filter_count=0; 67 67 int burstsize=10; 68 uint8_t report_drops = 0; 68 69 69 70 struct filter_t { … … 90 91 } 91 92 92 static void report_results(double ts,uint64_t count,uint64_t bytes) 93 static void report_results(double ts,uint64_t count,uint64_t bytes, 94 libtrace_stat_t *stats) 93 95 { 94 int i=0 ;96 int i=0, offset = 3; 95 97 output_set_data_time(output,0,ts); 96 98 output_set_data_int(output,1,count); 97 99 output_set_data_int(output,2,bytes); 100 if (stats) { 101 if (stats->dropped_valid) { 102 output_set_data_int(output, 3, stats->dropped); 103 } else { 104 output_set_data_int(output, 3, -1); 105 } 106 if (stats->missing_valid) { 107 output_set_data_int(output, 4, stats->missing); 108 } else { 109 output_set_data_int(output, 4, -1); 110 } 111 offset += 2; 112 } 98 113 for(i=0;i<filter_count;++i) { 99 output_set_data_int(output,i*2+ 3,filters[i].count);100 output_set_data_int(output,i*2+ 4,filters[i].bytes);114 output_set_data_int(output,i*2+offset,filters[i].count); 115 output_set_data_int(output,i*2+offset+1,filters[i].bytes); 101 116 filters[i].count=filters[i].bytes=0; 102 117 } … … 115 130 output_add_column(output,"packets"); 116 131 output_add_column(output,"bytes"); 132 if (report_drops) { 133 output_add_column(output, "dropped"); 134 output_add_column(output, "missing"); 135 } 117 136 for(i=0;i<filter_count;++i) { 118 137 char buff[1024]; … … 145 164 int j; 146 165 result_t *res; 166 libtrace_stat_t *stats = NULL; 147 167 148 168 if (stopped) … … 153 173 if (glob_last_ts == 0) 154 174 glob_last_ts = ts; 175 if (report_drops) { 176 stats = trace_create_statistics(); 177 trace_get_statistics(trace, stats); 178 } 155 179 while ((glob_last_ts >> 32) < (ts >> 32)) { 156 report_results(glob_last_ts >> 32, count, bytes );180 report_results(glob_last_ts >> 32, count, bytes, stats); 157 181 count = 0; 158 182 bytes = 0; … … 169 193 } 170 194 free(res); 195 if (stats) { 196 free(stats); 197 } 171 198 172 199 /* Be careful to only call pstop once from within this thread! */ … … 261 288 libtrace_t *trace = NULL; 262 289 libtrace_callback_set_t *pktcbs, *repcbs; 290 libtrace_stat_t *stats = NULL; 263 291 264 292 if (!merge_inputs) … … 312 340 313 341 // Flush the last one out 314 report_results((glob_last_ts >> 32), count, bytes); 342 if (report_drops) { 343 stats = trace_create_statistics(); 344 stats = trace_get_statistics(trace, stats); 345 } 346 report_results((glob_last_ts >> 32), count, bytes, stats); 315 347 if (trace_is_err(trace)) 316 348 trace_perror(trace,"%s",uri); 317 349 350 if (stats) { 351 free(stats); 352 } 318 353 trace_destroy(trace); 319 354 trace_destroy_callback_set(pktcbs); … … 338 373 "-N --nobuffer Disable packet buffering within libtrace to force faster\n" 339 374 " updates at very low traffic rates\n" 375 "-d --report-drops Include statistics about number of packets dropped or\n" 376 " lost by the capture process\n" 340 377 "-h --help Print this usage statement\n" 341 378 ,argv0); … … 358 395 { "threads", 1, 0, 't' }, 359 396 { "nobuffer", 0, 0, 'N' }, 397 { "report-drops", 0, 0, 'd' }, 360 398 { NULL, 0, 0, 0 }, 361 399 }; 362 400 363 int c=getopt_long(argc, argv, "c:f:i:o:t: hmN",401 int c=getopt_long(argc, argv, "c:f:i:o:t:dhmN", 364 402 long_options, &option_index); 365 403 … … 368 406 369 407 switch (c) { 408 case 'd': 409 report_drops = 1; 410 break; 370 411 case 'N': 371 412 burstsize = 1;
Note: See TracChangeset
for help on using the changeset viewer.