| 1 | use strict; |
| 2 | |
| 3 | my @fields = ( |
| 4 | [ "_n", "UINT", " - Number of samples", 4 ], |
| 5 | [ "_s", "UINT", " - Sum of samples", 8 ], |
| 6 | [ "_ss", "UINT", " - Sum of squared samples", 8 ], |
| 7 | ); |
| 8 | |
| 9 | my $file = $ARGV[0] or die "Syntax: $0 <file> <start>\n"; |
| 10 | -f $file or die "File not found\n"; |
| 11 | my $start = $ARGV[1]; |
| 12 | $start =~ /^\d+$/ or die "Invalid start number"; |
| 13 | open FILE, "<$file" or die "Can't open file"; |
| 14 | while (<FILE>) { |
| 15 | /^(%?)(\w+),\s*(\w+),\s*(.+)$/ and do { |
| 16 | my $counter = $1; |
| 17 | my $rfield = $2; |
| 18 | my $nfield = $3; |
| 19 | my $descr = $4; |
| 20 | my @f; |
| 21 | if ($counter) { |
| 22 | @f = [ "", "UINT", "", 4]; |
| 23 | } else { |
| 24 | @f = @fields; |
| 25 | } |
| 26 | foreach my $f (@f) { |
| 27 | my $nr = $start++; |
| 28 | my $n = $f->[0]; |
| 29 | my $N = uc $n; |
| 30 | my $ftype = $f->[1]; |
| 31 | my $fdesc = $f->[2]; |
| 32 | my $size = $f->[3]; |
| 33 | print "$nr, IPFIX_FT_WPROBE_$rfield$N, $size, IPFIX_CODING_$ftype, \"$nfield$n\", \"$descr$fdesc\"\n"; |
| 34 | } |
| 35 | }; |
| 36 | } |
| 37 | close FILE; |
| 38 | |
| 39 | |