jablonka.czprosek.czf

hotsanic

Subversion Repositories:
[/] [branches/] [HotSaNIC-0.5.0-pre6/] [modules/] [traffic/] [platform/] [openbsd.pm] - Blame information for rev 18

 

Line No. Rev Author Line
11simandlpackage HotSaNICmod::OSdep;
2 
3sub version {
4 ($VERSION = '$Revision: 1.7 $') =~ s/.*(\d+\.\d+).*/$1/;
5 return "$^O.pm $VERSION";
6 }
7 
8sub sample {
9 my %args=@_;
10 
11 my %devin;
12 my %devout;
13 my %sampletime;
14 
15 # first sample device stats
16 #
17 # untested, but very similar to FreeBSD so should work. will test soon.
18 open(IN,"netstat -ib | grep Link |");
19 while(<IN>) {
20 chomp;
21 s/[0-9a-f]{2}(:([0-9a-f]{2})){5}//; # remove mac address
22 ($name, $d, $d, $input, $output)=split;
23 $devin{$name}=$input;
24 $devout{$name}=$output;
25 $sampletime{$name}=time;
26 }
27 close(IN);
28 
29 # then feed all configured items into the DBs
30 #
31 foreach my $entry (@{$args{DEV}}) {
32 my ($host,undef,$item,$dbname,undef,undef,$description,$maxin,$maxout)=HotSaNICmod::common::get_names($entry);
33 if ($host eq "") {
34 my $devin=$devin{$item} || "U";
35 my $devout=$devout{$item} || "U";
36 my $sampletime=$sampletime{$item} || time;
37 
38 # if max-transmission is not set, assume 100 MBit.
39 #
40 my $max=$maxin;
41 if ($max < $maxout) { $max=$maxout };
42 if ($max == 0) { $max=12500000; }
43 
44 HotSaNICmod::do_rrd($dbname,$max,$sampletime,$devin,$devout);
45 }
46 }
47 }
48 
491;
50 

Powered by WebSVN 2.2.1