jablonka.czprosek.czf

hotsanic

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

 

Line No. Rev Author Line
11simandlpackage HotSaNICmod::OSdep;
2 
3sub version {
4 ($VERSION = '$Revision: 1.6 $') =~ 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,"netstat -nib | grep Link |");
18 while(<IN>) {
19 chomp;
20 @line = split;
21 $name = $line[0];
22 $input = $line[$#line-4];
23 $output= $line[$#line-1];
24 $devin{$name}=$input;
25 $devout{$name}=$output;
26 $sampletime{$name}=time;
27 }
28 close(IN);
29 
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