2012-04-19 Koichiro Kikuchi <koichiro@rworks.jp>

* conf/pandora_server.conf.windows,
	  conf/pandora_server.conf,
	  lib/PandoraFMS/DB.pm
	  lib/PandoraFMS/Core.pm
	  lib/PandoraFMS/SNMPServer.pm
	  lib/PandoraFMS/Config.pm
	  lib/PandoraFMS/ProducerConsumerServer.pm
	  bin/pandora_server
	  FreeBSD/pandora_server.conf
	  util/pandora_db.pl
	  util/recon_scripts/snmpdevices.pl
	  util/recon_scripts/ipmi-recon.pl
	  util/plugin/pandora_inventory_change.pl
	  util/plugin/pandora_server_status.pl
	  util/pandora_manage.pl
	  util/pandora_recode_db.pl
	  util/pandora_dbstress.pl: Now pandora_server supports MySQL
	 server running on non-standard port.



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6054 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
koichirok 2012-04-20 03:56:09 +00:00
parent 5f9bc6112f
commit 151024c1c3
18 changed files with 78 additions and 17 deletions

View File

@ -1,3 +1,24 @@
2012-04-19 Koichiro Kikuchi <koichiro@rworks.jp>
* conf/pandora_server.conf.windows,
conf/pandora_server.conf,
lib/PandoraFMS/DB.pm
lib/PandoraFMS/Core.pm
lib/PandoraFMS/SNMPServer.pm
lib/PandoraFMS/Config.pm
lib/PandoraFMS/ProducerConsumerServer.pm
bin/pandora_server
FreeBSD/pandora_server.conf
util/pandora_db.pl
util/recon_scripts/snmpdevices.pl
util/recon_scripts/ipmi-recon.pl
util/plugin/pandora_inventory_change.pl
util/plugin/pandora_server_status.pl
util/pandora_manage.pl
util/pandora_recode_db.pl
util/pandora_dbstress.pl: Now pandora_server supports MySQL
server running on non-standard port.
2012-04-19 Sancho Lerena <slerena@artica.es>
(Merged from 4.0.x Branch)

View File

@ -62,6 +62,11 @@ dbpass pandora
dbhost localhost
# dbport: Database port number
# Default value depends on the dbengine (mysql: 3306, postgresql: 5432, oracle: 1521)
#dbport 3306
# By default, parent agent will not update
#update_parent 0

View File

