* Licence banner change (for more accurate information about GPL and copyrights in all files of this commit.

* pandora_db.pm: Fixed a debug message written in console when inserting a new event.
* pandora_snmpconsole.pl: No longer use the NET:SNMP module, we use now SNMP module.
* Some of calls to log with low debuglevel are increased to write a bit less garbage into log.
* Added pandora_SNMP_test.pl to test SNMP functionality and perl module operatibility

git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@63 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
slerena 2006-06-29 19:37:46 +00:00
parent 97c43db2a8
commit fdfee7fe40
9 changed files with 159 additions and 32 deletions

View File

@ -1,4 +1,22 @@
#!/usr/bin/perl
##################################################################################
# DBI Memory Leak Tester
##################################################################################
# Copyright (c) 2004-2006 Sancho Lerena, slerena@gmail.com
# Copyright (c) 2005-2006 Artica Soluciones Tecnológicas S.L
#
#This program is free software; you can redistribute it and/or
#modify it under the terms of the GNU General Public License
#as published by the Free Software Foundation; either version 2
#of the License, or (at your option) any later version.
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#GNU General Public License for more details.
#You should have received a copy of the GNU General Public License
#along with this program; if not, write to the Free Software
#Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
##################################################################################
use strict;
use warnings;

View File

@ -1,4 +1,22 @@
#!/usr/bin/perl
##################################################################################
# SNMP Test tool
##################################################################################
# Copyright (c) 2004-2006 Sancho Lerena, slerena@gmail.com
# Copyright (c) 2005-2006 Artica Soluciones Tecnológicas S.L
#
#This program is free software; you can redistribute it and/or
#modify it under the terms of the GNU General Public License
#as published by the Free Software Foundation; either version 2
#of the License, or (at your option) any later version.
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#GNU General Public License for more details.
#You should have received a copy of the GNU General Public License
#along with this program; if not, write to the Free Software
#Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
##################################################################################
#use Net::SNMP; # For query2 testing
use SNMP '5.0.2.pre1' || die("Cannot load module\n");

View File

@ -1,4 +1,23 @@
package pandora_config;
##################################################################################
# Pandora Config package
##################################################################################
# Copyright (c) 2004-2006 Sancho Lerena, slerena@gmail.com
# Copyright (c) 2005-2006 Artica Soluciones Tecnológicas S.L
#
#This program is free software; you can redistribute it and/or
#modify it under the terms of the GNU General Public License
#as published by the Free Software Foundation; either version 2
#of the License, or (at your option) any later version.
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#GNU General Public License for more details.
#You should have received a copy of the GNU General Public License
#along with this program; if not, write to the Free Software
#Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
##################################################################################
use warnings;
use Time::Local;
@ -17,8 +36,8 @@ our @EXPORT = qw( pandora_help_screen
# There is no global vars, all variables (setup) passed as hash reference
# version: Defines actual version of Pandora Server for this module only
my $pandora_version = "1.2beta2";
my $pandora_build="PS060606";
my $pandora_version = "1.2 Beta2";
my $pandora_build="PS60629";
# Setup hash
my %pa_config;
@ -30,9 +49,6 @@ my %pa_config;
##############################################################################
sub help_screen {
printf "Permission is granted to copy, distribute and/or modify this document \n";
printf "under the terms of the GNU Free Documentation License, Version 2.0 \n";
printf "or any later version published by the Free Software Foundation at www.gnu.org \n\n";
printf "\n\nSyntax: \n pandora_xxxxxxx.pl <fullpathname to PANDORA HOME directory> [ options ] \n\n";
printf "Following options are optional : \n";
printf " -v : Verbose mode activated, give more information in logfile \n";
@ -51,7 +67,8 @@ sub help_screen {
sub pandora_init {
my $pa_config = $_[0];
my $init_string = $_[1];
printf "\n$init_string $pandora_version Build $pandora_build Copyright (c) 2004-2006 <slerena\@gmail.com>\n";
printf "\n$init_string $pandora_version Build $pandora_build Copyright (c) 2004-2006 ArticaST\n";
printf "This program is Free Software, licensed under the terms of GPL License v2 or later.\n";
printf "You can download latest versions and documentation at http://pandora.sourceforge.net. \n\n";
# Check we are running Linux

View File

@ -1,4 +1,22 @@
package pandora_db;
##################################################################################
# Pandora Database Package
##################################################################################
# Copyright (c) 2004-2006 Sancho Lerena, slerena@gmail.com
# Copyright (c) 2005-2006 Artica Soluciones Tecnológicas S.L
#
#This program is free software; you can redistribute it and/or
#modify it under the terms of the GNU General Public License
#as published by the Free Software Foundation; either version 2
#of the License, or (at your option) any later version.
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#GNU General Public License for more details.
#You should have received a copy of the GNU General Public License
#along with this program; if not, write to the Free Software
#Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
##################################################################################
use warnings;
use Time::Local;
@ -939,10 +957,8 @@ sub pandora_event (%$$$$) {
$evento = $dbh->quote($evento);
$timestamp = $dbh->quote($timestamp);
my $query = "insert into tevento (id_agente, id_grupo, evento, timestamp, estado) VALUES ($id_agente,$id_grupo,$evento,$timestamp,0)";
logger ($pa_config,"EVENT Insertion: $query",2);
print "$query";
$dbh->do($query);
logger ($pa_config,"EVENT Insertion: $query",5);
$dbh->do($query);
}
#################################################################################

View File

@ -3,9 +3,19 @@
# Pandora DB Stress tool
##################################################################################
# Copyright (c) 2004-2006 Sancho Lerena, slerena@gmail.com
# Permission is granted to copy, distribute and/or modify this document
# under the terms of the GNU Free Documentation License, Version 2.0
# or any later version published by the Free Software Foundation at www.gnu.org
# Copyright (c) 2005-2006 Artica Soluciones Tecnológicas S.L
#
#This program is free software; you can redistribute it and/or
#modify it under the terms of the GNU General Public License
#as published by the Free Software Foundation; either version 2
#of the License, or (at your option) any later version.
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#GNU General Public License for more details.
#You should have received a copy of the GNU General Public License
#along with this program; if not, write to the Free Software
#Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
##################################################################################
# Includes list

View File

@ -3,9 +3,19 @@
# Pandora Network Server
##################################################################################
# Copyright (c) 2004-2006 Sancho Lerena, slerena@gmail.com
# Permission is granted to copy, distribute and/or modify this document
# under the terms of the GNU Free Documentation License, Version 2.0
# or any later version published by the Free Software Foundation at www.gnu.org
# Copyright (c) 2005-2006 Artica Soluciones Tecnológicas S.L
#
#This program is free software; you can redistribute it and/or
#modify it under the terms of the GNU General Public License
#as published by the Free Software Foundation; either version 2
#of the License, or (at your option) any later version.
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#GNU General Public License for more details.
#You should have received a copy of the GNU General Public License
#along with this program; if not, write to the Free Software
#Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
##################################################################################
# Includes list
@ -231,8 +241,7 @@ sub pandora_query_snmp {
my $SESSION = new SNMP::Session (DestHost => $snmp_target,
Community => $snmp_community,
Version => 1);
if (!defined($SESSION)) {
if ((!defined($SESSION))&& ($snmp_community != "") && ($snmp_oid != "")) {
logger($pa_config, "SNMP ERROR SESSION", 4);
$_[4]="1";
} else {
@ -316,7 +325,12 @@ sub exec_network_module {
# SNMP Modules (Proc, inc, data, string)
# ------------
} elsif (($id_tipo_modulo == 15) || ($id_tipo_modulo == 18) || ($id_tipo_modulo == 16) || ($id_tipo_modulo == 17)) { # SNMP module
$temp2 = pandora_query_snmp ($pa_config, $mysnmp_oid, $mysnmp_community, $ip_target, $error, $dbh);
if ($mysnmp_oid ne ""){
$temp2 = pandora_query_snmp ($pa_config, $mysnmp_oid, $mysnmp_community, $ip_target, $error, $dbh);
} else {
$error = 1
}
# SUB pandora_query_snmp (pa_config, oid, community, target, error, dbh)
if ($error == 0) { # A correct SNMP Query
$module_result = 0;

View File

@ -1,18 +1,27 @@
#!/usr/bin/perl
##################################################################################
# Pandora Server
# Pandora Data Server
##################################################################################
# Copyright (c) 2004-2005 Sancho Lerena, slerena@gmail.com
# Permission is granted to copy, distribute and/or modify this document
# under the terms of the GNU Free Documentation License, Version 2.0
# or any later version published by the Free Software Foundation at www.gnu.org
# Copyright (c) 2004-2006 Sancho Lerena, slerena@gmail.com
# Copyright (c) 2005-2006 Artica Soluciones Tecnológicas S.L
#
#This program is free software; you can redistribute it and/or
#modify it under the terms of the GNU General Public License
#as published by the Free Software Foundation; either version 2
#of the License, or (at your option) any later version.
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#GNU General Public License for more details.
#You should have received a copy of the GNU General Public License
#along with this program; if not, write to the Free Software
#Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
##################################################################################
# Includes list
use strict;
use warnings;
use XML::Simple; # Useful XML functions
use Digest::MD5; # MD5 generation
use Time::Local; # DateTime basic manipulation
@ -22,7 +31,6 @@ use File::Copy; # Needed to manipulate files
use threads;
use threads::shared;
# Librerias / Modulos de pandora
use pandora_config;
use pandora_tools;
@ -105,7 +113,7 @@ sub pandora_dataserver {
my $config; # Hash Reference, used to store XML data
# But first we needed to verify integrity of data file
if ($pa_config->{'pandora_check'} == 1){
logger ($pa_config, "Integrity of Datafile using MD5 is verified: $file_data",2);
logger ($pa_config, "Integrity of Datafile using MD5 is verified: $file_data",3);
}
eval { # XML Processing error catching procedure. Critical due XML was no validated
logger ($pa_config, "Ready to parse $file_data",4);
@ -119,7 +127,6 @@ sub pandora_dataserver {
copy ($file_md5,$file_md5."_BAD");
}
}
undef $config;
# If _everything_ its ok..
# delete files
@ -134,7 +141,6 @@ sub pandora_dataserver {
if ( -e $file_md5 ) {
unlink ($file_md5);
}
}
} # No existe fichero de checksum, ignoramos el archivo
}

View File

@ -3,9 +3,19 @@
# Pandora Server. SNMP Console
##################################################################################
# Copyright (c) 2004-2006 Sancho Lerena, slerena@gmail.com
# Permission is granted to copy, distribute and/or modify this document
# under the terms of the GNU Free Documentation License, Version 2.0
# or any later version published by the Free Software Foundation at www.gnu.org
# Copyright (c) 2005-2006 Artica Soluciones Tecnológicas S.L
#
#This program is free software; you can redistribute it and/or
#modify it under the terms of the GNU General Public License
#as published by the Free Software Foundation; either version 2
#of the License, or (at your option) any later version.
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#GNU General Public License for more details.
#You should have received a copy of the GNU General Public License
#along with this program; if not, write to the Free Software
#Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
##################################################################################
# Includes list

View File

@ -1,4 +1,22 @@
package pandora_tools;
##################################################################################
# Pandora Tools Package
##################################################################################
# Copyright (c) 2004-2006 Sancho Lerena, slerena@gmail.com
# Copyright (c) 2005-2006 Artica Soluciones Tecnológicas S.L
#
#This program is free software; you can redistribute it and/or
#modify it under the terms of the GNU General Public License
#as published by the Free Software Foundation; either version 2
#of the License, or (at your option) any later version.
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#GNU General Public License for more details.
#You should have received a copy of the GNU General Public License
#along with this program; if not, write to the Free Software
#Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
##################################################################################
use warnings;
use Time::Local;