hotsanic |
Subversion Repositories: |
Compare with Previous - Blame - Download
package HotSaNICmod::OSdep;
sub version {
($VERSION = '$Revision: 1.6 $') =~ 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];
$input = $line[$#line-4];
$output= $line[$#line-1];
$devin{$name}=$input;
$devout{$name}=$output;
$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;