diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index af01c3d07b..a60da38117 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.732-190301 +Version: 7.0NG.732-190305 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 298108cf60..5e5b7970e3 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.732-190301" +pandora_version="7.0NG.732-190305" 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/pandora_agent b/pandora_agents/unix/pandora_agent index f330d0d742..b647a812e4 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -42,7 +42,7 @@ my $Sem = undef; my $ThreadSem = undef; use constant AGENT_VERSION => '7.0NG.732'; -use constant AGENT_BUILD => '190301'; +use constant AGENT_BUILD => '190305'; # Agent log default file size maximum and instances use constant DEFAULT_MAX_LOG_SIZE => 600000; diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec index 91e5ecc0bb..46c1332c53 100644 --- a/pandora_agents/unix/pandora_agent.redhat.spec +++ b/pandora_agents/unix/pandora_agent.redhat.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_unix %define version 7.0NG.732 -%define release 190301 +%define release 190305 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 1f54cb9607..55c914cbb0 100644 --- a/pandora_agents/unix/pandora_agent.spec +++ b/pandora_agents/unix/pandora_agent.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_unix %define version 7.0NG.732 -%define release 190301 +%define release 190305 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 399e6674ea..a5c8231bd7 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -10,7 +10,7 @@ # ********************************************************************** PI_VERSION="7.0NG.732" -PI_BUILD="190301" +PI_BUILD="190305" OS_NAME=`uname -s` FORCE=0 diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index 9d3ae58a5f..555a4e405b 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{190301} +{190305} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index 9bb6e98c3b..187d8c3ec9 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.732(Build 190301)") +#define PANDORA_VERSION ("7.0NG.732(Build 190305)") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index 1ff3c27c25..507f50d48f 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.732(Build 190301))" + VALUE "ProductVersion", "(7.0NG.732(Build 190305))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index 4dbb111bbb..209ebb30f6 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.732-190301 +Version: 7.0NG.732-190305 Architecture: all Priority: optional Section: admin diff --git a/pandora_console/DEBIAN/make_deb_package.sh b/pandora_console/DEBIAN/make_deb_package.sh index 025ce73ae1..af3b144c81 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.732-190301" +pandora_version="7.0NG.732-190305" package_pear=0 package_pandora=1 diff --git a/pandora_console/general/mysqlerr.php b/pandora_console/general/mysqlerr.php new file mode 100644 index 0000000000..40da530386 --- /dev/null +++ b/pandora_console/general/mysqlerr.php @@ -0,0 +1,113 @@ + +
+ + + + + + + + + + + \ No newline at end of file diff --git a/pandora_console/godmode/setup/setup_auth.php b/pandora_console/godmode/setup/setup_auth.php index cdb75816cc..e02ec79270 100644 --- a/pandora_console/godmode/setup/setup_auth.php +++ b/pandora_console/godmode/setup/setup_auth.php @@ -43,7 +43,7 @@ if (is_ajax()) { if ($type_auth != 'mysql') { // Fallback to local authentication $row = []; - $row['name'] = __('Fallback to local authentication').ui_print_help_tip(__('Enable this option if you want to fallback to local authentication when remote (ldap etc...) authentication failed.'), true); + $row['name'] = __('Fallback to local authentication').ui_print_help_tip(__('Enable this option if you want to fallback to local authentication when remote (ldap etc...) authentication failed. Only available when \'Save password\' is enabled.'), true); $row['control'] = html_print_checkbox_switch('fallback_local_auth', 1, $config['fallback_local_auth'], true); $table->data['fallback_local_auth'] = $row; diff --git a/pandora_console/images/mysqlerr.png b/pandora_console/images/mysqlerr.png new file mode 100644 index 0000000000..7f6e0ffbc3 Binary files /dev/null and b/pandora_console/images/mysqlerr.png differ diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index e7d3463964..9969fc6dc5 100644 --- a/pandora_console/include/config_process.php +++ b/pandora_console/include/config_process.php @@ -20,7 +20,7 @@ /** * Pandora build version and version */ -$build_version = 'PC190301'; +$build_version = 'PC190305'; $pandora_version = 'v7.0NG.732'; // Do not overwrite default timezone set if defined. diff --git a/pandora_console/include/db/mysql.php b/pandora_console/include/db/mysql.php index 66366c1289..82b654e374 100644 --- a/pandora_console/include/db/mysql.php +++ b/pandora_console/include/db/mysql.php @@ -45,6 +45,7 @@ function mysql_connect_db($host=null, $db=null, $user=null, $pass=null, $port=nu if ($config['mysqli']) { $connect_id = mysqli_connect($host, $user, $pass, $db, $port); if (mysqli_connect_errno() > 0) { + include 'general/mysqlerr.php'; return false; } diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php index 8c4f5db14b..0ac9bb876f 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -82,17 +82,25 @@ function agents_get_agent_id_by_alias($alias) /** - * Creates an agent + * Creates an agent. * - * @param string Agent name. - * @param string Group to be included. - * @param int Agent interval - * @param string Agent IP + * @param string $name Agent name. + * @param string $id_group Group to be included. + * @param integer $interval Agent interval. + * @param string $ip_address Agent IP. + * @param mixed $values Other tagente fields. + * @param boolean $alias_as_name True to not assign an alias as name. * * @return integer New agent id if created. False if it could not be created. */ -function agents_create_agent($name, $id_group, $interval, $ip_address, $values=false) -{ +function agents_create_agent( + $name, + $id_group, + $interval, + $ip_address, + $values=false, + $alias_as_name=false +) { if (empty($name)) { return false; } @@ -101,7 +109,7 @@ function agents_create_agent($name, $id_group, $interval, $ip_address, $values=f return false; } - // Check interval greater than zero + // Check interval greater than zero. if ($interval < 0) { $interval = false; } @@ -115,7 +123,7 @@ function agents_create_agent($name, $id_group, $interval, $ip_address, $values=f } $values['alias'] = $name; - $values['nombre'] = hash('sha256', $name.'|'.$ip_address.'|'.time().'|'.sprintf('%04d', rand(0, 10000))); + $values['nombre'] = ($alias_as_name === false) ? hash('sha256', $name.'|'.$ip_address.'|'.time().'|'.sprintf('%04d', rand(0, 10000))) : $name; $values['id_grupo'] = $id_group; $values['intervalo'] = $interval; @@ -128,12 +136,12 @@ function agents_create_agent($name, $id_group, $interval, $ip_address, $values=f return false; } - // Create address for this agent in taddress + // Create address for this agent in taddress. if (!empty($ip_address)) { agents_add_address($id_agent, $ip_address); } - db_pandora_audit('Agent management', "New agent '$name' created"); + db_pandora_audit('Agent management', 'New agent '.$name.' created'); return $id_agent; } diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index 15570de763..fa8287f406 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -2272,35 +2272,29 @@ function events_page_responses($event, $childrens_ids=[]) /** * Replace macros in the target of a response and return it. - * If server_id > 0, is a metaconsole query. + * If server_id > 0, it's a metaconsole query. * - * @param integer $event_id Event_id. - * @param integer $response_id Response_id. - * @param integer $server_id Server_id. - * @param boolean $history History. + * @param integer $event_id Event identifier. + * @param integer $response_id Event response identifier. + * @param integer $server_id Node identifier (for metaconsole). + * @param boolean $history Use the history database or not. * - * @return string Target. + * @return string The response text with the macros applied. */ function events_get_response_target( - $event_id, - $response_id, - $server_id, - $history=false + int $event_id, + int $response_id, + int $server_id=0, + bool $history=false ) { global $config; - $event_response = db_get_row('tevent_response', 'id', $response_id); - - if ($server_id > 0) { - $meta = true; - } else { - $meta = false; - } - + // If server_id > 0, it's a metaconsole query. + $meta = $server_id > 0; $event_table = events_get_events_table($meta, $history); - $event = db_get_row($event_table, 'id_evento', $event_id); + $event_response = db_get_row('tevent_response', 'id', $response_id); $target = io_safe_output($event_response['target']); // Substitute each macro. @@ -2317,7 +2311,7 @@ function events_get_response_target( } $ip = db_get_value_filter('direccion', $agente_table_name, $filter); - // If agent has not an ip, display N/A. + // If agent has not an IP, display N/A. if ($ip === false) { $ip = __('N/A'); } @@ -2499,6 +2493,11 @@ function events_get_response_target( } } + // This will replace the macro with the current logged user. + if (strpos($target, '_current_user_') !== false) { + $target = str_replace('_current_user_', $config['id_user'], $target); + } + return $target; } diff --git a/pandora_console/include/functions_planned_downtimes.php b/pandora_console/include/functions_planned_downtimes.php index 6660a19f10..7f1a587b65 100644 --- a/pandora_console/include/functions_planned_downtimes.php +++ b/pandora_console/include/functions_planned_downtimes.php @@ -534,9 +534,10 @@ function planned_downtimes_migrate_malformed_downtimes_copy_items($original_down /** * Stop a planned downtime. * - * @param array Planned downtime data. + * @param array $downtime Planned downtime data. * - * @return mixes False on error or an array with the result and a message of the operation. + * @return mixed False on error or an array with the result and a message of + * the operation. */ function planned_downtimes_stop($downtime) { @@ -566,7 +567,9 @@ function planned_downtimes_stop($downtime) case 'periodically': return false; - break; + default: + // Nothing to do. + break; } $message .= ui_print_result_message( @@ -593,7 +596,7 @@ function planned_downtimes_stop($downtime) true ); - // Reenabled the Agents or Modules or alerts...depends of type + // Reenabled the Agents or Modules or alerts...depends of type. switch ($downtime['type_downtime']) { case 'quiet': $agents = db_get_all_rows_filter( @@ -658,7 +661,10 @@ function planned_downtimes_stop($downtime) foreach ($agents as $agent) { $result = db_process_sql_update( 'tagente', - ['disabled' => 0], + [ + 'disabled' => 0, + 'update_module_count' => 1, + ], ['id_agente' => $agent['id_agent']] ); @@ -702,6 +708,10 @@ function planned_downtimes_stop($downtime) } } break; + + default: + // Nothing to do. + break; } $message .= ui_print_info_message( diff --git a/pandora_console/include/graphs/functions_flot.php b/pandora_console/include/graphs/functions_flot.php index 637d02b34b..39c4c347dc 100644 --- a/pandora_console/include/graphs/functions_flot.php +++ b/pandora_console/include/graphs/functions_flot.php @@ -748,7 +748,7 @@ function flot_slicesbar_graph( if ($widgets) { $return = ""; } else { - $return = ""; + $return = ""; } } diff --git a/pandora_console/install.php b/pandora_console/install.php index 7808652e67..90b397128c 100644 --- a/pandora_console/install.php +++ b/pandora_console/install.php @@ -129,7 +129,7 @@