2008-11-04 Ramon Novoa <rnovoa@artica.es>

* lib/PandoraFMS/Config.pm,
          lib/PandoraFMS/DB.pm,
          lib/PandoraFMS/Tools.pm,
          bin/pandora_snmpconsole: Added support for enterprise version
          features.




git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1214 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
Ramon Novoa 2008-11-04 11:33:07 +00:00
parent 76187ab8ec
commit 35820d07ac
5 changed files with 62 additions and 1 deletions

View File

@ -1,3 +1,11 @@
2008-11-04 Ramon Novoa <rnovoa@artica.es>
* lib/PandoraFMS/Config.pm,
lib/PandoraFMS/DB.pm,
lib/PandoraFMS/Tools.pm,
bin/pandora_snmpconsole: Added support for enterprise version
features.
2008-10-30 Sancho Lerena <slerena@gmail.com>
* lib/PandoraFMS/DB.pm: Some people reports problems with

View File

@ -30,6 +30,7 @@ use Time::HiRes; # For high precission timedate functions (Net::Ping)
use PandoraFMS::Config;
use PandoraFMS::Tools;
use PandoraFMS::DB;
PandoraFMS::Tools::enterprise_load ();
# FLUSH in each IO (only for debug, very slooow)
# ENABLED in DEBUGMODE
@ -117,7 +118,7 @@ sub pandora_snmptrapd {
# 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 $trap2agent = get_db_value ("value", "tconfig", "token", "trap2agent", $dbh);
my $trap2agent = PandoraFMS::Tools::enterprise_hook('snmp_get_trap2module', [$dbh]);
# Main loop for reading file
while ( 1 ){
@ -168,6 +169,7 @@ sub pandora_snmptrapd {
logger ($pa_config, "[ERROR] Cannot access to database while updating SNMP Trap data",0);
logger ($pa_config, "[ERROR] SQL Errorcode: $@", 2);
}
PandoraFMS::Tools::enterprise_hook ('snmp_trap2agent', [defined($trap2agent) ? $trap2agent : 0, $pa_config, $source, $oid, $value, $custom_oid, $custom_value, $timestamp, $dbh]);
}
}
sleep ($pa_config{'server_threshold'});

View File

@ -163,6 +163,7 @@ sub pandora_loadconfig {
$pa_config->{"pluginserver"} = 0; # Introduced on 2.0
$pa_config->{"predictionserver"} = 0; # Introduced on 2.0
$pa_config->{"exportserver"} = 0; # 2.0
$pa_config->{"inventoryserver"} = 0; # 2.1
$pa_config->{"servermode"} = "";
$pa_config->{'snmp_logfile'} = "/var/log/pandora_snmptrap.log";
$pa_config->{"network_threads"} = 5; # Fixed default
@ -183,6 +184,7 @@ sub pandora_loadconfig {
$pa_config->{"wmi_timeout"} = 5; # Introduced on 2.0
$pa_config->{"compound_max_depth"} = 5; # Maximum nested compound alert depth. Not in config file.
$pa_config->{"dataserver_threads"} = 3; # Introduced on 2.0
$pa_config->{"inventory_threads"} = 5; # 2.1
# Internal MTA for alerts, each server need its own config.
$pa_config->{"mta_address"} = '127.0.0.1'; # Introduced on 2.0
@ -501,6 +503,11 @@ sub pandora_loadconfig {
print " [*] You are running Pandora FMS Export Server. \n";
$parametro ="Pandora FMS Export Server";
$pa_config->{"servermode"}="_Export";
}
if ($opmode == 8){
print " [*] You are running Pandora FMS Inventory Server. \n";
$parametro ="Pandora FMS Inventory Server";
$pa_config->{"servermode"}="_Inventory";
}
if ($pa_config->{"pandora_check"} == 1) {
print " [*] MD5 Security enabled.\n";

View File

@ -1428,6 +1428,8 @@ sub pandora_updateserver (%$$$) {
$pandorasuffix = "_WMI";
} elsif ($opmode == 7){
$pandorasuffix = "_Export";
} elsif ($opmode == 8){
$pandorasuffix = "_Inventory";
} else {
logger ($pa_config, "Error: received a unknown server type. Aborting startup.",0);
print (" [ERROR] Received a unknown server type. Aborting startup \n\n");
@ -1476,6 +1478,8 @@ sub pandora_updateserver (%$$$) {
$sql_update = "wmi_server = 1";
} elsif ($opmode == 7) {
$sql_update = "export_server = 1";
} elsif ($opmode == 8) {
$sql_update = "inventory_server = 1";
}
$sql_update = "UPDATE tserver SET $sql_update $sql_update_post , status = $status, keepalive = '$timestamp', master = $pa_config->{'pandora_master'} WHERE id_server = $id_server";
@ -2251,6 +2255,10 @@ sub export_module_data {
my $tagente_modulo = get_db_free_row ("SELECT id_export, id_agente_modulo
FROM tagente_modulo WHERE id_agente = " . $id_agent .
" AND nombre = '" . $module_name . "'", $dbh);
if ($tagente_modulo eq '-1') {
return;
}
my $id_export = $tagente_modulo->{'id_export'};
my $id_agente_modulo = $tagente_modulo->{'id_agente_modulo'};
if ($id_export < 1) {

View File

@ -314,6 +314,42 @@ sub float_equal {
return sprintf("%.${dp}g", $A) eq sprintf("%.${dp}g", $B);
}
##########################################################################
# sub enterprise_load ()
# Tries to load the PandoraEnterprise module. Must be called once before
# enterprise_hook ().
##########################################################################
sub enterprise_load () {
eval { require PandoraFMS::Enterprise; };
}
##########################################################################
# sub enterprise_hook ($function_name, \@arguments)
# Tries to call a PandoraEnterprise function. Returns undef if unsuccessful.
##########################################################################
sub enterprise_hook ($$) {
my $func = $_[0];
my @args = @{$_[1]};
my $output;
# Temporarily disable strict refs
no strict 'refs';
# Prepend the package name
$func = 'PandoraFMS::Enterprise::' . $func;
# Try to call the function
$output = eval { &$func (@args); };
# Check for errors
if ($@) {
return undef;
}
else {
return $output;
}
}
# End of function declaration
# End of defined Code