2007-07-13 Sancho Lerena <slerena@artica.es>
* bin/pandora_recon.pl: Testing changes for two items: (a) Bug detected in forking startup (-D). (b) Bug detected due creation of modules without inserting record in tagente_estado table. * bin/pandora_server.pl: Updated some flags (IO flush), and indenting some code. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@559 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
3c59b83501
commit
d2191706cb
|
@ -1,3 +1,12 @@
|
|||
2007-07-13 Sancho Lerena <slerena@artica.es>
|
||||
|
||||
* bin/pandora_recon.pl: Testing changes for two items: (a) Bug
|
||||
detected in forking startup (-D). (b) Bug detected due creation of
|
||||
modules without inserting record in tagente_estado table.
|
||||
|
||||
* bin/pandora_server.pl: Updated some flags (IO flush), and
|
||||
indenting some code.
|
||||
|
||||
2007-07-11 Manuel Arostegui <marostegui@artica.es>
|
||||
|
||||
* bin/pandora_server.pl: Fixed a bug which make
|
||||
|
|
|
@ -22,13 +22,14 @@ use strict;
|
|||
use warnings;
|
||||
|
||||
use Date::Manip; # Needed to manipulate DateTime formats
|
||||
# of input, output and compare
|
||||
# of input, output and compare
|
||||
use Net::Ping;
|
||||
use Time::Local; # DateTime basic manipulation
|
||||
use NetAddr::IP; # To manage IP Addresses
|
||||
use POSIX; # to use ceil() function
|
||||
use Socket; # to resolve address
|
||||
use threads;
|
||||
use threads::shared;
|
||||
|
||||
# Pandora Modules
|
||||
use PandoraFMS::Config;
|
||||
|
@ -44,12 +45,25 @@ my %pa_config;
|
|||
|
||||
# Inicio del bucle principal de programa
|
||||
pandora_init(\%pa_config, "Pandora FMS Recon server");
|
||||
|
||||
# Read config file for Global variables
|
||||
pandora_loadconfig (\%pa_config, 3);
|
||||
|
||||
# Audit server starting
|
||||
pandora_audit (\%pa_config, "Pandora FMS Recon Daemon starting", "SYSTEM", "System");
|
||||
sleep(1);
|
||||
|
||||
# Daemonize of configured
|
||||
if ( $pa_config{"daemon"} eq "1" ) {
|
||||
print " [*] Backgrounding...\n";
|
||||
&daemonize;
|
||||
}
|
||||
|
||||
# Runs main program (have a infinite loop inside)
|
||||
threads->new( \&pandora_recon_subsystem, \%pa_config);
|
||||
|
||||
sleep(1);
|
||||
|
||||
# Connect ONCE to Database, we cannot pass DBI handler to all subprocess because
|
||||
# cannot share DBI between threads without use method CLONE.
|
||||
my $pa_config = \%pa_config;
|
||||
|
@ -59,17 +73,6 @@ my $dbpass = $pa_config->{'dbpass'};
|
|||
my $dbname = $pa_config->{'dbname'};
|
||||
my $dbh = DBI->connect("DBI:mysql:$dbname:$dbhost:3306", $dbuser, $dbpass, { RaiseError => 1, AutoCommit => 1 });
|
||||
|
||||
# Daemonize of configured
|
||||
if ( $pa_config{"daemon"} eq "1" ) {
|
||||
print " [*] Backgrounding...\n";
|
||||
&daemonize;
|
||||
}
|
||||
|
||||
# Runs main program (have a infinite loop inside)
|
||||
|
||||
threads->new( \&pandora_recon_subsystem, \%pa_config);
|
||||
|
||||
sleep(1);
|
||||
while ( 1 ){
|
||||
pandora_serverkeepaliver ($pa_config, 3, $dbh);
|
||||
threads->yield;
|
||||
|
@ -91,7 +94,7 @@ while ( 1 ){
|
|||
##########################################################################
|
||||
|
||||
sub pandora_recon_subsystem {
|
||||
# Init vars
|
||||
# Init vars
|
||||
my $pa_config = $_[0];
|
||||
my $dbh = DBI->connect("DBI:mysql:$pa_config->{'dbname'}:$pa_config->{'dbhost'}:3306", $pa_config->{'dbuser'}, $pa_config->{'dbpass'}, { RaiseError => 1, AutoCommit => 1 });
|
||||
my $server_id = dame_server_id($pa_config, $pa_config->{'servername'}."_Recon", $dbh);
|
||||
|
@ -160,7 +163,6 @@ sub pandora_exec_task {
|
|||
my $list_host = "";
|
||||
my $host_found = 0;
|
||||
|
||||
|
||||
# Asign target dir to netaddr object "space"
|
||||
$space = new NetAddr::IP $target_network;
|
||||
if (!defined($space)){
|
||||
|
@ -414,7 +416,10 @@ sub pandora_task_create_agentmodules {
|
|||
|
||||
my $query_sql3 = "INSERT INTO tagente_modulo (id_agente, id_tipo_modulo, descripcion, nombre, max, min, module_interval, tcp_port, tcp_send, tcp_rcv, snmp_community, snmp_oid, ip_target, id_module_group, flag ) VALUES ( $agent_id, $type, '$description', '$name', $max, $min, $interval, $tcp_port, '$tcp_send', '$tcp_rcv', '$snmp_community', '$snmp_oid', '$ip_adress', $id_module_group, 1)";
|
||||
$dbh->do($query_sql3);
|
||||
my $last_id_agente_modulo = $dbh->{'mysql_insertid'};
|
||||
logger($pa_config,"Recon Server: Creating module $name for agent $ip_adress",3);
|
||||
my $query_sql4 = "INSERT INTO tagente_estado (id_agente_modulo, datos, timestamp, cambio, estado, id_agente, last_try, utimestamp, current_interval, running_by) VALUES ($last_id_agente_modulo, '', '0000-00-00 00:00:00', 0, 0, $agent_id, '0000-00-00 00:00:00', 0, $interval, 0)";
|
||||
$dbh->do($query_sql4);
|
||||
}
|
||||
$exec_sql2->finish();
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ use PandoraFMS::Tools;
|
|||
use PandoraFMS::DB;
|
||||
|
||||
# FLUSH in each IO, only for DEBUG, very slow !
|
||||
$| = 1;
|
||||
$| = 0;
|
||||
|
||||
my %pa_config;
|
||||
|
||||
|
@ -111,7 +111,7 @@ sub pandora_dataserver {
|
|||
};
|
||||
if ($@) {
|
||||
logger ($pa_config, "[ERROR] Error processing XML contents in $file_data",0);
|
||||
logger ($pa_config, "[ERROR] $@", 0);
|
||||
logger ($pa_config, "[ERROR] $@", 0);
|
||||
copy ($file_data,$file_data."_BADXML");
|
||||
if (($pa_config->{'pandora_check'} == 1) && ( -e $file_md5 )) {
|
||||
copy ($file_md5,$file_md5."_BADCHECKSUM");
|
||||
|
|
Loading…
Reference in New Issue