From a553e8613d07b64ad4824e62c1c53f7e38650d00 Mon Sep 17 00:00:00 2001 From: Ramon Novoa Date: Thu, 2 Oct 2008 09:27:35 +0000 Subject: [PATCH] 2008-10-02 Ramon Novoa * bin/pandora_network: Added support for multiple SNMP versions. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1128 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_server/ChangeLog | 4 ++++ pandora_server/bin/pandora_network | 20 +++++++++++++------- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/pandora_server/ChangeLog b/pandora_server/ChangeLog index 5338e96163..57f6161080 100644 --- a/pandora_server/ChangeLog +++ b/pandora_server/ChangeLog @@ -1,3 +1,7 @@ +2008-10-02 Ramon Novoa + + * bin/pandora_network: Added support for multiple SNMP versions. + 2008-09-08 Raul Mateos * README: Updated version and URL. diff --git a/pandora_server/bin/pandora_network b/pandora_server/bin/pandora_network index cb62fe60c9..d7a5abb941 100755 --- a/pandora_server/bin/pandora_network +++ b/pandora_server/bin/pandora_network @@ -462,12 +462,18 @@ next_pair: # SUB pandora_query_snmp (pa_config, oid, community, target, error, dbh) # Makes a call to SNMP modules to get a value, ########################################################################## -sub pandora_query_snmp (%$$$$) { +sub pandora_query_snmp (%$$$$$) { my $pa_config = $_[0]; my $snmp_oid = $_[1]; my $snmp_community =$_[2]; my $snmp_target = $_[3]; - # $_[4] contains error var. + my $snmp_version = $_[4]; + # $_[5] contains error var. + + if ($snmp_version ne '1' && $snmp_version ne '2' + && $snmp_version ne '2c' && $snmp_version ne '3') { + $snmp_version = '1'; + } my $output =""; my $snmp_timeout = 1000 * 1000 * $pa_config->{"snmp_timeout"}; @@ -480,12 +486,12 @@ sub pandora_query_snmp (%$$$$) { Timeout => $snmp_timeout, Retries => $snmp_retries, Community => $snmp_community, - Version => 1); + Version => $snmp_version); } if ((!defined($SESSION)) || ($SESSION->{ErrorStr})) { logger($pa_config, "SNMP ERROR SESSION for Target $snmp_target ".$SESSION->{ErrorStr}, 2); - $_[4] = "1"; + $_[5] = "1"; if (defined($SESSION)){ undef ($SESSION); } @@ -499,11 +505,11 @@ sub pandora_query_snmp (%$$$$) { } if ((!defined($output)) || ($output eq "")) { logger($pa_config, "SNMP ERROR SNMPGET for Target $snmp_target ".$SESSION->{ErrorStr}, 2); - $_[4] = "1"; + $_[5] = "1"; undef ($SESSION); return 0; } - $_[4] = "0"; + $_[5] = "0"; undef ($SESSION); return $output; } @@ -592,7 +598,7 @@ sub exec_network_module { # ------------ } elsif (($id_tipo_modulo == 15) || ($id_tipo_modulo == 18) || ($id_tipo_modulo == 16) || ($id_tipo_modulo == 17)) { # SNMP module if ((defined($snmp_oid)) && ($snmp_oid ne "") && (defined($snmp_community)) && ($snmp_community ne "")) { # Port check - $temp2 = pandora_query_snmp ($pa_config, $snmp_oid, $snmp_community, $ip_target, $error); + $temp2 = pandora_query_snmp ($pa_config, $snmp_oid, $snmp_community, $ip_target, $tcp_send, $error); } else { $error = 1 }