mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-28 08:14:38 +02:00
2009-02-10 Sancho Lerena <slerena@artica.es>
* bin/pandora_network: An important BUG discovered in SNMP call locking mechanism. Now calls to SNMP are using exec to snmpget command. Much faster due solved locking problems. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1440 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
e9242c71a9
commit
663b7e9854
@ -1,3 +1,9 @@
|
|||||||
|
2009-02-10 Sancho Lerena <slerena@artica.es>
|
||||||
|
|
||||||
|
* bin/pandora_network: An important BUG discovered in SNMP call locking
|
||||||
|
mechanism. Now calls to SNMP are using exec to snmpget command. Much
|
||||||
|
faster due solved locking problems.
|
||||||
|
|
||||||
2009-02-06 Sancho Lerena <slerena@artica.es>
|
2009-02-06 Sancho Lerena <slerena@artica.es>
|
||||||
|
|
||||||
* util/plugin/multicast.pl: Multicast check plugin.
|
* util/plugin/multicast.pl: Multicast check plugin.
|
||||||
|
@ -29,7 +29,6 @@ use Time::Local; # DateTime basic manipulation
|
|||||||
use Net::Ping; # For ICMP latency
|
use Net::Ping; # For ICMP latency
|
||||||
use Time::HiRes; # For high precission timedate functions (Net::Ping)
|
use Time::HiRes; # For high precission timedate functions (Net::Ping)
|
||||||
use IO::Socket; # For TCP/UDP access
|
use IO::Socket; # For TCP/UDP access
|
||||||
use SNMP; # For SNMP access (libsnmp-perl PACKAGE!)
|
|
||||||
use threads;
|
use threads;
|
||||||
use threads::shared;
|
use threads::shared;
|
||||||
|
|
||||||
@ -48,13 +47,9 @@ my %pa_config;
|
|||||||
my @pending_task : shared;
|
my @pending_task : shared;
|
||||||
my %pending_task_hash : shared;
|
my %pending_task_hash : shared;
|
||||||
my %current_task_hash : shared;
|
my %current_task_hash : shared;
|
||||||
my $snmp_lock : shared;
|
|
||||||
my $icmp_lock : shared;
|
my $icmp_lock : shared;
|
||||||
my $queue_lock : shared;
|
my $queue_lock : shared;
|
||||||
|
|
||||||
$ENV{'MIBS'}="ALL"; #Load all available MIBs only once
|
|
||||||
&SNMP::initMib();
|
|
||||||
|
|
||||||
$SIG{'TERM'} = 'pandora_shutdown';
|
$SIG{'TERM'} = 'pandora_shutdown';
|
||||||
$SIG{'INT'} = 'pandora_shutdown';
|
$SIG{'INT'} = 'pandora_shutdown';
|
||||||
|
|
||||||
@ -306,7 +301,7 @@ sub pandora_ping_icmp {
|
|||||||
my $p;
|
my $p;
|
||||||
# Some hosts don't accept ICMP with too small payload. Use 16 Bytes min
|
# Some hosts don't accept ICMP with too small payload. Use 16 Bytes min
|
||||||
{
|
{
|
||||||
lock $icmp_lock;
|
#lock $icmp_lock;
|
||||||
$p = Net::Ping->new("icmp", $l_timeout, 32);
|
$p = Net::Ping->new("icmp", $l_timeout, 32);
|
||||||
$result = $p->ping($dest);
|
$result = $p->ping($dest);
|
||||||
}
|
}
|
||||||
@ -478,42 +473,14 @@ sub pandora_query_snmp (%$$$$$) {
|
|||||||
$snmp_version = '1';
|
$snmp_version = '1';
|
||||||
}
|
}
|
||||||
|
|
||||||
my $output ="";
|
my $snmp_timeout = $pa_config->{"snmp_timeout"};
|
||||||
my $snmp_timeout = 1000 * 1000 * $pa_config->{"snmp_timeout"};
|
|
||||||
my $snmp_retries = $pa_config->{'snmp_checks'};
|
my $snmp_retries = $pa_config->{'snmp_checks'};
|
||||||
my $SESSION;
|
|
||||||
# Locking for SNMP call. SNMP is not thread safe !!
|
|
||||||
{
|
|
||||||
lock $snmp_lock;
|
|
||||||
$SESSION = new SNMP::Session (DestHost => $snmp_target,
|
|
||||||
Timeout => $snmp_timeout,
|
|
||||||
Retries => $snmp_retries,
|
|
||||||
Community => $snmp_community,
|
|
||||||
Version => $snmp_version);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((!defined($SESSION)) || ($SESSION->{ErrorStr})) {
|
$_[5] = 0;
|
||||||
logger($pa_config, "SNMP ERROR SESSION for Target $snmp_target ".$SESSION->{ErrorStr}, 2);
|
my $output = `snmpget -v $snmp_version -r $snmp_retries -t $snmp_timeout -OUevqt -c $snmp_community $snmp_target $snmp_oid`;
|
||||||
$_[5] = "1";
|
if ($output eq ""){
|
||||||
if (defined($SESSION)){
|
$_[5] = 1;
|
||||||
undef ($SESSION);
|
|
||||||
}
|
}
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
my $oid = SNMP::translateObj($snmp_oid);
|
|
||||||
# Locking for SNMP call. SNMP is not thread safe !!
|
|
||||||
{
|
|
||||||
lock $snmp_lock;
|
|
||||||
$output = $SESSION->get($oid);
|
|
||||||
}
|
|
||||||
if ((!defined($output)) || ($output eq "")) {
|
|
||||||
logger($pa_config, "SNMP ERROR SNMPGET for Target $snmp_target ".$SESSION->{ErrorStr}, 2);
|
|
||||||
$_[5] = "1";
|
|
||||||
undef ($SESSION);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
$_[5] = "0";
|
|
||||||
undef ($SESSION);
|
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user