1 | 1 | simandl | package HotSaNICmod::OSdep; |
2 | | | |
3 | | | sub version { |
4 | | | ($VERSION = '$Revision: 1.9 $') =~ s/.*(\d+\.\d+).*/$1/; |
5 | | | return "$^O.pm $VERSION"; |
6 | | | } |
7 | | | |
8 | | | sub 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 | | | $devin{$name} = $line[$#line-1]; |
23 | | | $devout{$name}= $line[$#line]; |
24 | | | $sampletime{$name}=time; |
25 | | | } |
26 | | | close(IN); |
27 | | | |
28 | | | |
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 | | | |
51 | | | 1; |
52 | | | |