![]() ![]() |
hotsanic |
Subversion Repositories: |
Compare with Previous - Blame - Download
package HotSaNICmod::OSdep;sub version {($VERSION = '$Revision: 1.7 $') =~ s/.*(\d+\.\d+).*/$1/;return "$^O.pm $VERSION";}sub sample {my %args=@_;my %devin;my %devout;my %sampletime;# first sample device stats## untested, but very similar to FreeBSD so should work. will test soon.open(IN,"netstat -ib | grep Link |");while(<IN>) {chomp;s/[0-9a-f]{2}(:([0-9a-f]{2})){5}//; # remove mac address($name, $d, $d, $input, $output)=split;$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;