package HotSaNICmod::OSdep; use RRDs; eval { require "platform/syssnmp.pm"; }; $NO_SNMP=1 if($@); eval { require "platform/sysrrcp.pm"; }; $NO_RRCP=1 if($@); sub version { ($VERSION = '$Revision: 1.7 $') =~ s/.*(\d+\.\d+).*/$1/; return "$^O.pm $VERSION"; } sub sample { my %args=@_; my %maxin; my %maxout; my %devin; my %devout; my %sampletime; my %snmpdev; my %rrcpdev; foreach (keys(%args)) { if ( index($_,"DEV") >= 0) { ($dev,$maxin,$maxout,$description)=split /,/,$args{$_}; if(index($dev,"SNMP\:") >= 0) { (undef,$host,$community,$interface)=split /:/,$dev; my $max = $maxin; $max = $maxout if $maxin < $maxout; my @data = ( $interface, $max); if (defined $snmpdev{$host."_".$community}) { push @{$snmpdev{$host."_".$community}}, @data; } else { $snmpdev{$host."_".$community} = [ @data ] ; } } else { if(index($dev,"RRCP\:") >= 0) { # print "l1 $dev\n"; (undef,$host,$community,$interface)=split /:/,$dev; $host =~ s/\./:/g; my $max = $maxin; $max = $maxout if $maxin < $maxout; my @data = ( $interface, $max); if (defined $rrcpdev{$host."_".$community}) { push @{$rrcpdev{$host."_".$community}}, @data; # print "defined\n"; } else { $rrcpdev{$host."_".$community} = [ @data ] ; # print "undefined\n"; } } else { $dev =~ s/:/_/g; $maxin{$dev}=$maxin; $maxout{$dev}=$maxout; $devin{$dev}="U"; $devout{$dev}="U"; $sampletime{$dev}=time; } # else } # else } # if } # foreach open(IN,"/proc/net/dev"); while() { chomp; if ( /:/ ) { my ($combined, $a, undef, undef, undef, undef, undef, undef, $output, $e)=split; ($name, $input)=split(":",$combined); if(!$input) { ($input, $output) = ($a, $e); } $devin{$name}=$input; $devout{$name}=$output; $sampletime{$name}=time; } } close(IN); # # then query SNMP hosts and check interfaces # syssnmp::do_snmp(%snmpdev); # # then query RRCP hosts and check interfaces # sysrrcp::do_rrcp(%rrcpdev); foreach $name (keys %maxin) { # build new database if needed # if (! -e "rrd/$name.rrd" ) { # get max. transmission value # my $max=$maxin{$name}; if ($max < $maxout{$name}) { $max=$maxout{$name} }; # if max-transmission is not set, assume 100 MBit. # if ($max == 0) { $max=12500000; } system("./makerrd","$name","$max") } # update database RRDs::update "rrd/$name.rrd",$sampletime{$name}.":".$devin{$name}.":".$devout{$name}; if ($ERROR = RRDs::error) { print time,": ",$args{MODNAME},": unable to update `$name.rrd': $ERROR\n"; } } } 1; WebSVN - hotsanic - Blame - Rev 36 - /trunk/modules/traffic/platform/linux.pm
  jablonka.czprosek.czf

hotsanic

Subversion Repositories:
[/] [trunk/] [modules/] [traffic/] [platform/] [linux.pm] - Blame information for rev 36

 

Line No. Rev Author Line

Powered by WebSVN 2.2.1