jablonka.czprosek.czf

hotsanic

Subversion Repositories:
[/] [branches/] [HotSaNIC-0.5.0-pre6/] [modules/] [traffic/] [platform/] [syssnmp.pm] - Blame information for rev 24

 

Line No. Rev Author Line
11simandlpackage HotSaNICmod::syssnmp;
2 
3use lib "../../lib";
4use HotSaNICsnmp;
5 
6sub version {
7 ($VERSION = '$Revision: 1.15 $') =~ s/.*(\d+\.\d+).*/$1/;
8 return "syssnmp.pm $VERSION";
9 }
10 
11 
12sub sample {
13 my %args=@_;
14 
15 my $oid = '.1.3.6.1.2.1.2.2.1'; # interfaces.ifTable.ifEntry.ifDesc
16 my $suf_descr = '.2'; # .ifDescr
17 my $suf_in = '.10'; # .ifInOctets
18 my $suf_out = '.16'; # .ifOutOctets
19 
20 my %maxin;
21 my %maxout;
22 my %devin;
23 my %devout;
24 my %sampletime;
25 my %snmpdev;
26 
27 foreach my $entry (@{$args{DEV}}) {
28 my ($host,$community,$item,$dbname,$name,$file,$description,$maxin,$maxout)=HotSaNICmod::common::get_names($entry);
29 
30 if ($host ne "") {
31 my $max = $maxin;
32 $max = $maxout if $maxin < $maxout;
33 my @data = ($item, $max);
34 if (defined $snmpdev{$host."_".$community}) { push @{$snmpdev{$host."_".$community}}, @data; }
35 else { $snmpdev{$host."_".$community} = [ @data ] ; }
36 $dbname{$host."_".$item}=$dbname;
37 }
38 }
39 
40 foreach (keys %snmpdev) {
41 my ($host, $com) = split /_/;
42 my $res;
43 undef my %max;
44 
45 while (@{$snmpdev{$_}}) {
46 my $name=shift @{$snmpdev{$_}};
47 my $max=shift @{$snmpdev{$_}};
48 $max{$name}=$max;
49 }
50 
51 my @query = ($oid.$suf_descr, $oid.$suf_in, $oid.$suf_out);
52 $res = HotSaNICsnmp::snmp_walk($host, $com, @query);
53 
54 if(keys(%$res) == 0) { HotSaNICmod::do_rrd($dbname{$host."_".$_}, $max{$_}, time, "U", "U") foreach keys(%max); }
55 
56 else {
57 for ( my $i=1; defined($$res{$oid.$suf_descr.".".$i}); $i++) {
58 my $dev = $$res{$oid.$suf_descr.".".$i};
59 if(defined($max{$dev})) {
60 HotSaNICmod::do_rrd($dbname{$host."_".$dev}, $max{$dev}, time, $$res{$oid.$suf_in.".".$i}, $$res{$oid.$suf_out.".".$i});
61 }
62 }
63 }
64 }
65 }
66 
671;
68 

Powered by WebSVN 2.2.1