@ -74,7 +74,7 @@ sub pandora_startup () {
pandora_start_log (\%Config);
# Connect to the DB
$DBH = db_connect ($Config{'dbengine'}, $Config{'dbname'}, $Config{'dbhost'}, 3306,
$DBH = db_connect ($Config{'dbengine'}, $Config{'dbname'}, $Config{'dbhost'}, $Config{'dbport'},
$Config{'dbuser'}, $Config{'dbpass'});
# Grab config tokens shared with the console and not in the .conf

View File

@ -62,6 +62,11 @@ dbpass pandora
dbhost localhost
# dbport: Database port number
# Default value depends on the dbengine (mysql: 3306, postgresql: 5432, oracle: 1521)
#dbport 3306
# By default, parent agent will not update
#update_parent 0

View File

@ -59,6 +59,11 @@ dbpass pandora
dbhost 192.168.55.1
# dbport: Database port number
# Default value depends on the dbengine (mysql: 3306, postgresql: 5432, oracle: 1521)
#dbport 3306
# verbosity: level of detail on errors/messages (0 default, 1 verbose, 2 debug.... 10 noisy)
# -v in command line (verbose) or -d (debug). Set this to 10 when try to locate problems and
# set to 0 or 1 on production enviroments.

View File

@ -168,6 +168,7 @@ sub pandora_load_config {
$pa_config->{"dbuser"} = "pandora";
$pa_config->{"dbpass"} = "pandora";
$pa_config->{"dbhost"} = "localhost";
$pa_config->{'dbport'} = undef; # set to standard port of "dbengine" later
$pa_config->{"dbname"} = "pandora";
$pa_config->{"basepath"} = $pa_config->{'pandora_path'}; # Compatibility with Pandora 1.1
$pa_config->{"incomingdir"} = "/var/spool/pandora/data_in";
@ -406,6 +407,9 @@ sub pandora_load_config {
elsif ($parametro =~ m/^dbhost\s(.*)/i) {
$pa_config->{'dbhost'}= clean_blank($1);
}
elsif ($parametro =~ m/^dbport\s(.*)/i) {
$pa_config->{'dbport'}= clean_blank($1);
}
elsif ($parametro =~ m/^daemon\s([0-9]*)/i) {
$pa_config->{'daemon'}= clean_blank($1);
}
@ -613,6 +617,19 @@ sub pandora_load_config {
}
} # end of loop for parameter #
# Set to RDBMS' standard port
if (!defined($pa_config->{'dbport'})) {
if ($pa_config->{'dbengine'} eq "mysql") {
$pa_config->{'dbport'} = 3306;
}
elsif ($pa_config->{'dbengine'} eq "postgresql") {
$pa_config->{'dbport'} = 5432;
}
elsif ($pa_config->{'dbengine'} eq "oracle") {
$pa_config->{'dbport'} = 1521;
}
}
if (($pa_config->{"verbosity"} > 4) && ($pa_config->{"quiet"} == 0)){
if ($pa_config->{"PID"} ne ""){
print " [*] PID File is written at ".$pa_config->{'PID'}."\n";

View File

@ -2403,7 +2403,7 @@ sub pandora_process_policy_queue ($) {
my %pa_config = %{$pa_config};
my $dbh = db_connect ($pa_config{'dbengine'}, $pa_config{'dbname'}, $pa_config{'dbhost'}, 3306,
my $dbh = db_connect ($pa_config{'dbengine'}, $pa_config{'dbname'}, $pa_config{'dbhost'}, $pa_config{'dbport'},
$pa_config{'dbuser'}, $pa_config{'dbpass'});
while(1) {

View File

@ -85,7 +85,7 @@ sub db_connect ($$$$$$) {
$RDBMS = 'mysql';
# Connect to MySQL
my $dbh = DBI->connect("DBI:mysql:$db_name:$db_host:3306", $db_user, $db_pass, { RaiseError => 1, AutoCommit => 1 });
my $dbh = DBI->connect("DBI:mysql:$db_name:$db_host:$db_port", $db_user, $db_pass, { RaiseError => 1, AutoCommit => 1 });
return undef unless defined ($dbh);
# Enable auto reconnect
@ -99,7 +99,7 @@ sub db_connect ($$$$$$) {
$RDBMS = 'postgresql';
# Connect to PostgreSQL
my $dbh = DBI->connect("DBI:Pg:dbname=$db_name;host=$db_host;port=5432", $db_user, $db_pass, { RaiseError => 1, AutoCommit => 1 });
my $dbh = DBI->connect("DBI:Pg:dbname=$db_name;host=$db_host;port=$db_port", $db_user, $db_pass, { RaiseError => 1, AutoCommit => 1 });
return undef unless defined ($dbh);
return $dbh;
@ -107,7 +107,7 @@ sub db_connect ($$$$$$) {
$RDBMS = 'oracle';
# Connect to Oracle
my $dbh = DBI->connect("DBI:Oracle:dbname=$db_name;host=$db_host;port=1521;sid=pandora", $db_user, $db_pass, { RaiseError => 1, AutoCommit => 1 });
my $dbh = DBI->connect("DBI:Oracle:dbname=$db_name;host=$db_host;port=$db_port;sid=pandora", $db_user, $db_pass, { RaiseError => 1, AutoCommit => 1 });
return undef unless defined ($dbh);
# Set date format

View File

@ -104,7 +104,7 @@ sub data_producer ($$$$$) {
eval {
# Connect to the DB
my $dbh = db_connect ($pa_config->{'dbengine'}, $pa_config->{'dbname'}, $pa_config->{'dbhost'}, 3306,
my $dbh = db_connect ($pa_config->{'dbengine'}, $pa_config->{'dbname'}, $pa_config->{'dbhost'}, $pa_config->{'dbport'},
$pa_config->{'dbuser'}, $pa_config->{'dbpass'});
$self->setDBH ($dbh);
@ -151,7 +151,7 @@ sub data_consumer ($$$$$) {
eval {
# Connect to the DB
my $dbh = db_connect ($pa_config->{'dbengine'}, $pa_config->{'dbname'}, $pa_config->{'dbhost'}, 3306,
my $dbh = db_connect ($pa_config->{'dbengine'}, $pa_config->{'dbname'}, $pa_config->{'dbhost'}, $pa_config->{'dbport'},
$pa_config->{'dbuser'}, $pa_config->{'dbpass'});
$self->setDBH ($dbh);

View File

@ -108,7 +108,7 @@ sub pandora_snmptrapd {
eval {
# Connect to the DB
my $dbh = db_connect ($pa_config->{'dbengine'}, $pa_config->{'dbname'}, $pa_config->{'dbhost'},
3306, $pa_config->{'dbuser'}, $pa_config->{'dbpass'});
$pa_config->{'dbport'}, $pa_config->{'dbuser'}, $pa_config->{'dbpass'});
$self->setDBH ($dbh);
# Wait for the SNMP log file to be available

View File

@ -54,7 +54,7 @@ if (enterprise_load (\%conf) == 0) {
}
# Connect to the DB
my $dbh = db_connect ('mysql', $conf{'dbname'}, $conf{'dbhost'}, '3306', $conf{'dbuser'}, $conf{'dbpass'});
my $dbh = db_connect ('mysql', $conf{'dbname'}, $conf{'dbhost'}, $conf{'dbport'}, $conf{'dbuser'}, $conf{'dbpass'});
my $history_dbh = ($conf{'_history_db_enabled'} eq '1') ? db_connect ('mysql', $conf{'_history_db_name'},
$conf{'_history_db_host'}, '3306', $conf{'_history_db_user'}, $conf{'_history_db_pass'}) : undef;
@ -380,7 +380,7 @@ sub pandora_load_config ($) {
}
# Read additional tokens from the DB
my $dbh = db_connect ('mysql', $conf->{'dbname'}, $conf->{'dbhost'}, '3306', $conf->{'dbuser'}, $conf->{'dbpass'});
my $dbh = db_connect ('mysql', $conf->{'dbname'}, $conf->{'dbhost'}, $conf->{'dbport'}, $conf->{'dbuser'}, $conf->{'dbpass'});
$conf->{'_event_purge'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'event_purge'");
$conf->{'_trap_purge'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'trap_purge'");

View File

@ -62,7 +62,7 @@ pandora_init(\%pa_config,"Pandora DB Stress tool");
pandora_load_config (\%pa_config,0); #Start like a data server
# open database, only ONCE. We pass reference to DBI handler ($dbh) to all subprocess
my $dbh = DBI->connect("DBI:mysql:$pa_config{'dbname'}:$pa_config{'dbhost'}:3306",$pa_config{'dbuser'}, $pa_config{'dbpass'}, { RaiseError => 1, AutoCommit => 1 });
my $dbh = DBI->connect("DBI:mysql:$pa_config{'dbname'}:$pa_config{'dbhost'}:$pa_config{'dbport'}",$pa_config{'dbuser'}, $pa_config{'dbpass'}, { RaiseError => 1, AutoCommit => 1 });
print " [*] Working for agent ID $target_agent \n";
print " [*] Generating data of $target_days days ago \n";

View File

@ -54,7 +54,7 @@ if (enterprise_load (\%conf) == 0) {
}
# Connect to the DB
my $dbh = db_connect ('mysql', $conf{'dbname'}, $conf{'dbhost'}, '3306', $conf{'dbuser'}, $conf{'dbpass'});
my $dbh = db_connect ('mysql', $conf{'dbname'}, $conf{'dbhost'}, $conf{'dbport'}, $conf{'dbuser'}, $conf{'dbpass'});
my $history_dbh = ($conf{'_history_db_enabled'} eq '1') ? db_connect ('mysql', $conf{'_history_db_name'},
$conf{'_history_db_host'}, '3306', $conf{'_history_db_user'}, $conf{'_history_db_pass'}) : undef;

View File

@ -46,7 +46,7 @@ my @tables_data = @{$tables_data};
$| = 0;
# Connect to the DBs
my $dbh = db_connect ('mysql', $conf{'dbname'}, $conf{'dbhost'}, '3306', $conf{'dbuser'}, $conf{'dbpass'});
my $dbh = db_connect ('mysql', $conf{'dbname'}, $conf{'dbhost'}, $conf{'dbport'}, $conf{'dbuser'}, $conf{'dbpass'});
my $history_dbh = ($conf{'_history_db_enabled'} eq '1') ? db_connect ('mysql', $conf{'_history_db_name'},
$conf{'_history_db_host'}, '3306', $conf{'_history_db_user'}, $conf{'_history_db_pass'}) : undef;

View File

@ -137,7 +137,11 @@ sub load_config {
elsif ($parametro =~ m/^dbhost\s(.*)/i) {
$pa_config->{'dbhost'}= clean_blank($1);
}
elsif ($parametro =~ m/^dbport\s(.*)/i) {
$pa_config->{'dbport'}= clean_blank($1);
}
} # end of loop for parameter #
$pa_config->{'dbport'} = 3306 unless exists $pa_config->{'dbport'};
}
sub simple_sql ($$){
@ -181,7 +185,7 @@ $SIG{ALRM} = sub { die_return_timeout(); };
eval {
# Connect to MySQL
my $dbh = DBI->connect("DBI:mysql:".$pa_config{'dbname'}.":".$pa_config{"dbhost"}.":3306", $pa_config{"dbuser"}, $pa_config{"dbpass"}, { RaiseError => 1, AutoCommit => 1 });
my $dbh = DBI->connect("DBI:mysql:".$pa_config{'dbname'}.":".$pa_config{"dbhost"}.":".$pa_config{"dbport"}, $pa_config{"dbuser"}, $pa_config{"dbpass"}, { RaiseError => 1, AutoCommit => 1 });
return undef unless defined ($dbh);
my $sql_query = "SELECT md5(data) FROM tagente, tmodule_inventory, tagent_module_inventory

View File

@ -146,7 +146,11 @@ sub load_config {
elsif ($parametro =~ m/^dbhost\s(.*)/i) {
$pa_config->{'dbhost'}= clean_blank($1);
}
elsif ($parametro =~ m/^dbport\s(.*)/i) {
$pa_config->{'dbport'}= clean_blank($1);
}
} # end of loop for parameter #
$pa_config->{'dbport'} = 3306 unless exists $pa_config->{'dbport'};
}
@ -177,7 +181,7 @@ $SIG{ALRM} = sub { die_return_timeout(); };
eval {
# Connect to MySQL
my $dbh = DBI->connect("DBI:mysql:".$pa_config{'dbname'}.":".$pa_config{"dbhost"}.":3306", $pa_config{"dbuser"}, $pa_config{"dbpass"}, { RaiseError => 1, AutoCommit => 1 });
my $dbh = DBI->connect("DBI:mysql:".$pa_config{'dbname'}.":".$pa_config{"dbhost"}.":".$pa_config{"dbport"}, $pa_config{"dbuser"}, $pa_config{"dbpass"}, { RaiseError => 1, AutoCommit => 1 });
return undef unless defined ($dbh);
if ($queuedmodules == 0){

View File

@ -160,7 +160,7 @@ $conf{'pandora_path'} = $pandora_conf;
pandora_load_config (\%conf);
# Connect to the DB
my $dbh = db_connect ('mysql', $conf{'dbname'}, $conf{'dbhost'}, '3306', $conf{'dbuser'}, $conf{'dbpass'});
my $dbh = db_connect ('mysql', $conf{'dbname'}, $conf{'dbhost'}, $conf{'dbport'}, $conf{'dbuser'}, $conf{'dbpass'});
# Start the network sweep

View File

@ -140,7 +140,7 @@ $conf{'pandora_path'} = $pandora_conf;
pandora_load_config (\%conf);
# Connect to the DB
my $dbh = db_connect ('mysql', $conf{'dbname'}, $conf{'dbhost'}, '3306', $conf{'dbuser'}, $conf{'dbpass'});
my $dbh = db_connect ('mysql', $conf{'dbname'}, $conf{'dbhost'}, $conf{'dbport'}, $conf{'dbuser'}, $conf{'dbpass'});
# Start the network sweep