Rev 18 |
|
Rev 22 |
Line 7... |
|
Line 7... |
($VERSION = '$Revision: 1.11 $') =~ s/.*(\d+\.\d+).*/$1/; |
|
($VERSION = '$Revision: 1.11 $') =~ s/.*(\d+\.\d+).*/$1/; |
return "syssnmp.pm $VERSION"; |
|
return "syssnmp.pm $VERSION"; |
} |
|
} |
|
|
|
sub do_snmp { |
|
sub do_snmp { |
my $oid = '.1.3.6.1.2.1.2.2.1'; |
|
#my $oid = '.1.3.6.1.2.1.2.2.1'; |
|
|
my $oid = '.1.3.6.1.2.1.31.1.1.1'; |
# interfaces.ifTable.ifEntry.ifDesc |
|
# interfaces.ifTable.ifEntry.ifDesc |
|
|
|
my $suf_descr = '.1'; |
|
my $suf_descr = '.1'; |
# .ifDescr |
|
# .ifDescr |
my $suf_in = '.10'; |
|
my $suf_in = '.6'; |
# .ifInOctets |
|
# .ifInOctets |
my $suf_out = '.16'; |
|
my $suf_out = '.10'; |
# .ifOutOctets |
|
# .ifOutOctets |
|
|
|
my (%targets) = @_; |
|
my (%targets) = @_; |
my (%snmpdev) = @_; |
|
my (%snmpdev) = @_; |
|
|
|
Line 39... |
|
Line 40... |
} |
|
} |
|
|
|
my @query = ($oid.$suf_descr, $oid.$suf_in, $oid.$suf_out); |
|
my @query = ($oid.$suf_descr, $oid.$suf_in, $oid.$suf_out); |
$res = HotSaNICsnmp::snmp_walk($host, $com, @query); |
|
$res = HotSaNICsnmp::snmp_walk($host, $com, @query); |
if(keys(%$res) == 0) { |
|
if(keys(%$res) == 0) { |
|
|
print "vytvarim pro $_ ... $nics{$_}"; |
do_rrd($host."_".$_, "U", "U", $nics{$_}) foreach keys(%nics); |
|
do_rrd($host."_".$_, "U", "U", $nics{$_}) foreach keys(%nics); |
return undef; |
|
return undef; |
} |
|
} |
my $koncovy = 200; |
|
#ciselne porty |
|
|
my $koncovy = 600; |
for ( my $i=1; $i < $koncovy; $i++) { |
|
for ( my $i=1; $i < $koncovy; $i++) { |
my $dev = $$res{$oid.$suf_descr.".".$i}; |
|
my $dev = $$res{$oid.$suf_descr.".".$i}; |
my $devin = $$res{$oid.$suf_in.".".$i}; |
|
my $devin = $$res{$oid.$suf_in.".".$i}; |
my $devout = $$res{$oid.$suf_out.".".$i}; |
|
my $devout = $$res{$oid.$suf_out.".".$i}; |
if(defined($nics{$dev})) { |
|
if(defined($nics{$dev})) { |
do_rrd($host."_".$dev, $$res{$oid.$suf_in.".".$i}, $$res{$oid.$suf_out.".".$i}, $nics{$dev}); |
|
do_rrd($host."_".$dev, $$res{$oid.$suf_in.".".$i}, $$res{$oid.$suf_out.".".$i}, $nics{$dev}); |
} |
|
} |
} |
|
} |
|
|
#jmenne porty |
|
|
for ( my $i=1; defined($$res{$oid.$suf_descr.".".$i}); $i++) { |
|
|
my $dev = $$res{$oid.$suf_descr.".".$i}; |
|
|
print "1 mam tu $dev"; |
|
|
if(defined($nics{$dev})) { |
|
|
do_rrd($host."_".$dev, $$res{$oid.$suf_in.".".$i}, $$res{$oid.$suf_out.".".$i}, $nics{$dev}); |
|
|
} |
|
|
} |
} |
|
} |
|
|
|
} |
|
} |
|
|
|
sub do_rrd { |
|
sub do_rrd { |
my ($name, $in, $out, $max) = @_; |
|
my ($name, $in, $out, $max) = @_; |
|
|
$name =~ s/\//-/g; |
if (! -e "rrd/$name.rrd" ) { |
|
if (! -e "rrd/$name.rrd" ) { |
system("./makerrd","$name","$max") |
|
system("./makerrd","$name","$max") |
} |
|
} |
|
|
|
RRDs::update "rrd/$name.rrd",time.":".$in.":".$out; |
|
RRDs::update "rrd/$name.rrd",time.":".$in.":".$out; |