From 474d273e2504c9216815e9bbba39328a26528a1b Mon Sep 17 00:00:00 2001 From: slerena Date: Mon, 25 Jun 2007 12:05:52 +0000 Subject: [PATCH] 2007-06-25 Sancho Lerena This should be definitive commit for Beta1 * General cleanup of unused or old stuff. * bin/PandoraFMS/Config.pm: Now uses errorlog for each perl error. Now render database bad connect string in connection phase (useful to debug startup errors by blank spaces). * util/pandora_checkdep.pl: Small perl script to check all dependencies. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@541 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_server/bin/pandora_SNMP_test.pl | 92 --------------------- pandora_server/util/pandora_checkdep.pl | 19 +++++ pandora_server/util/pandora_dbstress.README | 8 ++ pandora_server/util/pandora_dbstress.log | 0 pandora_server/util/pandora_snmp.README | 17 ++++ 5 files changed, 44 insertions(+), 92 deletions(-) delete mode 100644 pandora_server/bin/pandora_SNMP_test.pl create mode 100755 pandora_server/util/pandora_checkdep.pl create mode 100644 pandora_server/util/pandora_dbstress.README delete mode 100644 pandora_server/util/pandora_dbstress.log create mode 100755 pandora_server/util/pandora_snmp.README diff --git a/pandora_server/bin/pandora_SNMP_test.pl b/pandora_server/bin/pandora_SNMP_test.pl deleted file mode 100644 index 8f3b839cc7..0000000000 --- a/pandora_server/bin/pandora_SNMP_test.pl +++ /dev/null @@ -1,92 +0,0 @@ -#!/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"); - -########################################################################################## -# SUB pandora_query_snmp (pa_config, oid, community, target, error, dbh) -# Makes a call to SNMP modules to get a value, -########################################################################################## -sub pandora_query_snmp2 { - my $snmp_oid = shift; - my $snmp_community = shift; - my $snmp_target = shift; - - - print "DEBUG OID $snmp_oid comm $snmp_community target $snmp_target \n"; - my $output =""; - - my ($session1, $error) = Net::SNMP->session( - -hostname => $snmp_target, - -community => $snmp_community, - -port => 161 ); - - if (!defined($session1)) { - printf("SNMP ERROR SESSION"); - } - - my $result = $session1->get_request( - -varbindlist => $snmp_oid - ); - - if (!defined($result)) { - printf("SNMP ERROR GET"); - $session1->close; - } else { - $output = $result->{$snmp_oid}; - $session1->close; - } - - return $output; -} - -sub pandora_query_snmp { - my $snmp_oid = shift; - my $snmp_community = shift; - my $snmp_target = shift; - - $ENV{'MIBS'}="ALL"; #Load all available MIBs - $SNMP_TARGET = $snmp_target; - $SNMP_COMMUNITY = $snmp_community; - - $SESSION = new SNMP::Session (DestHost => $SNMP_TARGET, - Community => $SNMP_COMMUNITY, - Version => 1); - - # Populate a VarList with OID values. - $APC_VLIST = new SNMP::VarList([$snmp_oid]); - - # Pass the VarList to getnext building an array of the output - @APC_INFO = $SESSION->getnext($APC_VLIST); - - print $APC_INFO[0]; - print "\n"; -} - -if ($#ARGV == -1 ){ - print "Syntax: snmptest community hostname oid\n"; - exit; - } -my $snmp_community = $ARGV[0]; -my $snmp_target = $ARGV[1]; -my $snmp_oid = $ARGV[2]; - -pandora_query_snmp($snmp_oid, $snmp_community, $snmp_target); diff --git a/pandora_server/util/pandora_checkdep.pl b/pandora_server/util/pandora_checkdep.pl new file mode 100755 index 0000000000..2ad9c93964 --- /dev/null +++ b/pandora_server/util/pandora_checkdep.pl @@ -0,0 +1,19 @@ +#!/usr/bin/perl + +use Date::Manip; # Needed to manipulate DateTime formats of input, output and compare +use Time::Local; # DateTime basic manipulation +use Net::Ping; # For ICMP latency +use Time::HiRes; # For high precission timedate functions (Net::Ping) +use IO::Socket; # For TCP/UDP access +use SNMP; # For SNMP access (libsnmp-perl PACKAGE!) +use threads; +use NetAddr::IP; # To manage IP Addresses +use POSIX; # to use ceil() function +use Socket; # to resolve address +use XML::Simple; # Useful XML functions +use Digest::MD5; +use DBI; +use File::Copy; + +print "All dependencies tested and OK\n\n"; + diff --git a/pandora_server/util/pandora_dbstress.README b/pandora_server/util/pandora_dbstress.README new file mode 100644 index 0000000000..e0220b7051 --- /dev/null +++ b/pandora_server/util/pandora_dbstress.README @@ -0,0 +1,8 @@ +This small utility is make to test your database speed in Pandora Scheme. + +You need to create an agent and assing modules for automated data injection with this tool. Name this modules acording this: + +random - To generate "random" data. +curve - To generate a math curve using trigonometrical functions, useful to see interpolation working with different intervals, etc +boolean - Generate "random" boolean data. + diff --git a/pandora_server/util/pandora_dbstress.log b/pandora_server/util/pandora_dbstress.log deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/pandora_server/util/pandora_snmp.README b/pandora_server/util/pandora_snmp.README new file mode 100755 index 0000000000..9b1cb76364 --- /dev/null +++ b/pandora_server/util/pandora_snmp.README @@ -0,0 +1,17 @@ +Some example traps from Linux +============================== + +http://www.hn.edu.cn/book/NetWork/NetworkingBookshelf_2ndEd/snmp/ + +GenericTrap 0 - Coldstart, 1 - Warmup, 2 - Linkdown, 3 - Linkup .... 6 - User defined + +snmptrap -v 1 -c public 192.168.5.2 1.3.6.1.2.1.2.2.1.1 192.168.5.2 6 666 1233433 +snmptrap -v 1 -c public 192.168.5.2 1.3.6.1.2.1.2.2.1.1 192.168.5.2 6 666 1233433 .1.3.6.1.2.1.2.2.1.1.6 i 234234234 +snmptrap -v 1 -c public 192.168.5.2 .1.3.6.1.4.1.2789.2005 192.168.5.2 6 666 1233433 .1.3.6.1.4.1.2789.2005.1 s "Alcachofa" + +snmptrapd -f -t -On -n -a -Lf logfile.txt -p pidfile -F "%02.2m/%02.2l/%y %02.2h:%02.2j:%02.2k %B %N %w %W %q %v \n" + +Logfile format (sample) + +08/18/2005 03:01:14 192.168.5.2 .1.3.6.1.2.1.2.2.1.1 6 Enterprise Specific .666 .1.3.6.1.2.1.2.2.1.1.6 = INTEGER: 234234234 +08/18/2005 03:02:37 192.168.5.2 .1.3.6.1.4.1.2789.2005 6 Enterprise Specific .666 .1.3.6.1.4.1.2789.2005.1 = STRING: "Alcachofa"