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 eccb76a0cb..fa23e439e6 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 +Version: 7.0NG.703-170522 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 79689d6e7b..66b473e2ab 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" +pandora_version="7.0NG.703-170522" 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 cbee6925bb..d8cb7e9e10 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 => '170425'; +use constant AGENT_VERSION => '7.0NG.703'; +use constant AGENT_BUILD => '170522'; # 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 7917462004..4e3ea64cb5 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 1 +%define version 7.0NG.703 +%define release 170522 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 5d5df22903..a4d19700e2 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 1 +%define version 7.0NG.703 +%define release 170522 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 30b9c8a4e0..954e422aca 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="170425" +PI_VERSION="7.0NG.703" +PI_BUILD="170522" 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 56a11ec5bc..cb5dc44b9b 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 -{170425} +{170522} ViewReadme {Yes} @@ -2387,7 +2387,7 @@ Windows,BuildSeparateArchives {No} Windows,Executable -{<%AppName%>-Setup<%Ext%>} +{<%AppName%>-<%Version%>-Setup<%Ext%>} Windows,FileDescription {<%AppName%> <%Version%> Setup} 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 80dae66705..5f72d28894 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 170425)") +#define PANDORA_VERSION ("7.0NG.703(Build 170522)") 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 50ee4b016a..63539dd2fa 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 170425))" + VALUE "ProductVersion", "(7.0NG.703(Build 170522))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index f9b0df8722..3ae6ce38b0 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,10 +1,10 @@ package: pandorafms-console -Version: 7.0NG.702 +Version: 7.0NG.703-170522 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 9978146002..831bb5dd20 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" +pandora_version="7.0NG.703-170522" package_pear=0 package_pandora=1 diff --git a/pandora_console/extensions/agents_modules.php b/pandora_console/extensions/agents_modules.php index cd6ceb2518..2c7a9147b8 100644 --- a/pandora_console/extensions/agents_modules.php +++ b/pandora_console/extensions/agents_modules.php @@ -75,6 +75,8 @@ function mainAgentsModules() { $modules_selected = (array)get_parameter('module', 0); $update_item = (string)get_parameter('edit_item',''); $save_serialize = (int)get_parameter('save_serialize', 0); + $full_modules_selected = explode(";",get_parameter('full_modules_selected', 0)); + $full_agents_id = explode(";",get_parameter('full_agents_id', 0)); if($save_serialize && $update_item == ''){ $unserialize_modules_selected = unserialize_in_temp($config['id_user']."_agent_module", true, 1); @@ -97,16 +99,40 @@ function mainAgentsModules() { if($agents_id[0] != -1 ){ serialize_in_temp($agents_id, $config['id_user']."_agents", 1); } + if ($config["pure"] == 0) { - $fullscreen['text'] = '' - . html_print_image ("images/full_screen.png", true, array ("title" => __('Full screen mode'))) - . ""; + if($modules_selected[0] && $agents_id[0]){ + + $full_modules = urlencode(implode(";",$modules_selected)); + $full_agents = urlencode(implode(";",$agents_id)); + + $fullscreen['text'] = '' + . html_print_image ("images/full_screen.png", true, array ("title" => __('Full screen mode'))) + . ""; + + } else if($full_modules_selected[0] && $full_agents_id[0]){ + + $full_modules = urlencode(implode(";",$full_modules_selected)); + $full_agents = urlencode(implode(";",$full_agents_id)); + + $fullscreen['text'] = '' + . html_print_image ("images/full_screen.png", true, array ("title" => __('Full screen mode'))) + . ""; + + } else { + + $fullscreen['text'] = '' + . html_print_image ("images/full_screen.png", true, array ("title" => __('Full screen mode'))) + . ""; + } } - else { - - } - + $groups = users_get_groups (); //groups @@ -144,7 +170,7 @@ function mainAgentsModules() { //modules $all_modules = select_modules_for_agent_group($group_id, $agents_id, $selection_a_m, false); $filter_modules_label = ''.__('Module').''; - $filter_modules = html_print_select($all_modules, 'module[]', $modules_selected, '', '', 0, true, true, true, '', false, "min-width: 180px; max-width: 200px;"); + $filter_modules = html_print_select($all_modules, 'module[]', $modules_selected, '', '', 0, true, true, false, '', false, "min-width: 180px; max-width: 200px;"); //update $filter_update = html_print_submit_button(__('Update item'), 'edit_item', false, 'class="sub upd"', true); @@ -164,7 +190,19 @@ function mainAgentsModules() { echo ""; echo ""; } else { - $url =" index.php?sec=view&sec2=extensions/agents_modules&pure=0&offset='.$offset.'&group_id='.$group_id.'&modulegroup='.$modulegroup.'&refresh=$refr"; + if ($full_agents_id[0]){ + + $full_modules = urlencode(implode(";",$full_modules_selected)) ; + $full_agents = urlencode(implode(";",$full_agents_id)); + + $url =" index.php?sec=view&sec2=extensions/agents_modules&pure=0&offset=$offset + &group_id=$group_id&modulegroup=$modulegroup&refresh=$refr&full_modules_selected=$full_modules + &full_agents_id=$full_agents&selection_agent_module=$selection_a_m"; + + } else { + $url =" index.php?sec=view&sec2=extensions/agents_modules&pure=0&offset=$offset&group_id=$group_id&modulegroup=$modulegroup&refresh=$refr"; + } + // Floating menu - Start echo '
'; @@ -206,7 +244,9 @@ function mainAgentsModules() { if($config['pure'] != 1){ - echo '
'; + echo ''; + echo ''; echo ""; echo ""; @@ -235,9 +275,14 @@ function mainAgentsModules() { $agents = $agents_id; } else { - $agents = ''; - $agents = agents_get_group_agents($group_id,array('disabled' => 0)); - $agents = array_keys($agents); + if($full_agents_id[0]){ + $agents = $full_agents_id; + } else { + $agents = ''; + $agents = agents_get_group_agents($group_id,array('disabled' => 0)); + $agents = array_keys($agents); + } + } $filter_module_group = array('disabled' => 0); @@ -260,7 +305,6 @@ function mainAgentsModules() { if($agents_id[0] != -1){ $all_modules = array(); foreach ($modules_selected as $key => $value) { - //$all_modules[$value] = io_safe_output(modules_get_agentmodule_name($value)); $name = modules_get_agentmodule_name($value); $sql = "SELECT id_agente_modulo FROM tagente_modulo @@ -277,14 +321,34 @@ function mainAgentsModules() { } } else{ - $all_modules = agents_get_modules($agents, false, - $filter_module_group, true, true); + if ($full_modules_selected[0]){ + foreach ($full_modules_selected as $key => $value) { + $name = modules_get_agentmodule_name($value); + $sql = "SELECT id_agente_modulo + FROM tagente_modulo + WHERE nombre = '". $name ."';"; + + $result_sql = db_get_all_rows_sql($sql); + if(is_array($result_sql)){ + foreach ($result_sql as $key => $value) { + $all_modules[$value['id_agente_modulo']] = io_safe_output($name); + } + } + // $all_modules[$value] = modules_get_agentmodule_name($value); + } + + } else { + $all_modules = agents_get_modules($agents, false, + $filter_module_group, true, true); + } + } $modules_by_name = array(); $name = ''; $cont = 0; + foreach ($all_modules as $key => $module) { if ($module == $name) { $modules_by_name[$cont-1]['id'][] = $key; @@ -494,7 +558,6 @@ function mainAgentsModules() { echo ""; } } - echo ""; } @@ -509,7 +572,7 @@ function mainAgentsModules() { echo ""; echo ""; echo ""; - echo ""; + echo ""; echo "
" . $filter_groups_label . "
" . __("Yellow cell when the module has a warning status") . "
" . __("Green cell when the module has a normal status") . "
" . __("Grey cell when the module has an unknown status") . "
" . __("Cell turns grey when the module is in 'not initialize' status") . "
" . __("Cell turns blue when the module is in 'not initialize' status") . "
"; echo "
"; @@ -562,6 +625,8 @@ $ignored_params['refresh']=''; var refr = ; var pure = ; var href = ""; + + if (pure) { var startCountDown = function (duration, cb) { $('div.vc-countdown').countdown('destroy'); @@ -593,6 +658,17 @@ $ignored_params['refresh']=''; } else { + var agentes_id = $("#id_agents2").val(); + var id_agentes = $.get("full_agents_id"); + if (agentes_id === null && id_agentes !== null) { + id_agentes = id_agentes.split(";") + id_agentes.forEach(function(element) { + $("#id_agents2 option[value="+ element +"]").attr("selected",true); + }); + + selection_agent_module(); + } + $('#refresh').change(function () { $('#hidden-vc_refr').val($('#refresh option:selected').val()); }); @@ -693,9 +769,34 @@ $ignored_params['refresh']=''; .html (value["nombre"]); $("#module").append (option); }); + + var id_modules = $.get("full_modules_selected"); + if(id_modules !== null) { + id_modules = id_modules.split(";"); + id_modules.forEach(function(element) { + $("#module option[value="+ element +"]").attr("selected",true); + }); + } } }, "json" ); } + + (function($) { + $.get = function(key) { + key = key.replace(/[\[]/, '\\['); + key = key.replace(/[\]]/, '\\]'); + var pattern = "[\\?&]" + key + "=([^&#]*)"; + var regex = new RegExp(pattern); + var url = unescape(window.location.href); + var results = regex.exec(url); + if (results === null) { + return null; + } else { + return results[1]; + } + } + })(jQuery); + \ No newline at end of file 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 858ad945c0..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 '
'; @@ -103,7 +110,7 @@ echo '