2007-05-03 Sancho Lerena <slerena@artica.es>

* bin/pandora_network.pl: Fix problem with ICMP timeouts.

        * util/pandora_dbstress.pl: Update for new needsupdate fix in some
        DB code. Needs to be improved for specific module/agent selection.




git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@449 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
slerena 2007-05-03 02:15:42 +00:00
parent aaaec7f71c
commit 9ebfe51efd
4 changed files with 34 additions and 25 deletions

View File

@ -1,3 +1,11 @@
2007-05-03 Sancho Lerena <slerena@artica.es>
* bin/pandora_network.pl: Fix problem with ICMP timeouts.
* util/pandora_dbstress.pl: Update for new needsupdate fix in some
DB code. Needs to be improved for specific module/agent selection.
2007-04-24 Sancho Lerena <slerena@artica.es> 2007-04-24 Sancho Lerena <slerena@artica.es>
* pandora_db.pm: Added sanity checks to avoid problems when some * pandora_db.pm: Added sanity checks to avoid problems when some

View File

@ -25,7 +25,7 @@ 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 (libnet-snmp-perl package! use SNMP; # For SNMP access (libsnmp-perl PACKAGE!)
use threads; use threads;
# Pandora Modules # Pandora Modules
@ -324,7 +324,7 @@ sub pandora_ping_icmp {
my $l_timeout = $_[1]; my $l_timeout = $_[1];
$p = Net::Ping->new("icmp",$l_timeout); $p = Net::Ping->new("icmp",$l_timeout);
if ($p->ping($dest)) { if ($p->ping($dest) == 1) {
$p->close(); $p->close();
return 1; return 1;
} else { } else {
@ -510,7 +510,7 @@ sub exec_network_module {
$module_result = 0; # Successful $module_result = 0; # Successful
$module_data = 1; $module_data = 1;
} else { } else {
$module_result = 1; # Error, cannot connect $module_result = 0; # If cannot connect, its down.
$module_data = 0; $module_data = 0;
} }
} elsif ($id_tipo_modulo == 7){ # ICMP (data for latency in ms) } elsif ($id_tipo_modulo == 7){ # ICMP (data for latency in ms)

View File

@ -6,7 +6,7 @@
# if not given, it takes localhost. It's preferable to setup one # if not given, it takes localhost. It's preferable to setup one
# because machine name could change by some reason. # because machine name could change by some reason.
servername localhost #servername
# incomingdir: Defines directory where incoming data packets are stored # incomingdir: Defines directory where incoming data packets are stored
# You could set directory relative to base path or absolute, starting with / # You could set directory relative to base path or absolute, starting with /
@ -25,7 +25,7 @@ errorlog_file /var/log/pandora_server.error
# dbuser: Database user name (pandora by default) # dbuser: Database user name (pandora by default)
dbuser pandora dbuser root
# daemon: Runs in daemon mode (background) if 1, if 0 runs in foreground # daemon: Runs in daemon mode (background) if 1, if 0 runs in foreground
# this could be setup on command line with -D option # this could be setup on command line with -D option
@ -34,7 +34,7 @@ dbuser pandora
# dbpass: Database password # dbpass: Database password
dbpass pandora dbpass none
# dbhost: Database hostname or IP address # dbhost: Database hostname or IP address
@ -43,7 +43,7 @@ dbhost localhost
# verbosity: level of detail on errors/messages (0 default, 1 verbose, 2 debug.... 10 noisy) # verbosity: level of detail on errors/messages (0 default, 1 verbose, 2 debug.... 10 noisy)
# -v in command line (verbose) or -d (debug) # -v in command line (verbose) or -d (debug)
verbosity 4 verbosity 10
# Alert threshold # Alert threshold
@ -80,9 +80,9 @@ network_timeout 5
# Server keepalive (in seconds) # Server keepalive (in seconds)
server_keepalive 90 server_keepalive 30
# Server Threshold: defines number of seconds of main loop (in sec) # Server Threshold: defines number of seconds of main loop (in sec)
server_threshold 5 server_threshold 10

View File

@ -18,9 +18,10 @@
#Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
################################################################################ ################################################################################
# Configure here target (AGENT_ID for Stress)
my $target_agent_id = 1; # -1 for all modules of that agent
my $target_interval = 300; my $target_interval = 300;
my $target_days = 30 ; my $target_days = 45;
my $target_agent = 640; # if -1, uses ALL agents
################################################################################ ################################################################################
################################################################################ ################################################################################
@ -40,7 +41,7 @@ use pandora_db;
################################################################################ ################################################################################
################################################################################ ################################################################################
my $version = "1.3-dev 070312"; my $version = "1.3-dev 070216";
# FLUSH in each IO (only for debug, very slooow) # FLUSH in each IO (only for debug, very slooow)
# ENABLED in DEBUGMODE # ENABLED in DEBUGMODE
@ -58,9 +59,11 @@ pandora_loadconfig (\%pa_config,0); #Start like a data server
# open database, only ONCE. We pass reference to DBI handler ($dbh) to all subprocess # open database, only ONCE. We pass reference to DBI handler ($dbh) to all subprocess
my $dbh = DBI->connect("DBI:mysql:pandora:$pa_config{'dbhost'}:3306",$pa_config{'dbuser'}, $pa_config{'dbpass'}, { RaiseError => 1, AutoCommit => 1 }); my $dbh = DBI->connect("DBI:mysql:pandora:$pa_config{'dbhost'}:3306",$pa_config{'dbuser'}, $pa_config{'dbpass'}, { RaiseError => 1, AutoCommit => 1 });
print " [*] Working for agent ID $target_agent_id \n";
print " [*] Generating data of $target_days days ago \n"; print " [*] Generating data of $target_days days ago \n";
print " [*] Interval for this workload is $target_interval \n"; print " [*] Interval for this workload is $target_interval \n";
# For each module of $target_agent_id
my $query_idag; my $query_idag;
if ($target_agent ne -1){ if ($target_agent ne -1){
@ -72,12 +75,10 @@ if ($target_agent ne -1){
my $s_idag = $dbh->prepare($query_idag); my $s_idag = $dbh->prepare($query_idag);
$s_idag ->execute; $s_idag ->execute;
my @data; my @data;
# Read all alerts and apply to this incoming trap
if ($s_idag->rows != 0) { if ($s_idag->rows != 0) {
while (@data = $s_idag->fetchrow_array()) { while (@data = $s_idag->fetchrow_array()) {
print " [*] Working for agent ID ".$data[1]." \n";
# Fill this module with data ! # Fill this module with data !
process_module (\%pa_config, $data[0], $target_interval, $data[4], $target_days, $data[2], $data[1], $dbh); process_module (\%pa_config, $data[0], $target_interval, $data[4], $target_days, $data[2], $target_agent_id, $dbh);
} }
} }
$s_idag->finish(); $s_idag->finish();
@ -115,7 +116,7 @@ sub process_module(){
my $fecha_actual = &UnixDate("today","%Y-%m-%d %H:%M:%S"); my $fecha_actual = &UnixDate("today","%Y-%m-%d %H:%M:%S");
my $m_timestamp = DateCalc($fecha_actual,"- $target_days days",\$err); my $m_timestamp = DateCalc($fecha_actual,"- $target_days days",\$err);
my $mysql_date; my $mysql_date;
my $bUpdateDatos;
# Calculate how many iterations need to fill data range # Calculate how many iterations need to fill data range
# $target_days*min*sec / $target_interval # $target_days*min*sec / $target_interval
@ -145,8 +146,8 @@ sub process_module(){
} }
pandora_lastagentcontact($pa_config, $mysql_date, $agent_name, "none","1.2", $target_interval, $dbh); pandora_lastagentcontact($pa_config, $mysql_date, $agent_name, "none","1.2", $target_interval, $dbh);
# print LOG $mysql_date, $target_name, $valor, "\n"; # print LOG $mysql_date, $target_name, $valor, "\n";
pandora_writedata($pa_config,$mysql_date,$agent_name,$target_type,$target_name,$valor,0,0,"",$dbh); pandora_writedata($pa_config,$mysql_date,$agent_name,$target_type,$target_name,$valor,0,0,"",$dbh,\$bUpdateDatos);
pandora_writestate ($pa_config,$agent_name,$target_type,$target_name,$valor,100,$dbh); pandora_writestate ($pa_config,$agent_name,$target_type,$target_name,$valor,100,$dbh,$bUpdateDatos);
} }
} }
@ -164,8 +165,8 @@ sub process_module(){
} }
pandora_lastagentcontact($pa_config, $mysql_date, $agent_name, "none","1.2", $target_interval, $dbh); pandora_lastagentcontact($pa_config, $mysql_date, $agent_name, "none","1.2", $target_interval, $dbh);
#print LOG $mysql_date, $target_name, $valor, "\n"; #print LOG $mysql_date, $target_name, $valor, "\n";
pandora_writedata($pa_config,$mysql_date,$agent_name,$target_type,$target_name,$valor,0,0,"",$dbh); pandora_writedata($pa_config,$mysql_date,$agent_name,$target_type,$target_name,$valor,0,0,"",$dbh,\$bUpdateDatos);
pandora_writestate ($pa_config,$agent_name,$target_type,$target_name,$valor,100,$dbh); pandora_writestate ($pa_config,$agent_name,$target_type,$target_name,$valor,100,$dbh,$bUpdateDatos);
} }
} }
@ -186,8 +187,8 @@ sub process_module(){
} }
pandora_lastagentcontact($pa_config, $mysql_date, $agent_name, "none","1.2", $target_interval, $dbh); pandora_lastagentcontact($pa_config, $mysql_date, $agent_name, "none","1.2", $target_interval, $dbh);
#print LOG $mysql_date, $target_name, $valor, "\n"; #print LOG $mysql_date, $target_name, $valor, "\n";
pandora_writedata($pa_config,$mysql_date,$agent_name,$target_type,$target_name,$valor,0,0,"",$dbh); pandora_writedata($pa_config,$mysql_date,$agent_name,$target_type,$target_name,$valor,0,0,"",$dbh,\$bUpdateDatos);
pandora_writestate ($pa_config,$agent_name,$target_type,$target_name,$valor,$valor,$dbh); pandora_writestate ($pa_config,$agent_name,$target_type,$target_name,$valor,$valor,$dbh,$bUpdateDatos);
} }
} }