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::ReconServer ;
##########################################################################
# Pandora FMS Recon Server.
# Pandora FMS. the Flexible Monitoring System. http://www.pandorafms.org
##########################################################################
2009-06-08 17:12:32 +02:00
# Copyright (c) 2005-2009 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 IO::Socket::INET ;
2009-04-20 11:44:24 +02:00
use POSIX qw( strftime ceil ) ;
2014-04-22 11:22:08 +02:00
use JSON qw( decode_json encode_json ) ;
2014-05-08 07:12:08 +02:00
use Encode qw( encode_utf8 ) ;
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 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 ;
2010-02-15 21:34:57 +01:00
use PandoraFMS::GIS qw( get_reverse_geoip_sql get_reverse_geoip_file get_random_close_point ) ;
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-08-24 20:07:59 +02:00
# Patched Nmap::Parser. See http://search.cpan.org/dist/Nmap-Parser/.
use PandoraFMS::NmapParser ;
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
# Inherits from PandoraFMS::ProducerConsumerServer
our @ ISA = qw( PandoraFMS::ProducerConsumerServer ) ;
# Global variables
my @ TaskQueue : shared ;
my % PendingTasks : shared ;
2013-08-01 11:54:21 +02:00
my $ Sem : shared ;
my $ TaskSem : shared ;
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
########################################################################################
# Recon Server class constructor.
########################################################################################
sub new ($$$$$$) {
my ( $ class , $ config , $ dbh ) = @ _ ;
2012-06-12 14:34:51 +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
return undef unless $ config - > { 'reconserver' } == 1 ;
2012-06-12 14:34:51 +02:00
2011-07-01 14:38:54 +02:00
if ( ! - e $ config - > { 'nmap' } ) {
logger ( $ config , ' [E] ' . $ config - > { 'nmap' } . " needed by Pandora FMS Recon Server not found." , 1 ) ;
print_message ( $ config , ' [E] ' . $ config - > { 'nmap' } . " needed by Pandora FMS Recon Server not found." , 1 ) ;
return undef ;
}
2013-08-01 11:54:21 +02:00
# Initialize semaphores and queues
@ TaskQueue = ( ) ;
% PendingTasks = ( ) ;
$ Sem = Thread::Semaphore - > new ;
$ TaskSem = Thread::Semaphore - > new ( 0 ) ;
2011-07-01 14:38:54 +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
# Call the constructor of the parent class
2014-09-10 13:18:02 +02:00
my $ self = $ class - > SUPER:: new ( $ config , RECONSERVER , \ & PandoraFMS::ReconServer:: data_producer , \ & PandoraFMS::ReconServer:: data_consumer , $ dbh ) ;
2012-06-12 14:34:51 +02: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 ( ) ;
2012-06-12 14:34:51 +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
print_message ( $ pa_config , " [*] Starting Pandora FMS Recon 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 - > { 'recon_threads' } ) ;
$ self - > SUPER:: run ( \ @ TaskQueue , \ % PendingTasks , $ Sem , $ TaskSem ) ;
}
###############################################################################
# Data producer.
###############################################################################
sub data_producer ($) {
my $ self = shift ;
my ( $ pa_config , $ dbh ) = ( $ self - > getConfig ( ) , $ self - > getDBH ( ) ) ;
2012-06-12 14:34:51 +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
my @ tasks ;
2012-06-12 14:34:51 +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
my $ server_id = get_server_id ( $ dbh , $ pa_config - > { 'servername' } , $ self - > getServerType ( ) ) ;
return @ tasks unless defined ( $ server_id ) ;
2012-06-12 14:34:51 +02:00
2011-04-13 16:59:18 +02:00
# Manual tasks have interval_sweep = 0
# Manual tasks are "forced" like the other, setting the utimestamp to 1
# By default, after create a tasks it takes the utimestamp to 0
# Status -1 means "done".
2012-06-12 14:34:51 +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
my @ rows = get_db_rows ( $ dbh , ' SELECT * FROM trecon_task
2011-07-07 10:48:38 +02:00
WHERE id_recon_server = ?
AND disabled = 0
2011-07-01 14:38:54 +02:00
AND utimestamp = 0 OR ( status = - 1 AND interval_sweep > 0 AND ( utimestamp + interval_sweep ) < UNIX_TIMESTAMP ( ) ) ' , $ server_id ) ;
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
foreach my $ row ( @ rows ) {
2012-06-12 14:34:51 +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
# Update task status
2009-04-20 11:44:24 +02:00
update_recon_task ( $ dbh , $ row - > { 'id_rt' } , 1 ) ;
2012-06-12 14:34:51 +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
push ( @ tasks , $ row - > { 'id_rt' } ) ;
}
2012-06-12 14:34:51 +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
return @ tasks ;
}
###############################################################################
# Data consumer.
###############################################################################
sub data_consumer ($$) {
my ( $ self , $ task_id ) = @ _ ;
my ( $ pa_config , $ dbh ) = ( $ self - > getConfig ( ) , $ self - > getDBH ( ) ) ;
# Get recon task data
my $ task = get_db_single_row ( $ dbh , 'SELECT * FROM trecon_task WHERE id_rt = ?' , $ task_id ) ;
return - 1 unless defined ( $ task ) ;
2011-04-13 16:59:18 +02:00
2010-10-15 15:00:25 +02:00
# Is it a recon script?
2011-07-01 14:38:54 +02:00
if ( defined ( $ task - > { 'id_recon_script' } ) && ( $ task - > { 'id_recon_script' } != 0 ) ) {
2011-05-07 21:29:29 +02:00
exec_recon_script ( $ pa_config , $ dbh , $ task ) ;
return ;
2013-06-06 20:33:38 +02:00
} else {
logger ( $ pa_config , 'Starting recon task for net ' . $ task - > { 'subnet' } . '.' , 10 ) ;
2010-10-15 15:00:25 +02:00
}
2011-07-01 14:38:54 +02:00
# Call nmap
2014-09-09 13:06:42 +02:00
my $ nmap_args = '-nsP -PE --max-retries ' . $ pa_config - > { 'icmp_checks' } . ' --host-timeout ' . $ pa_config - > { 'networktimeout' } . 's -T' . $ pa_config - > { 'recon_timing_template' } ;
2011-08-25 22:52:42 +02:00
my $ np = new PandoraFMS:: NmapParser ;
2011-08-24 20:07:59 +02:00
eval {
2014-08-07 12:43:25 +02:00
$ np - > parsescan ( $ pa_config - > { 'nmap' } , $ nmap_args , ( $ task - > { 'subnet' } ) ) ;
2011-08-24 20:07:59 +02:00
} ;
if ( $@ ) {
2009-04-16 20:19:39 +02:00
update_recon_task ( $ dbh , $ task_id , - 1 ) ;
2011-07-01 14:38:54 +02:00
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-08-24 20:07:59 +02:00
# Parse scanned hosts
my $ module_hash ;
my @ up_hosts = $ np - > all_hosts ( 'up' ) ;
my $ total_up = scalar ( @ up_hosts ) ;
2011-07-01 14:38:54 +02:00
my $ progress = 0 ;
2011-08-24 20:07:59 +02:00
my $ added_hosts = '' ;
foreach my $ host ( @ up_hosts ) {
2011-07-01 14:38:54 +02:00
$ progress + + ;
2011-05-07 21:29:29 +02:00
2011-08-24 20:07:59 +02:00
# Get agent address
my $ addr = $ host - > addr ( ) ;
next unless ( $ addr ne '0' ) ;
2012-04-19 20:47:57 +02:00
2009-05-27 19:23:28 +02:00
# Update the recon task or break if it does not exist anymore
2011-08-24 20:07:59 +02:00
last if ( update_recon_task ( $ dbh , $ task_id , ceil ( $ progress / ($total_up / 100 ) ) ) eq '0E0' ) ;
2012-06-12 14:34:51 +02:00
2012-09-28 16:04:33 +02:00
# Resolve hostnames
my $ host_name = undef ;
if ( $ task - > { 'resolve_names' } == 1 ) {
$ host_name = gethostbyaddr ( inet_aton ( $ addr ) , AF_INET ) ;
}
$ host_name = $ addr unless defined ( $ host_name ) ;
2011-05-07 21:29:29 +02:00
# Does the host already exist?
2011-07-01 14:38:54 +02:00
my $ agent = get_agent_from_addr ( $ dbh , $ addr ) ;
2012-09-28 16:04:33 +02:00
if ( ! defined ( $ agent ) ) {
$ agent = get_agent_from_name ( $ dbh , $ host_name ) ;
}
2011-07-01 14:38:54 +02:00
my $ agent_id = defined ( $ agent ) ? $ agent - > { 'id_agente' } : 0 ;
if ( $ agent_id > 0 ) {
2011-04-13 16:59:18 +02:00
2012-09-28 16:04:33 +02:00
# Skip if not in learning mode
2016-06-03 11:58:13 +02:00
next unless ( ( $ agent - > { 'modo' } == 1 ) || ( $ agent - > { 'modo' } == 2 ) ) ;
2011-07-01 14:38:54 +02:00
}
2011-05-07 21:29:29 +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
# Get the parent host
2011-05-07 21:29:29 +02:00
my $ parent_id = 0 ;
2011-07-01 14:38:54 +02:00
if ( $ task - > { 'parent_detection' } == 1 ) {
2011-05-07 21:29:29 +02:00
$ parent_id = get_host_parent ( $ pa_config , $ addr , $ dbh , $ task - > { 'id_group' } , $ task - > { 'parent_recursion' } , $ task - > { 'resolve_names' } , $ task - > { 'os_detect' } ) ;
}
2012-09-28 16:04:33 +02:00
2012-04-12 12:04:35 +02:00
# If the agent already exists update parent and continue
if ( $ agent_id > 0 ) {
if ( $ parent_id > 0 ) {
db_do ( $ dbh , 'UPDATE tagente SET id_parent = ? WHERE id_agente = ?' , $ parent_id , $ agent_id ) ;
}
next ;
}
2012-09-28 16:04:33 +02:00
2013-06-06 20:33:38 +02:00
# Filter by TCP port
if ( ( defined ( $ task - > { 'recon_ports' } ) ) && ( $ task - > { 'recon_ports' } ne "" ) ) {
next unless ( tcp_scan ( $ pa_config , $ addr , $ task - > { 'recon_ports' } ) > 0 ) ;
}
# Filter by OS
my $ id_os = 11 ; # Network by default
if ( $ task - > { 'os_detect' } == 1 ) {
$ id_os = guess_os ( $ pa_config , $ dbh , $ addr ) ;
next if ( $ task - > { 'id_os' } > 0 && $ task - > { 'id_os' } != $ id_os ) ;
}
2012-09-28 16:04:33 +02:00
# GIS Code -----------------------------
2010-08-18 13:37:47 +02:00
# If GIS is activated try to geolocate the ip address of the agent
2012-09-28 16:04:33 +02:00
# and store also it's position.
2010-02-15 21:34:57 +01:00
if ( $ pa_config - > { 'activate_gis' } == 1 && $ pa_config - > { 'recon_reverse_geolocation_mode' } !~ m/^disabled$/i ) {
2012-09-28 16:04:33 +02:00
2010-02-15 21:34:57 +01:00
# Try to get aproximated positional information for the Agent.
my $ region_info = undef ;
if ( $ pa_config - > { 'recon_reverse_geolocation_mode' } =~ m/^sql$/i ) {
logger ( $ pa_config , "Trying to get gis data of $addr from the SQL database" , 8 ) ;
$ region_info = get_reverse_geoip_sql ( $ pa_config , $ addr , $ dbh ) ;
}
elsif ( $ pa_config - > { 'recon_reverse_geolocation_mode' } =~ m/^file$/i ) {
logger ( $ pa_config , "Trying to get gis data of $addr from the file database" , 8 ) ;
$ region_info = get_reverse_geoip_file ( $ pa_config , $ addr ) ;
}
else {
logger ( $ pa_config , "ERROR:Trying to get gis data of $addr. Unknown source" , 5 ) ;
}
if ( defined ( $ region_info ) ) {
my $ location_description = '' ;
if ( defined ( $ region_info - > { 'region' } ) ) {
$ location_description . = "$region_info->{'region'}, " ;
}
if ( defined ( $ region_info - > { 'city' } ) ) {
$ location_description . = "$region_info->{'city'}, " ;
}
if ( defined ( $ region_info - > { 'country_name' } ) ) {
$ location_description . = "($region_info->{'country_name'})" ;
}
# We store a random offset in the coordinates to avoid all the agents apear on the same place.
my ( $ longitude , $ latitude ) = get_random_close_point ( $ pa_config , $ region_info - > { 'longitude' } , $ region_info - > { 'latitude' } ) ;
logger ( $ pa_config , "Placing agent on random position (Lon,Lat) = ($longitude, $latitude)" , 8 ) ;
# Crate a new agent adding the positional info (as is unknown we set 0 time_offset, and 0 altitude)
$ agent_id = pandora_create_agent ( $ pa_config , $ pa_config - > { 'servername' } ,
2010-07-06 17:06:00 +02:00
$ host_name , $ addr , $ task - > { 'id_group' } ,
$ parent_id , $ id_os , '' , 300 , $ dbh , 0 ,
$ longitude , $ latitude , 0 , $ location_description ) ;
2010-02-15 21:34:57 +01:00
}
else {
logger ( $ pa_config , "Id location of '$addr' for host '$host_name' NOT found" , 3 ) ;
2010-08-18 13:37:47 +02:00
# Create a new agent
2010-02-15 21:34:57 +01:00
$ agent_id = pandora_create_agent ( $ pa_config , $ pa_config - > { 'servername' } ,
2010-07-06 17:06:00 +02:00
$ host_name , $ addr , $ task - > { 'id_group' } ,
$ parent_id , $ id_os , '' , 300 , $ dbh ) ;
2010-02-15 21:34:57 +01:00
}
2010-08-18 13:37:47 +02:00
}
2011-05-07 21:29:29 +02:00
# End of GIS code -----------------------------
2014-07-25 15:15:24 +02:00
else {
2010-08-18 13:37:47 +02:00
# Create a new agent
2016-02-09 15:34:33 +01:00
logger ( $ pa_config , "Creating an agent through recon task: " . $ host_name , 10 ) ;
2010-02-15 21:34:57 +01:00
$ agent_id = pandora_create_agent ( $ pa_config , $ pa_config - > { 'servername' } ,
2010-07-06 17:06:00 +02:00
$ host_name , $ addr , $ task - > { 'id_group' } ,
$ parent_id , $ id_os , '' , 300 , $ dbh ) ;
2010-02-15 21:34:57 +01:00
}
2012-06-12 14:34:51 +02:00
2011-07-01 14:38:54 +02:00
# Check agent creation
if ( $ agent_id <= 0 ) {
logger ( $ pa_config , "Error creating agent '$host_name'." , 3 ) ;
next ;
}
2014-07-25 15:15:24 +02:00
2013-06-06 20:33:38 +02:00
# Add the new address if it does not exist
my $ addr_id = get_addr_id ( $ dbh , $ addr ) ;
$ addr_id = add_address ( $ dbh , $ addr ) unless ( $ addr_id > 0 ) ;
if ( $ addr_id <= 0 ) {
logger ( $ pa_config , "Could not add address '$addr' for host '$host_name'." , 3 ) ;
next ;
}
2014-07-25 15:15:24 +02:00
2013-06-06 20:33:38 +02:00
# Assign the new address to the agent
my $ agent_addr_id = get_agent_addr_id ( $ dbh , $ addr_id , $ agent_id ) ;
if ( $ agent_addr_id <= 0 ) {
2015-06-09 12:43:48 +02:00
db_do ( $ dbh , ' INSERT INTO taddress_agent ( id_a , id_agent )
2014-07-25 15:15:24 +02:00
VALUES ( ? , ? ) ' , $ addr_id , $ agent_id ) ;
2013-06-06 20:33:38 +02:00
}
2014-07-25 15:15:24 +02:00
2010-08-18 13:37:47 +02:00
# Create network profile modules for the agent
create_network_profile_modules ( $ pa_config , $ dbh , $ agent_id , $ task - > { 'id_network_profile' } , $ addr , $ task - > { 'snmp_community' } ) ;
2012-06-12 14:34:51 +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
# Generate an event
2011-08-24 20:07:59 +02:00
pandora_event ( $ pa_config , "[RECON] New host [$host_name] detected on network [" . $ task - > { 'subnet' } . ']' ,
$ task - > { 'id_group' } , $ agent_id , 2 , 0 , 0 , 'recon_host_detected' , 0 , $ dbh ) ;
2011-07-01 14:38:54 +02:00
2011-08-24 20:07:59 +02:00
$ added_hosts . = "$addr " ;
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
}
2012-06-12 14:34:51 +02:00
2010-08-18 13:37:47 +02:00
# Create an incident with totals
2011-08-24 20:07:59 +02:00
if ( $ added_hosts ne '' && $ task - > { 'create_incident' } == 1 ) {
my $ text = "At " . strftime ( "%Y-%m-%d %H:%M:%S" , localtime ( ) ) . " ($added_hosts) new hosts were detected by Pandora FMS Recon Server running on [" . $ pa_config - > { 'servername' } . "_Recon]. This incident has been automatically created following instructions for this recon task [" . $ task - > { 'id_group' } . "].\n\n" ;
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 ( $ task - > { 'id_network_profile' } > 0 ) {
$ text . = "Aditionally, and following instruction for this task, agent(s) has been created, with modules assigned to network component profile [" . get_nc_profile_name ( $ dbh , $ task - > { 'id_network_profile' } ) . "]. Please check this agent as soon as possible to verify it." ;
}
2011-08-24 20:07:59 +02:00
$ text . = "\n\nThis is the list of IP addresses found: \n\n$added_hosts" ;
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
pandora_create_incident ( $ pa_config , $ dbh , "[RECON] New hosts detected" , $ text , 0 , 0 , 'Pandora FMS Recon Server' , $ task - > { 'id_group' } ) ;
}
2014-07-25 15:15:24 +02:00
2013-06-06 20:33:38 +02:00
logger ( $ pa_config , "Finished recon task for net " . $ task - > { 'subnet' } . "." , 10 ) ;
2014-07-25 15:15:24 +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
# Mark recon task as done
2009-04-16 20:19:39 +02:00
update_recon_task ( $ dbh , $ task_id , - 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
}
2011-05-07 21:29:29 +02:00
##########################################################################
# Returns the ID of the parent of the given host if available.
##########################################################################
2011-07-01 14:38:54 +02:00
sub get_host_parent {
2011-05-07 21:29:29 +02:00
my ( $ pa_config , $ host , $ dbh , $ group , $ max_depth , $ resolve , $ os_detect ) = @ _ ;
2012-06-12 14:34:51 +02:00
2011-07-01 14:38:54 +02:00
# Call nmap
2014-09-09 13:06:42 +02:00
my $ nmap_args = '-nsP -PE --traceroute --max-retries ' . $ pa_config - > { 'icmp_checks' } . ' --host-timeout ' . $ pa_config - > { 'networktimeout' } . 's -T' . $ pa_config - > { 'nmap_timing_template' } ;
2011-08-25 22:52:42 +02:00
my $ np = new PandoraFMS:: NmapParser ;
eval {
2014-08-07 12:43:25 +02:00
$ np - > parsescan ( $ pa_config - > { 'nmap' } , $ nmap_args , ( $ host ) ) ;
2011-08-25 22:52:42 +02:00
} ;
if ( $@ ) {
return 0 ;
2011-05-07 21:29:29 +02:00
}
2012-06-12 14:34:51 +02:00
2011-08-25 22:52:42 +02:00
# Get hops
my ( $ h ) = $ np - > all_hosts ( ) ;
return 0 unless defined ( $ h ) ;
my @ all_hops = $ h - > all_trace_hops ( ) ;
my @ hops ;
2011-07-01 14:38:54 +02:00
2011-08-25 22:52:42 +02:00
# Skip target host
pop ( @ all_hops ) ;
2011-07-01 14:38:54 +02:00
2011-08-25 22:52:42 +02:00
# Save the last max_depth hosts in reverse order
for ( my $ i = 0 ; $ i < $ max_depth ; $ i + + ) {
my $ hop = pop ( @ all_hops ) ;
last unless defined ( $ hop ) ;
push ( @ hops , $ hop ) ;
2011-05-07 21:29:29 +02:00
}
2012-06-12 14:34:51 +02:00
2011-08-25 22:52:42 +02:00
# Parse hops from first to last
my $ parent_id = 0 ;
for ( my $ i = 0 ; $ i < $ max_depth ; $ i + + ) {
my $ hop = pop ( @ hops ) ;
last unless defined ( $ hop ) ;
# Get host information
my $ host_addr = $ hop - > ipaddr ( ) ;
2012-06-12 14:34:51 +02:00
2011-08-25 22:52:42 +02:00
# Check if the host exists
2013-06-24 13:07:21 +02:00
my $ agent = get_agent_from_addr ( $ dbh , $ host_addr ) ;
if ( defined ( $ agent ) ) {
2016-02-09 15:34:33 +01:00
# Move to the next host if module is not in learning mode
if ( $ agent - > { 'modo' } != 1 ) {
$ parent_id = $ agent - > { 'id_agente' } ;
next ;
}
2011-08-25 22:52:42 +02:00
}
2012-06-12 14:34:51 +02:00
2011-08-25 22:52:42 +02:00
# Add the new address if it does not exist
my $ addr_id = get_addr_id ( $ dbh , $ host_addr ) ;
$ addr_id = add_address ( $ dbh , $ host_addr ) unless ( $ addr_id > 0 ) ;
# Should not happen
2012-06-12 14:34:51 +02:00
if ( $ addr_id <= 0 ) {
2011-08-25 22:52:42 +02:00
logger ( $ pa_config , "Could not add address '$host_addr'" , 1 ) ;
return 0 ;
}
2012-06-12 14:34:51 +02:00
2011-08-25 22:52:42 +02:00
# Get the host's name
my $ host_name = undef ;
if ( $ resolve == 1 ) {
$ host_name = gethostbyaddr ( inet_aton ( $ host_addr ) , AF_INET ) ;
}
$ host_name = $ host_addr unless defined ( $ host_name ) ;
# Detect host's OS
my $ id_os = 11 ;
if ( $ os_detect == 1 ) {
2013-03-26 17:13:15 +01:00
$ id_os = guess_os ( $ pa_config , $ dbh , $ host_addr ) ;
2011-08-25 22:52:42 +02:00
}
2014-07-25 15:15:24 +02:00
2011-08-25 22:52:42 +02:00
# Create the host
2016-02-09 15:34:33 +01:00
my $ agent_id = 0 ;
my $ agent_parent = get_agent_from_addr ( $ dbh , $ host_addr ) ;
if ( ! defined ( $ agent_parent ) ) {
$ agent_parent = get_agent_from_name ( $ dbh , $ host_addr ) ;
}
if ( defined ( $ agent_parent ) ) {
$ agent_id = $ agent_parent - > { 'id_agente' } ;
logger ( $ pa_config , "Updating agent " . $ agent_id . " with parent $parent_id in host $host_addr" ) ;
db_do ( $ dbh , 'UPDATE tagente SET id_parent=? WHERE id_agente=?' , $ parent_id , $ agent_id ) ;
} else {
$ agent_id = pandora_create_agent ( $ pa_config , $ pa_config - > { 'servername' } , $ host_name , $ host_addr , $ group , $ parent_id , $ id_os , '' , 300 , $ dbh ) ;
db_do ( $ dbh , ' INSERT INTO taddress_agent ( id_a , id_agent )
VALUES ( ? , ? ) ' , $ addr_id , $ agent_id ) ;
}
2011-08-25 22:52:42 +02:00
# Move to the next host
$ parent_id = $ agent_id ;
}
return $ parent_id ;
2011-05-07 21:29:29 +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
##############################################################################
# TCP scan the given host/port. Returns 1 if successful, 0 otherwise.
##############################################################################
sub tcp_scan ($$$) {
2009-08-19 21:49:55 +02:00
my ( $ pa_config , $ host , $ portlist ) = @ _ ;
my $ nmap = $ pa_config - > { 'nmap' } ;
2014-05-22 12:49:49 +02:00
my $ output = `"$nmap" -p$portlist $host | grep open | wc -l` ;
2011-07-01 14:38:54 +02:00
return 0 if ( $? != 0 ) ;
return $ output ;
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
}
##########################################################################
# Guess OS using xprobe2.
##########################################################################
sub guess_os {
2014-07-25 15:15:24 +02:00
my ( $ pa_config , $ dbh , $ host ) = @ _ ;
# Use xprobe2 if available
2009-08-19 21:49:55 +02:00
my $ xprobe = $ pa_config - > { 'xprobe2' } ;
2012-06-12 14:34:51 +02:00
if ( - e $ xprobe ) {
2014-05-22 12:49:49 +02:00
my $ output = `$xprobe $host 2>$DEVNULL | grep 'Running OS' | head -1` ;
2012-06-12 14:34:51 +02:00
return 10 if ( $? != 0 ) ;
2013-03-26 17:13:15 +01:00
return pandora_get_os ( $ dbh , $ output ) ;
2012-06-12 14:34:51 +02:00
}
# Use nmap by default
my $ nmap = $ pa_config - > { 'nmap' } ;
2014-05-22 12:49:49 +02:00
my $ output = `"$nmap" -F -O $host 2>$DEVNULL | grep 'Aggressive OS guesses'` ;
2011-07-01 14:38:54 +02:00
return 10 if ( $? != 0 ) ;
2013-03-26 17:13:15 +01:00
return pandora_get_os ( $ dbh , $ output ) ;
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
}
##########################################################################
# Update recon task status.
##########################################################################
2009-04-16 20:19:39 +02:00
sub update_recon_task ($$$) {
my ( $ dbh , $ id_task , $ status ) = @ _ ;
2012-06-12 14:34:51 +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
db_do ( $ dbh , 'UPDATE trecon_task SET utimestamp = ?, status = ? WHERE id_rt = ?' , time ( ) , $ status , $ id_task ) ;
2011-08-13 04:38:36 +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
##########################################################################
# Create network profile modules for the given agent.
##########################################################################
sub create_network_profile_modules {
2010-08-18 13:37:47 +02:00
my ( $ pa_config , $ dbh , $ agent_id , $ np_id , $ addr , $ snmp_community ) = @ _ ;
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 unless ( $ np_id > 0 ) ;
2012-06-12 14:34:51 +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
# Get network components associated to the network profile
my @ np_components = get_db_rows ( $ dbh , 'SELECT * FROM tnetwork_profile_component WHERE id_np = ?' , $ np_id ) ;
2012-06-12 14:34:51 +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
foreach my $ np_component ( @ np_components ) {
# Get network component data
2013-02-15 11:27:13 +01:00
my $ component = get_db_single_row ( $ dbh , 'SELECT * FROM tnetwork_component WHERE id_nc = ?' , $ np_component - > { 'id_nc' } ) ;
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 ( $ component ) ) {
logger ( $ pa_config , "Network component ID " . $ np_component - > { 'id_nc' } . " for agent $addr not found." , 3 ) ;
next ;
}
2012-06-12 14:34:51 +02:00
# Use snmp_community from network task instead the component snmp_community
$ component - > { 'snmp_community' } = safe_output ( $ snmp_community ) ;
2013-02-15 11:27:13 +01:00
pandora_create_module_from_network_component ( $ pa_config , $ component , $ agent_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-10-15 15:00:25 +02:00
##########################################################################
# Executes recon scripts
##########################################################################
sub exec_recon_script ($$$) {
my ( $ pa_config , $ dbh , $ task ) = @ _ ;
# Get recon plugin data
my $ script = get_db_single_row ( $ dbh , 'SELECT * FROM trecon_script WHERE id_recon_script = ?' , $ task - > { 'id_recon_script' } ) ;
return - 1 unless defined ( $ script ) ;
2012-06-12 14:34:51 +02:00
2010-12-02 11:01:04 +01:00
logger ( $ pa_config , 'Executing recon script ' . safe_output ( $ script - > { 'name' } ) , 10 ) ;
2012-06-12 14:34:51 +02:00
2010-11-29 17:24:25 +01:00
my $ command = safe_output ( $ script - > { 'script' } ) ;
2014-04-22 11:22:08 +02:00
my $ macros = safe_output ( $ task - > { 'macros' } ) ;
2014-05-08 07:12:08 +02:00
# \r and \n should be escaped for decode_json().
$ macros =~ s/\n/\\n/g ;
$ macros =~ s/\r/\\r/g ;
my $ decoded_macros = decode_json ( encode_utf8 ( $ macros ) ) ;
2014-04-22 11:22:08 +02:00
my $ macros_parameters = '' ;
# Add module macros as parameter
if ( ref ( $ decoded_macros ) eq "HASH" ) {
2014-05-28 16:54:02 +02:00
# Convert the hash to a sorted array
my @ sorted_macros ;
2014-04-22 11:22:08 +02:00
while ( my ( $ i , $ m ) = each ( % { $ decoded_macros } ) ) {
2014-05-28 16:54:02 +02:00
$ sorted_macros [ $ i ] = $ m ;
}
# Remove the 0 position
shift @ sorted_macros ;
foreach my $ m ( @ sorted_macros ) {
2014-04-22 11:22:08 +02:00
$ macros_parameters = $ macros_parameters . ' "' . $ m - > { "value" } . '"' ;
}
}
2012-06-12 14:34:51 +02:00
2013-06-06 20:33:38 +02:00
if ( - x $ command ) {
2014-04-22 11:22:08 +02:00
`$command $task->{'id_rt'} $task->{'id_group'} $task->{'create_incident'} $macros_parameters` ;
2013-06-06 20:33:38 +02:00
} else {
logger ( $ pa_config , "Cannot execute recon task command $command." ) ;
}
2012-06-12 14:34:51 +02:00
2011-04-13 16:59:18 +02:00
# Notify this recon task is ended
update_recon_task ( $ dbh , $ task - > { 'id_rt' } , - 1 ) ;
2012-06-12 14:34:51 +02:00
2014-05-05 16:57:10 +02:00
logger ( $ pa_config , 'Done executing recon script ' . safe_output ( $ script - > { 'name' } ) , 10 ) ;
2010-10-15 15:00:25 +02:00
return 0 ;
}
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__