jablonka.czprosek.czf

hotsanic

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

 

Line No. Rev Author Line
11simandlpackage syssnmp;
2 
3use lib "../../../lib";
4use HotSaNICsnmp;
5 
6sub version {
7 ($VERSION = '$Revision: 1.11 $') =~ s/.*(\d+\.\d+).*/$1/;
8 return "syssnmp.pm $VERSION";
9 }
10 
11sub do_snmp {
12 my $oid = '.1.3.6.1.2.1.2.2.1';
13 # interfaces.ifTable.ifEntry.ifDesc
14 
1518simandl my $suf_descr = '.1';
161simandl # .ifDescr
17 my $suf_in = '.10';
18 # .ifInOctets
19 my $suf_out = '.16';
20 # .ifOutOctets
21 
22 my (%targets) = @_;
2318simandl my (%snmpdev) = @_;
241simandl 
25 foreach ( keys(%targets) ) {
26 my ($host, $com) = split /_/;
2718simandl my ($res, $lastnic, %nics);
281simandl my $i = 0;
2918simandl #pro jednotlive porty switche se vyberou max hodnoty a ulozi do pole %nics
301simandl for (@{$targets{$_}}) {
31 if($i == 0) {
32 $nics{$_} = 0;
33 $lastnic = $_;
34 $i++;
35 } else {
36 $nics{$lastnic} = $_;
37 $i = 0;
38 }
39 }
40 
41 my @query = ($oid.$suf_descr, $oid.$suf_in, $oid.$suf_out);
42 $res = HotSaNICsnmp::snmp_walk($host, $com, @query);
43 if(keys(%$res) == 0) {
4418simandl 
45 do_rrd($host."_".$_, "U", "U", $nics{$_}) foreach keys(%nics);
461simandl return undef;
47 }
4818simandl my $koncovy = 200;
49 for ( my $i=1; $i < $koncovy; $i++) {
50 my $dev = $$res{$oid.$suf_descr.".".$i};
51 my $devin = $$res{$oid.$suf_in.".".$i};
52 my $devout = $$res{$oid.$suf_out.".".$i};
53 if(defined($nics{$dev})) {
541simandl do_rrd($host."_".$dev, $$res{$oid.$suf_in.".".$i}, $$res{$oid.$suf_out.".".$i}, $nics{$dev});
5518simandl }
561simandl }
57 }
5818simandl 
591simandl}
60 
61sub do_rrd {
62 my ($name, $in, $out, $max) = @_;
6318simandl 
641simandl if (! -e "rrd/$name.rrd" ) {
65 system("./makerrd","$name","$max")
66 }
67 
68 RRDs::update "rrd/$name.rrd",time.":".$in.":".$out;
69 if ($ERROR = RRDs::error) { print time,": ",$args{MODNAME},": unable to update `$name.rrd': $ERROR\n"; }
70}
71 
721;

Powered by WebSVN 2.2.1