2008-03-06 Sancho Lerena <slerena@gmail.com>
* conf/pandora_server.conf: New tokens for the new servers. * lib/PandoraFMS/Config.pm: Added support for WMI Server. * lib/PandoraFMS/DB.pm: Updated pandora_updateserver function. * bin/pandora_wmi: Skeleton of WMI server, not functional, only a concept proof and initializacion for create a WMI server. * bin/pandora_plugin: Almost functional code, fully skeleton, initializacion and modules. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@740 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
86415f86cb
commit
1c713a2465
|
@ -1,3 +1,17 @@
|
|||
2008-03-06 Sancho Lerena <slerena@gmail.com>
|
||||
|
||||
* conf/pandora_server.conf: New tokens for the new servers.
|
||||
|
||||
* lib/PandoraFMS/Config.pm: Added support for WMI Server.
|
||||
|
||||
* lib/PandoraFMS/DB.pm: Updated pandora_updateserver function.
|
||||
|
||||
* bin/pandora_wmi: Skeleton of WMI server, not functional, only
|
||||
a concept proof and initializacion for create a WMI server.
|
||||
|
||||
* bin/pandora_plugin: Almost functional code, fully skeleton,
|
||||
initializacion and modules.
|
||||
|
||||
2008-02-25 Sancho Lerena <slerena@gmail.com>
|
||||
|
||||
* conf/pandora_server.conf: Added new tokens.
|
||||
|
|
|
@ -35,6 +35,8 @@ use PandoraFMS::DB;
|
|||
my @pending_task : shared;
|
||||
my %pending_task_hash : shared;
|
||||
my %current_task_hash : shared;
|
||||
my $queue_lock : shared;
|
||||
|
||||
|
||||
# FLUSH in each IO (only for debug, very slooow)
|
||||
# ENABLED in DEBUGMODE
|
||||
|
@ -57,22 +59,22 @@ pandora_audit (\%pa_config, "Pandora FMS Plugin server starting", "SYSTEM", "Sys
|
|||
|
||||
print " [*] Starting up plugin threads\n";
|
||||
|
||||
die "Aqui me quedo";
|
||||
|
||||
if ( $pa_config{"daemon"} eq "1" ) {
|
||||
print " [*] Backgrounding Pandora FMS Plugin Server process.\n\n";
|
||||
&daemonize;
|
||||
}
|
||||
|
||||
/*
|
||||
=for COMMENT BLOCK
|
||||
# Launch now all plugin threads
|
||||
# $ax is local thread id for this server
|
||||
for (my $ax=0; $ax < $pa_config{'plugin_threads'}; $ax++){
|
||||
threads->new( \&pandora_plugin_consumer, \%pa_config, $ax);
|
||||
}
|
||||
|
||||
=cut
|
||||
# Launch now the producer thread
|
||||
threads->new( \&pandora_plugin_producer, \%pa_config);
|
||||
*/
|
||||
|
||||
|
||||
print " [*] All threads loaded and running \n\n";
|
||||
# Last thread is the main process (this process)
|
||||
|
@ -84,7 +86,6 @@ my $dbh = DBI->connect("DBI:mysql:$dbname:$dbhost:3306",
|
|||
$pa_config{'dbpass'},
|
||||
{ RaiseError => 1, AutoCommit => 1 });
|
||||
|
||||
|
||||
# Server keepalive thread running in main thread on a infinite loop
|
||||
while (1) {
|
||||
pandora_serverkeepaliver (\%pa_config, 1, $dbh);
|
||||
|
@ -145,7 +146,8 @@ sub pandora_plugin_consumer ($$) {
|
|||
# Executing network task with unmanaged error trapping
|
||||
eval {
|
||||
# Call network execution process
|
||||
exec_network_module ( $pa_config, $data_id_agent_module, $dbh);
|
||||
# exec_network_module ( $pa_config, $data_id_agent_module, $dbh);
|
||||
exec_plugin_module ($pa_config, $data_id_agent_module, $dbh);
|
||||
};
|
||||
if ($@){
|
||||
logger ($pa_config, "[ERROR] Plugin Task for module $data_id_agent_module causes a system exception", 0);
|
||||
|
@ -256,7 +258,7 @@ sub pandora_plugin_producer ($) {
|
|||
##########################################################################
|
||||
sub exec_plugin_module {
|
||||
my $pa_config = $_[0];
|
||||
my $id_agent_plugin = $_[1];
|
||||
my $id_am = $_[1];
|
||||
my $dbh = $_[2];
|
||||
|
||||
# Set global variables for this sub
|
||||
|
@ -265,26 +267,16 @@ sub exec_plugin_module {
|
|||
my $plugin; # hash container for tplugin
|
||||
|
||||
# Get a full hash for agent_plugin record reference ($agent_plugin)
|
||||
my $query_sql = "SELECT * FROM tagent_plugin WHERE id = $id_agent_plugin";
|
||||
my $query_sql = "SELECT * FROM tagente_modulo WHERE id_agente_modulo = $id_am";
|
||||
my $exec_sql = $dbh->prepare($query_sql);
|
||||
$exec_sql ->execute;
|
||||
if (! $agent_plugin = $exec_sql->fetchrow_hashref){
|
||||
# This piece of code should not be executed never.
|
||||
$exec_sql->finish();
|
||||
logger (\%pa_config,"[ERROR] Processing data for invalid plugin module", 0);
|
||||
return 0;
|
||||
}
|
||||
$agent_plugin = $exec_sql->fetchrow_hashref;
|
||||
|
||||
# Get a full hash for plugin record reference ($plugin)
|
||||
$query_sql = "SELECT * FROM tplugin WHERE id = ".$agent_plugin->{'id_plugin'};
|
||||
$exec_sql = $dbh->prepare($query_sql);
|
||||
$exec_sql ->execute;
|
||||
if (! $plugin = $exec_sql->fetchrow_hashref){
|
||||
# This piece of code should not be executed never.
|
||||
$exec_sql->finish();
|
||||
logger (\%pa_config,"[ERROR] Processing data for invalid plugin reference", 0);
|
||||
return 0;
|
||||
}
|
||||
$exec_sql->execute();
|
||||
$plugin = $exec_sql->fetchrow_hashref;
|
||||
|
||||
# Calculate min timeout for this call
|
||||
if ($plugin->{'max_timeout'} < $timeout){
|
||||
|
@ -295,38 +287,27 @@ sub exec_plugin_module {
|
|||
my $agent_name = dame_agente_nombre ($pa_config, $agent_plugin->{'id_agente'}, $dbh);
|
||||
my $module_result = 1; # Fail by default
|
||||
my $module_data = 0; # 0 data for default
|
||||
my $module_interval = 0;
|
||||
|
||||
# Build execution command to plugin
|
||||
my $exec_output = "";
|
||||
my $plugin_command = $plugin->{"execute"};
|
||||
if ($plugin->{'net_dst_opt'} ne ""){
|
||||
$plugin_command = $plugin_command . " ". $plugin->{'net_dst_opt'} ." ". $agent_module->{'net_dst'};
|
||||
$plugin_command = $plugin_command . " ". $plugin->{'net_dst_opt'} ." ". $agent_plugin->{'ip_target'};
|
||||
}
|
||||
if ($plugin->{'net_port_opt'} ne "") {
|
||||
$plugin_command = $plugin_command . " ". $plugin->{'net_port_opt'} ." ". $agent_module->{'net_port'};
|
||||
$plugin_command = $plugin_command . " ". $plugin->{'net_port_opt'} ." ". $agent_plugin->{'tcp_port'};
|
||||
}
|
||||
if ($plugin->{'user_opt'} ne "") {
|
||||
$plugin_command = $plugin_command . " ". $plugin->{'user_opt'} ." ". $agent_module->{'access_user'};
|
||||
$plugin_command = $plugin_command . " ". $plugin->{'user_opt'} ." ". $agent_plugin->{'plugin_user'};
|
||||
}
|
||||
if ($plugin->{'pass_opt'} ne "") {
|
||||
$plugin_command = $plugin_command . " ". $plugin->{'pass_opt'} ." ". $agent_module->{'access_pass'};
|
||||
$plugin_command = $plugin_command . " ". $plugin->{'pass_opt'} ." ". $agent_plugin->{'plugin_pass'};
|
||||
}
|
||||
|
||||
# Proccess field / optional / dynamic fields (5)
|
||||
if ($agent_module->{'field1'} ne "") {
|
||||
$plugin_command = $plugin_command . " \"". $agent_module->{'field1'}. "\"";
|
||||
}
|
||||
if ($agent_module->{'field2'} ne "") {
|
||||
$plugin_command = $plugin_command . " \"". $agent_module->{'field2'}. "\"";
|
||||
}
|
||||
if ($agent_module->{'field3'} ne "") {
|
||||
$plugin_command = $plugin_command . " \"". $agent_module->{'field3'}. "\"";
|
||||
}
|
||||
if ($agent_module->{'field4'} ne "") {
|
||||
$plugin_command = $plugin_command . " \"". $agent_module->{'field4'}. "\"";
|
||||
}
|
||||
if ($agent_module->{'field5'} ne "") {
|
||||
$plugin_command = $plugin_command . " \"". $agent_module->{'field5'}. "\"";
|
||||
# Proccess field / optional / dynamic field
|
||||
if ($agent_plugin->{'plugin_parameter'} ne "") {
|
||||
$plugin_command = $plugin_command . $agent_plugin->{'plugin_parameter'};
|
||||
}
|
||||
|
||||
# Final command line execution is stored at "plugin_command"
|
||||
|
@ -337,10 +318,10 @@ sub exec_plugin_module {
|
|||
$module_result = 0; # If comes here, this is a successfull exec
|
||||
};
|
||||
if ($@ =~ /PANDORA PLUGIN SERVER TIMED OUT/) {
|
||||
logger ($pa_config, "[ERROR] Plugin Task for module ".$agent_plugin->{'id'}." causes a system timeout in exec", 1);
|
||||
logger ($pa_config, "[ERROR] Plugin Task for module ".$agent_plugin->{'id_agente_modulo'}." causes a system timeout in exec", 1);
|
||||
# resuming eval block...
|
||||
} else {
|
||||
logger ($pa_config, "[ERROR] Plugin Task for module ".$agent_plugin->{'id'}." causes an unknown system error", 1);
|
||||
logger ($pa_config, "[ERROR] Plugin Task for module ".$agent_plugin->{'id_agente_modulo'}." causes an unknown system error", 1);
|
||||
logger ($pa_config, "[ERROR] $@", 1);
|
||||
}
|
||||
|
||||
|
@ -358,18 +339,23 @@ sub exec_plugin_module {
|
|||
$part{'name'}[0] = $agent_plugin->{'id_agent'};
|
||||
$part{'description'}[0] = "";
|
||||
$part{'data'}[0] = $module_data;
|
||||
my $tipo_modulo = dame_nombretipomodulo_idagentemodulo ($pa_config, $agent_plugin->{'id_module_type'}, $dbh);
|
||||
my $tipo_modulo = $agent_plugin->{'id_module_type'};
|
||||
|
||||
if ($tipo_modulo eq 'generic_data') {
|
||||
# 1 - generic_data
|
||||
# 2 - generic_proc
|
||||
# 3 - generic_data_string
|
||||
# 4 - generic_data_inc
|
||||
|
||||
if (1 == $tipo_modulo) {
|
||||
module_generic_data ($pa_config, \%part, $timestamp, $agent_name, $tipo_modulo, $dbh);
|
||||
}
|
||||
elsif ($tipo_modulo eq 'generic_data_inc' ) {
|
||||
elsif (4 == $tipo_modulo) {
|
||||
module_generic_data_inc ($pa_config, \%part, $timestamp, $agent_name, $tipo_modulo, $dbh);
|
||||
}
|
||||
elsif ($tipo_modulo eq 'generic_data_string') {
|
||||
elsif (3 == $tipo_modulo) {
|
||||
module_generic_data_string ($pa_config, \%part, $timestamp, $agent_name, $tipo_modulo, $dbh);
|
||||
}
|
||||
elsif ($tipo_modulo eq 'generic_data_proc') {
|
||||
elsif (2 == $tipo_modulo) {
|
||||
module_generic_proc ($pa_config, \%part, $timestamp, $agent_name, $tipo_modulo, $dbh);
|
||||
}
|
||||
else {
|
||||
|
@ -379,14 +365,14 @@ sub exec_plugin_module {
|
|||
# Update agent last contact
|
||||
# Insert Pandora version as agent version
|
||||
pandora_lastagentcontact ($pa_config, $timestamp, $agent_name, $pa_config->{'servername'}.$pa_config->{"servermode"}, $pa_config->{'version'}, -1, $dbh);
|
||||
} else {
|
||||
} else {
|
||||
# If module execution get a INVALID value
|
||||
if ($module_interval == 0){
|
||||
$module_interval = dame_intervalo ($pa_config, $agent_plugin->{'id_agent'}, $dbh);
|
||||
if ($agent_plugin->{'intervalo'} == 0){
|
||||
$module_interval = dame_intervalo ($pa_config, $agent_plugin->{'id_agente'}, $dbh);
|
||||
}
|
||||
# Modules who cannot connect or something go bad, update last_execution_try field
|
||||
logger ($pa_config, "Cannot obtain exec Network Module $nombre from agent $agent_name", 4);
|
||||
my $query_act = "UPDATE tagente_estado SET current_interval = $module_interval, last_execution_try = $utimestamp WHERE id_agente_modulo = $id_agente_modulo AND data_source = 2";
|
||||
logger ($pa_config, "Cannot obtain exec plugin Module ".$agent_plugin->{'nombre'}." from agent $agent_name", 3);
|
||||
my $query_act = "UPDATE tagente_estado SET current_interval = $module_interval, last_execution_try = $utimestamp WHERE id_agente_modulo = ".$agent_plugin->{'id_agente_modulo'};
|
||||
$dbh->do($query_act);
|
||||
}
|
||||
skipdb_execmod:
|
||||
|
|
|
@ -0,0 +1,88 @@
|
|||
#!/usr/bin/perl
|
||||
##########################################################################
|
||||
# Pandora FMS Plugin Server
|
||||
##########################################################################
|
||||
# Copyright (c) 2008 Sancho Lerena, slerena@gmail.com
|
||||
# (c) 2008 Artica Soluciones Tecnologicas 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; version 2 (only).
|
||||
#
|
||||
# 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.
|
||||
##########################################################################
|
||||
|
||||
# Includes list
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Date::Manip; # Needed to manipulate DateTime formats of input, output and compare
|
||||
use Time::Local; # DateTime basic manipulation
|
||||
use threads;
|
||||
use threads::shared;
|
||||
|
||||
# Pandora Modules
|
||||
use PandoraFMS::Config;
|
||||
use PandoraFMS::Tools;
|
||||
use PandoraFMS::DB;
|
||||
# use Win32::OLE qw(in);
|
||||
|
||||
# Queue management
|
||||
my @pending_task : shared;
|
||||
my %pending_task_hash : shared;
|
||||
my %current_task_hash : shared;
|
||||
my $queue_lock : shared;
|
||||
|
||||
# FLUSH in each IO (only for debug, very slooow)
|
||||
# ENABLED in DEBUGMODE
|
||||
# DISABLE FOR PRODUCTION
|
||||
$| = 0;
|
||||
|
||||
my %pa_config;
|
||||
|
||||
$SIG{'TERM'} = 'pandora_shutdown';
|
||||
$SIG{'INT'} = 'pandora_shutdown';
|
||||
|
||||
# Inicio del bucle principal de programa
|
||||
pandora_init(\%pa_config, "Pandora FMS WMI Server");
|
||||
|
||||
# Read config file for Global variables
|
||||
pandora_loadconfig (\%pa_config, 6);
|
||||
|
||||
# Audit server starting
|
||||
pandora_audit (\%pa_config, "Pandora FMS WMI server starting", "SYSTEM", "System");
|
||||
|
||||
print " [*] Starting up plugin threads\n";
|
||||
|
||||
die ("hasta aqui hemos llegado");
|
||||
|
||||
# This is a prototype, not real code !!!
|
||||
|
||||
# Basic Skeleton to exec a WMI call remotely
|
||||
|
||||
|
||||
$Win32::OLE::Warn = 3;
|
||||
|
||||
my $wmipath = "root\\cimv2";
|
||||
my $user = "administrador"; # if ADO needs DOMAIN\user
|
||||
my $pwd = "none";
|
||||
my $computer = "192.168.50.121";
|
||||
|
||||
|
||||
my $wmiwebloc = Win32::OLE->new('WbemScripting.SWbemLocator') ||
|
||||
die "Cannot access WMI on local machine: ", Win32::OLE->LastError;
|
||||
|
||||
my $wmi = $wmiwebloc->ConnectServer($computer,$wmipath,$user,$pwd);
|
||||
|
||||
# get all the service objects
|
||||
my @services = in $wmi->InstancesOf("Win32_Service");
|
||||
|
||||
# Take 10 first services
|
||||
for (my $a=0;$a<10;$a++){
|
||||
print "Service ", $services[$a]->Name, " is ", $services[$a]->Status, "\n";
|
||||
}
|
|
@ -139,3 +139,15 @@ pluginserver 1
|
|||
# predictionserver : 1 or 0. Set to 1 to activate prediction server with this setup
|
||||
|
||||
predictionserver 1
|
||||
|
||||
# wmiserver : 1 or 0. Set to 1 to activate prediction server with this setup
|
||||
|
||||
wmiserver 1
|
||||
|
||||
# wmi_timeout : specific timeout for wmi request.
|
||||
|
||||
wmi_timeout 10
|
||||
|
||||
# wmi_threads: Specify number of WMI server threads for processing WMI remote calls
|
||||
|
||||
wmi_threads 3
|
||||
|
|
|
@ -34,8 +34,8 @@ our @EXPORT = qw( pandora_help_screen
|
|||
# There is no global vars, all variables (setup) passed as hash reference
|
||||
|
||||
# version: Defines actual version of Pandora Server for this module only
|
||||
my $pandora_version = "1.4-dev";
|
||||
my $pandora_build="PS080225";
|
||||
my $pandora_version = "2.0-dev";
|
||||
my $pandora_build="PS080226";
|
||||
our $VERSION = $pandora_version." ".$pandora_build;
|
||||
|
||||
# Setup hash
|
||||
|
@ -70,9 +70,6 @@ sub pandora_init {
|
|||
printf "This program is Free Software, licensed under the terms of GPL License v2.\n";
|
||||
printf "You can download latest versions and documentation at http://pandora.sourceforge.net. \n\n";
|
||||
|
||||
# Check we are running GNU/Linux
|
||||
die "[ERROR] This isn't GNU/Linux. Pandora FMS Servers are only OFFICIALLY supported in GNU/Linux.\nContact us if you require assistance running Pandora FMS Server in other OS.\n\n" unless ($^O =~ m/linux/i);
|
||||
|
||||
# Load config file from command line
|
||||
if ($#ARGV == -1 ){
|
||||
print "I Need at least one parameter: Complete path to Pandora FMS Server configuration file. \n";
|
||||
|
@ -85,18 +82,27 @@ sub pandora_init {
|
|||
# If there are not valid parameters
|
||||
my $parametro;
|
||||
my $ltotal=$#ARGV; my $ax;
|
||||
for ($ax=0;$ax<=$ltotal;$ax++){
|
||||
$parametro = $ARGV[$ax];
|
||||
if ($parametro =~ m/-h\z/i ) { help_screen(); }
|
||||
elsif ($parametro =~ m/-help\z/i ) { help_screen(); }
|
||||
elsif ($parametro =~ m/-help\z/i ) { help_screen(); }
|
||||
elsif ($parametro =~ m/-v\z/i) { $pa_config->{"verbosity"}=5; }
|
||||
elsif ($parametro =~ m/-d\z/) { $pa_config->{"verbosity"}=10; }
|
||||
elsif ($parametro =~ m/-D\z/) { $pa_config->{"daemon"}=1; }
|
||||
else { ($pa_config->{"pandora_path"} = $parametro); }
|
||||
}
|
||||
for ($ax=0;$ax<=$ltotal;$ax++){
|
||||
$parametro = $ARGV[$ax];
|
||||
if (($parametro =~ m/-h\z/i ) || ($parametro =~ m/help\z/i )) {
|
||||
help_screen();
|
||||
}
|
||||
elsif ($parametro =~ m/-v\z/i) {
|
||||
$pa_config->{"verbosity"}=5;
|
||||
}
|
||||
elsif ($parametro =~ m/-d\z/) {
|
||||
$pa_config->{"verbosity"}=10;
|
||||
}
|
||||
elsif ($parametro =~ m/-D\z/) {
|
||||
$pa_config->{"daemon"}=1;
|
||||
}
|
||||
else {
|
||||
($pa_config->{"pandora_path"} = $parametro);
|
||||
}
|
||||
}
|
||||
if ($pa_config->{"pandora_path"} eq ""){
|
||||
print "I Need at least one parameter: Complete path to Pandora FMS configuration file. \n";
|
||||
print " [ERROR] I Need at least one parameter: Complete path to Pandora FMS configuration file. \n";
|
||||
print " For example: ./pandora_server /etc/pandora/pandora_server.conf\n\n";
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
@ -107,7 +113,9 @@ sub pandora_init {
|
|||
|
||||
sub pandora_loadconfig {
|
||||
my $pa_config = $_[0];
|
||||
my $opmode = $_[1]; # 0 dataserver, 1 network server, 2 snmp console, 3 recon server, 4 plugin server, 5 prediction server
|
||||
my $opmode = $_[1]; # 0 dataserver, 1 network server, 2 snmp console
|
||||
# 3 recon srv, 4 plugin srv, 5 prediction srv
|
||||
# 6 WMI server
|
||||
my $archivo_cfg = $pa_config->{'pandora_path'};
|
||||
my $buffer_line;
|
||||
my @command_line;
|
||||
|
@ -137,8 +145,9 @@ sub pandora_loadconfig {
|
|||
$pa_config->{"networkserver"} = 0;
|
||||
$pa_config->{"snmpconsole"} = 0;
|
||||
$pa_config->{"reconserver"} = 0;
|
||||
$pa_config->{"pluginserver"} = 0; # Introduced on 1.4
|
||||
$pa_config->{"predictionserver"} = 0; # Introduced on 1.4
|
||||
$pa_config->{"wmiserver"} = 0; # Introduced on 2.0
|
||||
$pa_config->{"pluginserver"} = 0; # Introduced on 2.0
|
||||
$pa_config->{"predictionserver"} = 0; # Introduced on 2.0
|
||||
$pa_config->{"servermode"} = "";
|
||||
$pa_config->{'snmp_logfile'} = "/var/log/pandora_snmptrap.log";
|
||||
$pa_config->{"network_threads"} = 5; # Fixed default
|
||||
|
@ -151,8 +160,10 @@ sub pandora_loadconfig {
|
|||
$pa_config->{"tcp_checks"} = 1; # Introduced on 1.3.1
|
||||
$pa_config->{"tcp_timeout"} = 20; # Introduced on 1.3.1
|
||||
$pa_config->{"snmp_proc_deadresponse"} = 0; # Introduced on 1.3.1 10 Feb08
|
||||
$pa_config->{"plugin_threads"} = 3; # Introduced on 1.4
|
||||
$pa_config->{"plugin_timeout"} = 5; # Introduced on 1.
|
||||
$pa_config->{"plugin_threads"} = 3; # Introduced on 2.0
|
||||
$pa_config->{"plugin_timeout"} = 5; # Introduced on 2.0
|
||||
$pa_config->{"wmi_threads"} = 3; # Introduced on 2.0
|
||||
$pa_config->{"wmi_timeout"} = 5; # Introduced on 2.0
|
||||
|
||||
# Check for UID0
|
||||
if ($> == 0){
|
||||
|
@ -248,8 +259,11 @@ sub pandora_loadconfig {
|
|||
elsif ($parametro =~ m/^reconserver\s([0-9]*)/i) {
|
||||
$pa_config->{'reconserver'}= clean_blank($1);
|
||||
}
|
||||
elsif ($parametro =~ m/^networkserver\s([0-9]*)/i) {
|
||||
$pa_config->{'networkserver'}= clean_blank($1);
|
||||
elsif ($parametro =~ m/^reconserver\s([0-9]*)/i) {
|
||||
$pa_config->{'reconserver'}= clean_blank($1);
|
||||
}
|
||||
elsif ($parametro =~ m/^wmiserver\s([0-9]*)/i) {
|
||||
$pa_config->{'wmiserver'}= clean_blank($1);
|
||||
}
|
||||
elsif ($parametro =~ m/^servername\s(.*)/i) {
|
||||
$pa_config->{'servername'}= clean_blank($1);
|
||||
|
@ -326,27 +340,31 @@ sub pandora_loadconfig {
|
|||
exit;
|
||||
}
|
||||
if (($opmode ==0) && ($pa_config->{"dataserver"} ne 1)) {
|
||||
print " [ERROR] You must enable Dataserver in setup file to run Pandora FMS Data Server. \n\n";
|
||||
print " [ERROR] You must enable 'dataserver' in setup file to run Pandora FMS Data Server. \n\n";
|
||||
exit;
|
||||
}
|
||||
if (($opmode ==1) && ($pa_config->{"networkserver"} ne 1)) {
|
||||
print " [ERROR] You must enable NetworkServer in setup file to run Pandora FMS Network Server. \n\n";
|
||||
print " [ERROR] You must enable 'networkserver' in setup file to run Pandora FMS Network Server. \n\n";
|
||||
exit;
|
||||
}
|
||||
if (($opmode ==2) && ($pa_config->{"snmpconsole"} ne 1)) {
|
||||
print " [ERROR] You must enable SnmpConsole in setup file to run Pandora FMS SNMP Console. \n\n";
|
||||
print " [ERROR] You must enable 'snmpconsole' in setup file to run Pandora FMS SNMP Console. \n\n";
|
||||
exit;
|
||||
}
|
||||
if (($opmode ==3) && ($pa_config->{"reconserver"} ne 1)) {
|
||||
print " [ERROR] You must enable Recon server in setup file to run Pandora FMS Recon server. \n\n";
|
||||
print " [ERROR] You must enable 'reconserver' in setup file to run Pandora FMS Recon server. \n\n";
|
||||
exit;
|
||||
}
|
||||
if (($opmode ==4) && ($pa_config->{"pluginserver"} ne 1)) {
|
||||
print " [ERROR] You must enable Plugin server in setup file to run Pandora FMS Plugin server. \n\n";
|
||||
print " [ERROR] You must enable 'pluginserver' in setup file to run Pandora FMS Plugin server. \n\n";
|
||||
exit;
|
||||
}
|
||||
if (($opmode ==5) && ($pa_config->{"predictionserver"} ne 1)) {
|
||||
print " [ERROR] You must enable Prediction server in setup file to run Pandora FMS Prediction server. \n\n";
|
||||
print " [ERROR] You must enable 'predictionserver' in setup file to run Pandora FMS Prediction server. \n\n";
|
||||
exit;
|
||||
}
|
||||
if (($opmode ==6) && ($pa_config->{"wmiserver"} ne 1)) {
|
||||
print " [ERROR] You must enable 'wmiserver' in setup file to run Pandora FMS WMI server. \n\n";
|
||||
exit;
|
||||
}
|
||||
if ($opmode == 0){
|
||||
|
@ -374,10 +392,15 @@ sub pandora_loadconfig {
|
|||
$parametro ="Pandora FMS Plugin Server";
|
||||
$pa_config->{"servermode"}="_Plugin";
|
||||
}
|
||||
if ($opmode == 3){
|
||||
if ($opmode == 5){
|
||||
print " [*] You are running Pandora FMS Prediction Server. \n";
|
||||
$parametro ="Pandora FMS Prediction Server";
|
||||
$pa_config->{"servermode"}="_Prediction";
|
||||
}
|
||||
if ($opmode == 6){
|
||||
print " [*] You are running Pandora FMS WMI Server. \n";
|
||||
$parametro ="Pandora FMS WMI Server";
|
||||
$pa_config->{"servermode"}="_WMI";
|
||||
}
|
||||
if ($pa_config->{"pandora_check"} == 1) {
|
||||
print " [*] MD5 Security enabled.\n";
|
||||
|
|
|
@ -1001,14 +1001,17 @@ sub pandora_serverkeepaliver (%$$) {
|
|||
## Update server status
|
||||
##########################################################################
|
||||
sub pandora_updateserver (%$$$) {
|
||||
my $pa_config= $_[0];
|
||||
my $servername = $_[1];
|
||||
my $status = $_[2];
|
||||
my $opmode = $_[3]; # 0 dataserver, 1 network server, 2 snmp console, 3 recon
|
||||
my $dbh = $_[4];
|
||||
my $sql_update;
|
||||
my $pandorasuffix;
|
||||
my $version_data;
|
||||
my $pa_config= $_[0];
|
||||
my $servername = $_[1];
|
||||
my $status = $_[2];
|
||||
my $opmode = $_[3]; # 0 dataserver, 1 network server, 2 snmp console, 3 recon
|
||||
# 4 plugin, 5 prediction, 6 wmi
|
||||
my $dbh = $_[4];
|
||||
|
||||
|
||||
my $sql_update;
|
||||
my $pandorasuffix;
|
||||
my $version_data;
|
||||
|
||||
if ($opmode == 0){
|
||||
$pandorasuffix = "_Data";
|
||||
|
@ -1018,7 +1021,18 @@ sub pandora_updateserver (%$$$) {
|
|||
$pandorasuffix = "_SNMP";
|
||||
} elsif ($opmode == 3){
|
||||
$pandorasuffix = "_Recon";
|
||||
}
|
||||
} elsif ($opmode == 4){
|
||||
$pandorasuffix = "_Plugin";
|
||||
} elsif ($opmode == 5){
|
||||
$pandorasuffix = "_IA";
|
||||
} elsif ($opmode == 6){
|
||||
$pandorasuffix = "_WMI";
|
||||
} else {
|
||||
logger ($pa_config, "Error: received a unknown server type. Aborting startup.",0);
|
||||
print (" [ERROR] Received a unknown server type. Aborting startup \n\n");
|
||||
exit;
|
||||
}
|
||||
|
||||
my $id_server = dame_server_id($pa_config, $servername.$pandorasuffix, $dbh);
|
||||
if ($id_server == -1){
|
||||
# Must create a server entry
|
||||
|
@ -1028,7 +1042,7 @@ sub pandora_updateserver (%$$$) {
|
|||
$id_server = dame_server_id($pa_config, $pa_config->{'servername'}.$pandorasuffix, $dbh);
|
||||
}
|
||||
my @data;
|
||||
my $query_idag = "select * from tserver where id_server = $id_server";
|
||||
my $query_idag = "SELECT * FROM tserver WHERE id_server = $id_server";
|
||||
my $s_idag = $dbh->prepare($query_idag);
|
||||
$s_idag ->execute;
|
||||
if ($s_idag->rows != 0) {
|
||||
|
@ -1048,7 +1062,13 @@ sub pandora_updateserver (%$$$) {
|
|||
$sql_update = "update tserver set version = '$version_data', status = 1, laststart = '$timestamp', keepalive = '$timestamp', recon_server = 0, snmp_server = 1, network_server = 0, data_server = 0, master = $pa_config->{'pandora_master'}, checksum = 0 where id_server = $id_server";
|
||||
} elsif ($opmode == 3) {
|
||||
$sql_update = "update tserver set version = '$version_data', status = 1, laststart = '$timestamp', keepalive = '$timestamp', recon_server = 1, snmp_server = 0, network_server = 0, data_server = 0, master = $pa_config->{'pandora_master'}, checksum = 0 where id_server = $id_server";
|
||||
}
|
||||
} elsif ($opmode == 4) {
|
||||
$sql_update = "update tserver set version = '$version_data', status = 1, laststart = '$timestamp', keepalive = '$timestamp', plugin_server = 1, master = $pa_config->{'pandora_master'}, checksum = 0 where id_server = $id_server";
|
||||
} elsif ($opmode == 5) {
|
||||
$sql_update = "update tserver set version = '$version_data', status = 1, laststart = '$timestamp', keepalive = '$timestamp', prediction_server = 1, master = $pa_config->{'pandora_master'}, checksum = 0 where id_server = $id_server";
|
||||
} elsif ($opmode == 6) {
|
||||
$sql_update = "update tserver set version = '$version_data', status = 1, laststart = '$timestamp', keepalive = '$timestamp', wmi_server = 1, master = $pa_config->{'pandora_master'}, checksum = 0 where id_server = $id_server";
|
||||
}
|
||||
$dbh->do($sql_update);
|
||||
}
|
||||
$s_idag->finish();
|
||||
|
@ -1345,7 +1365,6 @@ sub give_group_disabled (%$$) {
|
|||
return $disabled;
|
||||
}
|
||||
|
||||
|
||||
##########################################################################
|
||||
## SUB dame_modulo_id (nombre_modulo)
|
||||
## Return module ID, given "nombre_modulo" as module name
|
||||
|
|
Loading…
Reference in New Issue