fa838ff76a36d77f48ea0f3ad80e77788fb3af4c
[openwrt/svn-archive/archive.git] / package / libipfix / extra / append-wprobe-ie.pl
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>\n";
10 -f $file or die "File not found\n";
11 my $last_ie = 0;
12 my $line;
13 open IES, "<$file" or die "Can't open file";
14 while ($line = <IES>) {
15 $line =~ /^(\d+)\s*,/ and $last_ie = $1;
16 }
17 close IES;
18 while (<STDIN>) {
19 /^(%?)(\w+),\s*(\w+),\s*(.+)$/ and do {
20 my $counter = $1;
21 my $rfield = $2;
22 my $nfield = $3;
23 my $descr = $4;
24 my @f;
25 if ($counter) {
26 @f = [ "", "UINT", "", 4];
27 } else {
28 @f = @fields;
29 }
30 foreach my $f (@f) {
31 my $nr = ++$last_ie;
32 my $n = $f->[0];
33 my $N = uc $n;
34 my $ftype = $f->[1];
35 my $fdesc = $f->[2];
36 my $size = $f->[3];
37 print "$nr, IPFIX_FT_WPROBE_$rfield$N, $size, IPFIX_CODING_$ftype, \"$nfield$n\", \"$descr$fdesc\"\n";
38 }
39 };
40 }
41