add libipfix
[openwrt/svn-archive/archive.git] / package / libipfix / extra / append-wprobe-ie.pl
1 use strict;
2
3 my @fields = (
4 [ "_avg", "FLOAT", " - Average" ],
5 [ "_stdev", "FLOAT", " - Standard deviation" ],
6 [ "_n", "UINT", " - Number of samples" ]
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", "" ];
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 print "$nr, IPFIX_FT_WPROBE_$rfield$N, 4, IPFIX_CODING_$ftype, \"$nfield$n\", \"$descr$fdesc\"\n";
37 }
38 };
39 }
40