2009-04-14 Ramon Novoa <rnovoa@artica.es>
* pandora_ctl, pandora_network, pandora_wmi, pandora_plugin,
pandora_prediction, bin/pandora_wmi, bin/pandora_plugin,
bin/pandora_prediction, bin/pandora_snmpconsole, bin/pandora_recon,
bin/pandora_network, pandora_recon, pandora_snmpconsole: Deleted
from repository. Old server code and startup scripts.
* Makefile.PL, pandora_server_installer, lib/PandoraFMS/Config.pm
lib/PandoraFMS/DB.pm, lib/PandoraFMS/Tools.pm, bin/pandora_server,
pandora_package_installer, pandora_server: Updated to work with the
new code, removed unneeded dependencies, fixed some bugs etc.
* lib/PandoraFMS/SNMPServer.pm, lib/PandoraFMS/PluginServer.pm,
lib/PandoraFMS/ProducerConsumerServer.pm, lib/PandoraFMS/Server.pm,
lib/PandoraFMS/PredictionServer.pm, lib/PandoraFMS/Core.pm,
lib/PandoraFMS/ReconServer.pm, lib/PandoraFMS/DataServer.pm,
lib/PandoraFMS/NetworkServer.pm, lib/PandoraFMS/WMIServer.pm: Added
to repository. New server code.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1620 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-04-14 21:13:16 +02:00
package PandoraFMS::DataServer ;
##########################################################################
# Pandora FMS Data Server.
# Pandora FMS. the Flexible Monitoring System. http://www.pandorafms.org
##########################################################################
2011-03-14 11:39:31 +01:00
# Copyright (c) 2005-2011 Artica Soluciones Tecnologicas S.L
2009-04-14 Ramon Novoa <rnovoa@artica.es>
* pandora_ctl, pandora_network, pandora_wmi, pandora_plugin,
pandora_prediction, bin/pandora_wmi, bin/pandora_plugin,
bin/pandora_prediction, bin/pandora_snmpconsole, bin/pandora_recon,
bin/pandora_network, pandora_recon, pandora_snmpconsole: Deleted
from repository. Old server code and startup scripts.
* Makefile.PL, pandora_server_installer, lib/PandoraFMS/Config.pm
lib/PandoraFMS/DB.pm, lib/PandoraFMS/Tools.pm, bin/pandora_server,
pandora_package_installer, pandora_server: Updated to work with the
new code, removed unneeded dependencies, fixed some bugs etc.
* lib/PandoraFMS/SNMPServer.pm, lib/PandoraFMS/PluginServer.pm,
lib/PandoraFMS/ProducerConsumerServer.pm, lib/PandoraFMS/Server.pm,
lib/PandoraFMS/PredictionServer.pm, lib/PandoraFMS/Core.pm,
lib/PandoraFMS/ReconServer.pm, lib/PandoraFMS/DataServer.pm,
lib/PandoraFMS/NetworkServer.pm, lib/PandoraFMS/WMIServer.pm: Added
to repository. New server code.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1620 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-04-14 21:13:16 +02:00
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public License
# as published by the Free Software Foundation; version 2
# 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.
##########################################################################
use strict ;
use warnings ;
use threads ;
use threads::shared ;
use Thread::Semaphore ;
use Time::Local ;
use XML::Simple ;
2009-08-19 03:41:25 +02:00
use POSIX qw( setsid strftime ) ;
2009-04-14 Ramon Novoa <rnovoa@artica.es>
* pandora_ctl, pandora_network, pandora_wmi, pandora_plugin,
pandora_prediction, bin/pandora_wmi, bin/pandora_plugin,
bin/pandora_prediction, bin/pandora_snmpconsole, bin/pandora_recon,
bin/pandora_network, pandora_recon, pandora_snmpconsole: Deleted
from repository. Old server code and startup scripts.
* Makefile.PL, pandora_server_installer, lib/PandoraFMS/Config.pm
lib/PandoraFMS/DB.pm, lib/PandoraFMS/Tools.pm, bin/pandora_server,
pandora_package_installer, pandora_server: Updated to work with the
new code, removed unneeded dependencies, fixed some bugs etc.
* lib/PandoraFMS/SNMPServer.pm, lib/PandoraFMS/PluginServer.pm,
lib/PandoraFMS/ProducerConsumerServer.pm, lib/PandoraFMS/Server.pm,
lib/PandoraFMS/PredictionServer.pm, lib/PandoraFMS/Core.pm,
lib/PandoraFMS/ReconServer.pm, lib/PandoraFMS/DataServer.pm,
lib/PandoraFMS/NetworkServer.pm, lib/PandoraFMS/WMIServer.pm: Added
to repository. New server code.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1620 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-04-14 21:13:16 +02:00
2011-02-07 14:45:34 +01:00
# For Reverse Geocoding
use LWP::Simple ;
2010-05-19 Ramon Novoa <rnovoa@artica.es>
* lib/PandoraFMS/SNMPServer.pm, lib/PandoraFMS/Config.pm,
lib/PandoraFMS/Server.pm, lib/PandoraFMS/NetworkServer.pm,
lib/PandoraFMS/GIS.pm, lib/PandoraFMS/WMIServer.pm,
lib/PandoraFMS/PluginServer.pm, lib/PandoraFMS/ProducerConsumerServer.pm,
lib/PandoraFMS/PredictionServer.pm, lib/PandoraFMS/Core.pm,
lib/PandoraFMS/ReconServer.pm, lib/PandoraFMS/DataServer.pm,
bin/pandora_server, util/pandora_db.pl, util/gpx2pandora_agent_data.pl,
util/pandora_manage.pl, util/pandora_dbstress.pl: Added the default library path
used by RPM and DEB packages.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2755 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2010-05-19 18:59:00 +02:00
# Default lib dir for RPM and DEB packages
use lib '/usr/lib/perl5' ;
2009-04-14 Ramon Novoa <rnovoa@artica.es>
* pandora_ctl, pandora_network, pandora_wmi, pandora_plugin,
pandora_prediction, bin/pandora_wmi, bin/pandora_plugin,
bin/pandora_prediction, bin/pandora_snmpconsole, bin/pandora_recon,
bin/pandora_network, pandora_recon, pandora_snmpconsole: Deleted
from repository. Old server code and startup scripts.
* Makefile.PL, pandora_server_installer, lib/PandoraFMS/Config.pm
lib/PandoraFMS/DB.pm, lib/PandoraFMS/Tools.pm, bin/pandora_server,
pandora_package_installer, pandora_server: Updated to work with the
new code, removed unneeded dependencies, fixed some bugs etc.
* lib/PandoraFMS/SNMPServer.pm, lib/PandoraFMS/PluginServer.pm,
lib/PandoraFMS/ProducerConsumerServer.pm, lib/PandoraFMS/Server.pm,
lib/PandoraFMS/PredictionServer.pm, lib/PandoraFMS/Core.pm,
lib/PandoraFMS/ReconServer.pm, lib/PandoraFMS/DataServer.pm,
lib/PandoraFMS/NetworkServer.pm, lib/PandoraFMS/WMIServer.pm: Added
to repository. New server code.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1620 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-04-14 21:13:16 +02:00
use PandoraFMS::Tools ;
use PandoraFMS::DB ;
use PandoraFMS::Core ;
use PandoraFMS::ProducerConsumerServer ;
# Inherits from PandoraFMS::ProducerConsumerServer
our @ ISA = qw( PandoraFMS::ProducerConsumerServer ) ;
# Global variables
my @ TaskQueue : shared ;
my % PendingTasks : shared ;
my $ Sem : shared = Thread::Semaphore - > new ;
my $ TaskSem : shared = Thread::Semaphore - > new ( 0 ) ;
2009-11-10 13:25:10 +01:00
my $ AgentSem : shared = Thread::Semaphore - > new ( 1 ) ;
2009-11-13 Ramon Novoa <rnovoa@artica.es>
* conf/pandora_server.conf: Updated configuration tokens.
* lib/PandoraFMS/SNMPServer.pm, lib/PandoraFMS/Config.pm,
lib/PandoraFMS/PluginServer.pm, lib/PandoraFMS/PredictionServer.pm,
lib/PandoraFMS/Core.pm, lib/PandoraFMS/ReconServer.pm,
lib/PandoraFMS/DataServer.pm, lib/PandoraFMS/NetworkServer.pm,
lib/PandoraFMS/Tools.pm, lib/PandoraFMS/WMIServer.pm,
bin/pandora_server: Standardized and improved logging.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2108 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-11-13 14:52:48 +01:00
my $ ModuleSem : shared = Thread::Semaphore - > new ( 1 ) ;
2009-04-14 Ramon Novoa <rnovoa@artica.es>
* pandora_ctl, pandora_network, pandora_wmi, pandora_plugin,
pandora_prediction, bin/pandora_wmi, bin/pandora_plugin,
bin/pandora_prediction, bin/pandora_snmpconsole, bin/pandora_recon,
bin/pandora_network, pandora_recon, pandora_snmpconsole: Deleted
from repository. Old server code and startup scripts.
* Makefile.PL, pandora_server_installer, lib/PandoraFMS/Config.pm
lib/PandoraFMS/DB.pm, lib/PandoraFMS/Tools.pm, bin/pandora_server,
pandora_package_installer, pandora_server: Updated to work with the
new code, removed unneeded dependencies, fixed some bugs etc.
* lib/PandoraFMS/SNMPServer.pm, lib/PandoraFMS/PluginServer.pm,
lib/PandoraFMS/ProducerConsumerServer.pm, lib/PandoraFMS/Server.pm,
lib/PandoraFMS/PredictionServer.pm, lib/PandoraFMS/Core.pm,
lib/PandoraFMS/ReconServer.pm, lib/PandoraFMS/DataServer.pm,
lib/PandoraFMS/NetworkServer.pm, lib/PandoraFMS/WMIServer.pm: Added
to repository. New server code.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1620 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-04-14 21:13:16 +02:00
########################################################################################
# Data Server class constructor.
########################################################################################
sub new ($$;$) {
my ( $ class , $ config , $ dbh ) = @ _ ;
return undef unless $ config - > { 'dataserver' } == 1 ;
# Call the constructor of the parent class
my $ self = $ class - > SUPER:: new ( $ config , 0 , \ & PandoraFMS::DataServer:: data_producer , \ & PandoraFMS::DataServer:: data_consumer , $ dbh ) ;
2011-03-14 11:39:31 +01:00
bless $ self , $ class ;
return $ self ;
2009-04-14 Ramon Novoa <rnovoa@artica.es>
* pandora_ctl, pandora_network, pandora_wmi, pandora_plugin,
pandora_prediction, bin/pandora_wmi, bin/pandora_plugin,
bin/pandora_prediction, bin/pandora_snmpconsole, bin/pandora_recon,
bin/pandora_network, pandora_recon, pandora_snmpconsole: Deleted
from repository. Old server code and startup scripts.
* Makefile.PL, pandora_server_installer, lib/PandoraFMS/Config.pm
lib/PandoraFMS/DB.pm, lib/PandoraFMS/Tools.pm, bin/pandora_server,
pandora_package_installer, pandora_server: Updated to work with the
new code, removed unneeded dependencies, fixed some bugs etc.
* lib/PandoraFMS/SNMPServer.pm, lib/PandoraFMS/PluginServer.pm,
lib/PandoraFMS/ProducerConsumerServer.pm, lib/PandoraFMS/Server.pm,
lib/PandoraFMS/PredictionServer.pm, lib/PandoraFMS/Core.pm,
lib/PandoraFMS/ReconServer.pm, lib/PandoraFMS/DataServer.pm,
lib/PandoraFMS/NetworkServer.pm, lib/PandoraFMS/WMIServer.pm: Added
to repository. New server code.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1620 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-04-14 21:13:16 +02:00
}
###############################################################################
# Run.
###############################################################################
sub run ($) {
my $ self = shift ;
my $ pa_config = $ self - > getConfig ( ) ;
2009-11-13 Ramon Novoa <rnovoa@artica.es>
* conf/pandora_server.conf: Updated configuration tokens.
* lib/PandoraFMS/SNMPServer.pm, lib/PandoraFMS/Config.pm,
lib/PandoraFMS/PluginServer.pm, lib/PandoraFMS/PredictionServer.pm,
lib/PandoraFMS/Core.pm, lib/PandoraFMS/ReconServer.pm,
lib/PandoraFMS/DataServer.pm, lib/PandoraFMS/NetworkServer.pm,
lib/PandoraFMS/Tools.pm, lib/PandoraFMS/WMIServer.pm,
bin/pandora_server: Standardized and improved logging.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2108 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-11-13 14:52:48 +01:00
print_message ( $ pa_config , " [*] Starting Pandora FMS Data Server." , 1 ) ;
2009-04-14 Ramon Novoa <rnovoa@artica.es>
* pandora_ctl, pandora_network, pandora_wmi, pandora_plugin,
pandora_prediction, bin/pandora_wmi, bin/pandora_plugin,
bin/pandora_prediction, bin/pandora_snmpconsole, bin/pandora_recon,
bin/pandora_network, pandora_recon, pandora_snmpconsole: Deleted
from repository. Old server code and startup scripts.
* Makefile.PL, pandora_server_installer, lib/PandoraFMS/Config.pm
lib/PandoraFMS/DB.pm, lib/PandoraFMS/Tools.pm, bin/pandora_server,
pandora_package_installer, pandora_server: Updated to work with the
new code, removed unneeded dependencies, fixed some bugs etc.
* lib/PandoraFMS/SNMPServer.pm, lib/PandoraFMS/PluginServer.pm,
lib/PandoraFMS/ProducerConsumerServer.pm, lib/PandoraFMS/Server.pm,
lib/PandoraFMS/PredictionServer.pm, lib/PandoraFMS/Core.pm,
lib/PandoraFMS/ReconServer.pm, lib/PandoraFMS/DataServer.pm,
lib/PandoraFMS/NetworkServer.pm, lib/PandoraFMS/WMIServer.pm: Added
to repository. New server code.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1620 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-04-14 21:13:16 +02:00
$ self - > setNumThreads ( $ pa_config - > { 'dataserver_threads' } ) ;
$ self - > SUPER:: run ( \ @ TaskQueue , \ % PendingTasks , $ Sem , $ TaskSem ) ;
}
###############################################################################
# Data producer.
###############################################################################
sub data_producer ($) {
my $ self = shift ;
my $ pa_config = $ self - > getConfig ( ) ;
my @ tasks ;
2010-07-27 19:12:17 +02:00
my @ files ;
2009-04-14 Ramon Novoa <rnovoa@artica.es>
* pandora_ctl, pandora_network, pandora_wmi, pandora_plugin,
pandora_prediction, bin/pandora_wmi, bin/pandora_plugin,
bin/pandora_prediction, bin/pandora_snmpconsole, bin/pandora_recon,
bin/pandora_network, pandora_recon, pandora_snmpconsole: Deleted
from repository. Old server code and startup scripts.
* Makefile.PL, pandora_server_installer, lib/PandoraFMS/Config.pm
lib/PandoraFMS/DB.pm, lib/PandoraFMS/Tools.pm, bin/pandora_server,
pandora_package_installer, pandora_server: Updated to work with the
new code, removed unneeded dependencies, fixed some bugs etc.
* lib/PandoraFMS/SNMPServer.pm, lib/PandoraFMS/PluginServer.pm,
lib/PandoraFMS/ProducerConsumerServer.pm, lib/PandoraFMS/Server.pm,
lib/PandoraFMS/PredictionServer.pm, lib/PandoraFMS/Core.pm,
lib/PandoraFMS/ReconServer.pm, lib/PandoraFMS/DataServer.pm,
lib/PandoraFMS/NetworkServer.pm, lib/PandoraFMS/WMIServer.pm: Added
to repository. New server code.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1620 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-04-14 21:13:16 +02:00
2010-07-27 19:12:17 +02:00
# Open the incoming directory
2009-04-14 Ramon Novoa <rnovoa@artica.es>
* pandora_ctl, pandora_network, pandora_wmi, pandora_plugin,
pandora_prediction, bin/pandora_wmi, bin/pandora_plugin,
bin/pandora_prediction, bin/pandora_snmpconsole, bin/pandora_recon,
bin/pandora_network, pandora_recon, pandora_snmpconsole: Deleted
from repository. Old server code and startup scripts.
* Makefile.PL, pandora_server_installer, lib/PandoraFMS/Config.pm
lib/PandoraFMS/DB.pm, lib/PandoraFMS/Tools.pm, bin/pandora_server,
pandora_package_installer, pandora_server: Updated to work with the
new code, removed unneeded dependencies, fixed some bugs etc.
* lib/PandoraFMS/SNMPServer.pm, lib/PandoraFMS/PluginServer.pm,
lib/PandoraFMS/ProducerConsumerServer.pm, lib/PandoraFMS/Server.pm,
lib/PandoraFMS/PredictionServer.pm, lib/PandoraFMS/Core.pm,
lib/PandoraFMS/ReconServer.pm, lib/PandoraFMS/DataServer.pm,
lib/PandoraFMS/NetworkServer.pm, lib/PandoraFMS/WMIServer.pm: Added
to repository. New server code.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1620 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-04-14 21:13:16 +02:00
opendir ( DIR , $ pa_config - > { 'incomingdir' } )
2011-03-14 11:39:31 +01:00
|| die "[FATAL] Cannot open Incoming data directory at " . $ pa_config - > { 'incomingdir' } . ": $!" ;
2009-04-14 Ramon Novoa <rnovoa@artica.es>
* pandora_ctl, pandora_network, pandora_wmi, pandora_plugin,
pandora_prediction, bin/pandora_wmi, bin/pandora_plugin,
bin/pandora_prediction, bin/pandora_snmpconsole, bin/pandora_recon,
bin/pandora_network, pandora_recon, pandora_snmpconsole: Deleted
from repository. Old server code and startup scripts.
* Makefile.PL, pandora_server_installer, lib/PandoraFMS/Config.pm
lib/PandoraFMS/DB.pm, lib/PandoraFMS/Tools.pm, bin/pandora_server,
pandora_package_installer, pandora_server: Updated to work with the
new code, removed unneeded dependencies, fixed some bugs etc.
* lib/PandoraFMS/SNMPServer.pm, lib/PandoraFMS/PluginServer.pm,
lib/PandoraFMS/ProducerConsumerServer.pm, lib/PandoraFMS/Server.pm,
lib/PandoraFMS/PredictionServer.pm, lib/PandoraFMS/Core.pm,
lib/PandoraFMS/ReconServer.pm, lib/PandoraFMS/DataServer.pm,
lib/PandoraFMS/NetworkServer.pm, lib/PandoraFMS/WMIServer.pm: Added
to repository. New server code.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1620 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-04-14 21:13:16 +02:00
2010-07-27 19:12:17 +02:00
# Do not read more than max_queue_files files
my $ file_count = 0 ;
while ( my $ file = readdir ( DIR ) ) {
2011-06-02 17:28:29 +02:00
# Data files must have the extension .data
next if ( $ file !~ /^.*\.data$/ ) ;
2011-06-08 13:07:39 +02:00
push ( @ files , $ file ) ;
$ file_count + + ;
2011-06-02 17:28:29 +02:00
# Do not queue more than max_queue_files files
2011-06-08 13:07:39 +02:00
if ( $ file_count >= $ pa_config - > { "max_queue_files" } ) {
2010-07-27 19:12:17 +02:00
last ;
}
}
2010-07-22 13:00:37 +02:00
closedir ( DIR ) ;
2010-07-27 19:12:17 +02:00
# Temporarily disable warnings (some files may have been deleted)
{
no warnings ;
2011-06-02 17:28:29 +02:00
@ tasks = sort { - C $ pa_config - > { 'incomingdir' } . "/$b" <=> - C $ pa_config - > { 'incomingdir' } . "/$a" } ( @ files ) ;
2009-04-14 Ramon Novoa <rnovoa@artica.es>
* pandora_ctl, pandora_network, pandora_wmi, pandora_plugin,
pandora_prediction, bin/pandora_wmi, bin/pandora_plugin,
bin/pandora_prediction, bin/pandora_snmpconsole, bin/pandora_recon,
bin/pandora_network, pandora_recon, pandora_snmpconsole: Deleted
from repository. Old server code and startup scripts.
* Makefile.PL, pandora_server_installer, lib/PandoraFMS/Config.pm
lib/PandoraFMS/DB.pm, lib/PandoraFMS/Tools.pm, bin/pandora_server,
pandora_package_installer, pandora_server: Updated to work with the
new code, removed unneeded dependencies, fixed some bugs etc.
* lib/PandoraFMS/SNMPServer.pm, lib/PandoraFMS/PluginServer.pm,
lib/PandoraFMS/ProducerConsumerServer.pm, lib/PandoraFMS/Server.pm,
lib/PandoraFMS/PredictionServer.pm, lib/PandoraFMS/Core.pm,
lib/PandoraFMS/ReconServer.pm, lib/PandoraFMS/DataServer.pm,
lib/PandoraFMS/NetworkServer.pm, lib/PandoraFMS/WMIServer.pm: Added
to repository. New server code.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1620 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-04-14 21:13:16 +02:00
}
return @ tasks ;
}
###############################################################################
# Data consumer.
###############################################################################
sub data_consumer ($$) {
my ( $ self , $ task ) = @ _ ;
my ( $ pa_config , $ dbh ) = ( $ self - > getConfig ( ) , $ self - > getDBH ( ) ) ;
my $ file_name = $ pa_config - > { 'incomingdir' } ;
2010-09-20 19:01:27 +02:00
my $ xml_err ;
2009-04-14 Ramon Novoa <rnovoa@artica.es>
* pandora_ctl, pandora_network, pandora_wmi, pandora_plugin,
pandora_prediction, bin/pandora_wmi, bin/pandora_plugin,
bin/pandora_prediction, bin/pandora_snmpconsole, bin/pandora_recon,
bin/pandora_network, pandora_recon, pandora_snmpconsole: Deleted
from repository. Old server code and startup scripts.
* Makefile.PL, pandora_server_installer, lib/PandoraFMS/Config.pm
lib/PandoraFMS/DB.pm, lib/PandoraFMS/Tools.pm, bin/pandora_server,
pandora_package_installer, pandora_server: Updated to work with the
new code, removed unneeded dependencies, fixed some bugs etc.
* lib/PandoraFMS/SNMPServer.pm, lib/PandoraFMS/PluginServer.pm,
lib/PandoraFMS/ProducerConsumerServer.pm, lib/PandoraFMS/Server.pm,
lib/PandoraFMS/PredictionServer.pm, lib/PandoraFMS/Core.pm,
lib/PandoraFMS/ReconServer.pm, lib/PandoraFMS/DataServer.pm,
lib/PandoraFMS/NetworkServer.pm, lib/PandoraFMS/WMIServer.pm: Added
to repository. New server code.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1620 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-04-14 21:13:16 +02:00
# Fix path
$ file_name . = "/" unless ( substr ( $ file_name , - 1 , 1 ) eq '/' ) ;
$ file_name . = $ task ;
2010-07-26 13:51:49 +02:00
# Double check that the file exists
return unless ( - f $ file_name ) ;
2010-10-13 17:15:06 +02:00
# Try to parse the XML 2 times, with a delay between tries of 2 seconds
2009-04-14 Ramon Novoa <rnovoa@artica.es>
* pandora_ctl, pandora_network, pandora_wmi, pandora_plugin,
pandora_prediction, bin/pandora_wmi, bin/pandora_plugin,
bin/pandora_prediction, bin/pandora_snmpconsole, bin/pandora_recon,
bin/pandora_network, pandora_recon, pandora_snmpconsole: Deleted
from repository. Old server code and startup scripts.
* Makefile.PL, pandora_server_installer, lib/PandoraFMS/Config.pm
lib/PandoraFMS/DB.pm, lib/PandoraFMS/Tools.pm, bin/pandora_server,
pandora_package_installer, pandora_server: Updated to work with the
new code, removed unneeded dependencies, fixed some bugs etc.
* lib/PandoraFMS/SNMPServer.pm, lib/PandoraFMS/PluginServer.pm,
lib/PandoraFMS/ProducerConsumerServer.pm, lib/PandoraFMS/Server.pm,
lib/PandoraFMS/PredictionServer.pm, lib/PandoraFMS/Core.pm,
lib/PandoraFMS/ReconServer.pm, lib/PandoraFMS/DataServer.pm,
lib/PandoraFMS/NetworkServer.pm, lib/PandoraFMS/WMIServer.pm: Added
to repository. New server code.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1620 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-04-14 21:13:16 +02:00
my $ xml_data ;
2010-10-13 17:15:06 +02:00
for ( 0 .. 1 ) {
2009-04-14 Ramon Novoa <rnovoa@artica.es>
* pandora_ctl, pandora_network, pandora_wmi, pandora_plugin,
pandora_prediction, bin/pandora_wmi, bin/pandora_plugin,
bin/pandora_prediction, bin/pandora_snmpconsole, bin/pandora_recon,
bin/pandora_network, pandora_recon, pandora_snmpconsole: Deleted
from repository. Old server code and startup scripts.
* Makefile.PL, pandora_server_installer, lib/PandoraFMS/Config.pm
lib/PandoraFMS/DB.pm, lib/PandoraFMS/Tools.pm, bin/pandora_server,
pandora_package_installer, pandora_server: Updated to work with the
new code, removed unneeded dependencies, fixed some bugs etc.
* lib/PandoraFMS/SNMPServer.pm, lib/PandoraFMS/PluginServer.pm,
lib/PandoraFMS/ProducerConsumerServer.pm, lib/PandoraFMS/Server.pm,
lib/PandoraFMS/PredictionServer.pm, lib/PandoraFMS/Core.pm,
lib/PandoraFMS/ReconServer.pm, lib/PandoraFMS/DataServer.pm,
lib/PandoraFMS/NetworkServer.pm, lib/PandoraFMS/WMIServer.pm: Added
to repository. New server code.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1620 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-04-14 21:13:16 +02:00
eval {
threads - > yield ;
2009-06-02 13:19:27 +02:00
$ xml_data = XMLin ( $ file_name , forcearray = > 'module' ) ;
2010-07-26 13:51:49 +02:00
} ;
2010-02-23 18:49:05 +01:00
2010-07-26 13:51:49 +02:00
# Invalid XML
if ( $@ ) {
2010-09-20 19:01:27 +02:00
$ xml_err = $@ ;
2010-10-13 17:15:06 +02:00
sleep ( 2 ) ;
2010-07-26 13:51:49 +02:00
next ;
}
2010-02-23 18:49:05 +01:00
2010-07-26 13:51:49 +02:00
# Ignore the timestamp in the XML and use the file timestamp instead
$ xml_data - > { 'timestamp' } = strftime ( "%Y-%m-%d %H:%M:%S" , localtime ( ( stat ( $ file_name ) ) [ 9 ] ) ) if ( $ pa_config - > { 'use_xml_timestamp' } eq '1' || ! defined ( $ xml_data - > { 'timestamp' } ) ) ;
2009-08-24 20:25:42 +02:00
2011-03-14 11:39:31 +01:00
# Double check that the file exists
return unless ( - f $ file_name ) ;
2010-10-13 17:15:06 +02:00
2010-07-26 13:51:49 +02:00
unlink ( $ file_name ) ;
2009-11-13 Ramon Novoa <rnovoa@artica.es>
* conf/pandora_server.conf: Updated configuration tokens.
* lib/PandoraFMS/SNMPServer.pm, lib/PandoraFMS/Config.pm,
lib/PandoraFMS/PluginServer.pm, lib/PandoraFMS/PredictionServer.pm,
lib/PandoraFMS/Core.pm, lib/PandoraFMS/ReconServer.pm,
lib/PandoraFMS/DataServer.pm, lib/PandoraFMS/NetworkServer.pm,
lib/PandoraFMS/Tools.pm, lib/PandoraFMS/WMIServer.pm,
bin/pandora_server: Standardized and improved logging.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2108 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-11-13 14:52:48 +01:00
process_xml_data ( $ self - > getConfig ( ) , $ file_name , $ xml_data , $ self - > getServerID ( ) , $ self - > getDBH ( ) ) ;
2009-04-14 Ramon Novoa <rnovoa@artica.es>
* pandora_ctl, pandora_network, pandora_wmi, pandora_plugin,
pandora_prediction, bin/pandora_wmi, bin/pandora_plugin,
bin/pandora_prediction, bin/pandora_snmpconsole, bin/pandora_recon,
bin/pandora_network, pandora_recon, pandora_snmpconsole: Deleted
from repository. Old server code and startup scripts.
* Makefile.PL, pandora_server_installer, lib/PandoraFMS/Config.pm
lib/PandoraFMS/DB.pm, lib/PandoraFMS/Tools.pm, bin/pandora_server,
pandora_package_installer, pandora_server: Updated to work with the
new code, removed unneeded dependencies, fixed some bugs etc.
* lib/PandoraFMS/SNMPServer.pm, lib/PandoraFMS/PluginServer.pm,
lib/PandoraFMS/ProducerConsumerServer.pm, lib/PandoraFMS/Server.pm,
lib/PandoraFMS/PredictionServer.pm, lib/PandoraFMS/Core.pm,
lib/PandoraFMS/ReconServer.pm, lib/PandoraFMS/DataServer.pm,
lib/PandoraFMS/NetworkServer.pm, lib/PandoraFMS/WMIServer.pm: Added
to repository. New server code.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1620 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-04-14 21:13:16 +02:00
return ;
}
rename ( $ file_name , $ file_name . '_BADXML' ) ;
2010-09-20 19:01:27 +02:00
pandora_event ( $ pa_config , "Unable to process XML data file '$file_name': $xml_err" , 0 , 0 , 0 , 0 , 0 , 'error' , 0 , $ dbh ) ;
2009-04-14 Ramon Novoa <rnovoa@artica.es>
* pandora_ctl, pandora_network, pandora_wmi, pandora_plugin,
pandora_prediction, bin/pandora_wmi, bin/pandora_plugin,
bin/pandora_prediction, bin/pandora_snmpconsole, bin/pandora_recon,
bin/pandora_network, pandora_recon, pandora_snmpconsole: Deleted
from repository. Old server code and startup scripts.
* Makefile.PL, pandora_server_installer, lib/PandoraFMS/Config.pm
lib/PandoraFMS/DB.pm, lib/PandoraFMS/Tools.pm, bin/pandora_server,
pandora_package_installer, pandora_server: Updated to work with the
new code, removed unneeded dependencies, fixed some bugs etc.
* lib/PandoraFMS/SNMPServer.pm, lib/PandoraFMS/PluginServer.pm,
lib/PandoraFMS/ProducerConsumerServer.pm, lib/PandoraFMS/Server.pm,
lib/PandoraFMS/PredictionServer.pm, lib/PandoraFMS/Core.pm,
lib/PandoraFMS/ReconServer.pm, lib/PandoraFMS/DataServer.pm,
lib/PandoraFMS/NetworkServer.pm, lib/PandoraFMS/WMIServer.pm: Added
to repository. New server code.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1620 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-04-14 21:13:16 +02:00
}
###############################################################################
# Process XML data coming from an agent.
###############################################################################
2009-11-13 Ramon Novoa <rnovoa@artica.es>
* conf/pandora_server.conf: Updated configuration tokens.
* lib/PandoraFMS/SNMPServer.pm, lib/PandoraFMS/Config.pm,
lib/PandoraFMS/PluginServer.pm, lib/PandoraFMS/PredictionServer.pm,
lib/PandoraFMS/Core.pm, lib/PandoraFMS/ReconServer.pm,
lib/PandoraFMS/DataServer.pm, lib/PandoraFMS/NetworkServer.pm,
lib/PandoraFMS/Tools.pm, lib/PandoraFMS/WMIServer.pm,
bin/pandora_server: Standardized and improved logging.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2108 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-11-13 14:52:48 +01:00
sub process_xml_data ($$$$$) {
my ( $ pa_config , $ file_name , $ data , $ server_id , $ dbh ) = @ _ ;
2009-04-14 Ramon Novoa <rnovoa@artica.es>
* pandora_ctl, pandora_network, pandora_wmi, pandora_plugin,
pandora_prediction, bin/pandora_wmi, bin/pandora_plugin,
bin/pandora_prediction, bin/pandora_snmpconsole, bin/pandora_recon,
bin/pandora_network, pandora_recon, pandora_snmpconsole: Deleted
from repository. Old server code and startup scripts.
* Makefile.PL, pandora_server_installer, lib/PandoraFMS/Config.pm
lib/PandoraFMS/DB.pm, lib/PandoraFMS/Tools.pm, bin/pandora_server,
pandora_package_installer, pandora_server: Updated to work with the
new code, removed unneeded dependencies, fixed some bugs etc.
* lib/PandoraFMS/SNMPServer.pm, lib/PandoraFMS/PluginServer.pm,
lib/PandoraFMS/ProducerConsumerServer.pm, lib/PandoraFMS/Server.pm,
lib/PandoraFMS/PredictionServer.pm, lib/PandoraFMS/Core.pm,
lib/PandoraFMS/ReconServer.pm, lib/PandoraFMS/DataServer.pm,
lib/PandoraFMS/NetworkServer.pm, lib/PandoraFMS/WMIServer.pm: Added
to repository. New server code.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1620 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-04-14 21:13:16 +02:00
2010-01-25 19:36:23 +01:00
my ( $ agent_name , $ agent_version , $ timestamp , $ interval , $ os_version , $ timezone_offset ) =
2010-02-23 18:49:05 +01:00
( $ data - > { 'agent_name' } , $ data - > { 'version' } , $ data - > { 'timestamp' } ,
$ data - > { 'interval' } , $ data - > { 'os_version' } , $ data - > { 'timezone_offset' } ) ;
2010-01-25 19:36:23 +01:00
2010-01-29 16:40:05 +01:00
# Timezone offset must be an integer beween -12 and +12
2010-02-10 21:17:08 +01:00
if ( ! defined ( $ timezone_offset ) || $ timezone_offset !~ /[-+]?[0-9,11,12]/ ) {
2010-01-29 16:40:05 +01:00
$ timezone_offset = 0 ; # Default value
}
2010-02-22 20:43:39 +01:00
# Parent Agent Name
2010-02-25 18:09:19 +01:00
my $ parent_id = 0 ; # Default value for unknown parent
2010-02-22 20:43:39 +01:00
my $ parent_agent_name = $ data - > { 'parent_agent_name' } ;
2010-02-25 18:09:19 +01:00
if ( defined ( $ parent_agent_name ) ) {
2011-03-14 11:39:31 +01:00
$ parent_id = get_agent_id ( $ dbh , $ parent_agent_name ) ;
2010-02-25 18:09:19 +01:00
if ( $ parent_id < 1 ) { # Unknown parent
$ parent_id = 0 ;
}
logger ( $ pa_config , "Parent_agent_name: $parent_agent_name parent_id: $parent_id" , 10 ) ;
2010-03-04 10:24:52 +01:00
}
2010-01-29 16:40:05 +01:00
2010-01-25 19:36:23 +01:00
my $ valid_position_data = 1 ;
2009-04-14 Ramon Novoa <rnovoa@artica.es>
* pandora_ctl, pandora_network, pandora_wmi, pandora_plugin,
pandora_prediction, bin/pandora_wmi, bin/pandora_plugin,
bin/pandora_prediction, bin/pandora_snmpconsole, bin/pandora_recon,
bin/pandora_network, pandora_recon, pandora_snmpconsole: Deleted
from repository. Old server code and startup scripts.
* Makefile.PL, pandora_server_installer, lib/PandoraFMS/Config.pm
lib/PandoraFMS/DB.pm, lib/PandoraFMS/Tools.pm, bin/pandora_server,
pandora_package_installer, pandora_server: Updated to work with the
new code, removed unneeded dependencies, fixed some bugs etc.
* lib/PandoraFMS/SNMPServer.pm, lib/PandoraFMS/PluginServer.pm,
lib/PandoraFMS/ProducerConsumerServer.pm, lib/PandoraFMS/Server.pm,
lib/PandoraFMS/PredictionServer.pm, lib/PandoraFMS/Core.pm,
lib/PandoraFMS/ReconServer.pm, lib/PandoraFMS/DataServer.pm,
lib/PandoraFMS/NetworkServer.pm, lib/PandoraFMS/WMIServer.pm: Added
to repository. New server code.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1620 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-04-14 21:13:16 +02:00
2010-01-12 18:22:14 +01:00
# Get GIS information
2010-02-22 20:43:39 +01:00
my ( $ longitude , $ latitude , $ altitude , $ position_description ) = (
2010-02-23 18:49:05 +01:00
$ data - > { 'longitude' } , $ data - > { 'latitude' } , $ data - > { 'altitude' } ,
$ data - > { 'position_description' } ) ;
2010-01-12 18:22:14 +01:00
2010-01-25 19:36:23 +01:00
if ( $ pa_config - > { 'activate_gis' } ) {
2010-01-21 15:58:38 +01:00
2010-01-25 19:36:23 +01:00
# Validate the GIS informtation
2010-01-12 18:22:14 +01:00
2010-02-22 20:43:39 +01:00
if ( ! defined ( $ altitude ) || $ altitude !~ /[-+]?[0-9,11,12]/ ) {
2011-03-14 11:39:31 +01:00
$ altitude = '' ; # Default value
2010-03-10 19:46:52 +01:00
# This could be a valid position data, not always will get altitude
2011-03-14 11:39:31 +01:00
}
2010-02-23 18:49:05 +01:00
2010-03-10 19:46:52 +01:00
if ( ! defined ( $ longitude ) || $ longitude !~ /[-+]?[0-9,11,12]/ ) {
2011-03-14 11:39:31 +01:00
$ longitude = '' ; # Default value
2010-03-10 19:46:52 +01:00
$ valid_position_data = 0 ;
2011-03-14 11:39:31 +01:00
}
2010-03-10 19:46:52 +01:00
if ( ! defined ( $ latitude ) || $ latitude !~ /[-+]?[0-9,11,12]/ ) {
2011-03-14 11:39:31 +01:00
$ latitude = '' ; # Default value
2010-03-10 19:46:52 +01:00
$ valid_position_data = 0 ;
2011-03-14 11:39:31 +01:00
}
2010-03-10 19:46:52 +01:00
2011-06-21 17:19:43 +02:00
if ( ( ! defined ( $ position_description ) ) && ( $ latitude ne '' ) ) { #FIXME: Validate the data with a regexp
2011-02-07 14:45:34 +01:00
2011-03-14 11:39:31 +01:00
# This code gets description (Reverse Geocoding) from a current GPS coordinates using Google maps API
# This requires a connection to internet and could be very slow and have a huge impact in performance.
# Other methods for reverse geocoding are OpenStreetmaps, in nternet or in a local server
2011-02-07 14:45:34 +01:00
2011-03-14 11:39:31 +01:00
if ( $ pa_config - > { 'google_maps_description' } ) {
my $ content = get ( 'http://maps.google.com/maps/geo?q=' . $ latitude . ',' . $ longitude . '&output=csv&sensor=false' ) ;
my @ address = split ( /\"/ , $ content ) ;
$ position_description = $ address [ 1 ] ;
2011-03-09 14:49:30 +01:00
}
elsif ( $ pa_config - > { 'openstreetmaps_description' } ) {
2011-03-14 11:39:31 +01:00
# Sample Query: http://nominatim.openstreetmap.org/reverse?format=csv&lat=40.43197&lon=-3.6993818&zoom=18&addressdetails=1&email=info@pandorafms.org
# Email address is sent by courtesy to OpenStreetmaps people.
2011-03-09 14:49:30 +01:00
# I read the API :-), thanks guys for your work.
2011-03-14 11:39:31 +01:00
# Change here URL to make request to a local openstreetmap server
my $ content = get ( 'http://nominatim.openstreetmap.org/reverse?format=csv&lat=' . $ latitude . '&lon=' . $ longitude . '&zoom=18&addressdetails=1&email=info@pandorafms.org' ) ;
2011-03-09 14:49:30 +01:00
2011-09-14 12:59:53 +02:00
if ( ( defined ( $ content ) ) && ( $ content ne "" ) ) {
# Yep, I need to parse the XML output.
my $ xs1 = XML::Simple - > new ( ) ;
my $ doc = $ xs1 - > XMLin ( $ content ) ;
$ position_description = safe_input ( $ doc - > { result } { content } ) ;
} else {
$ position_description = "" ;
}
2011-03-09 14:49:30 +01:00
2011-03-14 11:39:31 +01:00
}
}
2010-03-10 19:46:52 +01:00
2011-08-17 22:11:32 +02:00
if ( ! defined ( $ position_description ) ) {
$ position_description = "" ;
}
2010-02-22 20:43:39 +01:00
logger ( $ pa_config , "Getting GIS Data=timezone_offset=$timezone_offset longitude=$longitude latitude=$latitude altitude=$altitude position_description=$position_description" , 8 ) ;
2010-01-25 19:36:23 +01:00
}
2011-03-09 14:49:30 +01:00
2009-04-14 Ramon Novoa <rnovoa@artica.es>
* pandora_ctl, pandora_network, pandora_wmi, pandora_plugin,
pandora_prediction, bin/pandora_wmi, bin/pandora_plugin,
bin/pandora_prediction, bin/pandora_snmpconsole, bin/pandora_recon,
bin/pandora_network, pandora_recon, pandora_snmpconsole: Deleted
from repository. Old server code and startup scripts.
* Makefile.PL, pandora_server_installer, lib/PandoraFMS/Config.pm
lib/PandoraFMS/DB.pm, lib/PandoraFMS/Tools.pm, bin/pandora_server,
pandora_package_installer, pandora_server: Updated to work with the
new code, removed unneeded dependencies, fixed some bugs etc.
* lib/PandoraFMS/SNMPServer.pm, lib/PandoraFMS/PluginServer.pm,
lib/PandoraFMS/ProducerConsumerServer.pm, lib/PandoraFMS/Server.pm,
lib/PandoraFMS/PredictionServer.pm, lib/PandoraFMS/Core.pm,
lib/PandoraFMS/ReconServer.pm, lib/PandoraFMS/DataServer.pm,
lib/PandoraFMS/NetworkServer.pm, lib/PandoraFMS/WMIServer.pm: Added
to repository. New server code.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1620 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-04-14 21:13:16 +02:00
# Unknown agent!
if ( ! defined ( $ agent_name ) || $ agent_name eq '' ) {
2009-11-13 Ramon Novoa <rnovoa@artica.es>
* conf/pandora_server.conf: Updated configuration tokens.
* lib/PandoraFMS/SNMPServer.pm, lib/PandoraFMS/Config.pm,
lib/PandoraFMS/PluginServer.pm, lib/PandoraFMS/PredictionServer.pm,
lib/PandoraFMS/Core.pm, lib/PandoraFMS/ReconServer.pm,
lib/PandoraFMS/DataServer.pm, lib/PandoraFMS/NetworkServer.pm,
lib/PandoraFMS/Tools.pm, lib/PandoraFMS/WMIServer.pm,
bin/pandora_server: Standardized and improved logging.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2108 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-11-13 14:52:48 +01:00
logger ( $ pa_config , "$file_name has data from an unnamed agent" , 3 ) ;
2009-04-14 Ramon Novoa <rnovoa@artica.es>
* pandora_ctl, pandora_network, pandora_wmi, pandora_plugin,
pandora_prediction, bin/pandora_wmi, bin/pandora_plugin,
bin/pandora_prediction, bin/pandora_snmpconsole, bin/pandora_recon,
bin/pandora_network, pandora_recon, pandora_snmpconsole: Deleted
from repository. Old server code and startup scripts.
* Makefile.PL, pandora_server_installer, lib/PandoraFMS/Config.pm
lib/PandoraFMS/DB.pm, lib/PandoraFMS/Tools.pm, bin/pandora_server,
pandora_package_installer, pandora_server: Updated to work with the
new code, removed unneeded dependencies, fixed some bugs etc.
* lib/PandoraFMS/SNMPServer.pm, lib/PandoraFMS/PluginServer.pm,
lib/PandoraFMS/ProducerConsumerServer.pm, lib/PandoraFMS/Server.pm,
lib/PandoraFMS/PredictionServer.pm, lib/PandoraFMS/Core.pm,
lib/PandoraFMS/ReconServer.pm, lib/PandoraFMS/DataServer.pm,
lib/PandoraFMS/NetworkServer.pm, lib/PandoraFMS/WMIServer.pm: Added
to repository. New server code.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1620 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-04-14 21:13:16 +02:00
return ;
}
2010-02-23 18:49:05 +01:00
2009-08-19 03:41:25 +02:00
# Get current datetime from system if value AUTO is coming in the XML
if ( $ data - > { 'timestamp' } =~ /AUTO/ ) {
$ timestamp = strftime ( "%Y/%m/%d %H:%M:%S" , localtime ( ) ) ;
}
2010-01-21 15:58:38 +01:00
else {
2010-01-29 16:40:05 +01:00
if ( $ timezone_offset != 0 ) {
2010-01-21 15:58:38 +01:00
# Modify the timestamp with the timezone_offset
logger ( $ pa_config , "Unmodified timestamp = $timestamp" , 5 ) ;
2010-01-29 16:40:05 +01:00
$ timestamp =~ /(\d+)[\/|\-](\d+)[\/|\-](\d+) +(\d+):(\d+):(\d+)/ ;
logger ( $ pa_config , "Unmodified timestamp = $1/$2/$3 $4:$5:$6" , 5 ) ;
2010-02-22 20:43:39 +01:00
my $ utimestamp = ( $ timezone_offset * 3600 ) ;
eval {
$ utimestamp += timelocal ( $ 6 , $ 5 , $ 4 , $ 3 , $ 2 - 1 , $ 1 - 1900 ) ;
} ;
2010-02-23 18:49:05 +01:00
if ( $@ ) {
2010-02-22 20:43:39 +01:00
logger ( $ pa_config , "WARNING: Invalid timestamp ($@) using server timestamp." , 4 ) ;
$ timestamp = strftime ( "%Y/%m/%d %H:%M:%S" , localtime ( ) ) ;
}
2010-01-21 15:58:38 +01:00
logger ( $ pa_config , "Seconds timestamp = $timestamp modified timestamp in seconds $utimestamp with timezone_offset = $timezone_offset" , 5 ) ;
2010-02-23 18:49:05 +01:00
$ timestamp = strftime ( "%Y-%m-%d %H:%M:%S" , localtime ( $ utimestamp ) ) ;
2010-01-29 16:40:05 +01:00
}
2010-01-21 15:58:38 +01:00
logger ( $ pa_config , "Modified timestamp = $timestamp with timezone_offset = $timezone_offset" , 5 ) ;
}
2009-08-19 03:41:25 +02:00
2010-01-21 15:58:38 +01:00
2010-02-23 18:49:05 +01:00
# Check some variables
$ interval = 300 if ( ! defined ( $ interval ) || $ interval eq '' ) ;
$ os_version = 'N/A' if ( ! defined ( $ os_version ) || $ os_version eq '' ) ;
2010-11-18 19:24:21 +01:00
# Get agent address from the XML if available
my $ address = '' ;
$ address = $ data - > { 'address' } if ( defined ( $ data - > { 'address' } ) ) ;
2010-02-23 18:49:05 +01:00
# Get agent id
$ AgentSem - > down ( ) ;
2009-04-14 Ramon Novoa <rnovoa@artica.es>
* pandora_ctl, pandora_network, pandora_wmi, pandora_plugin,
pandora_prediction, bin/pandora_wmi, bin/pandora_plugin,
bin/pandora_prediction, bin/pandora_snmpconsole, bin/pandora_recon,
bin/pandora_network, pandora_recon, pandora_snmpconsole: Deleted
from repository. Old server code and startup scripts.
* Makefile.PL, pandora_server_installer, lib/PandoraFMS/Config.pm
lib/PandoraFMS/DB.pm, lib/PandoraFMS/Tools.pm, bin/pandora_server,
pandora_package_installer, pandora_server: Updated to work with the
new code, removed unneeded dependencies, fixed some bugs etc.
* lib/PandoraFMS/SNMPServer.pm, lib/PandoraFMS/PluginServer.pm,
lib/PandoraFMS/ProducerConsumerServer.pm, lib/PandoraFMS/Server.pm,
lib/PandoraFMS/PredictionServer.pm, lib/PandoraFMS/Core.pm,
lib/PandoraFMS/ReconServer.pm, lib/PandoraFMS/DataServer.pm,
lib/PandoraFMS/NetworkServer.pm, lib/PandoraFMS/WMIServer.pm: Added
to repository. New server code.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1620 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-04-14 21:13:16 +02:00
my $ agent_id = get_agent_id ( $ dbh , $ agent_name ) ;
if ( $ agent_id < 1 ) {
if ( $ pa_config - > { 'autocreate' } == 0 ) {
logger ( $ pa_config , "ERROR: There is no agent defined with name $agent_name" , 3 ) ;
2009-11-10 13:25:10 +01:00
$ AgentSem - > up ( ) ;
2009-04-14 Ramon Novoa <rnovoa@artica.es>
* pandora_ctl, pandora_network, pandora_wmi, pandora_plugin,
pandora_prediction, bin/pandora_wmi, bin/pandora_plugin,
bin/pandora_prediction, bin/pandora_snmpconsole, bin/pandora_recon,
bin/pandora_network, pandora_recon, pandora_snmpconsole: Deleted
from repository. Old server code and startup scripts.
* Makefile.PL, pandora_server_installer, lib/PandoraFMS/Config.pm
lib/PandoraFMS/DB.pm, lib/PandoraFMS/Tools.pm, bin/pandora_server,
pandora_package_installer, pandora_server: Updated to work with the
new code, removed unneeded dependencies, fixed some bugs etc.
* lib/PandoraFMS/SNMPServer.pm, lib/PandoraFMS/PluginServer.pm,
lib/PandoraFMS/ProducerConsumerServer.pm, lib/PandoraFMS/Server.pm,
lib/PandoraFMS/PredictionServer.pm, lib/PandoraFMS/Core.pm,
lib/PandoraFMS/ReconServer.pm, lib/PandoraFMS/DataServer.pm,
lib/PandoraFMS/NetworkServer.pm, lib/PandoraFMS/WMIServer.pm: Added
to repository. New server code.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1620 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-04-14 21:13:16 +02:00
return ;
}
2009-08-04 18:19:15 +02:00
# Get OS, group and description
2009-08-19 03:41:25 +02:00
my $ os = pandora_get_os ( $ data - > { 'os_name' } ) ;
2011-05-03 16:24:51 +02:00
my $ group_id = - 1 ;
$ group_id = get_group_id ( $ dbh , $ data - > { 'group' } ) if ( defined ( $ data - > { 'group' } ) ) ;
if ( $ group_id == - 1 ) {
$ group_id = $ pa_config - > { 'autocreate_group' } ;
if ( ! defined ( get_group_name ( $ dbh , $ group_id ) ) ) {
logger ( $ pa_config , "Group id $group_id does not exist (check autocreate_group config token)" , 3 ) ;
$ AgentSem - > up ( ) ;
return ;
}
}
2009-08-04 18:19:15 +02:00
my $ description = '' ;
$ description = $ data - > { 'description' } if ( defined ( $ data - > { 'description' } ) ) ;
# Create the agent
2010-02-23 18:49:05 +01:00
if ( $ valid_position_data == 1 && $ pa_config - > { 'activate_gis' } != 0 ) {
2010-01-21 15:58:38 +01:00
logger ( $ pa_config , "Creating agent $agent_name at long: $longitude lat: $latitude alt: $altitude" , 5 ) ;
2010-11-18 19:24:21 +01:00
$ agent_id = pandora_create_agent ( $ pa_config , $ pa_config - > { 'servername' } , $ agent_name , $ address , $ group_id , $ parent_id , $ os ,
2010-02-23 18:49:05 +01:00
$ description , $ interval , $ dbh , $ timezone_offset , $ longitude , $ latitude , $ altitude , $ position_description ) ;
2010-01-21 15:58:38 +01:00
}
else { # Ignore agent positional data
logger ( $ pa_config , "Creating agent $agent_name" , 5 ) ;
2010-11-18 19:24:21 +01:00
$ agent_id = pandora_create_agent ( $ pa_config , $ pa_config - > { 'servername' } , $ agent_name , $ address , $ group_id , $ parent_id , $ os ,
2010-02-23 18:49:05 +01:00
$ description , $ interval , $ dbh , $ timezone_offset ) ;
2010-01-21 15:58:38 +01:00
}
2009-11-10 13:25:10 +01:00
if ( ! defined ( $ agent_id ) ) {
$ AgentSem - > up ( ) ;
return ;
}
2009-04-14 Ramon Novoa <rnovoa@artica.es>
* pandora_ctl, pandora_network, pandora_wmi, pandora_plugin,
pandora_prediction, bin/pandora_wmi, bin/pandora_plugin,
bin/pandora_prediction, bin/pandora_snmpconsole, bin/pandora_recon,
bin/pandora_network, pandora_recon, pandora_snmpconsole: Deleted
from repository. Old server code and startup scripts.
* Makefile.PL, pandora_server_installer, lib/PandoraFMS/Config.pm
lib/PandoraFMS/DB.pm, lib/PandoraFMS/Tools.pm, bin/pandora_server,
pandora_package_installer, pandora_server: Updated to work with the
new code, removed unneeded dependencies, fixed some bugs etc.
* lib/PandoraFMS/SNMPServer.pm, lib/PandoraFMS/PluginServer.pm,
lib/PandoraFMS/ProducerConsumerServer.pm, lib/PandoraFMS/Server.pm,
lib/PandoraFMS/PredictionServer.pm, lib/PandoraFMS/Core.pm,
lib/PandoraFMS/ReconServer.pm, lib/PandoraFMS/DataServer.pm,
lib/PandoraFMS/NetworkServer.pm, lib/PandoraFMS/WMIServer.pm: Added
to repository. New server code.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1620 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-04-14 21:13:16 +02:00
}
2010-02-23 18:49:05 +01:00
$ AgentSem - > up ( ) ;
2009-04-14 Ramon Novoa <rnovoa@artica.es>
* pandora_ctl, pandora_network, pandora_wmi, pandora_plugin,
pandora_prediction, bin/pandora_wmi, bin/pandora_plugin,
bin/pandora_prediction, bin/pandora_snmpconsole, bin/pandora_recon,
bin/pandora_network, pandora_recon, pandora_snmpconsole: Deleted
from repository. Old server code and startup scripts.
* Makefile.PL, pandora_server_installer, lib/PandoraFMS/Config.pm
lib/PandoraFMS/DB.pm, lib/PandoraFMS/Tools.pm, bin/pandora_server,
pandora_package_installer, pandora_server: Updated to work with the
new code, removed unneeded dependencies, fixed some bugs etc.
* lib/PandoraFMS/SNMPServer.pm, lib/PandoraFMS/PluginServer.pm,
lib/PandoraFMS/ProducerConsumerServer.pm, lib/PandoraFMS/Server.pm,
lib/PandoraFMS/PredictionServer.pm, lib/PandoraFMS/Core.pm,
lib/PandoraFMS/ReconServer.pm, lib/PandoraFMS/DataServer.pm,
lib/PandoraFMS/NetworkServer.pm, lib/PandoraFMS/WMIServer.pm: Added
to repository. New server code.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1620 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-04-14 21:13:16 +02:00
2010-05-19 15:40:21 +02:00
# Check if agent is disabled and return if it's disabled. Disabled agents doesnt process data
# in order to avoid not only events, also possible invalid data coming from agents.
2010-09-21 17:32:53 +02:00
my $ agent = get_db_single_row ( $ dbh , 'SELECT * FROM tagente WHERE id_agente = ?' , $ agent_id ) ;
if ( ! defined ( $ agent ) ) {
logger ( $ pa_config , "Error retrieving information for agent ID $agent_id" , 10 ) ;
2010-05-19 15:40:21 +02:00
return ;
}
2010-09-21 17:32:53 +02:00
return if ( $ agent - > { 'disabled' } == 1 ) ;
# Do not overwrite agent parameters if the agent is in normal mode
if ( $ agent - > { 'modo' } == 0 ) { ;
$ interval = $ agent - > { 'intervalo' } ;
$ os_version = $ agent - > { 'os_version' } ;
$ agent_version = $ agent - > { 'agent_version' } ;
$ timezone_offset = $ agent - > { 'timezone_offset' } ;
2010-11-18 19:24:21 +01:00
} else {
# Update agent address if necessary
if ( $ address ne '' && $ address ne $ agent - > { 'direccion' } ) {
2011-06-28 17:41:13 +02:00
# Update the main address
2010-11-18 19:24:21 +01:00
pandora_update_agent_address ( $ pa_config , $ agent_id , $ agent_name , $ address , $ dbh ) ;
2011-06-28 17:41:13 +02:00
# Update the addres list if necessary
pandora_add_agent_address ( $ pa_config , $ agent_id , $ address , $ dbh ) ;
2010-11-18 19:24:21 +01:00
}
2010-09-21 17:32:53 +02:00
}
2010-05-19 15:40:21 +02:00
2010-02-23 18:49:05 +01:00
if ( $ valid_position_data == 1 && $ pa_config - > { 'activate_gis' } != 0 ) {
2010-05-07 18:29:52 +02:00
if ( ! defined ( $ parent_agent_name ) ) {
2011-03-14 11:39:31 +01:00
$ parent_agent_name = "" ;
}
2010-02-24 16:25:56 +01:00
logger ( $ pa_config , "Parent_agent_name $parent_agent_name" , 10 ) ;
2010-02-25 18:09:19 +01:00
if ( $ pa_config - > { 'update_parent' } == 1 && $ parent_id != 0 ) {
2010-02-24 16:25:56 +01:00
logger ( $ pa_config , "Parent_agent_name $parent_agent_name" , 10 ) ;
2010-02-25 18:09:19 +01:00
logger ( $ pa_config , "Updating agent $agent_name at long: $longitude lat: $latitude alt: $altitude parent_id: $parent_id" , 5 ) ;
2010-02-24 16:25:56 +01:00
# Update agent information including position information and the paret
pandora_update_agent ( $ pa_config , $ timestamp , $ agent_id , $ os_version , $ agent_version , $ interval , $ dbh , $ timezone_offset ,
2010-02-25 18:09:19 +01:00
$ longitude , $ latitude , $ altitude , $ position_description , $ parent_id ) ;
2010-02-24 16:25:56 +01:00
}
else {
logger ( $ pa_config , "Updating agent $agent_name at long: $longitude lat: $latitude alt: $altitude" , 5 ) ;
# Update agent information including position information
} pandora_update_agent ( $ pa_config , $ timestamp , $ agent_id , $ os_version , $ agent_version , $ interval , $ dbh , $ timezone_offset , $ longitude , $ latitude , $ altitude , $ position_description ) ;
2010-01-21 15:58:38 +01:00
}
else {
2010-02-25 18:09:19 +01:00
if ( $ pa_config - > { 'update_parent' } == 1 && $ parent_id != 0 ) {
logger ( $ pa_config , "Updating agent $agent_name parent_id: $parent_id" , 5 ) ;
2011-03-14 11:39:31 +01:00
# Update agent information including the parent without position information
2010-02-25 18:09:19 +01:00
pandora_update_agent ( $ pa_config , $ timestamp , $ agent_id , $ os_version , $ agent_version , $ interval , $ dbh , $ timezone_offset , undef , undef , undef , undef , $ parent_id ) ;
2010-02-24 16:25:56 +01:00
}
else {
logger ( $ pa_config , "Updating agent $agent_name" , 5 ) ;
# Update agent information without position information ignoring the parent
pandora_update_agent ( $ pa_config , $ timestamp , $ agent_id , $ os_version , $ agent_version , $ interval , $ dbh , $ timezone_offset ) ;
}
2010-01-21 15:58:38 +01:00
}
2009-04-23 17:33:25 +02:00
pandora_module_keep_alive ( $ pa_config , $ agent_id , $ agent_name , $ server_id , $ dbh ) ;
2011-06-28 17:41:13 +02:00
2009-04-14 Ramon Novoa <rnovoa@artica.es>
* pandora_ctl, pandora_network, pandora_wmi, pandora_plugin,
pandora_prediction, bin/pandora_wmi, bin/pandora_plugin,
bin/pandora_prediction, bin/pandora_snmpconsole, bin/pandora_recon,
bin/pandora_network, pandora_recon, pandora_snmpconsole: Deleted
from repository. Old server code and startup scripts.
* Makefile.PL, pandora_server_installer, lib/PandoraFMS/Config.pm
lib/PandoraFMS/DB.pm, lib/PandoraFMS/Tools.pm, bin/pandora_server,
pandora_package_installer, pandora_server: Updated to work with the
new code, removed unneeded dependencies, fixed some bugs etc.
* lib/PandoraFMS/SNMPServer.pm, lib/PandoraFMS/PluginServer.pm,
lib/PandoraFMS/ProducerConsumerServer.pm, lib/PandoraFMS/Server.pm,
lib/PandoraFMS/PredictionServer.pm, lib/PandoraFMS/Core.pm,
lib/PandoraFMS/ReconServer.pm, lib/PandoraFMS/DataServer.pm,
lib/PandoraFMS/NetworkServer.pm, lib/PandoraFMS/WMIServer.pm: Added
to repository. New server code.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1620 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-04-14 21:13:16 +02:00
# Process modules
foreach my $ module_data ( @ { $ data - > { 'module' } } ) {
2009-06-02 13:19:27 +02:00
my $ module_name = get_tag_value ( $ module_data , 'name' , '' ) ;
2009-04-14 Ramon Novoa <rnovoa@artica.es>
* pandora_ctl, pandora_network, pandora_wmi, pandora_plugin,
pandora_prediction, bin/pandora_wmi, bin/pandora_plugin,
bin/pandora_prediction, bin/pandora_snmpconsole, bin/pandora_recon,
bin/pandora_network, pandora_recon, pandora_snmpconsole: Deleted
from repository. Old server code and startup scripts.
* Makefile.PL, pandora_server_installer, lib/PandoraFMS/Config.pm
lib/PandoraFMS/DB.pm, lib/PandoraFMS/Tools.pm, bin/pandora_server,
pandora_package_installer, pandora_server: Updated to work with the
new code, removed unneeded dependencies, fixed some bugs etc.
* lib/PandoraFMS/SNMPServer.pm, lib/PandoraFMS/PluginServer.pm,
lib/PandoraFMS/ProducerConsumerServer.pm, lib/PandoraFMS/Server.pm,
lib/PandoraFMS/PredictionServer.pm, lib/PandoraFMS/Core.pm,
lib/PandoraFMS/ReconServer.pm, lib/PandoraFMS/DataServer.pm,
lib/PandoraFMS/NetworkServer.pm, lib/PandoraFMS/WMIServer.pm: Added
to repository. New server code.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1620 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-04-14 21:13:16 +02:00
# Unnamed module
2009-06-02 13:19:27 +02:00
next if ( $ module_name eq '' ) ;
2009-04-14 Ramon Novoa <rnovoa@artica.es>
* pandora_ctl, pandora_network, pandora_wmi, pandora_plugin,
pandora_prediction, bin/pandora_wmi, bin/pandora_plugin,
bin/pandora_prediction, bin/pandora_snmpconsole, bin/pandora_recon,
bin/pandora_network, pandora_recon, pandora_snmpconsole: Deleted
from repository. Old server code and startup scripts.
* Makefile.PL, pandora_server_installer, lib/PandoraFMS/Config.pm
lib/PandoraFMS/DB.pm, lib/PandoraFMS/Tools.pm, bin/pandora_server,
pandora_package_installer, pandora_server: Updated to work with the
new code, removed unneeded dependencies, fixed some bugs etc.
* lib/PandoraFMS/SNMPServer.pm, lib/PandoraFMS/PluginServer.pm,
lib/PandoraFMS/ProducerConsumerServer.pm, lib/PandoraFMS/Server.pm,
lib/PandoraFMS/PredictionServer.pm, lib/PandoraFMS/Core.pm,
lib/PandoraFMS/ReconServer.pm, lib/PandoraFMS/DataServer.pm,
lib/PandoraFMS/NetworkServer.pm, lib/PandoraFMS/WMIServer.pm: Added
to repository. New server code.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1620 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-04-14 21:13:16 +02:00
2009-06-02 13:19:27 +02:00
my $ module_type = get_tag_value ( $ module_data , 'type' , 'generic_data' ) ;
2009-04-14 Ramon Novoa <rnovoa@artica.es>
* pandora_ctl, pandora_network, pandora_wmi, pandora_plugin,
pandora_prediction, bin/pandora_wmi, bin/pandora_plugin,
bin/pandora_prediction, bin/pandora_snmpconsole, bin/pandora_recon,
bin/pandora_network, pandora_recon, pandora_snmpconsole: Deleted
from repository. Old server code and startup scripts.
* Makefile.PL, pandora_server_installer, lib/PandoraFMS/Config.pm
lib/PandoraFMS/DB.pm, lib/PandoraFMS/Tools.pm, bin/pandora_server,
pandora_package_installer, pandora_server: Updated to work with the
new code, removed unneeded dependencies, fixed some bugs etc.
* lib/PandoraFMS/SNMPServer.pm, lib/PandoraFMS/PluginServer.pm,
lib/PandoraFMS/ProducerConsumerServer.pm, lib/PandoraFMS/Server.pm,
lib/PandoraFMS/PredictionServer.pm, lib/PandoraFMS/Core.pm,
lib/PandoraFMS/ReconServer.pm, lib/PandoraFMS/DataServer.pm,
lib/PandoraFMS/NetworkServer.pm, lib/PandoraFMS/WMIServer.pm: Added
to repository. New server code.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1620 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-04-14 21:13:16 +02:00
2010-02-23 18:49:05 +01:00
# Single data
if ( ! defined ( $ module_data - > { 'datalist' } ) ) {
2009-06-02 13:19:27 +02:00
my $ data_timestamp = get_tag_value ( $ module_data , 'timestamp' , $ timestamp ) ;
2009-04-23 17:33:25 +02:00
process_module_data ( $ pa_config , $ module_data , $ server_id , $ agent_name , $ module_name , $ module_type , $ interval , $ data_timestamp , $ dbh ) ;
2009-04-14 Ramon Novoa <rnovoa@artica.es>
* pandora_ctl, pandora_network, pandora_wmi, pandora_plugin,
pandora_prediction, bin/pandora_wmi, bin/pandora_plugin,
bin/pandora_prediction, bin/pandora_snmpconsole, bin/pandora_recon,
bin/pandora_network, pandora_recon, pandora_snmpconsole: Deleted
from repository. Old server code and startup scripts.
* Makefile.PL, pandora_server_installer, lib/PandoraFMS/Config.pm
lib/PandoraFMS/DB.pm, lib/PandoraFMS/Tools.pm, bin/pandora_server,
pandora_package_installer, pandora_server: Updated to work with the
new code, removed unneeded dependencies, fixed some bugs etc.
* lib/PandoraFMS/SNMPServer.pm, lib/PandoraFMS/PluginServer.pm,
lib/PandoraFMS/ProducerConsumerServer.pm, lib/PandoraFMS/Server.pm,
lib/PandoraFMS/PredictionServer.pm, lib/PandoraFMS/Core.pm,
lib/PandoraFMS/ReconServer.pm, lib/PandoraFMS/DataServer.pm,
lib/PandoraFMS/NetworkServer.pm, lib/PandoraFMS/WMIServer.pm: Added
to repository. New server code.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1620 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-04-14 21:13:16 +02:00
next ;
}
# Data list
foreach my $ list ( @ { $ module_data - > { 'datalist' } } ) {
# Empty list
next unless defined ( $ list - > { 'data' } ) ;
foreach my $ data ( @ { $ list - > { 'data' } } ) {
# No value
next unless defined ( $ data - > { 'value' } ) ;
$ module_data - > { 'data' } = $ data - > { 'value' } ;
2009-06-02 13:19:27 +02:00
my $ data_timestamp = get_tag_value ( $ module_data , 'timestamp' , $ timestamp ) ;
2009-04-23 17:33:25 +02:00
process_module_data ( $ pa_config , $ module_data , $ server_id , $ agent_name , $ module_name ,
2009-04-20 11:44:24 +02:00
$ module_type , $ interval , $ data_timestamp , $ dbh ) ;
2009-04-14 Ramon Novoa <rnovoa@artica.es>
* pandora_ctl, pandora_network, pandora_wmi, pandora_plugin,
pandora_prediction, bin/pandora_wmi, bin/pandora_plugin,
bin/pandora_prediction, bin/pandora_snmpconsole, bin/pandora_recon,
bin/pandora_network, pandora_recon, pandora_snmpconsole: Deleted
from repository. Old server code and startup scripts.
* Makefile.PL, pandora_server_installer, lib/PandoraFMS/Config.pm
lib/PandoraFMS/DB.pm, lib/PandoraFMS/Tools.pm, bin/pandora_server,
pandora_package_installer, pandora_server: Updated to work with the
new code, removed unneeded dependencies, fixed some bugs etc.
* lib/PandoraFMS/SNMPServer.pm, lib/PandoraFMS/PluginServer.pm,
lib/PandoraFMS/ProducerConsumerServer.pm, lib/PandoraFMS/Server.pm,
lib/PandoraFMS/PredictionServer.pm, lib/PandoraFMS/Core.pm,
lib/PandoraFMS/ReconServer.pm, lib/PandoraFMS/DataServer.pm,
lib/PandoraFMS/NetworkServer.pm, lib/PandoraFMS/WMIServer.pm: Added
to repository. New server code.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1620 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-04-14 21:13:16 +02:00
}
}
}
2009-08-03 17:12:07 +02:00
# Process inventory modules
2009-10-07 17:10:14 +02:00
enterprise_hook ( 'process_inventory_data' , [ $ pa_config , $ data , $ server_id , $ agent_name ,
2010-02-23 18:49:05 +01:00
$ interval , $ timestamp , $ dbh ] ) ;
2009-04-14 Ramon Novoa <rnovoa@artica.es>
* pandora_ctl, pandora_network, pandora_wmi, pandora_plugin,
pandora_prediction, bin/pandora_wmi, bin/pandora_plugin,
bin/pandora_prediction, bin/pandora_snmpconsole, bin/pandora_recon,
bin/pandora_network, pandora_recon, pandora_snmpconsole: Deleted
from repository. Old server code and startup scripts.
* Makefile.PL, pandora_server_installer, lib/PandoraFMS/Config.pm
lib/PandoraFMS/DB.pm, lib/PandoraFMS/Tools.pm, bin/pandora_server,
pandora_package_installer, pandora_server: Updated to work with the
new code, removed unneeded dependencies, fixed some bugs etc.
* lib/PandoraFMS/SNMPServer.pm, lib/PandoraFMS/PluginServer.pm,
lib/PandoraFMS/ProducerConsumerServer.pm, lib/PandoraFMS/Server.pm,
lib/PandoraFMS/PredictionServer.pm, lib/PandoraFMS/Core.pm,
lib/PandoraFMS/ReconServer.pm, lib/PandoraFMS/DataServer.pm,
lib/PandoraFMS/NetworkServer.pm, lib/PandoraFMS/WMIServer.pm: Added
to repository. New server code.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1620 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-04-14 21:13:16 +02:00
}
##########################################################################
# Process module data, creating module if necessary.
##########################################################################
2009-04-23 17:33:25 +02:00
sub process_module_data ($$$$$$$$$) {
my ( $ pa_config , $ data , $ server_id , $ agent_name ,
2010-02-23 18:49:05 +01:00
$ module_name , $ module_type , $ interval , $ timestamp ,
$ dbh ) = @ _ ;
2009-04-14 Ramon Novoa <rnovoa@artica.es>
* pandora_ctl, pandora_network, pandora_wmi, pandora_plugin,
pandora_prediction, bin/pandora_wmi, bin/pandora_plugin,
bin/pandora_prediction, bin/pandora_snmpconsole, bin/pandora_recon,
bin/pandora_network, pandora_recon, pandora_snmpconsole: Deleted
from repository. Old server code and startup scripts.
* Makefile.PL, pandora_server_installer, lib/PandoraFMS/Config.pm
lib/PandoraFMS/DB.pm, lib/PandoraFMS/Tools.pm, bin/pandora_server,
pandora_package_installer, pandora_server: Updated to work with the
new code, removed unneeded dependencies, fixed some bugs etc.
* lib/PandoraFMS/SNMPServer.pm, lib/PandoraFMS/PluginServer.pm,
lib/PandoraFMS/ProducerConsumerServer.pm, lib/PandoraFMS/Server.pm,
lib/PandoraFMS/PredictionServer.pm, lib/PandoraFMS/Core.pm,
lib/PandoraFMS/ReconServer.pm, lib/PandoraFMS/DataServer.pm,
lib/PandoraFMS/NetworkServer.pm, lib/PandoraFMS/WMIServer.pm: Added
to repository. New server code.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1620 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-04-14 21:13:16 +02:00
2009-04-23 17:33:25 +02:00
# Get agent data
2010-11-02 18:26:34 +01:00
my $ agent = get_db_single_row ( $ dbh , 'SELECT * FROM tagente WHERE nombre = ?' , safe_input ( $ agent_name ) ) ;
2009-11-13 Ramon Novoa <rnovoa@artica.es>
* conf/pandora_server.conf: Updated configuration tokens.
* lib/PandoraFMS/SNMPServer.pm, lib/PandoraFMS/Config.pm,
lib/PandoraFMS/PluginServer.pm, lib/PandoraFMS/PredictionServer.pm,
lib/PandoraFMS/Core.pm, lib/PandoraFMS/ReconServer.pm,
lib/PandoraFMS/DataServer.pm, lib/PandoraFMS/NetworkServer.pm,
lib/PandoraFMS/Tools.pm, lib/PandoraFMS/WMIServer.pm,
bin/pandora_server: Standardized and improved logging.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2108 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-11-13 14:52:48 +01:00
if ( ! defined ( $ agent ) ) {
logger ( $ pa_config , "Invalid agent '$agent_name' for module '$module_name'." , 3 ) ;
return ;
}
2009-04-14 Ramon Novoa <rnovoa@artica.es>
* pandora_ctl, pandora_network, pandora_wmi, pandora_plugin,
pandora_prediction, bin/pandora_wmi, bin/pandora_plugin,
bin/pandora_prediction, bin/pandora_snmpconsole, bin/pandora_recon,
bin/pandora_network, pandora_recon, pandora_snmpconsole: Deleted
from repository. Old server code and startup scripts.
* Makefile.PL, pandora_server_installer, lib/PandoraFMS/Config.pm
lib/PandoraFMS/DB.pm, lib/PandoraFMS/Tools.pm, bin/pandora_server,
pandora_package_installer, pandora_server: Updated to work with the
new code, removed unneeded dependencies, fixed some bugs etc.
* lib/PandoraFMS/SNMPServer.pm, lib/PandoraFMS/PluginServer.pm,
lib/PandoraFMS/ProducerConsumerServer.pm, lib/PandoraFMS/Server.pm,
lib/PandoraFMS/PredictionServer.pm, lib/PandoraFMS/Core.pm,
lib/PandoraFMS/ReconServer.pm, lib/PandoraFMS/DataServer.pm,
lib/PandoraFMS/NetworkServer.pm, lib/PandoraFMS/WMIServer.pm: Added
to repository. New server code.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1620 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-04-14 21:13:16 +02:00
2010-09-20 19:01:27 +02:00
# Get module parameters, matching column names in tagente_modulo
my $ module_conf ;
2011-08-10 18:58:26 +02:00
# Supported tags
my $ tags = { 'name' = > 0 , 'data' = > 0 , 'type' = > 0 , 'description' = > 0 , 'max' = > 0 ,
'min' = > 0 , 'descripcion' = > 0 , 'post_process' = > 0 , 'module_interval' = > 0 , 'min_critical' = > 0 ,
2011-08-24 13:41:27 +02:00
'max_critical' = > 0 , 'min_warning' = > 0 , 'max_warning' = > 0 , 'disabled' = > 0 , 'min_ff_event' = > 0 ,
2012-02-03 13:31:08 +01:00
'datalist' = > 0 , 'status' = > 0 , 'timestamp' = > 0 } ;
2011-08-10 18:58:26 +02:00
# Other tags will be saved here
$ module_conf - > { 'extended_info' } = '' ;
# Read tags
while ( my ( $ tag , $ value ) = each ( % { $ data } ) ) {
if ( defined ( $ tags - > { $ tag } ) ) {
2011-08-16 13:37:17 +02:00
$ module_conf - > { $ tag } = get_tag_value ( $ data , $ tag , '' ) ;
2011-08-10 18:58:26 +02:00
} else {
2011-08-16 13:37:17 +02:00
$ module_conf - > { 'extended_info' } . = "$tag: " . get_tag_value ( $ data , $ tag , '' ) . '<br/>' ;
2011-08-10 18:58:26 +02:00
}
}
# Description XML tag and column name don't match
$ module_conf - > { 'descripcion' } = $ module_conf - > { 'description' } ;
2010-09-20 19:01:27 +02:00
# Calculate the module interval in seconds
2011-02-23 11:50:00 +01:00
$ module_conf - > { 'module_interval' } *= $ interval if ( defined ( $ module_conf - > { 'module_interval' } ) ) ;
2010-09-20 19:01:27 +02:00
# Allow , as a decimal separator
2011-02-23 11:50:00 +01:00
$ module_conf - > { 'post_process' } =~ s/,/./ if ( defined ( $ module_conf - > { 'post_process' } ) ) ;
2010-09-20 19:01:27 +02:00
2009-04-23 17:33:25 +02:00
# Get module data or create it if it does not exist
2009-11-13 Ramon Novoa <rnovoa@artica.es>
* conf/pandora_server.conf: Updated configuration tokens.
* lib/PandoraFMS/SNMPServer.pm, lib/PandoraFMS/Config.pm,
lib/PandoraFMS/PluginServer.pm, lib/PandoraFMS/PredictionServer.pm,
lib/PandoraFMS/Core.pm, lib/PandoraFMS/ReconServer.pm,
lib/PandoraFMS/DataServer.pm, lib/PandoraFMS/NetworkServer.pm,
lib/PandoraFMS/Tools.pm, lib/PandoraFMS/WMIServer.pm,
bin/pandora_server: Standardized and improved logging.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2108 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-11-13 14:52:48 +01:00
$ ModuleSem - > down ( ) ;
2011-04-19 17:32:11 +02:00
my $ module = get_db_single_row ( $ dbh , 'SELECT * FROM tagente_modulo WHERE id_agente = ? AND ' . db_text ( 'nombre' ) . ' = ?' , $ agent - > { 'id_agente' } , safe_input ( $ module_name ) ) ;
2009-04-14 Ramon Novoa <rnovoa@artica.es>
* pandora_ctl, pandora_network, pandora_wmi, pandora_plugin,
pandora_prediction, bin/pandora_wmi, bin/pandora_plugin,
bin/pandora_prediction, bin/pandora_snmpconsole, bin/pandora_recon,
bin/pandora_network, pandora_recon, pandora_snmpconsole: Deleted
from repository. Old server code and startup scripts.
* Makefile.PL, pandora_server_installer, lib/PandoraFMS/Config.pm
lib/PandoraFMS/DB.pm, lib/PandoraFMS/Tools.pm, bin/pandora_server,
pandora_package_installer, pandora_server: Updated to work with the
new code, removed unneeded dependencies, fixed some bugs etc.
* lib/PandoraFMS/SNMPServer.pm, lib/PandoraFMS/PluginServer.pm,
lib/PandoraFMS/ProducerConsumerServer.pm, lib/PandoraFMS/Server.pm,
lib/PandoraFMS/PredictionServer.pm, lib/PandoraFMS/Core.pm,
lib/PandoraFMS/ReconServer.pm, lib/PandoraFMS/DataServer.pm,
lib/PandoraFMS/NetworkServer.pm, lib/PandoraFMS/WMIServer.pm: Added
to repository. New server code.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1620 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-04-14 21:13:16 +02:00
if ( ! defined ( $ module ) ) {
2009-04-23 17:33:25 +02:00
# Do not auto create modules
2009-11-13 Ramon Novoa <rnovoa@artica.es>
* conf/pandora_server.conf: Updated configuration tokens.
* lib/PandoraFMS/SNMPServer.pm, lib/PandoraFMS/Config.pm,
lib/PandoraFMS/PluginServer.pm, lib/PandoraFMS/PredictionServer.pm,
lib/PandoraFMS/Core.pm, lib/PandoraFMS/ReconServer.pm,
lib/PandoraFMS/DataServer.pm, lib/PandoraFMS/NetworkServer.pm,
lib/PandoraFMS/Tools.pm, lib/PandoraFMS/WMIServer.pm,
bin/pandora_server: Standardized and improved logging.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2108 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-11-13 14:52:48 +01:00
if ( $ pa_config - > { 'autocreate' } ne '1' ) {
logger ( $ pa_config , "Module '$module_name' not found for agent '$agent_name' and module auto-creation disabled." , 10 ) ;
$ ModuleSem - > up ( ) ;
return ;
}
2009-11-04 18:49:42 +01:00
# Is the agent learning?
2009-11-13 Ramon Novoa <rnovoa@artica.es>
* conf/pandora_server.conf: Updated configuration tokens.
* lib/PandoraFMS/SNMPServer.pm, lib/PandoraFMS/Config.pm,
lib/PandoraFMS/PluginServer.pm, lib/PandoraFMS/PredictionServer.pm,
lib/PandoraFMS/Core.pm, lib/PandoraFMS/ReconServer.pm,
lib/PandoraFMS/DataServer.pm, lib/PandoraFMS/NetworkServer.pm,
lib/PandoraFMS/Tools.pm, lib/PandoraFMS/WMIServer.pm,
bin/pandora_server: Standardized and improved logging.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2108 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-11-13 14:52:48 +01:00
if ( $ agent - > { 'modo' } ne '1' ) {
logger ( $ pa_config , "Learning mode disabled. Skipping module '$module_name' agent '$agent_name'." , 10 ) ;
$ ModuleSem - > up ( ) ;
return ;
}
2010-02-15 14:07:52 +01:00
2009-04-23 17:33:25 +02:00
# Get the module type
2009-04-14 Ramon Novoa <rnovoa@artica.es>
* pandora_ctl, pandora_network, pandora_wmi, pandora_plugin,
pandora_prediction, bin/pandora_wmi, bin/pandora_plugin,
bin/pandora_prediction, bin/pandora_snmpconsole, bin/pandora_recon,
bin/pandora_network, pandora_recon, pandora_snmpconsole: Deleted
from repository. Old server code and startup scripts.
* Makefile.PL, pandora_server_installer, lib/PandoraFMS/Config.pm
lib/PandoraFMS/DB.pm, lib/PandoraFMS/Tools.pm, bin/pandora_server,
pandora_package_installer, pandora_server: Updated to work with the
new code, removed unneeded dependencies, fixed some bugs etc.
* lib/PandoraFMS/SNMPServer.pm, lib/PandoraFMS/PluginServer.pm,
lib/PandoraFMS/ProducerConsumerServer.pm, lib/PandoraFMS/Server.pm,
lib/PandoraFMS/PredictionServer.pm, lib/PandoraFMS/Core.pm,
lib/PandoraFMS/ReconServer.pm, lib/PandoraFMS/DataServer.pm,
lib/PandoraFMS/NetworkServer.pm, lib/PandoraFMS/WMIServer.pm: Added
to repository. New server code.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1620 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-04-14 21:13:16 +02:00
my $ module_id = get_module_id ( $ dbh , $ module_type ) ;
2009-11-13 Ramon Novoa <rnovoa@artica.es>
* conf/pandora_server.conf: Updated configuration tokens.
* lib/PandoraFMS/SNMPServer.pm, lib/PandoraFMS/Config.pm,
lib/PandoraFMS/PluginServer.pm, lib/PandoraFMS/PredictionServer.pm,
lib/PandoraFMS/Core.pm, lib/PandoraFMS/ReconServer.pm,
lib/PandoraFMS/DataServer.pm, lib/PandoraFMS/NetworkServer.pm,
lib/PandoraFMS/Tools.pm, lib/PandoraFMS/WMIServer.pm,
bin/pandora_server: Standardized and improved logging.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2108 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-11-13 14:52:48 +01:00
if ( $ module_id <= 0 ) {
logger ( $ pa_config , "Invalid module type '$module_type' for module '$module_name' agent '$agent_name'." , 3 ) ;
$ ModuleSem - > up ( ) ;
return ;
}
2009-04-14 Ramon Novoa <rnovoa@artica.es>
* pandora_ctl, pandora_network, pandora_wmi, pandora_plugin,
pandora_prediction, bin/pandora_wmi, bin/pandora_plugin,
bin/pandora_prediction, bin/pandora_snmpconsole, bin/pandora_recon,
bin/pandora_network, pandora_recon, pandora_snmpconsole: Deleted
from repository. Old server code and startup scripts.
* Makefile.PL, pandora_server_installer, lib/PandoraFMS/Config.pm
lib/PandoraFMS/DB.pm, lib/PandoraFMS/Tools.pm, bin/pandora_server,
pandora_package_installer, pandora_server: Updated to work with the
new code, removed unneeded dependencies, fixed some bugs etc.
* lib/PandoraFMS/SNMPServer.pm, lib/PandoraFMS/PluginServer.pm,
lib/PandoraFMS/ProducerConsumerServer.pm, lib/PandoraFMS/Server.pm,
lib/PandoraFMS/PredictionServer.pm, lib/PandoraFMS/Core.pm,
lib/PandoraFMS/ReconServer.pm, lib/PandoraFMS/DataServer.pm,
lib/PandoraFMS/NetworkServer.pm, lib/PandoraFMS/WMIServer.pm: Added
to repository. New server code.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1620 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-04-14 21:13:16 +02:00
2011-02-23 11:50:00 +01:00
# Set default values
$ module_conf - > { 'max' } = 0 unless defined ( $ module_conf - > { 'max' } ) ;
$ module_conf - > { 'min' } = 0 unless defined ( $ module_conf - > { 'min' } ) ;
$ module_conf - > { 'descripcion' } = '' unless defined ( $ module_conf - > { 'descripcion' } ) ;
2011-02-28 11:21:03 +01:00
$ module_conf - > { 'post_process' } = 0 unless defined ( $ module_conf - > { 'post_process' } ) ;
2011-02-23 11:50:00 +01:00
$ module_conf - > { 'module_interval' } = $ interval unless defined ( $ module_conf - > { 'module_interval' } ) ; # 1 * $interval
2011-04-27 19:44:14 +02:00
$ module_conf - > { 'min_critical' } = 0 unless defined ( $ module_conf - > { 'min_critical' } ) ;
$ module_conf - > { 'max_critical' } = 0 unless defined ( $ module_conf - > { 'max_critical' } ) ;
$ module_conf - > { 'min_warning' } = 0 unless defined ( $ module_conf - > { 'min_warning' } ) ;
$ module_conf - > { 'max_warning' } = 0 unless defined ( $ module_conf - > { 'max_warning' } ) ;
$ module_conf - > { 'disabled' } = 0 unless defined ( $ module_conf - > { 'disabled' } ) ;
$ module_conf - > { 'min_ff_event' } = 0 unless defined ( $ module_conf - > { 'min_ff_event' } ) ;
2011-08-10 18:58:26 +02:00
$ module_conf - > { 'extended_info' } = '' unless defined ( $ module_conf - > { 'extended_info' } ) ;
2011-02-23 11:50:00 +01:00
2009-04-23 17:33:25 +02:00
# Create the module
2009-11-13 Ramon Novoa <rnovoa@artica.es>
* conf/pandora_server.conf: Updated configuration tokens.
* lib/PandoraFMS/SNMPServer.pm, lib/PandoraFMS/Config.pm,
lib/PandoraFMS/PluginServer.pm, lib/PandoraFMS/PredictionServer.pm,
lib/PandoraFMS/Core.pm, lib/PandoraFMS/ReconServer.pm,
lib/PandoraFMS/DataServer.pm, lib/PandoraFMS/NetworkServer.pm,
lib/PandoraFMS/Tools.pm, lib/PandoraFMS/WMIServer.pm,
bin/pandora_server: Standardized and improved logging.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2108 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-11-13 14:52:48 +01:00
pandora_create_module ( $ pa_config , $ agent - > { 'id_agente' } , $ module_id , $ module_name ,
2010-09-20 19:01:27 +02:00
$ module_conf - > { 'max' } , $ module_conf - > { 'min' } , $ module_conf - > { 'post_process' } ,
$ module_conf - > { 'descripcion' } , $ module_conf - > { 'module_interval' } , $ dbh ) ;
2011-04-19 17:32:11 +02:00
$ module = get_db_single_row ( $ dbh , 'SELECT * FROM tagente_modulo WHERE id_agente = ? AND ' . db_text ( 'nombre' ) . ' = ?' , $ agent - > { 'id_agente' } , safe_input ( $ module_name ) ) ;
2009-11-13 Ramon Novoa <rnovoa@artica.es>
* conf/pandora_server.conf: Updated configuration tokens.
* lib/PandoraFMS/SNMPServer.pm, lib/PandoraFMS/Config.pm,
lib/PandoraFMS/PluginServer.pm, lib/PandoraFMS/PredictionServer.pm,
lib/PandoraFMS/Core.pm, lib/PandoraFMS/ReconServer.pm,
lib/PandoraFMS/DataServer.pm, lib/PandoraFMS/NetworkServer.pm,
lib/PandoraFMS/Tools.pm, lib/PandoraFMS/WMIServer.pm,
bin/pandora_server: Standardized and improved logging.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2108 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-11-13 14:52:48 +01:00
if ( ! defined ( $ module ) ) {
logger ( $ pa_config , "Could not create module '$module_name' for agent '$agent_name'." , 3 ) ;
$ ModuleSem - > up ( ) ;
return ;
}
2010-09-20 19:01:27 +02:00
} else {
2011-02-23 11:50:00 +01:00
2011-04-19 17:32:11 +02:00
# Control NULL columns
$ module - > { 'descripcion' } = '' unless defined ( $ module - > { 'descripcion' } ) ;
2011-08-10 18:58:26 +02:00
$ module - > { 'extended_info' } = '' unless defined ( $ module - > { 'extended_info' } ) ;
2011-04-19 17:32:11 +02:00
2011-02-23 11:50:00 +01:00
# Set default values
$ module_conf - > { 'max' } = $ module - > { 'max' } unless defined ( $ module_conf - > { 'max' } ) ;
$ module_conf - > { 'min' } = $ module - > { 'min' } unless defined ( $ module_conf - > { 'min' } ) ;
$ module_conf - > { 'descripcion' } = $ module - > { 'descripcion' } unless defined ( $ module_conf - > { 'descripcion' } ) ;
$ module_conf - > { 'post_process' } = $ module - > { 'post_process' } unless defined ( $ module_conf - > { 'post_process' } ) ;
$ module_conf - > { 'module_interval' } = $ module - > { 'module_interval' } unless defined ( $ module_conf - > { 'module_interval' } ) ;
2011-04-27 19:44:14 +02:00
$ module_conf - > { 'min_critical' } = $ module - > { 'min_critical' } unless defined ( $ module_conf - > { 'min_critical' } ) ;
$ module_conf - > { 'max_critical' } = $ module - > { 'max_critical' } unless defined ( $ module_conf - > { 'max_critical' } ) ;
$ module_conf - > { 'min_warning' } = $ module - > { 'min_warning' } unless defined ( $ module_conf - > { 'min_warning' } ) ;
$ module_conf - > { 'max_warning' } = $ module - > { 'max_warning' } unless defined ( $ module_conf - > { 'max_warning' } ) ;
$ module_conf - > { 'disabled' } = $ module - > { 'disabled' } unless defined ( $ module_conf - > { 'disabled' } ) ;
$ module_conf - > { 'min_ff_event' } = $ module - > { 'min_ff_event' } unless defined ( $ module_conf - > { 'min_ff_event' } ) ;
2011-08-10 18:58:26 +02:00
$ module_conf - > { 'extended_info' } = $ module - > { 'extended_info' } unless defined ( $ module_conf - > { 'extended_info' } ) ;
2011-04-27 19:44:14 +02:00
# The group name has to be translated to a group ID
my $ conf_group_id = - 1 ;
if ( defined $ module_conf - > { 'group' } ) {
my $ conf_group_id = get_group_id ( $ dbh , $ module_conf - > { 'group' } ) ;
2010-09-20 19:01:27 +02:00
}
2011-04-27 19:44:14 +02:00
$ module_conf - > { 'id_module_group' } = ( $ conf_group_id == - 1 ) ? $ module - > { 'id_module_group' } : $ conf_group_id ;
}
2011-05-23 15:13:34 +02:00
# Update module configuration if in learning mode and not a policy module
if ( $ agent - > { 'modo' } eq '1' && $ module - > { 'id_policy_module' } == 0 ) {
2011-04-27 19:44:14 +02:00
update_module_configuration ( $ pa_config , $ dbh , $ module , $ module_conf ) ;
2009-04-14 Ramon Novoa <rnovoa@artica.es>
* pandora_ctl, pandora_network, pandora_wmi, pandora_plugin,
pandora_prediction, bin/pandora_wmi, bin/pandora_plugin,
bin/pandora_prediction, bin/pandora_snmpconsole, bin/pandora_recon,
bin/pandora_network, pandora_recon, pandora_snmpconsole: Deleted
from repository. Old server code and startup scripts.
* Makefile.PL, pandora_server_installer, lib/PandoraFMS/Config.pm
lib/PandoraFMS/DB.pm, lib/PandoraFMS/Tools.pm, bin/pandora_server,
pandora_package_installer, pandora_server: Updated to work with the
new code, removed unneeded dependencies, fixed some bugs etc.
* lib/PandoraFMS/SNMPServer.pm, lib/PandoraFMS/PluginServer.pm,
lib/PandoraFMS/ProducerConsumerServer.pm, lib/PandoraFMS/Server.pm,
lib/PandoraFMS/PredictionServer.pm, lib/PandoraFMS/Core.pm,
lib/PandoraFMS/ReconServer.pm, lib/PandoraFMS/DataServer.pm,
lib/PandoraFMS/NetworkServer.pm, lib/PandoraFMS/WMIServer.pm: Added
to repository. New server code.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1620 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-04-14 21:13:16 +02:00
}
2010-09-20 19:01:27 +02:00
2009-11-13 Ramon Novoa <rnovoa@artica.es>
* conf/pandora_server.conf: Updated configuration tokens.
* lib/PandoraFMS/SNMPServer.pm, lib/PandoraFMS/Config.pm,
lib/PandoraFMS/PluginServer.pm, lib/PandoraFMS/PredictionServer.pm,
lib/PandoraFMS/Core.pm, lib/PandoraFMS/ReconServer.pm,
lib/PandoraFMS/DataServer.pm, lib/PandoraFMS/NetworkServer.pm,
lib/PandoraFMS/Tools.pm, lib/PandoraFMS/WMIServer.pm,
bin/pandora_server: Standardized and improved logging.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2108 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-11-13 14:52:48 +01:00
$ ModuleSem - > up ( ) ;
2009-04-14 Ramon Novoa <rnovoa@artica.es>
* pandora_ctl, pandora_network, pandora_wmi, pandora_plugin,
pandora_prediction, bin/pandora_wmi, bin/pandora_plugin,
bin/pandora_prediction, bin/pandora_snmpconsole, bin/pandora_recon,
bin/pandora_network, pandora_recon, pandora_snmpconsole: Deleted
from repository. Old server code and startup scripts.
* Makefile.PL, pandora_server_installer, lib/PandoraFMS/Config.pm
lib/PandoraFMS/DB.pm, lib/PandoraFMS/Tools.pm, bin/pandora_server,
pandora_package_installer, pandora_server: Updated to work with the
new code, removed unneeded dependencies, fixed some bugs etc.
* lib/PandoraFMS/SNMPServer.pm, lib/PandoraFMS/PluginServer.pm,
lib/PandoraFMS/ProducerConsumerServer.pm, lib/PandoraFMS/Server.pm,
lib/PandoraFMS/PredictionServer.pm, lib/PandoraFMS/Core.pm,
lib/PandoraFMS/ReconServer.pm, lib/PandoraFMS/DataServer.pm,
lib/PandoraFMS/NetworkServer.pm, lib/PandoraFMS/WMIServer.pm: Added
to repository. New server code.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1620 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-04-14 21:13:16 +02:00
2009-10-16 13:26:22 +02:00
# Module disabled!
2009-11-13 Ramon Novoa <rnovoa@artica.es>
* conf/pandora_server.conf: Updated configuration tokens.
* lib/PandoraFMS/SNMPServer.pm, lib/PandoraFMS/Config.pm,
lib/PandoraFMS/PluginServer.pm, lib/PandoraFMS/PredictionServer.pm,
lib/PandoraFMS/Core.pm, lib/PandoraFMS/ReconServer.pm,
lib/PandoraFMS/DataServer.pm, lib/PandoraFMS/NetworkServer.pm,
lib/PandoraFMS/Tools.pm, lib/PandoraFMS/WMIServer.pm,
bin/pandora_server: Standardized and improved logging.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2108 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-11-13 14:52:48 +01:00
if ( $ module - > { 'disabled' } eq '1' ) {
logger ( $ pa_config , "Skipping disabled module '$module_name' agent '$agent_name'." , 10 ) ;
return ;
}
2009-10-16 13:26:22 +02:00
2009-04-23 17:33:25 +02:00
# Parse the timestamp and process the module
2009-11-13 Ramon Novoa <rnovoa@artica.es>
* conf/pandora_server.conf: Updated configuration tokens.
* lib/PandoraFMS/SNMPServer.pm, lib/PandoraFMS/Config.pm,
lib/PandoraFMS/PluginServer.pm, lib/PandoraFMS/PredictionServer.pm,
lib/PandoraFMS/Core.pm, lib/PandoraFMS/ReconServer.pm,
lib/PandoraFMS/DataServer.pm, lib/PandoraFMS/NetworkServer.pm,
lib/PandoraFMS/Tools.pm, lib/PandoraFMS/WMIServer.pm,
bin/pandora_server: Standardized and improved logging.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2108 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-11-13 14:52:48 +01:00
if ( $ timestamp !~ /(\d+)\/(\d+)\/(\d+) +(\d+):(\d+):(\d+)/ &&
2010-02-23 18:49:05 +01:00
$ timestamp !~ /(\d+)\-(\d+)\-(\d+) +(\d+):(\d+):(\d+)/ ) {
2009-11-13 Ramon Novoa <rnovoa@artica.es>
* conf/pandora_server.conf: Updated configuration tokens.
* lib/PandoraFMS/SNMPServer.pm, lib/PandoraFMS/Config.pm,
lib/PandoraFMS/PluginServer.pm, lib/PandoraFMS/PredictionServer.pm,
lib/PandoraFMS/Core.pm, lib/PandoraFMS/ReconServer.pm,
lib/PandoraFMS/DataServer.pm, lib/PandoraFMS/NetworkServer.pm,
lib/PandoraFMS/Tools.pm, lib/PandoraFMS/WMIServer.pm,
bin/pandora_server: Standardized and improved logging.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2108 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-11-13 14:52:48 +01:00
logger ( $ pa_config , "Invalid timestamp '$timestamp' from module '$module_name' agent '$agent_name'." , 3 ) ;
return ;
2009-04-14 Ramon Novoa <rnovoa@artica.es>
* pandora_ctl, pandora_network, pandora_wmi, pandora_plugin,
pandora_prediction, bin/pandora_wmi, bin/pandora_plugin,
bin/pandora_prediction, bin/pandora_snmpconsole, bin/pandora_recon,
bin/pandora_network, pandora_recon, pandora_snmpconsole: Deleted
from repository. Old server code and startup scripts.
* Makefile.PL, pandora_server_installer, lib/PandoraFMS/Config.pm
lib/PandoraFMS/DB.pm, lib/PandoraFMS/Tools.pm, bin/pandora_server,
pandora_package_installer, pandora_server: Updated to work with the
new code, removed unneeded dependencies, fixed some bugs etc.
* lib/PandoraFMS/SNMPServer.pm, lib/PandoraFMS/PluginServer.pm,
lib/PandoraFMS/ProducerConsumerServer.pm, lib/PandoraFMS/Server.pm,
lib/PandoraFMS/PredictionServer.pm, lib/PandoraFMS/Core.pm,
lib/PandoraFMS/ReconServer.pm, lib/PandoraFMS/DataServer.pm,
lib/PandoraFMS/NetworkServer.pm, lib/PandoraFMS/WMIServer.pm: Added
to repository. New server code.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1620 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-04-14 21:13:16 +02:00
}
2010-02-22 21:18:37 +01:00
my $ utimestamp ;
2010-02-23 18:49:05 +01:00
eval {
$ utimestamp = timelocal ( $ 6 , $ 5 , $ 4 , $ 3 , $ 2 - 1 , $ 1 - 1900 ) ;
} ;
if ( $@ ) {
logger ( $ pa_config , "Invalid timestamp '$timestamp' from module '$module_name' agent '$agent_name'." , 3 ) ;
2010-09-20 19:01:27 +02:00
return ;
2010-02-23 18:49:05 +01:00
}
2010-02-15 14:07:52 +01:00
#my $value = get_tag_value ($data, 'data', '');
2010-09-20 19:01:27 +02:00
my $ data_object = get_module_data ( $ data , $ module_type ) ;
my $ extra_macros = get_macros_for_data ( $ data , $ module_type ) ;
2010-02-15 14:07:52 +01:00
2011-04-20 17:55:28 +02:00
# Get module status from XML data file if available
$ module - > { 'status' } = get_tag_value ( $ data , 'status' , undef ) ;
2010-08-12 14:42:56 +02:00
pandora_process_module ( $ pa_config , $ data_object , $ agent , $ module , $ module_type , $ timestamp , $ utimestamp , $ server_id , $ dbh , $ extra_macros ) ;
2010-02-15 14:07:52 +01:00
}
2010-09-20 19:01:27 +02:00
##########################################################################
# Retrieve module data from the XML tree.
##########################################################################
2010-02-15 14:07:52 +01:00
sub get_module_data ($$) {
2010-09-20 19:01:27 +02:00
my ( $ data , $ module_type ) = @ _ ;
2010-08-12 14:42:56 +02:00
my % data_object ;
2010-09-20 19:01:27 +02:00
# Log4x modules hava extended information
if ( $ module_type eq 'log4x' ) {
2010-02-15 14:07:52 +01:00
foreach my $ attr ( 'severity' , 'message' , 'stacktrace' ) {
2010-08-12 14:42:56 +02:00
$ data_object { $ attr } = get_tag_value ( $ data , $ attr , '' ) ;
2010-02-15 14:07:52 +01:00
}
} else {
2010-09-20 19:01:27 +02:00
$ data_object { 'data' } = get_tag_value ( $ data , 'data' , '' ) ;
2010-02-15 14:07:52 +01:00
}
2010-09-20 19:01:27 +02:00
2010-08-12 14:42:56 +02:00
return \ % data_object ;
2010-02-15 14:07:52 +01:00
}
2010-09-20 19:01:27 +02:00
##########################################################################
# Retrieve module data from the XML tree.
##########################################################################
2010-02-15 14:07:52 +01:00
sub get_macros_for_data ($$) {
2010-09-20 19:01:27 +02:00
my ( $ data , $ module_type ) = @ _ ;
2010-02-15 14:07:52 +01:00
my % macros ;
2010-09-20 19:01:27 +02:00
if ( $ module_type eq 'log4x' ) {
foreach my $ attr ( 'severity' , 'message' , 'stacktrace' ) {
$ macros { '_' . $ attr . '_' } = get_tag_value ( $ data , $ attr , '' ) ;
2010-02-15 14:07:52 +01:00
}
}
2010-02-23 18:49:05 +01:00
2010-02-15 14:07:52 +01:00
return \ % macros ;
2009-04-14 Ramon Novoa <rnovoa@artica.es>
* pandora_ctl, pandora_network, pandora_wmi, pandora_plugin,
pandora_prediction, bin/pandora_wmi, bin/pandora_plugin,
bin/pandora_prediction, bin/pandora_snmpconsole, bin/pandora_recon,
bin/pandora_network, pandora_recon, pandora_snmpconsole: Deleted
from repository. Old server code and startup scripts.
* Makefile.PL, pandora_server_installer, lib/PandoraFMS/Config.pm
lib/PandoraFMS/DB.pm, lib/PandoraFMS/Tools.pm, bin/pandora_server,
pandora_package_installer, pandora_server: Updated to work with the
new code, removed unneeded dependencies, fixed some bugs etc.
* lib/PandoraFMS/SNMPServer.pm, lib/PandoraFMS/PluginServer.pm,
lib/PandoraFMS/ProducerConsumerServer.pm, lib/PandoraFMS/Server.pm,
lib/PandoraFMS/PredictionServer.pm, lib/PandoraFMS/Core.pm,
lib/PandoraFMS/ReconServer.pm, lib/PandoraFMS/DataServer.pm,
lib/PandoraFMS/NetworkServer.pm, lib/PandoraFMS/WMIServer.pm: Added
to repository. New server code.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1620 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-04-14 21:13:16 +02:00
}
2010-09-20 19:01:27 +02:00
##########################################################################
# Update module configuration in tagente_modulo if necessary.
##########################################################################
sub update_module_configuration ($$$$) {
my ( $ pa_config , $ dbh , $ module , $ module_conf ) = @ _ ;
# Update if at least one of the configuration tokens has changed
2011-08-10 18:58:26 +02:00
foreach my $ conf_token ( 'min' , 'max' , 'descripcion' , 'post_process' , 'module_interval' , 'min_critical' , 'max_critical' , 'min_warning' , 'max_warning' , 'disabled' , 'min_ff_event' , 'extended_info' ) {
2011-04-27 19:44:14 +02:00
if ( $ module - > { $ conf_token } ne $ module_conf - > { $ conf_token } ) {
logger ( $ pa_config , "Updating configuration for module '" . $ module - > { 'nombre' } . "'." , 10 ) ;
2011-08-10 18:58:26 +02:00
db_do ( $ dbh , ' UPDATE tagente_modulo SET min = ? , max = ? , descripcion = ? , post_process = ? , module_interval = ? , min_critical = ? , max_critical = ? , min_warning = ? , max_warning = ? , disabled = ? , min_ff_event = ? , extended_info = ?
2011-03-14 11:39:31 +01:00
WHERE id_agente_modulo = ? ', $module_conf->{' min '}, $module_conf->{' max '}, $module_conf->{' descripcion '} eq ' ' ? $module->{' descripcion '} : $module_conf->{' descripcion ' } ,
2011-08-10 18:58:26 +02:00
$ module_conf - > { 'post_process' } , $ module_conf - > { 'module_interval' } , $ module_conf - > { 'min_critical' } , $ module_conf - > { 'max_critical' } , $ module_conf - > { 'min_warning' } , $ module_conf - > { 'max_warning' } , $ module_conf - > { 'disabled' } , $ module_conf - > { 'min_ff_event' } , $ module_conf - > { 'extended_info' } , $ module - > { 'id_agente_modulo' } ) ;
2011-10-28 13:02:35 +02:00
last ;
2011-04-27 19:44:14 +02:00
}
2010-09-20 19:01:27 +02:00
}
2011-10-28 13:02:35 +02:00
# Update module hash
foreach my $ conf_token ( 'min' , 'max' , 'post_process' , 'module_interval' , 'min_critical' , 'max_critical' , 'min_warning' , 'max_warning' , 'disabled' , 'min_ff_event' , 'extended_info' ) {
$ module - > { $ conf_token } = $ module_conf - > { $ conf_token } ;
}
$ module - > { 'descripcion' } = ( $ module_conf - > { 'descripcion' } eq '' ) ? $ module - > { 'descripcion' } : $ module_conf - > { 'descripcion' } ;
2010-09-20 19:01:27 +02:00
}
2009-04-14 Ramon Novoa <rnovoa@artica.es>
* pandora_ctl, pandora_network, pandora_wmi, pandora_plugin,
pandora_prediction, bin/pandora_wmi, bin/pandora_plugin,
bin/pandora_prediction, bin/pandora_snmpconsole, bin/pandora_recon,
bin/pandora_network, pandora_recon, pandora_snmpconsole: Deleted
from repository. Old server code and startup scripts.
* Makefile.PL, pandora_server_installer, lib/PandoraFMS/Config.pm
lib/PandoraFMS/DB.pm, lib/PandoraFMS/Tools.pm, bin/pandora_server,
pandora_package_installer, pandora_server: Updated to work with the
new code, removed unneeded dependencies, fixed some bugs etc.
* lib/PandoraFMS/SNMPServer.pm, lib/PandoraFMS/PluginServer.pm,
lib/PandoraFMS/ProducerConsumerServer.pm, lib/PandoraFMS/Server.pm,
lib/PandoraFMS/PredictionServer.pm, lib/PandoraFMS/Core.pm,
lib/PandoraFMS/ReconServer.pm, lib/PandoraFMS/DataServer.pm,
lib/PandoraFMS/NetworkServer.pm, lib/PandoraFMS/WMIServer.pm: Added
to repository. New server code.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1620 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-04-14 21:13:16 +02:00
1 ;
__END__