diff --git a/pandora_agents/pc/AIX/pandora_agent.conf b/pandora_agents/pc/AIX/pandora_agent.conf index ad0469b3dd..477d2600a9 100644 --- a/pandora_agents/pc/AIX/pandora_agent.conf +++ b/pandora_agents/pc/AIX/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.702, AIX version +# Version 7.0NG.703, AIX version # Licensed under GPL license v2, # Copyright (c) 2003-2010 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/pc/FreeBSD/pandora_agent.conf b/pandora_agents/pc/FreeBSD/pandora_agent.conf index 4204520453..de6843c02b 100644 --- a/pandora_agents/pc/FreeBSD/pandora_agent.conf +++ b/pandora_agents/pc/FreeBSD/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.702, FreeBSD Version +# Version 7.0NG.703, FreeBSD Version # Licensed under GPL license v2, # Copyright (c) 2003-2010 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/pc/HP-UX/pandora_agent.conf b/pandora_agents/pc/HP-UX/pandora_agent.conf index f0960f0e88..46189c2461 100644 --- a/pandora_agents/pc/HP-UX/pandora_agent.conf +++ b/pandora_agents/pc/HP-UX/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.702, HP-UX Version +# Version 7.0NG.703, HP-UX Version # Licensed under GPL license v2, # Copyright (c) 2003-2009 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/pc/Linux/pandora_agent.conf b/pandora_agents/pc/Linux/pandora_agent.conf index a2c0d2d4f8..f6d2067115 100644 --- a/pandora_agents/pc/Linux/pandora_agent.conf +++ b/pandora_agents/pc/Linux/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.702, GNU/Linux +# Version 7.0NG.703, GNU/Linux # Licensed under GPL license v2, # Copyright (c) 2003-2009 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/pc/NT4/pandora_agent.conf b/pandora_agents/pc/NT4/pandora_agent.conf index 975cb5f461..213ba7e160 100644 --- a/pandora_agents/pc/NT4/pandora_agent.conf +++ b/pandora_agents/pc/NT4/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.702, GNU/Linux +# Version 7.0NG.703, GNU/Linux # Licensed under GPL license v2, # Copyright (c) 2003-2009 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/pc/SunOS/pandora_agent.conf b/pandora_agents/pc/SunOS/pandora_agent.conf index 4f0e52daf7..b3359bff68 100644 --- a/pandora_agents/pc/SunOS/pandora_agent.conf +++ b/pandora_agents/pc/SunOS/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.702, Solaris Version +# Version 7.0NG.703, Solaris Version # Licensed under GPL license v2, # Copyright (c) 2003-2009 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/pc/Win32/pandora_agent.conf b/pandora_agents/pc/Win32/pandora_agent.conf index b3dc383872..ccf7805593 100644 --- a/pandora_agents/pc/Win32/pandora_agent.conf +++ b/pandora_agents/pc/Win32/pandora_agent.conf @@ -1,6 +1,6 @@ # Base config file for Pandora FMS Windows Agent # (c) 2006-2010 Artica Soluciones Tecnologicas -# Version 7.0NG.702 +# Version 7.0NG.703 # This program is Free Software, you can redistribute it and/or modify it # under the terms of the GNU General Public Licence as published by the Free Software diff --git a/pandora_agents/shellscript/aix/pandora_agent.conf b/pandora_agents/shellscript/aix/pandora_agent.conf index 36d55bd170..a3d4981a96 100644 --- a/pandora_agents/shellscript/aix/pandora_agent.conf +++ b/pandora_agents/shellscript/aix/pandora_agent.conf @@ -1,6 +1,6 @@ # Fichero de configuracion base de agentes de Pandora # Base config file for Pandora agents -# Version 7.0NG.702, AIX version +# Version 7.0NG.703, AIX version # General Parameters # ================== diff --git a/pandora_agents/shellscript/bsd-ipso/pandora_agent.conf b/pandora_agents/shellscript/bsd-ipso/pandora_agent.conf index 8f0cbac3fb..10fbdb58f9 100644 --- a/pandora_agents/shellscript/bsd-ipso/pandora_agent.conf +++ b/pandora_agents/shellscript/bsd-ipso/pandora_agent.conf @@ -1,6 +1,6 @@ # Fichero de configuracion base de agentes de Pandora # Base config file for Pandora agents -# Version 7.0NG.702 +# Version 7.0NG.703 # FreeBSD/IPSO version # Licenced under GPL licence, 2003-2007 Sancho Lerena diff --git a/pandora_agents/shellscript/hp-ux/pandora_agent.conf b/pandora_agents/shellscript/hp-ux/pandora_agent.conf index 2e28fccb23..7a14c77ef7 100644 --- a/pandora_agents/shellscript/hp-ux/pandora_agent.conf +++ b/pandora_agents/shellscript/hp-ux/pandora_agent.conf @@ -1,6 +1,6 @@ # Fichero de configuracion base de agentes de Pandora # Base config file for Pandora agents -# Version 7.0NG.702, HPUX Version +# Version 7.0NG.703, HPUX Version # General Parameters # ================== diff --git a/pandora_agents/shellscript/linux/pandora_agent.conf b/pandora_agents/shellscript/linux/pandora_agent.conf index c6e5935841..50bd5d78fd 100644 --- a/pandora_agents/shellscript/linux/pandora_agent.conf +++ b/pandora_agents/shellscript/linux/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.702 +# Version 7.0NG.703 # Licensed under GPL license v2, # (c) 2003-2010 Artica Soluciones Tecnologicas # please visit http://pandora.sourceforge.net diff --git a/pandora_agents/shellscript/mac_osx/pandora_agent.conf b/pandora_agents/shellscript/mac_osx/pandora_agent.conf index 4b83ae44e6..9a9fb626a9 100644 --- a/pandora_agents/shellscript/mac_osx/pandora_agent.conf +++ b/pandora_agents/shellscript/mac_osx/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.702 +# Version 7.0NG.703 # Licensed under GPL license v2, # (c) 2003-2009 Artica Soluciones Tecnologicas # please visit http://pandora.sourceforge.net diff --git a/pandora_agents/shellscript/openWRT/pandora_agent.conf b/pandora_agents/shellscript/openWRT/pandora_agent.conf index c8ecb194c5..6326cd48ac 100644 --- a/pandora_agents/shellscript/openWRT/pandora_agent.conf +++ b/pandora_agents/shellscript/openWRT/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.702 +# Version 7.0NG.703 # Licensed under GPL license v2, # please visit http://pandora.sourceforge.net diff --git a/pandora_agents/shellscript/solaris/pandora_agent.conf b/pandora_agents/shellscript/solaris/pandora_agent.conf index b865c1cecd..566d07d0e5 100644 --- a/pandora_agents/shellscript/solaris/pandora_agent.conf +++ b/pandora_agents/shellscript/solaris/pandora_agent.conf @@ -1,6 +1,6 @@ # Fichero de configuracion base de agentes de Pandora # Base config file for Pandora agents -# Version 7.0NG.702, Solaris version +# Version 7.0NG.703, Solaris version # General Parameters # ================== diff --git a/pandora_agents/unix/AIX/pandora_agent.conf b/pandora_agents/unix/AIX/pandora_agent.conf index 213f2dad81..89f3c71d14 100644 --- a/pandora_agents/unix/AIX/pandora_agent.conf +++ b/pandora_agents/unix/AIX/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.702, AIX version +# Version 7.0NG.703, AIX version # Licensed under GPL license v2, # Copyright (c) 2003-2010 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index 3b89316d0b..3b4a5181aa 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.702-170511 +Version: 7.0NG.703-170518 Architecture: all Priority: optional Section: admin diff --git a/pandora_agents/unix/DEBIAN/make_deb_package.sh b/pandora_agents/unix/DEBIAN/make_deb_package.sh index 3565793d21..a6268e166d 100644 --- a/pandora_agents/unix/DEBIAN/make_deb_package.sh +++ b/pandora_agents/unix/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.702-170511" +pandora_version="7.0NG.703-170518" echo "Test if you has the tools for to make the packages." whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null diff --git a/pandora_agents/unix/Darwin/pandora_agent.conf b/pandora_agents/unix/Darwin/pandora_agent.conf index 99c55032b9..7028f11a9b 100644 --- a/pandora_agents/unix/Darwin/pandora_agent.conf +++ b/pandora_agents/unix/Darwin/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.702, GNU/Linux +# Version 7.0NG.703, GNU/Linux # Licensed under GPL license v2, # Copyright (c) 2003-2012 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/unix/FreeBSD/pandora_agent.conf b/pandora_agents/unix/FreeBSD/pandora_agent.conf index fa5133542e..6e44217cd9 100644 --- a/pandora_agents/unix/FreeBSD/pandora_agent.conf +++ b/pandora_agents/unix/FreeBSD/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.702, FreeBSD Version +# Version 7.0NG.703, FreeBSD Version # Licensed under GPL license v2, # Copyright (c) 2003-2016 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/unix/HP-UX/pandora_agent.conf b/pandora_agents/unix/HP-UX/pandora_agent.conf index b5b8b5ac89..231aab8fb7 100644 --- a/pandora_agents/unix/HP-UX/pandora_agent.conf +++ b/pandora_agents/unix/HP-UX/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.702, HP-UX Version +# Version 7.0NG.703, HP-UX Version # Licensed under GPL license v2, # Copyright (c) 2003-2009 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/unix/Linux/pandora_agent.conf b/pandora_agents/unix/Linux/pandora_agent.conf index 2193b79020..68c33feadb 100644 --- a/pandora_agents/unix/Linux/pandora_agent.conf +++ b/pandora_agents/unix/Linux/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.702, GNU/Linux +# Version 7.0NG.703, GNU/Linux # Licensed under GPL license v2, # Copyright (c) 2003-2014 Artica Soluciones Tecnologicas # http://www.pandorafms.com @@ -46,6 +46,12 @@ agent_name_cmd __rand__ #Parent agent_name #parent_agent_name caprica +# By default, agent takes machine alias +#agent_alias + +# To define agent alias by specific command, define 'agent_alias_cmd'. +#agent_alias_cmd + # Agent description #description This is a demo agent for Linux diff --git a/pandora_agents/unix/NT4/pandora_agent.conf b/pandora_agents/unix/NT4/pandora_agent.conf index 394324a119..c6bf2175fb 100644 --- a/pandora_agents/unix/NT4/pandora_agent.conf +++ b/pandora_agents/unix/NT4/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.702, GNU/Linux +# Version 7.0NG.703, GNU/Linux # Licensed under GPL license v2, # Copyright (c) 2003-2009 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/unix/NetBSD/pandora_agent.conf b/pandora_agents/unix/NetBSD/pandora_agent.conf index c95d19f363..9dec043a34 100644 --- a/pandora_agents/unix/NetBSD/pandora_agent.conf +++ b/pandora_agents/unix/NetBSD/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.702, NetBSD Version +# Version 7.0NG.703, NetBSD Version # Licensed under GPL license v2, # Copyright (c) 2003-2010 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/unix/SunOS/pandora_agent.conf b/pandora_agents/unix/SunOS/pandora_agent.conf index 53f3ac80a7..8a839dd648 100644 --- a/pandora_agents/unix/SunOS/pandora_agent.conf +++ b/pandora_agents/unix/SunOS/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.702, Solaris Version +# Version 7.0NG.703, Solaris Version # Licensed under GPL license v2, # Copyright (c) 2003-2009 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/unix/pandora_agent b/pandora_agents/unix/pandora_agent index a4157f023e..f5a70e0831 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -40,8 +40,8 @@ my $Sem = undef; # Semaphore used to control the number of threads my $ThreadSem = undef; -use constant AGENT_VERSION => '7.0NG.702'; -use constant AGENT_BUILD => '170511'; +use constant AGENT_VERSION => '7.0NG.703'; +use constant AGENT_BUILD => '170518'; # Agent log default file size maximum and instances use constant DEFAULT_MAX_LOG_SIZE => 600000; @@ -135,9 +135,10 @@ my %DefaultConf = ( 'interval' => 300, 'debug' => 0, 'agent_name' => '', - 'agent_alias' => hostname(), + 'agent_alias' => '', 'ehorus_conf' => undef, 'agent_name_cmd' => '', + 'agent_alias_cmd' => '', 'description' => '', 'group' => '', 'group_id' => undef, @@ -802,6 +803,23 @@ sub read_config (;$) { # Module, plugin and collection definitions parse_conf_modules(\@file); + + # If agent_alias_cmd is defined, agent_alias is set by command result. + if ($Conf{'agent_alias'} eq '') { + if ($Conf{'agent_alias_cmd'} ne '') { + my $result = `$Conf{'agent_alias_cmd'}`; + # Use only the first line. + my ($temp_agent_alias, $remain2) = split(/\n/, $result); + chomp ($temp_agent_alias); + + # Remove white spaces of the first and last. + $temp_agent_alias =~ s/^ *(.*?) *$/$1/; + + $Conf{'agent_alias'} = $temp_agent_alias if ($temp_agent_alias ne ''); + } else { + $Conf{'agent_alias'} = hostname(); + } + } # If agent_name_cmd is defined, agent_name is set by command result. if ($Conf{'agent_name'} eq '') { diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec index 658587290c..bdf0a020a0 100644 --- a/pandora_agents/unix/pandora_agent.redhat.spec +++ b/pandora_agents/unix/pandora_agent.redhat.spec @@ -2,8 +2,8 @@ #Pandora FMS Linux Agent # %define name pandorafms_agent_unix -%define version 7.0NG.702 -%define release 170511 +%define version 7.0NG.703 +%define release 170518 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent.spec b/pandora_agents/unix/pandora_agent.spec index 70b81bcd5a..d98a626456 100644 --- a/pandora_agents/unix/pandora_agent.spec +++ b/pandora_agents/unix/pandora_agent.spec @@ -2,8 +2,8 @@ #Pandora FMS Linux Agent # %define name pandorafms_agent_unix -%define version 7.0NG.702 -%define release 170511 +%define version 7.0NG.703 +%define release 170518 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent_installer b/pandora_agents/unix/pandora_agent_installer index 0f74db892b..376293af52 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -9,8 +9,8 @@ # Please see http://www.pandorafms.org. This code is licensed under GPL 2.0 license. # ********************************************************************** -PI_VERSION="7.0NG.702" -PI_BUILD="170511" +PI_VERSION="7.0NG.703" +PI_BUILD="170518" OS_NAME=`uname -s` FORCE=0 diff --git a/pandora_agents/win32/bin/pandora_agent.conf b/pandora_agents/win32/bin/pandora_agent.conf index 541132de4f..191dffec26 100644 --- a/pandora_agents/win32/bin/pandora_agent.conf +++ b/pandora_agents/win32/bin/pandora_agent.conf @@ -1,6 +1,6 @@ # Base config file for Pandora FMS Windows Agent # (c) 2006-2014 Artica Soluciones Tecnologicas -# Version 7.0NG.702 +# Version 7.0NG.703 # This program is Free Software, you can redistribute it and/or modify it # under the terms of the GNU General Public Licence as published by the Free Software diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index f4911dcd10..b7ae735469 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -3,7 +3,7 @@ AllowLanguageSelection {Yes} AppName -{Pandora FMS Windows Agent v7.0NG.702} +{Pandora FMS Windows Agent v7.0NG.703} ApplicationID {17E3D2CF-CA02-406B-8A80-9D31C17BD08F} @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{170511} +{170518} ViewReadme {Yes} diff --git a/pandora_agents/win32/modules/pandora_module.cc b/pandora_agents/win32/modules/pandora_module.cc index a1936912f2..296f42f2ea 100644 --- a/pandora_agents/win32/modules/pandora_module.cc +++ b/pandora_agents/win32/modules/pandora_module.cc @@ -368,7 +368,7 @@ Pandora_Module::getDataOutput (Pandora_Data *data) { } if (this->has_limits) { - if (value >= this->max || value <= this->min) { + if (value > this->max || value < this->min) { pandoraLog ("The returned value was not in the interval on module %s", this->module_name.c_str ()); throw Value_Error (); @@ -1789,5 +1789,9 @@ Pandora_Module::getIntensiveMatch () { return this->intensive_match; } +bool +Pandora_Module::getAsync () { + return this->async; +} diff --git a/pandora_agents/win32/modules/pandora_module.h b/pandora_agents/win32/modules/pandora_module.h index 4303b88eec..b2606d2442 100644 --- a/pandora_agents/win32/modules/pandora_module.h +++ b/pandora_agents/win32/modules/pandora_module.h @@ -91,7 +91,7 @@ namespace Pandora_Modules { MODULE_TCPCHECK, /**< The module checks whether a tcp port is open */ MODULE_REGEXP, /**< The module searches a file for matches of a regular expression */ MODULE_PLUGIN, /**< Plugin */ - MODULE_PING, /**< Ping module */ + MODULE_PING, /**< Ping module */ MODULE_SNMPGET /**< SNMP get module */ } Module_Kind; @@ -238,6 +238,7 @@ namespace Pandora_Modules { void setTimeout (int timeout); int getTimeout (); string getSave (); + bool getAsync (); virtual string getXml (); diff --git a/pandora_agents/win32/modules/pandora_module_proc.cc b/pandora_agents/win32/modules/pandora_module_proc.cc index 91deab0efb..e8eed1f97d 100644 --- a/pandora_agents/win32/modules/pandora_module_proc.cc +++ b/pandora_agents/win32/modules/pandora_module_proc.cc @@ -52,6 +52,17 @@ Pandora_Module_Proc::Pandora_Module_Proc (string name, string process_name) this->retries = 3; this->start_delay = 5000; this->retry_delay = 2000; + this->thread = 0; +} +/** + * Destroys a Pandora_Module_Service object. + */ +Pandora_Module_Proc::~Pandora_Module_Proc () { + + // Close the thread if module is async + if (this->thread) { + TerminateThread(this->thread, 0); + } } string diff --git a/pandora_agents/win32/modules/pandora_module_proc.h b/pandora_agents/win32/modules/pandora_module_proc.h index 60615f189a..edab85cb88 100644 --- a/pandora_agents/win32/modules/pandora_module_proc.h +++ b/pandora_agents/win32/modules/pandora_module_proc.h @@ -38,6 +38,7 @@ namespace Pandora_Modules { int retry_delay; public: Pandora_Module_Proc (string name, string process_name); + ~Pandora_Module_Proc (); string getProcessName () const; string getStartCommand () const; diff --git a/pandora_agents/win32/modules/pandora_module_service.cc b/pandora_agents/win32/modules/pandora_module_service.cc index bbbe799f9e..bf82120aa8 100644 --- a/pandora_agents/win32/modules/pandora_module_service.cc +++ b/pandora_agents/win32/modules/pandora_module_service.cc @@ -49,6 +49,16 @@ Pandora_Module_Service::Pandora_Module_Service (string name, string service_name this->thread = 0; this->watchdog = false; } +/** + * Destroys a Pandora_Module_Service object. + */ +Pandora_Module_Service::~Pandora_Module_Service () { + + // Close the thread if module is async + if (this->thread) { + TerminateThread(this->thread, 0); + } +} string Pandora_Module_Service::getServiceName () const { diff --git a/pandora_agents/win32/modules/pandora_module_service.h b/pandora_agents/win32/modules/pandora_module_service.h index 6e82697985..bdec6152ed 100644 --- a/pandora_agents/win32/modules/pandora_module_service.h +++ b/pandora_agents/win32/modules/pandora_module_service.h @@ -36,6 +36,7 @@ namespace Pandora_Modules { bool watchdog; public: Pandora_Module_Service (string name, string service_name); + ~Pandora_Module_Service (); void run (); string getServiceName () const; diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index 054411d96e..2a6933665a 100644 --- a/pandora_agents/win32/pandora.cc +++ b/pandora_agents/win32/pandora.cc @@ -30,7 +30,7 @@ using namespace Pandora; using namespace Pandora_Strutils; #define PATH_SIZE _MAX_PATH+1 -#define PANDORA_VERSION ("7.0NG.702(Build 170511)") +#define PANDORA_VERSION ("7.0NG.703(Build 170518)") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/pandora_agent_conf.cc b/pandora_agents/win32/pandora_agent_conf.cc index 83675cdde6..94617243d5 100644 --- a/pandora_agents/win32/pandora_agent_conf.cc +++ b/pandora_agents/win32/pandora_agent_conf.cc @@ -228,6 +228,15 @@ Pandora::Pandora_Agent_Conf::setFile (string *all_conf){ key_values->push_back (kv); continue; } + + /*Check if is a agent_alias_cmd"*/ + pos = buffer.find("agent_alias_cmd"); + if (pos != string::npos){ + Key_Value kv; + kv.parseLineByPosition(buffer, 15); + key_values->push_back (kv); + continue; + } /*Check if is a collection*/ pos = buffer.find("file_collection"); diff --git a/pandora_agents/win32/pandora_windows_service.cc b/pandora_agents/win32/pandora_windows_service.cc index 45c2189385..cad177411a 100644 --- a/pandora_agents/win32/pandora_windows_service.cc +++ b/pandora_agents/win32/pandora_windows_service.cc @@ -76,6 +76,7 @@ Pandora_Windows_Service::setValues (const char * svc_name, this->service_description = (char *) svc_description; execution_number = 0; this->modules = NULL; + this->broker_modules = NULL; this->conf = NULL; this->interval = 60000; this->timestamp = 0; @@ -105,6 +106,10 @@ Pandora_Windows_Service::~Pandora_Windows_Service () { if (this->modules != NULL) { delete this->modules; } + + if (this->broker_modules != NULL) { + delete this->broker_modules; + } pandoraLog ("Pandora agent stopped"); } @@ -136,10 +141,10 @@ Pandora_Windows_Service::pandora_init_broker (string file_conf) { this->conf = Pandora::Pandora_Agent_Conf::getInstance (); this->conf->setFile (file_conf); - if (this->modules != NULL) { - delete this->modules; + if (this->broker_modules != NULL) { + delete this->broker_modules; } - this->modules = new Pandora_Module_List (file_conf); + this->broker_modules = new Pandora_Module_List (file_conf); pandoraDebug ("Pandora broker agent started"); } @@ -208,9 +213,14 @@ Pandora_Windows_Service::check_broker_agents(string *all_conf){ void Pandora_Windows_Service::pandora_init () { + pandora_init(true); +} + +void +Pandora_Windows_Service::pandora_init (bool reload_modules) { string conf_file, interval, debug, disable_logfile, intensive_interval, util_dir, path, env; string udp_server_enabled, udp_server_port, udp_server_addr, udp_server_auth_addr; - string agent_name, agent_name_cmd, agent_alias, pandora_agent; + string agent_name, agent_name_cmd, agent_alias, agent_alias_cmd, pandora_agent; string proxy_mode, server_ip; string *all_conf; int pos, num; @@ -224,7 +234,7 @@ Pandora_Windows_Service::pandora_init () { this->conf = Pandora::Pandora_Agent_Conf::getInstance (); this->conf->setFile (all_conf); - if (this->modules != NULL) { + if (this->modules != NULL && reload_modules) { delete this->modules; } @@ -255,9 +265,40 @@ Pandora_Windows_Service::pandora_init () { this->setSleepTime (this->intensive_interval); // Read modules - this->modules = new Pandora_Module_List (conf_file); + if (reload_modules) { + this->modules = new Pandora_Module_List (conf_file); + } delete []all_conf; - + + // Get the agent alias. + agent_alias = conf->getValue ("agent_alias"); + if (agent_alias == "") { + agent_alias_cmd = conf->getValue ("agent_alias_cmd"); + if (agent_alias_cmd != "") { + agent_alias_cmd = "cmd.exe /c \"" + agent_alias_cmd + "\""; + static string temp_agent_alias = getAgentNameFromCmdExec(agent_alias_cmd); + + // Delete new line and carriage return. + pos = temp_agent_alias.find("\n"); + if(pos != string::npos) { + temp_agent_alias.erase(pos, temp_agent_alias.size () - pos); + } + pos = temp_agent_alias.find("\r"); + if(pos != string::npos) { + temp_agent_alias.erase(pos, temp_agent_alias.size () - pos); + } + + // Remove leading and trailing white spaces. + temp_agent_alias = trim(temp_agent_alias); + if (temp_agent_alias != "") { + agent_alias = temp_agent_alias; + } + } else { + agent_alias = Pandora_Windows_Info::getSystemName (); + } + } + this->conf->setValue("agent_alias", agent_alias); + // Get the agent name. agent_name = conf->getValue ("agent_name"); if (agent_name == "") { @@ -299,13 +340,6 @@ Pandora_Windows_Service::pandora_init () { this->conf->setValue("agent_name", agent_name); } - // Get the agent alias. - agent_alias = conf->getValue ("agent_alias"); - if (agent_alias == "") { - agent_alias = Pandora_Windows_Info::getSystemName (); - this->conf->setValue("agent_alias", agent_alias); - } - pandora_agent = "PANDORA_AGENT=" + agent_name; putenv(pandora_agent.c_str()); @@ -1834,19 +1868,19 @@ Pandora_Windows_Service::pandora_run_broker (string config) { server_addr = conf->getValue ("server_ip"); - if (this->modules != NULL) { - this->modules->goFirst (); + if (this->broker_modules != NULL) { + this->broker_modules->goFirst (); - while (! this->modules->isLast ()) { + while (! this->broker_modules->isLast ()) { Pandora_Module *module; - module = this->modules->getCurrentValue (); + module = this->broker_modules->getCurrentValue (); /* Check preconditions */ if (module->evaluatePreconditions () == 0) { pandoraDebug ("Preconditions not matched for module %s", module->getName ().c_str ()); module->setNoOutput (); - this->modules->goNext (); + this->broker_modules->goNext (); continue; } @@ -1854,15 +1888,23 @@ Pandora_Windows_Service::pandora_run_broker (string config) { if (module->checkCron (module->getInterval (), atoi (conf->getValue ("interval").c_str())) == 0) { pandoraDebug ("Cron not matched for module %s", module->getName ().c_str ()); module->setNoOutput (); - this->modules->goNext (); + this->broker_modules->goNext (); continue; } + /* Check async */ + if (module->getAsync()) { + pandoraDebug ("Forbidden async module %s in broker agents", module->getName ().c_str ()); + module->setNoOutput (); + this->broker_modules->goNext (); + continue; + } + pandoraDebug ("Run %s", module->getName ().c_str ()); module->run (); if (! module->hasOutput ()) { module->setNoOutput (); - this->modules->goNext (); + this->broker_modules->goNext (); continue; } @@ -1875,7 +1917,7 @@ Pandora_Windows_Service::pandora_run_broker (string config) { intensive_match = module->evaluateIntensiveConditions (); if (intensive_match == module->getIntensiveMatch () && module->getTimestamp () + module->getInterval () * this->interval_sec > this->run_time) { module->setNoOutput (); - this->modules->goNext (); + this->broker_modules->goNext (); continue; } module->setIntensiveMatch (intensive_match); @@ -1890,7 +1932,7 @@ Pandora_Windows_Service::pandora_run_broker (string config) { /* At least one module has data */ data_flag = 1; - this->modules->goNext (); + this->broker_modules->goNext (); } } @@ -1898,7 +1940,7 @@ Pandora_Windows_Service::pandora_run_broker (string config) { // Send the XML if (!server_addr.empty ()) { - this->sendXml (this->modules); + this->sendXml (this->broker_modules); } } @@ -2037,7 +2079,7 @@ Pandora_Windows_Service::pandora_run (int forced_run) { /* Reload the original configuration */ if (num != 0) { - pandora_init (); + pandora_init (false); } /* Reset time reference if necessary */ diff --git a/pandora_agents/win32/pandora_windows_service.h b/pandora_agents/win32/pandora_windows_service.h index be9a7a4eb3..17f0130884 100644 --- a/pandora_agents/win32/pandora_windows_service.h +++ b/pandora_agents/win32/pandora_windows_service.h @@ -42,6 +42,7 @@ namespace Pandora { private: Pandora_Agent_Conf *conf; Pandora_Module_List *modules; + Pandora_Module_List *broker_modules; long execution_number; string agent_name; string alias; @@ -98,6 +99,7 @@ namespace Pandora { void pandora_run (int forced_run); void pandora_run (); void pandora_init (); + void pandora_init (bool reload_modules); long interval; long interval_sec; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index 5d36e56748..400e74379c 100644 --- a/pandora_agents/win32/versioninfo.rc +++ b/pandora_agents/win32/versioninfo.rc @@ -11,7 +11,7 @@ BEGIN VALUE "LegalCopyright", "Artica ST" VALUE "OriginalFilename", "PandoraAgent.exe" VALUE "ProductName", "Pandora FMS Windows Agent" - VALUE "ProductVersion", "(7.0NG.702(Build 170511))" + VALUE "ProductVersion", "(7.0NG.703(Build 170518))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index 9b1ca7dfb8..498ff4ef0d 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,10 +1,10 @@ package: pandorafms-console -Version: 7.0NG.702-170511 +Version: 7.0NG.703-170518 Architecture: all Priority: optional Section: admin Installed-Size: 42112 Maintainer: Artica ST Homepage: http://pandorafms.org/ -Depends: php5, php5-snmp, php5-gd, php5-mysql, php-db, php5-xmlrpc, php-gettext, php5-curl, graphviz, dbconfig-common, php5-ldap, mysql-client | virtual-mysql-client +Depends: php5.6 | php5, php5.6-snmp | php5-snmp, php5.6-gd | php5-gd, php5.6-mysql | php5-mysql, php-db, php5.6-xmlrpc | php5-xmlrpc, php-gettext, php5.6-curl | php5-curl, graphviz, dbconfig-common, php5.6-ldap | php5-ldap, mysql-client | virtual-mysql-client Description: Pandora FMS is an Open Source monitoring tool. It monitor your systems and applications, and allows you to control the status of any element of them. The web console is the graphical user interface (GUI) to manage the pool and to generate reports and graphs from the Pandora FMS monitoring process. diff --git a/pandora_console/DEBIAN/make_deb_package.sh b/pandora_console/DEBIAN/make_deb_package.sh index 60a50c665f..38f9d70839 100644 --- a/pandora_console/DEBIAN/make_deb_package.sh +++ b/pandora_console/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.702-170511" +pandora_version="7.0NG.703-170518" package_pear=0 package_pandora=1 diff --git a/pandora_console/general/alert_enterprise.php b/pandora_console/general/alert_enterprise.php index 3cd1b0b93d..d5be19eebd 100644 --- a/pandora_console/general/alert_enterprise.php +++ b/pandora_console/general/alert_enterprise.php @@ -15,7 +15,7 @@ if(!enterprise_installed()){ $open=true; } -$tipo = $_GET['message']; +$tipo = $_POST['message']; echo "
@@ -185,7 +185,7 @@ echo "
"; if($open){ echo "
-About Enterprise +About Enterprise
"; } diff --git a/pandora_console/general/footer.php b/pandora_console/general/footer.php index 1570ec825c..64564d300a 100644 --- a/pandora_console/general/footer.php +++ b/pandora_console/general/footer.php @@ -32,7 +32,15 @@ if (!$config["MR"]) { echo ''; -echo sprintf(__('Pandora FMS %s - Build %s - MR %s', $pandora_version, $build_version, $config["MR"])); +if($current_package == 0){ +$build_package_version = $build_version; +} +else{ +$build_package_version = $current_package; +} + + +echo sprintf(__('Pandora FMS %s - Build %s - MR %s', $pandora_version, $build_package_version, $config["MR"])); echo '
'; echo ''. __('Page generated at') . ' '. date('F j, Y h:i a'); //Always use timestamp here diff --git a/pandora_console/general/login_page.php b/pandora_console/general/login_page.php index 53a4592a94..e49fdff340 100755 --- a/pandora_console/general/login_page.php +++ b/pandora_console/general/login_page.php @@ -83,12 +83,19 @@ echo '
'; echo 'pandora_console'; } echo '
'; - echo '
'; + + echo '
'; + + echo ''; echo '
'; diff --git a/pandora_console/godmode/agentes/configurar_agente.php b/pandora_console/godmode/agentes/configurar_agente.php index bc09729e15..c11edc91a3 100644 --- a/pandora_console/godmode/agentes/configurar_agente.php +++ b/pandora_console/godmode/agentes/configurar_agente.php @@ -159,8 +159,7 @@ if ($create_agent) { $intervalo = (string) get_parameter_post ("intervalo", SECONDS_5MINUTES); $comentarios = (string) get_parameter_post ("comentarios", ''); $modo = (int) get_parameter_post ("modo"); - $id_parent = (string) get_parameter_post ("id_parent",''); - $id_parent = (int) agents_get_agent_id ($id_parent); + $id_parent = (int) get_parameter_post ("id_agent_parent"); $server_name = (string) get_parameter_post ("server_name"); $id_os = (int) get_parameter_post ("id_os"); $disabled = (int) get_parameter_post ("disabled"); @@ -690,8 +689,7 @@ if ($update_agent) { // if modified some agent paramenter $id_os = (int) get_parameter_post ("id_os"); $disabled = (bool) get_parameter_post ("disabled"); $server_name = (string) get_parameter_post ("server_name", ""); - $parent_name = (string) get_parameter_post ("id_parent"); - $id_parent = (int) agents_get_agent_id ($parent_name); + $id_parent = (int) get_parameter_post ("id_agent_parent"); $custom_id = (string) get_parameter_post ("custom_id", ""); $cascade_protection = (int) get_parameter_post ("cascade_protection", 0); $cascade_protection_module = (int) get_parameter ("cascade_protection_module", 0); diff --git a/pandora_console/godmode/agentes/modificar_agente.php b/pandora_console/godmode/agentes/modificar_agente.php index 9487a5519c..8dae33a036 100644 --- a/pandora_console/godmode/agentes/modificar_agente.php +++ b/pandora_console/godmode/agentes/modificar_agente.php @@ -99,6 +99,7 @@ if ($agent_to_delete) { if ($enable_agent) { $result = db_process_sql_update('tagente', array('disabled' => 0), array('id_agente' => $enable_agent)); + $alias = agents_get_alias($enable_agent); if ($result) { // Update the agent from the metaconsole cache @@ -106,10 +107,10 @@ if ($enable_agent) { $values = array('disabled' => 0); enterprise_hook ('agent_update_from_cache', array($enable_agent, $values)); - db_pandora_audit("Agent management", 'Enable ' . $enable_agent); + db_pandora_audit("Agent management", 'Enable ' . $alias); } else { - db_pandora_audit("Agent management", 'Fail to enable ' . $enable_agent); + db_pandora_audit("Agent management", 'Fail to enable ' . $alias); } ui_print_result_message ($result, @@ -118,6 +119,7 @@ if ($enable_agent) { if ($disable_agent) { $result = db_process_sql_update('tagente', array('disabled' => 1), array('id_agente' => $disable_agent)); + $alias = agents_get_alias($disable_agent); if ($result) { // Update the agent from the metaconsole cache @@ -125,10 +127,10 @@ if ($disable_agent) { $values = array('disabled' => 1); enterprise_hook ('agent_update_from_cache', array($disable_agent, $values)); - db_pandora_audit("Agent management", 'Disable ' . $disable_agent); + db_pandora_audit("Agent management", 'Disable ' . $alias); } else { - db_pandora_audit("Agent management", 'Fail to disable ' . $disable_agent); + db_pandora_audit("Agent management", 'Fail to disable ' . $alias); } ui_print_result_message ($result, diff --git a/pandora_console/godmode/agentes/module_manager_editor_common.php b/pandora_console/godmode/agentes/module_manager_editor_common.php index 561266d6df..dbb6db2da0 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_common.php +++ b/pandora_console/godmode/agentes/module_manager_editor_common.php @@ -882,6 +882,9 @@ $(document).ready (function () { $('#dynamic_interval_select').change (function() { disabled_status(disabledBecauseInPolicy); }); + $('#dynamic_interval').change (function() { + disabled_status(disabledBecauseInPolicy); + }); disabled_two_tailed(disabledBecauseInPolicy); $('#checkbox-dynamic_two_tailed').change (function() { @@ -929,7 +932,7 @@ $(document).ready (function () { //readonly and add class input function disabled_status (disabledBecauseInPolicy) { - if($('#dynamic_interval_select').val() != 0){ + if($('#dynamic_interval_select').val() != 0 && $('#dynamic_interval').val() != 0){ $('#text-min_warning').prop('readonly', true); $('#text-min_warning').addClass('readonly'); $('#text-max_warning').prop('readonly', true); diff --git a/pandora_console/godmode/agentes/planned_downtime.editor.php b/pandora_console/godmode/agentes/planned_downtime.editor.php index b1311a7846..c797b268a3 100644 --- a/pandora_console/godmode/agentes/planned_downtime.editor.php +++ b/pandora_console/godmode/agentes/planned_downtime.editor.php @@ -633,8 +633,6 @@ echo ''; if ($id_downtime > 0) { echo ""; - // Show available agents to include into downtime - echo '

