add libipfix
[openwrt-10.03/.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 $rfield = $1;
21                 my $nfield = $2;
22                 my $descr = $3;
23                 foreach my $f (@fields) {
24                         my $nr = ++$last_ie;
25                         my $n = $f->[0];
26                         my $N = uc $n;
27                         my $ftype = $f->[1];
28                         my $fdesc = $f->[2];
29                         print "$nr, IPFIX_FT_WPROBE_$rfield\_$N, 4, IPFIX_CODING_$ftype, \"$nfield\_$n\", \"$descr - $fdesc\"\n";
30                 }
31         };
32 }
33