Changeset 67e9e2e
- Timestamp:
- 10/12/09 11:03:29 (11 years ago)
- Branches:
- 4.0.1-hotfixes, cachetimestamps, develop, dpdk-ndag, etsilive, getfragoff, help, 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:
- 23e1258
- Parents:
- c3c2c0b
- Location:
- tools/tracertstats
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
tools/tracertstats/tracertstats.1
r3298e12 r67e9e2e 8 8 [ -c | --count count ] 9 9 [ -o | --output-format csv,txt,png,html ] 10 [ -m | --merge-inputs ] 10 11 inputuri... 11 12 .P … … 41 42 .TP 42 43 .PD 0 44 .BI \-m 45 .TP 46 .PD 47 .BI \-\^\-merge-inputs 48 Treats all inputs as a single input, resulting a single unified output rather 49 than an output for each input. Works best with traces that are consecutive to 50 create a single CSV, for instance. 51 52 .TP 53 .PD 0 43 54 .BI \-o " format" 44 55 .TP 45 56 .PD 46 57 .BI \-\^\-output\-format " format" 47 Selects the output format 58 Selects the output format. 48 59 49 60 .RS -
tools/tracertstats/tracertstats.c
r530bcf0 r67e9e2e 64 64 char *output_format=NULL; 65 65 66 int merge_inputs = 0; 67 66 68 struct filter_t { 67 69 char *expr; … … 94 96 } 95 97 98 static void create_output(char *title) { 99 int i; 100 101 output=output_init(title,output_format?output_format:"txt"); 102 if (!output) { 103 fprintf(stderr,"Failed to create output file\n"); 104 return; 105 } 106 output_add_column(output,"ts"); 107 output_add_column(output,"packets"); 108 output_add_column(output,"bytes"); 109 for(i=0;i<filter_count;++i) { 110 char buff[1024]; 111 snprintf(buff,sizeof(buff),"%s packets",filters[i].expr); 112 output_add_column(output,buff); 113 snprintf(buff,sizeof(buff),"%s bytes",filters[i].expr); 114 output_add_column(output,buff); 115 } 116 output_flush_headings(output); 117 118 } 119 96 120 /* Process a trace, counting packets that match filter(s) */ 97 121 static void run_trace(char *uri) … … 104 128 double ts = 0; 105 129 106 fprintf(stderr,"output format: '%s'\n",output_format); 107 output=output_init(uri,output_format?output_format:"txt"); 108 if (!output) { 109 fprintf(stderr,"Failed to create output file\n"); 110 return; 111 } 112 output_add_column(output,"ts"); 113 output_add_column(output,"packets"); 114 output_add_column(output,"bytes"); 115 for(i=0;i<filter_count;++i) { 116 char buff[1024]; 117 snprintf(buff,sizeof(buff),"%s packets",filters[i].expr); 118 output_add_column(output,buff); 119 snprintf(buff,sizeof(buff),"%s bytes",filters[i].expr); 120 output_add_column(output,buff); 121 } 122 output_flush_headings(output); 123 130 if (!merge_inputs) 131 create_output(uri); 124 132 125 133 trace = trace_create(uri); … … 148 156 149 157 ts = trace_get_seconds(packet); 150 while (packet_interval!=UINT64_MAX 151 &&(last_ts==0 || last_ts<ts)) { 152 if (last_ts==0) 153 last_ts=ts; 158 159 if (last_ts == 0) 160 last_ts = ts; 161 162 while (packet_interval != UINT64_MAX && last_ts<ts) { 154 163 report_results(last_ts,count,bytes); 155 164 count=0; … … 177 186 178 187 trace_destroy(trace); 179 output_destroy(output); 188 189 if (!merge_inputs) 190 output_destroy(output); 191 180 192 trace_destroy_packet(packet); 181 193 } … … 189 201 "-o --output-format=txt|csv|html|png Reporting output format\n" 190 202 "-f --filter=bpf Apply BPF filter. Can be specified multiple times\n" 203 "-m --merge-inputs Do not create separate outputs for each input trace\n" 191 204 "-H --libtrace-help Print libtrace runtime documentation\n" 192 205 ,argv0); … … 196 209 197 210 int i; 198 211 199 212 while(1) { 200 213 int option_index; … … 205 218 { "output-format", 1, 0, 'o' }, 206 219 { "libtrace-help", 0, 0, 'H' }, 220 { "merge-inputs", 0, 0, 'm' }, 207 221 { NULL, 0, 0, 0 }, 208 222 }; 209 223 210 int c=getopt_long(argc, argv, "c:f:i:o:H ",224 int c=getopt_long(argc, argv, "c:f:i:o:Hm", 211 225 long_options, &option_index); 212 226 … … 233 247 output_format=strdup(optarg); 234 248 break; 249 case 'm': 250 merge_inputs = 1; 251 break; 235 252 case 'H': 236 253 trace_help(); … … 248 265 } 249 266 267 if (optind >= argc) 268 return 0; 269 270 fprintf(stderr,"output format: '%s'\n",output_format); 271 272 273 274 if (merge_inputs) { 275 /* If we're merging the inputs, we only want to create all 276 * the column headers etc. once rather than doing them once 277 * per trace */ 278 279 /* This is going to "name" the output based on the first 280 * provided URI - admittedly not ideal */ 281 create_output(argv[optind]); 282 283 } 284 250 285 for(i=optind;i<argc;++i) { 251 286 run_trace(argv[i]); 252 287 } 253 288 289 if (merge_inputs) { 290 /* Clean up after ourselves */ 291 output_destroy(output); 292 } 293 294 254 295 return 0; 255 296 }
Note: See TracChangeset
for help on using the changeset viewer.