' . __('Available agents') . ':

'; $filter_group = (int) get_parameter("filter_group", 0); @@ -707,7 +705,8 @@ if ($id_downtime > 0) { echo "

"; html_print_submit_button (__('Filter by group'), '', false, 'class="sub next"',false); echo ""; - + // Show available agents to include into downtime + echo '

' . __('Available agents') . ':

'; echo "
"; echo html_print_select ($agents, "id_agents[]", -1, '', _("Any"), -2, false, true, true, '', false, 'width: 180px;'); diff --git a/pandora_console/godmode/alerts/alert_templates.php b/pandora_console/godmode/alerts/alert_templates.php index ff0605390a..cda35892a4 100644 --- a/pandora_console/godmode/alerts/alert_templates.php +++ b/pandora_console/godmode/alerts/alert_templates.php @@ -129,7 +129,8 @@ if (!$delete_template) { alerts_meta_print_header (); } else { - ui_print_page_header (__('Alerts')." » ". __('Alert templates'), "images/gm_alerts.png", false, "alerts_config", true); + //~ ui_print_page_header (__('Alerts')." » ". __('Alert templates'), "images/gm_alerts.png", false, "alerts_config", true); + ui_print_page_header (__('Alerts')." » ". __('Alert templates'), "images/gm_alerts.png", false, "", true); } } diff --git a/pandora_console/godmode/alerts/configure_alert_template.php b/pandora_console/godmode/alerts/configure_alert_template.php index 206a0fb2b8..d2cc13a702 100644 --- a/pandora_console/godmode/alerts/configure_alert_template.php +++ b/pandora_console/godmode/alerts/configure_alert_template.php @@ -59,9 +59,12 @@ if ($a_template !== false) { alerts_meta_print_header(); } else { + //~ ui_print_page_header (__('Alerts') . + //~ ' » ' . __('Configure alert template'), "", + //~ false, "alerts_config", true); ui_print_page_header (__('Alerts') . ' » ' . __('Configure alert template'), "", - false, "alerts_config", true); + false, "", true); } } else { diff --git a/pandora_console/godmode/reporting/visual_console_builder.editor.js b/pandora_console/godmode/reporting/visual_console_builder.editor.js index 310286ae69..a828bd4fb4 100755 --- a/pandora_console/godmode/reporting/visual_console_builder.editor.js +++ b/pandora_console/godmode/reporting/visual_console_builder.editor.js @@ -1497,13 +1497,11 @@ function set_static_graph_status(idElement, image, status) { set_static_graph_status(idElement, image, data); if($('#'+idElement+' table').css('float') == 'right' || $('#'+idElement+ ' table').css('float') == 'left'){ - $('#'+idElement+ ' img').css('margin-top', parseInt($('#'+idElement).css('height'))/2 - parseInt($('#'+idElement+ ' img').css('height'))/2); + $('#'+idElement+ ' img').css('margin-top', parseInt($('#'+idElement).css('height'))/2 - parseInt($('#'+idElement+ ' img').css('height'))/2); } else{ - $('#'+idElement+ ' img').css('margin-left',parseInt($('#'+idElement).css('width'))/2 - parseInt($('#'+idElement+ ' img').css('width'))/2); + $('#'+idElement+ ' img').css('margin-left', parseInt($('#'+idElement).css('width'))/2 - parseInt($('#'+idElement+ ' img').css('width'))/2); } - - } }); @@ -1849,11 +1847,9 @@ function get_image_url(img_src) { }); } -function set_color_line_status(lines, line, id_data, values) { +function set_color_line_status(lines, id_data, values) { metaconsole = $("input[name='metaconsole']").val(); - - var parameter = Array(); parameter.push ({name: "page", value: "include/ajax/visual_console_builder.ajax"}); parameter.push ({name: "action", value: "get_color_line"}); @@ -1875,7 +1871,6 @@ function set_color_line_status(lines, line, id_data, values) { "node_end": id_data, "color": color }; - lines.push(line); refresh_lines(lines, 'background', true); @@ -2250,7 +2245,7 @@ function createItem(type, values, id_data) { lines.push(line); - set_color_line_status(lines, line, id_data, values); + set_color_line_status(lines, id_data, values); refresh_lines(lines, 'background', true); } @@ -2446,7 +2441,7 @@ function updateDB_visual(type, idElement , values, event, top, left) { if (typeof(values['parent']) != 'undefined' && values['parent'] > 0 ) { if (!found) { - set_color_line_status(lines, line, idElement, values); + set_color_line_status(lines, idElement, values); } } @@ -2465,6 +2460,7 @@ function updateDB_visual(type, idElement , values, event, top, left) { refresh_lines(lines, 'background', true); break; } + refresh_lines(lines, 'background', true); draw_user_lines("", 0, 0, 0 , 0, 0, true); } @@ -2601,9 +2597,19 @@ function updateDB(type, idElement , values, event) { url: get_url_ajax(), data: parameter, type: "POST", - dataType: 'text', + dataType: 'json', success: function (data) { - updateDB_visual(type, idElement , values, event, top, left); + if (data['correct']) { + if (data['new_line']) { + var line = {"id": idElement, + "node_begin": values['parent'], + "node_end": idElement, + "color": '#cccccc' }; + + lines.push(line); + } + updateDB_visual(type, idElement , values, event, top, left); + } } }); } diff --git a/pandora_console/godmode/update_manager/update_manager.offline.php b/pandora_console/godmode/update_manager/update_manager.offline.php index c6843034f3..f9ae0cd9e0 100644 --- a/pandora_console/godmode/update_manager/update_manager.offline.php +++ b/pandora_console/godmode/update_manager/update_manager.offline.php @@ -41,7 +41,7 @@ $baseurl = ui_get_full_url(false, false, false, false); var click_on_the_file_below_to_begin = "\n"; var updating = "\n"; var package_updated_successfully = "\n"; - var if_there_are_any_database_change = "\n"; + var if_there_are_any_database_change = "\n"; var mr_available = "\n"; var package_available = "\n"; var mr_not_accepted = "\n"; @@ -54,8 +54,9 @@ $baseurl = ui_get_full_url(false, false, false, false); var package_success = "\n"; var package_error = "\n"; var bad_mr_file = "\n"; - var text1_mr_file = "\n"; - var text2_mr_file = "\n"; + var mr_available_header = "\n"; + var text1_mr_file = "\n"; + var text2_mr_file = "\n"; var text3_mr_file = "\n"; var text4_mr_file = "\n"; var text1_package_file = "\n"; diff --git a/pandora_console/godmode/update_manager/update_manager.online.php b/pandora_console/godmode/update_manager/update_manager.online.php index 747b6a0ece..117c020515 100644 --- a/pandora_console/godmode/update_manager/update_manager.online.php +++ b/pandora_console/godmode/update_manager/update_manager.online.php @@ -82,7 +82,7 @@ echo ""; echo ""; echo "

"; -echo "
" . __('The last version of package installed is:') . "

"; +echo "
" . __('The latest version of package installed is:') . "

"; echo "
" . $current_package . "
"; echo "