hotsanic |
Subversion Repositories: |
Compare with Previous - Blame - Download
package HotSaNICmod::OSdep;
sub version {
($VERSION = '$Revision: 1.9 $') =~ s/.*(\d+\.\d+).*/$1/;
return "$^O.pm $VERSION";
}
sub sample {
my %args=@_;
my %devin;
my %devout;
my %sampletime;
# first sample device stats
#
open(IN,"netstat -nib | grep Link |");
while(<IN>) {
chomp;
@line = split;
$name = $line[0];
$devin{$name} = $line[$#line-1];
$devout{$name}= $line[$#line];
$sampletime{$name}=time;
}
close(IN);
# then feed all configured items into the DBs
#
foreach my $entry (@{$args{DEV}}) {
my ($host,undef,$item,$dbname,undef,undef,$description,$maxin,$maxout)=HotSaNICmod::common::get_names($entry);
if ($host eq "") {
my $devin=$devin{$item} || "U";
my $devout=$devout{$item} || "U";
my $sampletime=$sampletime{$item} || time;
# if max-transmission is not set, assume 100 MBit.
#
my $max=$maxin;
if ($max < $maxout) { $max=$maxout };
if ($max == 0) { $max=12500000; }
HotSaNICmod::do_rrd($dbname,$max,$sampletime,$devin,$devout);
}
}
}
1;