jablonka.czprosek.czf

hotsanic

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

 

Line No. Rev Author Line
11simandlpackage HotSaNICmod::OSdep;
2 
3sub version {
4 ($VERSION = '$Revision: 1.10 $') =~ 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 open(IN,"/proc/net/dev");
18 while(<IN>) {
19 chomp;
20 if ( /:/ ) {
21 my ($combined, $a, undef, undef, undef, undef, undef, undef, $output, $e)=split;
22 ($name, $input)=split(":",$combined);
23 if(!$input) { ($input, $output) = ($a, $e); }
24 $devin{$name}=$input;
25 $devout{$name}=$output;
26 $sampletime{$name}=time;
27 }
28 }
29 close(IN);
30 
31 # then feed all configured items into the DBs
32 #
33 foreach my $entry (@{$args{DEV}}) {
34 my ($host,undef,$item,$dbname,undef,undef,$description,$maxin,$maxout)=HotSaNICmod::common::get_names($entry);
35 if ($host eq "") {
36 my $devin=$devin{$item} || "U";
37 my $devout=$devout{$item} || "U";
38 my $sampletime=$sampletime{$item} || time;
39 
40 # if max-transmission is not set, assume 100 MBit.
41 #
42 my $max=$maxin;
43 if ($max < $maxout) { $max=$maxout };
44 if ($max == 0) { $max=12500000; }
45 
46 HotSaNICmod::do_rrd($dbname,$max,$sampletime,$devin,$devout);
47 }
48 }
49 }
50 
511;
52 

Powered by WebSVN 2.2.1