diff --git a/pandora_agents/unix/AIX/pandora_agent.conf b/pandora_agents/unix/AIX/pandora_agent.conf index 5f755ae4af..0d640badaa 100644 --- a/pandora_agents/unix/AIX/pandora_agent.conf +++ b/pandora_agents/unix/AIX/pandora_agent.conf @@ -87,6 +87,9 @@ transfer_mode tentacle # If set to 1 allows the agent to be configured via the web console (Only Enterprise version) # remote_config 1 +# Default 0, set to 1 to avoid module executions and report to server +# standby 1 + # If set to 1 start Drone Agent's Proxy Mode # proxy_mode 1 diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index 960dd1248c..2785fcb150 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.727-180927 +Version: 7.0NG.727-181010 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 53f00ab6fc..33335ae56b 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.727-180927" +pandora_version="7.0NG.727-181010" 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 bfe673cf6c..53dd20cf4f 100644 --- a/pandora_agents/unix/Darwin/pandora_agent.conf +++ b/pandora_agents/unix/Darwin/pandora_agent.conf @@ -117,6 +117,9 @@ transfer_mode tentacle # If set to 1 allows the agent to be configured via the web console (Only Enterprise version) #remote_config 1 +# Default 0, set to 1 to avoid module executions and report to server +# standby 1 + # If set to 1 start Drone Agent's Proxy Mode # proxy_mode 1 diff --git a/pandora_agents/unix/FreeBSD/pandora_agent.conf b/pandora_agents/unix/FreeBSD/pandora_agent.conf index d829dfe933..3590ee6551 100644 --- a/pandora_agents/unix/FreeBSD/pandora_agent.conf +++ b/pandora_agents/unix/FreeBSD/pandora_agent.conf @@ -130,6 +130,9 @@ transfer_mode tentacle # If set to 1 allows the agent to be configured via the web console (Only Enterprise version) remote_config 0 +# Default 0, set to 1 to avoid module executions and report to server +# standby 1 + # If set to 1 start Drone Agent's Proxy Mode #proxy_mode 1 diff --git a/pandora_agents/unix/HP-UX/pandora_agent.conf b/pandora_agents/unix/HP-UX/pandora_agent.conf index 29dc961d62..aa1dcb1592 100644 --- a/pandora_agents/unix/HP-UX/pandora_agent.conf +++ b/pandora_agents/unix/HP-UX/pandora_agent.conf @@ -89,6 +89,9 @@ transfer_mode tentacle # If set to 1 allows the agent to be configured via the web console (Only Enterprise version) # remote_config 1 +# Default 0, set to 1 to avoid module executions and report to server +# standby 1 + # If set to 1 start Drone Agent's Proxy Mode # proxy_mode 1 diff --git a/pandora_agents/unix/Linux/pandora_agent.conf b/pandora_agents/unix/Linux/pandora_agent.conf index c97d6b489f..fc55d1d872 100644 --- a/pandora_agents/unix/Linux/pandora_agent.conf +++ b/pandora_agents/unix/Linux/pandora_agent.conf @@ -136,6 +136,9 @@ transfer_mode tentacle # If set to 1 allows the agent to be configured via the web console (Only Enterprise version) remote_config 0 +# Default 0, set to 1 to avoid module executions and report to server +# standby 1 + # If set to 1 start Drone Agent's Proxy Mode # proxy_mode 1 diff --git a/pandora_agents/unix/NT4/pandora_agent.conf b/pandora_agents/unix/NT4/pandora_agent.conf index e493e71850..7a47602abc 100644 --- a/pandora_agents/unix/NT4/pandora_agent.conf +++ b/pandora_agents/unix/NT4/pandora_agent.conf @@ -41,9 +41,9 @@ udp_server_auth_address 0.0.0.0 # Group assigned for this agent (descriptive, p.e: Servers) #group Servers - -# Group password (if defined). -#group_password + +# Group password (if defined). +#group_password # Autotime: Enforce to server to ignore timestamp coming from this # agent, used when agents has no timer or it's inestable. 1 to enable @@ -102,6 +102,9 @@ transfer_mode tentacle # If set to 1 allows the agent to be configured via the web console (Only Enterprise version) remote_config 0 +# Default 0, set to 1 to avoid module executions and report to server +# standby 1 + # Number of threads to execute modules in parallel #agent_threads 1 diff --git a/pandora_agents/unix/NetBSD/pandora_agent.conf b/pandora_agents/unix/NetBSD/pandora_agent.conf index 6954f557e0..42d8c19a25 100644 --- a/pandora_agents/unix/NetBSD/pandora_agent.conf +++ b/pandora_agents/unix/NetBSD/pandora_agent.conf @@ -98,6 +98,9 @@ transfer_mode tentacle # If set to 1 allows the agent to be configured via the web console (Only Enterprise version) #remote_config 1 +# Default 0, set to 1 to avoid module executions and report to server +# standby 1 + # If set to 1 start Drone Agent's Proxy Mode #proxy_mode 1 diff --git a/pandora_agents/unix/SunOS/pandora_agent.conf b/pandora_agents/unix/SunOS/pandora_agent.conf index 8fe67c12d0..625bc89848 100644 --- a/pandora_agents/unix/SunOS/pandora_agent.conf +++ b/pandora_agents/unix/SunOS/pandora_agent.conf @@ -92,6 +92,9 @@ transfer_mode tentacle # If set to 1 allows the agent to be configured via the web console (Only Enterprise version) #remote_config 1 +# Default 0, set to 1 to avoid module executions and report to server +# standby 1 + # If set to 1 start Drone Agent's Proxy Mode #proxy_mode 1 diff --git a/pandora_agents/unix/pandora_agent b/pandora_agents/unix/pandora_agent index 02d8dbef17..7cf0c1e9a0 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.727'; -use constant AGENT_BUILD => '180927'; +use constant AGENT_BUILD => '181010'; # Agent log default file size maximum and instances use constant DEFAULT_MAX_LOG_SIZE => 600000; @@ -186,6 +186,7 @@ my %DefaultConf = ( 'xml_buffer' => 0, 'custom_id' => '', 'url_address' => '', + 'standby' => 0, ); my %Conf = %DefaultConf; @@ -1333,6 +1334,41 @@ sub check_collections () { } } +################################################################################ +# Sleep function +################################################################################ +sub sleep_agent { + my ($main_agent, $iter_base_time) = @_; + + # Sleep if main agent + if ($main_agent != 0) { + foreach my $broker_pid (@BrokerPid) { + waitpid ($broker_pid, 0); + } + + # Cron mode + exit (0) if ($Conf{'cron_mode'} == 1); + + $iter_base_time += $Conf{'intensive_interval'}; + my $now = time(); + + my $interval_remain = $iter_base_time - $now; + + if ($interval_remain >= 0) { + sleep ($interval_remain); + } else { + # don't sleep if iteraion took more than "intensive_interval" seconds + $iter_base_time = $now; # use current time as base time + } + } + # Finish if broker agent + else { + exit (0); + } + + return $iter_base_time; +} + ############################################################################### # Return the MD5 checksum of the given string as a hex string. # Pseudocode from: http://en.wikipedia.org/wiki/MD5#Pseudocode @@ -2959,6 +2995,12 @@ while (1) { } } + # Do not report to server if standby mode is enabled + if ($Conf{'standby'} eq '1' && $Conf{'debug'} ne '1') { + $iter_base_time = sleep_agent($main_agent, $iter_base_time); + next; + } + my $address; if(defined($Conf{'address'})) { @@ -3161,31 +3203,8 @@ while (1) { $SIG{'INT'} = \&udp_server_signal; } - # Sleep if main agent - if ($main_agent != 0) { - foreach my $broker_pid (@BrokerPid) { - waitpid ($broker_pid, 0); - } - - # Cron mode - last if ($Conf{'cron_mode'} == 1); - - $iter_base_time += $Conf{'intensive_interval'}; - my $now = time(); - - my $interval_remain = $iter_base_time - $now; - - if ($interval_remain >= 0) { - sleep ($interval_remain); - } else { - # don't sleep if iteraion took more than "intensive_interval" seconds - $iter_base_time = $now; # use current time as base time - } - } - # Finish if broker agent - else { - exit (0); - } + # Sleep agent function + $iter_base_time = sleep_agent($main_agent, $iter_base_time); } __END__ diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec index d1a9aff7a2..e0f718e4ae 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.727 -%define release 180927 +%define release 181010 Summary: Pandora FMS Linux agent, PERL version Name: %{name} @@ -24,7 +24,7 @@ Requires(preun): chkconfig /bin/rm /usr/sbin/userdel Requires: fileutils textutils unzip Requires: util-linux procps grep Requires: /sbin/ip /bin/awk -Requires: perl perl(Sys::Syslog) +Requires: perl perl(Sys::Syslog) perl(IO::Compress::Zip) # Required by plugins #Requires: sh-utils sed passwd net-tools rpm AutoReq: 0 diff --git a/pandora_agents/unix/pandora_agent.spec b/pandora_agents/unix/pandora_agent.spec index 6ca9c63f76..0c87f9e690 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.727 -%define release 180927 +%define release 181010 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 691f92b58e..b0ee6ccceb 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -10,7 +10,7 @@ # ********************************************************************** PI_VERSION="7.0NG.727" -PI_BUILD="180927" +PI_BUILD="181010" 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 e8caadc9c3..0901ac5234 100644 --- a/pandora_agents/win32/bin/pandora_agent.conf +++ b/pandora_agents/win32/bin/pandora_agent.conf @@ -82,6 +82,9 @@ server_port 41121 # Debug mode renames XML in the temp folder and continues running # debug 1 +# Default 0, set to 1 to avoid module executions and report to server +# standby 1 + # XML encoding (ISO-8859-1 by default). Most windows servers experience problems when you set to UTF-8. Other special codepages may be specified here. #encoding ISO-8859-1 diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index f9b33a9d34..6ca4584dc3 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{180927} +{181010} ViewReadme {Yes} diff --git a/pandora_agents/win32/modules/pandora_module_logchannel.cc b/pandora_agents/win32/modules/pandora_module_logchannel.cc index 2c7c056565..4ec72df63c 100755 --- a/pandora_agents/win32/modules/pandora_module_logchannel.cc +++ b/pandora_agents/win32/modules/pandora_module_logchannel.cc @@ -67,16 +67,16 @@ Pandora_Module_Logchannel::Pandora_Module_Logchannel (string name, string source // Set the type filter int type_number = -1; - if (upper_type.compare("ERROR") == 0) { - type_number = EVENTLOG_ERROR_TYPE; + if (upper_type.compare("CRITICAL") == 0) { + type_number = WINEVENT_LEVEL_CRITICAL; + } else if (upper_type.compare("ERROR") == 0) { + type_number = WINEVENT_LEVEL_ERROR; } else if (upper_type.compare("WARNING") == 0) { - type_number = EVENTLOG_WARNING_TYPE; - } else if (upper_type.compare("INFORMATION") == 0) { - type_number = EVENTLOG_INFORMATION_TYPE; - } else if (upper_type.compare("AUDIT SUCCESS") == 0) { - type_number = EVENTLOG_AUDIT_SUCCESS; - } else if (upper_type.compare("AUDIT FAILURE") == 0) { - type_number = EVENTLOG_AUDIT_FAILURE; + type_number = WINEVENT_LEVEL_WARNING; + } else if (upper_type.compare("INFO") == 0) { + type_number = WINEVENT_LEVEL_INFO; + } else if (upper_type.compare("VERBOSE") == 0) { + type_number = WINEVENT_LEVEL_VERBOSE; } // Append type to log query if (type_number != -1) { diff --git a/pandora_agents/win32/modules/pandora_module_logchannel.h b/pandora_agents/win32/modules/pandora_module_logchannel.h index 14617037c6..19cde78b93 100755 --- a/pandora_agents/win32/modules/pandora_module_logchannel.h +++ b/pandora_agents/win32/modules/pandora_module_logchannel.h @@ -29,6 +29,13 @@ // Log event read buffer size #define BUFFER_SIZE 1024 +// WINEVENT consts +#define WINEVENT_LEVEL_CRITICAL 1 +#define WINEVENT_LEVEL_ERROR 2 +#define WINEVENT_LEVEL_WARNING 3 +#define WINEVENT_LEVEL_INFO 4 +#define WINEVENT_LEVEL_VERBOSE 5 + // Types for pointers to Wevtapi.dll functions typedef EVT_HANDLE WINAPI (*EvtQueryT) (EVT_HANDLE Session, LPCWSTR Path, LPCWSTR Query, DWORD Flags); typedef WINBOOL WINAPI (*EvtNextT) (EVT_HANDLE ResultSet, DWORD EventArraySize, EVT_HANDLE* EventArray, DWORD Timeout, DWORD Flags, PDWORD Returned); diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index 4b3f32d9ac..3caa06fa7a 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.727(Build 180927)") +#define PANDORA_VERSION ("7.0NG.727(Build 181010)") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/pandora_windows_service.cc b/pandora_agents/win32/pandora_windows_service.cc index e843cdbc05..275ee60724 100644 --- a/pandora_agents/win32/pandora_windows_service.cc +++ b/pandora_agents/win32/pandora_windows_service.cc @@ -1869,7 +1869,7 @@ Pandora_Windows_Service::pandora_run_broker (string config) { server_addr = conf->getValue ("server_ip"); - if (this->broker_modules != NULL) { + if (this->broker_modules != NULL && !(conf->getValue ("standby") == "1" && !getPandoraDebug())) { this->broker_modules->goFirst (); while (! this->broker_modules->isLast ()) { @@ -1937,7 +1937,7 @@ Pandora_Windows_Service::pandora_run_broker (string config) { } } - if (data_flag == 1 || this->timestamp + this->interval_sec <= this->run_time) { + if ((data_flag == 1 || this->timestamp + this->interval_sec <= this->run_time) && !(conf->getValue ("standby") == "1" && !getPandoraDebug())) { // Send the XML if (!server_addr.empty ()) { @@ -1997,7 +1997,7 @@ Pandora_Windows_Service::pandora_run (int forced_run) { execution_number++; - if (this->modules != NULL) { + if (this->modules != NULL && !(conf->getValue ("standby") == "1" && !getPandoraDebug())) { this->modules->goFirst (); while (! this->modules->isLast ()) { @@ -2057,7 +2057,7 @@ Pandora_Windows_Service::pandora_run (int forced_run) { } } - if (forced_run == 1 || data_flag == 1 || this->timestamp + this->interval_sec <= this->run_time) { + if ((forced_run == 1 || data_flag == 1 || this->timestamp + this->interval_sec <= this->run_time) && !(conf->getValue ("standby") == "1" && !getPandoraDebug())) { // Send the XML if (!server_addr.empty ()) { diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index fd82225cbf..0d6f00b0cb 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.727(Build 180927))" + VALUE "ProductVersion", "(7.0NG.727(Build 181010))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index 54a24c2f2c..98acd458a4 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.727-180927 +Version: 7.0NG.727-181010 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 18673a2151..3ca2b46cf9 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.727-180927" +pandora_version="7.0NG.727-181010" package_pear=0 package_pandora=1 diff --git a/pandora_console/attachment/.htaccess b/pandora_console/attachment/.htaccess index 815f1e1776..d6a661a7f8 100644 --- a/pandora_console/attachment/.htaccess +++ b/pandora_console/attachment/.htaccess @@ -1,2 +1,3 @@ Order deny,allow Deny from All +Allow from localhost \ No newline at end of file diff --git a/pandora_console/extensions/module_groups.php b/pandora_console/extensions/module_groups.php index 9a4f66935c..b7eca3b3e9 100644 --- a/pandora_console/extensions/module_groups.php +++ b/pandora_console/extensions/module_groups.php @@ -17,103 +17,21 @@ global $config; -if (is_ajax ()) { - check_login (); - - require_once('include/functions_agents.php'); - - $get_info_alert_module_group = (bool)get_parameter('get_info_alert_module_group'); - $module_group = (int)get_parameter('module_group'); - $id_agent_group = (int)get_parameter('id_agent_group'); - - $data = false; - if ($get_info_alert_module_group) { - $agents = agents_get_group_agents($id_agent_group); - if (!empty($agents)) { - $alerts = agents_get_alerts_simple(array_keys($agents)); - foreach ($alerts as $alert) { - $module = db_get_row_filter('tagente_modulo', array('id_agente_modulo' => $alert['id_agent_module'])); - if ($module_group == $module['id_module_group']) { - if ($alert["times_fired"] > 0) { - $data = true; - echo '' . __('Number fired of alerts').': ' . $alert["times_fired"] . '
'; - $agent = db_get_row('tagente', 'id_agente', $module['id_agente']); - echo '' . __('Agent').': '; - echo io_safe_output($agent['nombre']) . '
'; - echo '' . __('Module') . ': '; - echo io_safe_output($module['nombre']) . '
'; - $template = db_get_row('talert_templates', 'id' , $alert['id_alert_template']); - echo '' . __('Alert template') . ': '; - echo io_safe_output($template['name']) . '
'; - - // This prevent from templates without predefined actions - if (empty($template['id_alert_action'])) - $template_id_alert_action = "''"; - else - $template_id_alert_action = $template['id_alert_action']; - - // True if the alert only has the default template action - $default_action = false; - // Try to get actions for the current alert - $sql = 'SELECT t2.name - FROM talert_template_module_actions t1 - INNER JOIN talert_actions t2 - INNER JOIN talert_template_modules t3 - ON t3.id = t1.id_alert_template_module - AND t1.id_alert_action = t2.id - WHERE (t3.id_alert_template = ' . $template['id'] . ' AND - t3.id_agent_module = ' . $module['id_agente_modulo'] . ');'; - - $actions = db_get_all_rows_sql($sql); - - // If this alert doesn't have actions try to get default action from template - if ($actions === false) { - $sql = 'SELECT name - FROM talert_actions - WHERE (id = ' . $template_id_alert_action . ');'; - - $default_action = true; - - $actions = db_get_all_rows_sql($sql); - } - - if ($actions === false) { - $actions = array(); - } - - echo '' . __('Actions') . ': ' . '
'; - echo ''; - if ($alert != end($alerts)) { - echo '
'; - } - } - } - } - if (!$data) { - echo 'These module/s have no alerts or alert/s are not fired'; - } - } - else { - echo 'No available data'; - } - } - else { - echo 'No available data'; - } -} +check_login (); -/** - * Translate the array texts using gettext - */ -function translate(&$item, $key) { - $item = __($item); +if (is_ajax ()) { + $get_info_alert_module_group = (bool)get_parameter('get_info_alert_module_group'); + + if ($get_info_alert_module_group) { + $send_tooltip = json_decode(io_safe_output(get_parameter('send_tooltip')), true); + echo ""; + } } /** @@ -121,169 +39,231 @@ function translate(&$item, $key) { * execute the code. */ function mainModuleGroups() { - global $config; //the useful global var of Pandora Console, it has many data can you use - - require_once ('include/functions_reporting.php'); - require_once($config['homedir'] . "/include/functions_agents.php"); - require_once($config['homedir'] . "/include/functions_users.php"); - - //The big query - $sql = "SELECT COUNT(id_agente) AS count, case utimestamp when 0 then 5 else estado end as estado - FROM tagente_estado - WHERE id_agente IN - (SELECT id_agente - FROM tagente ta LEFT JOIN tagent_secondary_group tasg - ON ta.id_agente = tasg.id_agent - WHERE (ta.id_grupo = %d OR tasg.id_group = %d) AND disabled IS FALSE - ) - AND id_agente_modulo IN - (SELECT id_agente_modulo - FROM tagente_modulo - WHERE id_module_group = %d AND disabled IS FALSE AND delete_pending IS FALSE) - GROUP BY estado"; + global $config; + + require_once($config['homedir'] . "/include/class/TreeGroup.class.php"); + require_once($config['homedir'] . "/include/functions_groupview.php"); + + $tree_group = new TreeGroup("group", "group"); + $tree_group->setPropagateCounters(false); + $tree_group->setDisplayAllGroups(true); + $tree_group->setFilter( array( + 'searchAgent' => '', + 'statusAgent' => AGENT_STATUS_ALL, + 'searchModule' => '', + 'statusModule' => -1, + 'groupID' => 0, + 'tagID' => 0, + 'show_not_init_agents' => 1, + 'show_not_init_modules' => 1 + )); + $info = $tree_group->getArray(); + $info = groupview_plain_groups($info); + $counter = count($info); + $offset = get_parameter('offset', 0); + $groups_view = $is_not_paginated + ? $info + : array_slice($info, $offset, $config['block_size']); + $agents_counters = array_reduce($groups_view, function($carry, $item){ + $carry[$item['id']] = $item; + return $carry; + }, array()); + + $ids_array = array_keys($agents_counters); + + $ids_group = implode(',', $ids_array); + + $condition_critical = modules_get_state_condition(AGENT_MODULE_STATUS_CRITICAL_ALERT); + $condition_warning = modules_get_state_condition(AGENT_MODULE_STATUS_WARNING_ALERT); + $condition_unknown = modules_get_state_condition(AGENT_MODULE_STATUS_UNKNOWN); + $condition_not_init = modules_get_state_condition(AGENT_MODULE_STATUS_NO_DATA); + $condition_normal = modules_get_state_condition(AGENT_MODULE_STATUS_NORMAL); + + $array_for_defect = array(); + $array_module_group = array(); + $array_data = array(); + + $sql = "SELECT id_mg, `name` FROM tmodule_group"; + $array_mod= db_get_all_rows_sql($sql); + + foreach ($array_mod as $key => $value) { + $array_module_group[$value['id_mg']] = $value['name']; + } + $array_module_group[0] = 'Nothing'; + foreach ($agents_counters as $key => $value) { + $array_for_defect[$key]['gm'] = $array_module_group; + $array_for_defect[$key]['data']['name'] = $value['name']; + $array_for_defect[$key]['data']['parent'] = $value['parent']; + $array_for_defect[$key]['data']['icon'] = $value['icon']; + } + +$sql = + "SELECT SUM(IF(tae.alert_fired <> 0, 1, 0)) AS alerts_module_count, + SUM(IF($condition_warning, 1, 0)) AS warning_module_count, + SUM(IF($condition_unknown, 1, 0)) AS unknown_module_count, + SUM(IF($condition_not_init, 1, 0)) AS notInit_module_count, + SUM(IF($condition_critical, 1, 0)) AS critical_module_count, + SUM(IF($condition_normal, 1, 0)) AS normal_module_count, + COUNT(tae.id_agente_modulo) AS total_count, + tmg.id_mg, + tmg.name as n, + tg.id_grupo + FROM ( + SELECT tam.id_agente_modulo, + tam.id_module_group, + ta.id_grupo AS g, + tae.estado, + SUM(IF(tatm.last_fired <> 0, 1, 0)) AS alert_fired + FROM tagente_modulo tam + LEFT JOIN talert_template_modules tatm + ON tatm.id_agent_module = tam.id_agente_modulo + AND tatm.times_fired = 1 + LEFT JOIN tagente_estado tae + ON tae.id_agente_modulo = tam.id_agente_modulo + INNER JOIN tagente ta + ON ta.id_agente = tam.id_agente + WHERE ta.disabled = 0 + AND tam.disabled = 0 + AND tam.delete_pending = 0 + AND ta.id_grupo IN ($ids_group) + GROUP BY tam.id_agente_modulo + UNION ALL + SELECT tam.id_agente_modulo, + tam.id_module_group, + tasg.id_group AS g, + tae.estado, + SUM(IF(tatm.last_fired <> 0, 1, 0)) AS alert_fired + FROM tagente_modulo tam + LEFT JOIN talert_template_modules tatm + ON tatm.id_agent_module = tam.id_agente_modulo + AND tatm.times_fired = 1 + LEFT JOIN tagente_estado tae + ON tae.id_agente_modulo = tam.id_agente_modulo + INNER JOIN tagente ta + ON ta.id_agente = tam.id_agente + INNER JOIN tagent_secondary_group tasg + ON ta.id_agente = tasg.id_agent + WHERE ta.disabled = 0 + AND tam.disabled = 0 + AND tam.delete_pending = 0 + AND tasg.id_group IN ($ids_group) + GROUP BY tam.id_agente_modulo, tasg.id_group + ) AS tae + RIGHT JOIN tgrupo tg + ON tg.id_grupo = tae.g + INNER JOIN ( + SELECT * FROM tmodule_group + UNION ALL + SELECT 0 AS 'id_mg', 'Nothing' AS 'name' + ) AS tmg + ON tae.id_module_group = tmg.id_mg + GROUP BY tae.g, tmg.id_mg"; + + $array_data_prev = db_get_all_rows_sql($sql); + + foreach ($array_data_prev as $key => $value) { + $array_data[$value['id_grupo']][$value['id_mg']] = $value; + } ui_print_page_header (__("Combined table of agent group and module group"), "images/module_group.png", false, "", false, ''); - - ui_print_info_message ( array('no_close'=>true, 'message'=> - __("This table shows in columns the modules group and in rows agents group. The cell shows all modules") ) - ); - - - $agentGroups = users_get_groups ($config['id_user'], "AR", false); - $modelGroups = users_get_all_model_groups(); - - if (!empty($agentGroups) && !empty($modelGroups)) { - array_walk($modelGroups, 'translate'); //Translate all head titles to language is set - - $table = null; - $table->headstyle[] = "width: 20%"; - foreach ($modelGroups as $i => $n) { - $table->headstyle[] = "min-width: 60px;max-width: 5%;text-align:center;"; - $modelGroups[$i] = ui_print_truncate_text($n, GENERIC_SIZE_TEXT, true, true, true, '…', 'color:#FFF'); - } - - $head = $modelGroups; - array_unshift($head, ' '); - - //Metaobject use in html_print_table - $table->align[0] = 'left'; //Align to left the first column. - $table->style[0] = 'color: #ffffff; '. - 'background-color: #373737; font-weight: bolder; padding-right: 10px; width:20%; '; - $table->head = $head; - $table->width = '100%'; - - //The content of table - $tableData = array(); - - //Create rows and cells - foreach ($agentGroups as $idAgentGroup => $name) { - $fired = false; - $row = array(); - - array_push($row, ui_print_truncate_text($name, GENERIC_SIZE_TEXT, true, true, true, '…', 'color:#FFF')); - - foreach ($modelGroups as $idModelGroup => $modelGroup) { - $fired = false; - $query = sprintf($sql, $idAgentGroup, $idAgentGroup, $idModelGroup); - - $rowsDB = db_get_all_rows_sql ($query); - - $agents = agents_get_group_agents($idAgentGroup); - - if (!empty($agents)) { - $alerts = agents_get_alerts_simple(array_keys($agents)); - - foreach ($alerts as $alert) { - $module = db_get_row_filter('tagente_modulo', array('id_agente_modulo' => $alert['id_agent_module'])); - - if ($idModelGroup == $module['id_module_group']) { - if ($alert["times_fired"] > 0) { - $fired = true; - } - } - } - } - - $states = array(); - if ($rowsDB !== false) { - foreach ($rowsDB as $rowDB) { - $states[$rowDB['estado']] = $rowDB['count']; - } - } - - $count = 0; - foreach ($states as $idState => $state) { - $count += $state; - } - - $color = 'transparent'; //Defaut color for cell - $font_color = '#000000'; //Default font color for cell - if ($count == 0) { - $color = '#eeeeee'; //Soft grey when the cell for this model group and agent group hasn't modules. - $alinkStart = ''; - $alinkEnd = ''; - } - else { - - if ($fired) { - $color = '#FFA631'; //Orange when the cell for this model group and agent has at least one alert fired. - } - else if (array_key_exists(1, $states)) { - $color = '#FC4444'; //Red when the cell for this model group and agent has at least one module in critical state and the rest in any state. - $font_color = '#ffffff'; - } - elseif (array_key_exists(2, $states)) { - $color = '#FAD403'; //Yellow when the cell for this model group and agent has at least one in warning state and the rest in green state. - } - elseif (array_key_exists(3, $states)) { - $color = '#B2B2B2 '; //Grey when the cell for this model group and agent has at least one module in unknown state and the rest in any state. - } - elseif (array_key_exists(0, $states)) { - $color = '#80BA27'; //Green when the cell for this model group and agent has OK state all modules. - } - elseif (array_key_exists(5, $states)) { - $color = '#5BB6E5'; // Blue when the cell for this module group and all modules have not init value. - } - - - $alinkStart = ''; - $alinkEnd = ''; - } - - array_push($row, - '
- ' . $alinkStart . $count . $alinkEnd . '
'); - } - array_push($tableData,$row); - } - $table->data = $tableData; - echo "
"; - html_print_table($table); - echo "
"; - - echo "
"; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo "
" . __('Legend') . "
" . __("Orange cell when the module group and agent have at least one alarm fired.") . "
" . __("Red cell when the module group and agent have at least one module in critical status and the others in any status") . "
" . __("Yellow cell when the module group and agent have at least one in warning status and the others in grey or green status") . "
" . __("Green cell when the module group and agent have all modules in OK status") . "
" . __("Grey cell when the module group and agent have at least one in unknown status and the others in green status") . "
" .__("Blue cell when the module group and agent have all modules in not init status.") . "
"; + if(count($array_for_defect) > 0){ + $table = new StdClass(); + $table->style[0] = 'color: #ffffff; background-color: #373737; font-weight: bolder; padding-right: 10px; min-width: 230px;'; + $table->width = '100%'; + + $head[0] = __('Groups'); + $headstyle[0] = "width: 20%; font-weight: bolder;"; + foreach ($array_module_group as $key => $value) { + $headstyle[] = "min-width: 60px;max-width: 5%;text-align:center; color: #ffffff; background-color: #373737; font-weight: bolder;"; + $head[] = ui_print_truncate_text($value, GENERIC_SIZE_TEXT, true, true, true, '…', 'color:#FFF'); + } + + $i = 0; + foreach ($array_for_defect as $key => $value) { + $deep = groups_get_group_deep($key); + $data[$i][0] = $deep . ui_print_truncate_text($value['data']['name'], GENERIC_SIZE_TEXT, true, true, true, '…', 'color:#FFF'); + $j = 1; + if(isset($array_data[$key])){ + foreach ($value['gm'] as $k => $v) { + if(isset($array_data[$key][$k])){ + $send_tooltip = json_encode($array_data[$key][$k]); + $rel = "ajax.php?page=extensions/module_groups&get_info_alert_module_group=1&send_tooltip=" . $send_tooltip; + $url = "index.php?sec=estado&sec2=operation/agentes/status_monitor&status=-1&ag_group=" . $key . "&modulegroup=" . $k; + + if ($array_data[$key][$k]['alerts_module_count'] != 0) { + $color = '#FFA631'; //Orange when the cell for this model group and agent has at least one alert fired. + } + else if ($array_data[$key][$k]['critical_module_count'] != 0) { + $color = '#FC4444'; //Red when the cell for this model group and agent has at least one module in critical state and the rest in any state. + } + elseif ($array_data[$key][$k]['warning_module_count'] != 0) { + $color = '#FAD403'; //Yellow when the cell for this model group and agent has at least one in warning state and the rest in green state. + } + elseif ($array_data[$key][$k]['unknown_module_count'] != 0) { + $color = '#B2B2B2 '; //Grey when the cell for this model group and agent has at least one module in unknown state and the rest in any state. + } + elseif ($array_data[$key][$k]['normal_module_count'] != 0) { + $color = '#80BA27'; //Green when the cell for this model group and agent has OK state all modules. + } + elseif ($array_data[$key][$k]['notInit_module_count'] != 0) { + $color = '#5BB6E5'; // Blue when the cell for this module group and all modules have not init value. + } + + $data[$i][$j] ="
"; + $data[$i][$j] .= ""; + $data[$i][$j] .= $array_data[$key][$k]['total_count']; + $data[$i][$j] .= "
"; + } + else{ + $data[$i][$j] ="
"; + $data[$i][$j] .= 0; + $data[$i][$j] .= "
"; + } + $j++; + } + } + else{ + foreach ($value['gm'] as $k => $v) { + $data[$i][$j] ="
"; + $data[$i][$j] .= 0; + $data[$i][$j] .= "
"; + $j++; + } + } + $i++; + } + + $table->head = $head; + $table->headstyle = $headstyle; + $table->data = $data; + + ui_pagination($counter); + + echo "
"; + html_print_table($table); echo "
"; + + ui_pagination($counter); + + echo "
"; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo "
" . __('Legend') . "
" . __("Orange cell when the module group and agent have at least one alarm fired.") . "
" . __("Red cell when the module group and agent have at least one module in critical status and the others in any status") . "
" . __("Yellow cell when the module group and agent have at least one in warning status and the others in grey or green status") . "
" . __("Grey cell when the module group and agent have at least one in unknown status and the others in green status") . "
" . __("Green cell when the module group and agent have all modules in OK status") . "
" .__("Blue cell when the module group and agent have all modules in not init status.") . "
"; + echo "
"; + } else { - echo "
".__('There are no defined groups or module groups')."
"; + ui_print_info_message ( array('no_close'=>true, 'message'=> __("This table shows in columns the modules group and in rows agents group. The cell shows all modules") )); + ui_print_info_message ( array('no_close'=>true, 'message'=> __('There are no defined groups or module groups') )); } - + ui_require_css_file('cluetip'); ui_require_jquery_file('cluetip'); ?> @@ -292,7 +272,8 @@ function mainModuleGroups() { $("a.info_cell").cluetip ({ arrows: true, attribute: 'rel', - cluetipClass: 'default' + cluetipClass: 'default', + width: '200px' }); }); diff --git a/pandora_console/extensions/realtime_graphs/realtime_graphs.js b/pandora_console/extensions/realtime_graphs/realtime_graphs.js index 64960cc658..34da7b1704 100644 --- a/pandora_console/extensions/realtime_graphs/realtime_graphs.js +++ b/pandora_console/extensions/realtime_graphs/realtime_graphs.js @@ -28,6 +28,11 @@ return formattedTime; } }, + yaxis: { + tickFormatter: function (value, axis) { + return shortNumber(value); + } + }, series: { lines: { lineWidth: 2, @@ -158,6 +163,22 @@ }); } + function shortNumber (number) { + if (Math.round(number) != number) return number; + number = Number.parseInt(number); + if (Number.isNaN(number)) return number; + + var shorts = ["", "K", "M", "G", "T", "P", "E", "Z", "Y"]; + var pos = 0; + + while (number >= 1000 || number <= -1000) { + pos++; + number = number / 1000; + } + + return number + " " + shorts[pos]; + } + $('#graph').change(function() { $('form#realgraph').submit(); }); diff --git a/pandora_console/extras/mr/21.sql b/pandora_console/extras/mr/21.sql new file mode 100644 index 0000000000..8283aa56a3 --- /dev/null +++ b/pandora_console/extras/mr/21.sql @@ -0,0 +1,12 @@ +START TRANSACTION; + +ALTER TABLE tlayout_data ADD COLUMN `show_last_value` tinyint(1) UNSIGNED NULL default '0'; +ALTER TABLE tlayout MODIFY `name` varchar(600) NOT NULL; + +ALTER TABLE tmetaconsole_setup ADD COLUMN `meta_dbuser` text; +ALTER TABLE tmetaconsole_setup ADD COLUMN `meta_dbpass` text; +ALTER TABLE tmetaconsole_setup ADD COLUMN `meta_dbhost` text; +ALTER TABLE tmetaconsole_setup ADD COLUMN `meta_dbport` text; +ALTER TABLE tmetaconsole_setup ADD COLUMN `meta_dbname` text; + +COMMIT; diff --git a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql index 29c5bb4f8b..b6d3d6d580 100644 --- a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql +++ b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql @@ -341,13 +341,18 @@ CREATE TABLE IF NOT EXISTS `ttrap_custom_values` ( -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `tmetaconsole_setup` ( `id` int(10) NOT NULL auto_increment primary key, - `server_name` text default '', - `server_url` text default '', - `dbuser` text default '', - `dbpass` text default '', - `dbhost` text default '', - `dbport` text default '', - `dbname` text default '', + `server_name` text, + `server_url` text, + `dbuser` text, + `dbpass` text, + `dbhost` text, + `dbport` text, + `dbname` text, + `meta_dbuser` text, + `meta_dbpass` text, + `meta_dbhost` text, + `meta_dbport` text, + `meta_dbname` text, `auth_token` text default '', `id_group` int(10) unsigned NOT NULL default 0, `api_password` text NOT NULL, @@ -1279,6 +1284,7 @@ ALTER TABLE `tservice` ADD COLUMN `evaluate_sla` int(1) NOT NULL default 0; -- --------------------------------------------------------------------- ALTER TABLE tlayout ADD `background_color` varchar(50) NOT NULL default '#FFF'; ALTER TABLE tlayout ADD `is_favourite` int(1) NOT NULL DEFAULT 0; +ALTER TABLE tlayout MODIFY `name` varchar(600) NOT NULL; UPDATE tlayout SET is_favourite = 1 WHERE name REGEXP '^(' OR name REGEXP '^\\['; @@ -1294,6 +1300,7 @@ ALTER TABLE tlayout_data ADD COLUMN `show_on_top` tinyint(1) NOT NULL default '0 ALTER TABLE tlayout_data ADD COLUMN `clock_animation` varchar(60) NOT NULL default "analogic_1"; ALTER TABLE tlayout_data ADD COLUMN `time_format` varchar(60) NOT NULL default "time"; ALTER TABLE tlayout_data ADD COLUMN `timezone` varchar(60) NOT NULL default "Europe/Madrid"; +ALTER TABLE tlayout_data ADD COLUMN `show_last_value` tinyint(1) UNSIGNED NULL default '0'; -- --------------------------------------------------------------------- -- Table `tagent_custom_fields` diff --git a/pandora_console/godmode/agentes/agent_manager.php b/pandora_console/godmode/agentes/agent_manager.php index 0196fb9393..4e6be0e725 100644 --- a/pandora_console/godmode/agentes/agent_manager.php +++ b/pandora_console/godmode/agentes/agent_manager.php @@ -479,6 +479,7 @@ $table->data[3][1] .= __('Autodisable mode') . ' ' . // Status (Disabled / Enabled) $table->data[4][0] = __('Status'); $table->data[4][1] = __('Disabled') . ' ' . + ui_print_help_tip(__('If the remote configuration is enabled, it will also go into standby mode when disabling it.'), true) . ' ' . html_print_radio_button_extended ("disabled", 1, '', $disabled, false, '', 'style="margin-right: 40px;"', true); $table->data[4][1] .= __('Enabled') . ' ' . html_print_radio_button_extended ("disabled", 0, '', $disabled, false, '', 'style="margin-right: 40px;"', true); diff --git a/pandora_console/godmode/agentes/configurar_agente.php b/pandora_console/godmode/agentes/configurar_agente.php index 81c8dc714f..49a9a85d9a 100644 --- a/pandora_console/godmode/agentes/configurar_agente.php +++ b/pandora_console/godmode/agentes/configurar_agente.php @@ -755,7 +755,7 @@ if ($update_agent) { // if modified some agent paramenter $quiet = (int) get_parameter("quiet", 0); $cps = (int) get_parameter("cps", 0); - $old_interval = db_get_value('intervalo', 'tagente', 'id_agente', $id_agente); + $old_values = db_get_row('tagente', 'id_agente', $id_agente); $fields = db_get_all_fields_in_table('tagent_custom_fields'); if ($fields === false) $fields = array(); @@ -855,11 +855,21 @@ if ($update_agent) { // if modified some agent paramenter // Update the agent from the metaconsole cache enterprise_include_once('include/functions_agents.php'); enterprise_hook ('agent_update_from_cache', array($id_agente, $values,$server_name)); - - if ($old_interval != $intervalo) { - enterprise_hook('config_agents_update_config_interval', array($id_agente, $intervalo)); + + # Update the configuration files + if ($old_values['intervalo'] != $intervalo) { + enterprise_hook( + 'config_agents_update_config_token', + array($id_agente, 'interval', $intervalo) + ); } - + if ($old_values['disabled'] != $disabled) { + enterprise_hook( + 'config_agents_update_config_token', + array($id_agente, 'standby', $disabled ? "1" : "0") + ); + } + if($tpolicy_group_old){ foreach ($tpolicy_group_old as $key => $value) { $tpolicy_agents_old= db_get_sql("SELECT * FROM tpolicy_agents @@ -914,8 +924,9 @@ if ($update_agent) { // if modified some agent paramenter enterprise_hook ('update_agent', array ($id_agente)); ui_print_success_message (__('Successfully updated')); + $unsafe_alias = io_safe_output($alias); db_pandora_audit("Agent management", - "Updated agent $alias", false, false, $info); + "Updated agent $unsafe_alias", false, false, $info); } } @@ -1416,7 +1427,7 @@ if ($update_module) { $edit_module = true; db_pandora_audit("Agent management", - "Fail to try update module '$name' for agent " . $agent["alias"]); + "Fail to try update module '".io_safe_output($name)."' for agent " . io_safe_output($agent["alias"])); } else { if ($prediction_module == 3) { @@ -1434,7 +1445,7 @@ if ($update_module) { $agent = db_get_row ('tagente', 'id_agente', $id_agente); db_pandora_audit("Agent management", - "Updated module '$name' for agent ".$agent["alias"], false, false, io_json_mb_encode($values)); + "Updated module '".io_safe_output($name)."' for agent ". io_safe_output($agent["alias"]), false, false, io_json_mb_encode($values)); } } @@ -1575,7 +1586,7 @@ if ($create_module) { $edit_module = true; $moduletype = $id_module; db_pandora_audit("Agent management", - "Fail to try added module '$name' for agent ".$agent["alias"]); + "Fail to try added module '".io_safe_output($name)."' for agent ".io_safe_output($agent["alias"])); } else { if ($prediction_module == 3) { @@ -1593,7 +1604,7 @@ if ($create_module) { $agent = db_get_row ('tagente', 'id_agente', $id_agente); db_pandora_audit("Agent management", - "Added module '$name' for agent ".$agent["alias"], false, true, io_json_mb_encode($values)); + "Added module '".io_safe_output($name)."' for agent ".io_safe_output($agent["alias"]), false, true, io_json_mb_encode($values)); } } @@ -1708,12 +1719,18 @@ if ($delete_module) { // DELETE agent module ! ui_print_error_message(__('There was a problem deleting the module')); } else { - ui_print_success_message(__('Module deleted succesfully')); + + echo ''; $agent = db_get_row ('tagente', 'id_agente', $id_agente); db_pandora_audit("Agent management", - "Deleted module '".$module_data["nombre"]."' for agent ".$agent["alias"]); + "Deleted module '".io_safe_output($module_data["nombre"])."' for agent ".io_safe_output($agent["alias"])); } + + } // MODULE DUPLICATION @@ -1743,11 +1760,11 @@ if (!empty($duplicate_module)) { // DUPLICATE agent module ! if ($result) { db_pandora_audit("Agent management", - "Duplicate module '".$id_duplicate_module."' for agent " . $agent["alias"] . " with the new id for clon " . $result); + "Duplicate module '".$id_duplicate_module."' for agent " . io_safe_output($agent["alias"]) . " with the new id for clon " . $result); } else { db_pandora_audit("Agent management", - "Fail to try duplicate module '".$id_duplicate_module."' for agent " . $agent["alias"]); + "Fail to try duplicate module '".$id_duplicate_module."' for agent " . io_safe_output($agent["alias"])); } } @@ -1931,11 +1948,11 @@ switch ($tab) { resizable: true, draggable: true, modal: true, - height: 220, + height: 240, width: 600, title: 'Changing the module name of a satellite agent', open: function(){ - $('#dialog').html('

Warning
The names of the modules of a satellite should not be
altered manually. Unless you are absolutely certain of
the process, do not alter these names.

'); + $('#dialog').html('

Warning
The names of the modules of a satellite should not be altered manually. Unless you are absolutely certain of the process, do not alter these names.

'); }, buttons: [{ text: "Ok", @@ -1965,11 +1982,11 @@ switch ($tab) { resizable: true, draggable: true, modal: true, - height: 280, - width: 670, + height: 240, + width: 650, title: 'Changing snmp module name', open: function(){ - $('#dialog').html('

Warning
If you change the name of this module, various features
associated with this module, such as network maps,
interface graphs or other network modules, may no longer
work. If you are not completely sure of the process, please
do not change the name of the module.

'); + $('#dialog').html('

Warning
If you change the name of this module, various features associated with this module, such as network maps, interface graphs or other network modules, may no longer work. If you are not completely sure of the process, please do not change the name of the module.

'); }, buttons: [{ text: "Ok", diff --git a/pandora_console/godmode/agentes/module_manager.php b/pandora_console/godmode/agentes/module_manager.php index 8f95620398..dc606ad1f5 100644 --- a/pandora_console/godmode/agentes/module_manager.php +++ b/pandora_console/godmode/agentes/module_manager.php @@ -43,6 +43,7 @@ echo '"; echo "'; + $show_last_value = array('0' => __('Hide last value on boolean modules'), '1' => __('Enabled'), '2' => __('Disabled')); + $form_items['show_last_value_row'] = array(); + $form_items['show_last_value_row']['items'] = array('static_graph'); + $form_items['show_last_value_row']['html'] = + ' + '; + $form_items['module_graph_size_row'] = array(); $form_items['module_graph_size_row']['items'] = array('module_graph', 'datos'); $form_items['module_graph_size_row']['html'] = ' diff --git a/pandora_console/include/graphs/flot/pandora.flot.js b/pandora_console/include/graphs/flot/pandora.flot.js index a71cb5eb19..45208c12b8 100644 --- a/pandora_console/include/graphs/flot/pandora.flot.js +++ b/pandora_console/include/graphs/flot/pandora.flot.js @@ -2240,7 +2240,6 @@ function pandoraFlotArea( graph_id, values, legend, } function yFormatter(v, axis) { - axis.datamin = 0; if (short_data) { var formatted = number_format(v, force_integer, "", short_data); } diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index 8cdfa3a9e7..a09df577a1 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -4726,3 +4726,41 @@ a.up_arrow { tr:last-child > td > a.down_arrow, tr:first-child > td > a.up_arrow { visibility: hidden; } + +.group_modules_status_box>tbody>tr>td{ + border-bottom: 1px solid #E2E2E2; + border-collapse: collapse; + border-spacing:0; + width: 10%; + height: 20px; +} + +.group_modules_status_div{ + color: #FFF; + width: 100%; + height: 100%; + text-align: left; + display: block; + vertical-align: middle; + line-height: 20px; +} + +.tooltip_counters h3{ + font-size: 12pt; + padding-bottom: 10px !important; + text-align: center; +} + +.tooltip_counters li{ + font-size: 8pt; + margin: 2px; + margin-left: 5px; + +} +.tooltip_counters li div{ + width: 12px; + height: 12px; + border-radius: 3px; + float: left; + margin-right: 5px; +} \ No newline at end of file diff --git a/pandora_console/index.php b/pandora_console/index.php index 015ab613f9..c1f55dd120 100755 --- a/pandora_console/index.php +++ b/pandora_console/index.php @@ -359,7 +359,7 @@ if (! isset ($config['id_user'])) { if ($blocked) { require_once ('general/login_page.php'); - db_pandora_audit("Password expired", "Password expired: ".$nick, $nick); + db_pandora_audit("Password expired", "Password expired: ".io_safe_output($nick), io_safe_output($nick)); while (@ob_end_flush ()); exit (""); } @@ -382,7 +382,7 @@ if (! isset ($config['id_user'])) { require_once ('general/login_page.php'); db_pandora_audit("Password expired", - "Password expired: " . $nick, $nick); + "Password expired: " . io_safe_output($nick), $nick); while (@ob_end_flush ()); exit (""); } @@ -539,20 +539,20 @@ if (! isset ($config['id_user'])) { if ((!is_user_admin($nick) || $config['enable_pass_policy_admin']) && file_exists (ENTERPRISE_DIR . "/load_enterprise.php")) { $blocked = login_check_blocked($nick); } - + $nick_usable = io_safe_output($nick); if (!$blocked) { if (file_exists (ENTERPRISE_DIR . "/load_enterprise.php")) { login_check_failed($nick); //Checks failed attempts } $login_failed = true; require_once ('general/login_page.php'); - db_pandora_audit("Logon Failed", "Invalid login: ".$nick, $nick); + db_pandora_audit("Logon Failed", "Invalid login: ".$nick_usable, $nick_usable); while (@ob_end_flush ()); exit (""); } else { require_once ('general/login_page.php'); - db_pandora_audit("Logon Failed", "Invalid login: ".$nick, $nick); + db_pandora_audit("Logon Failed", "Invalid login: ".$nick_usable, $nick_usable); while (@ob_end_flush ()); exit (""); } diff --git a/pandora_console/install.php b/pandora_console/install.php index fe1e2718a3..f7b85caf96 100755 --- a/pandora_console/install.php +++ b/pandora_console/install.php @@ -71,7 +71,7 @@
0)"; break; case AGENT_STATUS_WARNING: - $filter[] = "(critical_count = 0 AND warning_count > 0)"; + $filter[] = "( + critical_count = 0 + AND warning_count > 0 + AND total_count > 0)"; break; case AGENT_STATUS_CRITICAL: $filter[] = "(critical_count > 0)"; break; case AGENT_STATUS_UNKNOWN: - $filter[] = "(critical_count = 0 AND warning_count = 0 AND unknown_count > 0)"; + $filter[] = "( + critical_count = 0 + AND warning_count = 0 + AND unknown_count > 0)"; break; case AGENT_STATUS_NOT_NORMAL: - $filter[] = "(normal_count <> total_count)"; + $filter[] = "( + critical_count > 0 + OR warning_count > 0 + OR unknown_count > 0 + OR total_count = 0 + OR total_count = notinit_count)"; break; case AGENT_STATUS_NOT_INIT: - $filter[] = "(notinit_count = total_count)"; + $filter[] = "( + total_count = 0 + OR total_count = notinit_count)"; break; } $filter['order'] = "alias ASC"; diff --git a/pandora_console/operation/events/events.build_table.php b/pandora_console/operation/events/events.build_table.php index 84b995af28..6b5b1a033b 100644 --- a/pandora_console/operation/events/events.build_table.php +++ b/pandora_console/operation/events/events.build_table.php @@ -40,11 +40,13 @@ $params = array ( // Events query params "search" => io_safe_input($search), + "event_type" => $event_type, "severity" => $severity, "status" => $status, "id_group" => $id_group, "recursion" => $recursion, "refr" => (int)get_parameter("refr", 0), + "id_agent" => $id_agent, "id_agent_module" => $id_agent_module, "pagination" => $pagination, "group_rep" => $group_rep, @@ -156,12 +158,13 @@ else { $table->align[$i] = 'left'; $i++; - if (in_array('server_name', $show_fields)) { + foreach ($show_fields as $k_s => $fields) { + if ($fields == 'server_name') { $table->head[$i] = __('Server'); $table->align[$i] = 'left'; $i++; } - if (in_array('estado', $show_fields)) { + if ($fields == 'estado') { $table->head[$i] = __('Status') . html_print_sort_arrows( array_merge($params, array('sort_field' => 'status')), 'sort' @@ -169,7 +172,7 @@ else { $table->align[$i] = 'left'; $i++; } - if (in_array('id_evento', $show_fields)) { + if ($fields == 'id_evento') { $table->head[$i] = __('Event ID') . html_print_sort_arrows( array_merge($params, array('sort_field' => 'event_id')), 'sort' @@ -178,7 +181,7 @@ else { $i++; } - if (in_array('evento', $show_fields)) { + if ($fields == 'evento') { $table->head[$i] = __('Event Name') . html_print_sort_arrows( array_merge($params, array('sort_field' => 'event_name')), 'sort' @@ -187,7 +190,7 @@ else { $table->style[$i] = 'min-width: 200px; max-width: 350px; word-break: break-all;'; $i++; } - if (in_array('id_agente', $show_fields)) { + if ($fields == 'id_agente') { $table->head[$i] = __('Agent name') . html_print_sort_arrows( array_merge($params, array('sort_field' => 'agent_id')), 'sort' @@ -196,7 +199,7 @@ else { $table->style[$i] = 'max-width: 350px; word-break: break-all;'; $i++; } - if (in_array('timestamp', $show_fields)) { + if ($fields == 'timestamp') { $table->head[$i] = __('Timestamp') . html_print_sort_arrows( array_merge($params, array('sort_field' => 'timestamp')), 'sort' @@ -205,7 +208,7 @@ else { $i++; } - if (in_array('id_usuario', $show_fields)) { + if ($fields == 'id_usuario') { $table->head[$i] = __('User') . html_print_sort_arrows( array_merge($params, array('sort_field' => 'user_id')), 'sort' @@ -214,7 +217,7 @@ else { $i++; } - if (in_array('owner_user', $show_fields)) { + if ($fields == 'owner_user') { $table->head[$i] = __('Owner') . html_print_sort_arrows( array_merge($params, array('sort_field' => 'owner')), 'sort' @@ -223,7 +226,7 @@ else { $i++; } - if (in_array('id_grupo', $show_fields)) { + if ($fields == 'id_grupo') { $table->head[$i] = __('Group') . html_print_sort_arrows( array_merge($params, array('sort_field' => 'group_id')), 'sort' @@ -232,7 +235,7 @@ else { $i++; } - if (in_array('event_type', $show_fields)) { + if ($fields == 'event_type') { $table->head[$i] = __('Event Type') . html_print_sort_arrows( array_merge($params, array('sort_field' => 'event_type')), 'sort' @@ -242,7 +245,7 @@ else { $table->style[$i] = 'min-width: 85px;'; $i++; } - if (in_array('id_agentmodule', $show_fields)) { + if ($fields == 'id_agentmodule') { $table->head[$i] = __('Module Name') . html_print_sort_arrows( array_merge($params, array('sort_field' => 'module_name')), 'sort' @@ -251,7 +254,7 @@ else { $i++; } - if (in_array('id_alert_am', $show_fields)) { + if ($fields == 'id_alert_am') { $table->head[$i] = __('Alert') . html_print_sort_arrows( array_merge($params, array('sort_field' => 'alert_id')), 'sort' @@ -261,7 +264,7 @@ else { $i++; } - if (in_array('criticity', $show_fields)) { + if ($fields == 'criticity') { $table->head[$i] = __('Severity') . html_print_sort_arrows( array_merge($params, array('sort_field' => 'criticity')), 'sort' @@ -270,7 +273,7 @@ else { $i++; } - if (in_array('user_comment', $show_fields)) { + if ($fields == 'user_comment') { $table->head[$i] = __('Comment') . html_print_sort_arrows( array_merge($params, array('sort_field' => 'comment')), 'sort' @@ -279,7 +282,7 @@ else { $i++; } - if (in_array('tags', $show_fields)) { + if ($fields == 'tags') { $table->head[$i] = __('Tags') . html_print_sort_arrows( array_merge($params, array('sort_field' => 'tags')), 'sort' @@ -288,7 +291,7 @@ else { $i++; } - if (in_array('source', $show_fields)) { + if ($fields == 'source') { $table->head[$i] = __('Source') . html_print_sort_arrows( array_merge($params, array('sort_field' => 'source')), 'sort' @@ -296,7 +299,7 @@ else { $i++; } - if (in_array('id_extra', $show_fields)) { + if ($fields == 'id_extra') { $table->head[$i] = __('Extra ID') . html_print_sort_arrows( array_merge($params, array('sort_field' => 'extra_id')), 'sort' @@ -305,7 +308,7 @@ else { $i++; } - if (in_array('ack_utimestamp', $show_fields)) { + if ($fields == 'ack_utimestamp') { $table->head[$i] = __('ACK Timestamp') . html_print_sort_arrows( array_merge($params, array('sort_field' => 'ack_utimestamp')), 'sort' @@ -314,13 +317,13 @@ else { $i++; } - if (in_array('instructions', $show_fields)) { + if ($fields == 'instructions') { $table->head[$i] = __('Instructions'); $table->align[$i] = 'left'; $i++; } - if (in_array('data', $show_fields)) { + if ($fields == 'data') { $table->head[$i] = __('Data') . html_print_sort_arrows( array_merge($params, array('sort_field' => 'data')), 'sort' @@ -329,7 +332,7 @@ else { $i++; } - if (in_array('module_status', $show_fields)) { + if ($fields == 'module_status') { $table->head[$i] = __('Module Status') . html_print_sort_arrows( array_merge($params, array('sort_field' => 'module_status')), 'sort' @@ -337,6 +340,7 @@ else { $i++; } + } if ($i != 0 && $allow_action) { $table->head[$i] = __('Action'); $table->align[$i] = 'left'; @@ -447,35 +451,6 @@ else { $i++; - if (in_array('server_name',$show_fields)) { - if ($meta) { - if (can_user_access_node ()) { - $data[$i] = "" . $event["server_name"] . ""; - } - else { - $data[$i] = $event["server_name"]; - } - } - else { - $data[$i] = db_get_value('name','tserver'); - } - $table->cellclass[count($table->data)][$i] = $myclass; - $i++; - } - if (in_array('estado',$show_fields)) { - $data[$i] = html_print_image ($img_st, true, - array ("class" => "image_status", - "title" => $title_st, - "id" => 'status_img_'.$event["id_evento"])); - $table->cellstyle[count($table->data)][$i] = 'background: #F3F3F3;'; - $i++; - } - if (in_array('id_evento',$show_fields)) { - $data[$i] = $event["id_evento"]; - $table->cellclass[count($table->data)][$i] = $myclass; - $i++; - } - switch ($event["criticity"]) { default: case 0: @@ -500,8 +475,37 @@ else { $img_sev = "images/status_sets/default/severity_major.png"; break; } + foreach ($show_fields as $k_s => $fields) { + if ($fields == 'server_name') { + if ($meta) { + if (can_user_access_node ()) { + $data[$i] = "" . $event["server_name"] . ""; + } + else { + $data[$i] = $event["server_name"]; + } + } + else { + $data[$i] = db_get_value('name','tserver'); + } + $table->cellclass[count($table->data)][$i] = $myclass; + $i++; + } + if ($fields == 'estado') { + $data[$i] = html_print_image ($img_st, true, + array ("class" => "image_status", + "title" => $title_st, + "id" => 'status_img_'.$event["id_evento"])); + $table->cellstyle[count($table->data)][$i] = 'background: #F3F3F3;'; + $i++; + } + if ($fields == 'id_evento') { + $data[$i] = $event["id_evento"]; + $table->cellclass[count($table->data)][$i] = $myclass; + $i++; + } - if (in_array('evento', $show_fields)) { + if ($fields == 'evento') { // Event description $data[$i] = ''; if($allow_action) { @@ -516,7 +520,7 @@ else { $i++; } - if (in_array('id_agente', $show_fields)) { + if ($fields == 'id_agente') { $data[$i] = ''; if ($event["id_agente"] > 0) { @@ -549,7 +553,7 @@ else { $i++; } - if (in_array('timestamp', $show_fields)) { + if ($fields == 'timestamp') { //Time $data[$i] = ''; if ($group_rep == 1) { @@ -563,7 +567,7 @@ else { $i++; } - if (in_array('id_usuario',$show_fields)) { + if ($fields == 'id_usuario') { $user_name = db_get_value('fullname', 'tusuario', 'id_user', $event['id_usuario']); if(empty($user_name)) { $user_name = $event['id_usuario']; @@ -573,7 +577,7 @@ else { $i++; } - if (in_array('owner_user',$show_fields)) { + if ($fields == 'owner_user') { $owner_name = db_get_value('fullname', 'tusuario', 'id_user', $event['owner_user']); if(empty($owner_name)) { $owner_name = $event['owner_user']; @@ -583,7 +587,7 @@ else { $i++; } - if (in_array('id_grupo',$show_fields)) { + if ($fields == 'id_grupo') { if ($meta) { $data[$i] = $event['group_name']; } @@ -599,13 +603,13 @@ else { $i++; } - if (in_array('event_type',$show_fields)) { + if ($fields == 'event_type') { $data[$i] = events_print_type_description($event["event_type"], true); $table->cellclass[count($table->data)][$i] = $myclass; $i++; } - if (in_array('id_agentmodule',$show_fields)) { + if ($fields == 'id_agentmodule') { if ($meta) { $module_link = ''; if (can_user_access_node ()) { @@ -624,7 +628,7 @@ else { $i++; } - if (in_array('id_alert_am',$show_fields)) { + if ($fields == 'id_alert_am') { if($meta) { $data[$i] = $event["alert_template_name"]; } @@ -647,13 +651,13 @@ else { $i++; } - if (in_array('criticity',$show_fields)) { + if ($fields == 'criticity') { $data[$i] = get_priority_name ($event["criticity"]); $table->cellclass[count($table->data)][$i] = $myclass; $i++; } - if (in_array('user_comment',$show_fields)) { + if ($fields == 'user_comment') { $safe_event_user_comment = strip_tags(io_safe_output($event["user_comment"])); $line_breaks = array("\r\n", "\n", "\r"); $safe_event_user_comment = str_replace($line_breaks, '
', $safe_event_user_comment); @@ -684,25 +688,25 @@ else { $i++; } - if (in_array('tags',$show_fields)) { + if ($fields == 'tags') { $data[$i] = tags_get_tags_formatted($event['tags']); $table->cellclass[count($table->data)][$i] = $myclass; $i++; } - if (in_array('source',$show_fields)) { + if ($fields == 'source') { $data[$i] = $event["source"]; $table->cellclass[count($table->data)][$i] = $myclass; $i++; } - if (in_array('id_extra',$show_fields)) { + if ($fields == 'id_extra') { $data[$i] = $event["id_extra"]; $table->cellclass[count($table->data)][$i] = $myclass; $i++; } - if (in_array('ack_utimestamp',$show_fields)) { + if ($fields == 'ack_utimestamp') { if ($event["ack_utimestamp"] == 0) { $data[$i] = ''; } @@ -713,7 +717,7 @@ else { $i++; } - if (in_array('instructions',$show_fields)) { + if ($fields == 'instructions') { switch($event['event_type']) { case 'going_unknown': if(!empty($event["unknown_instructions"])) { @@ -751,7 +755,7 @@ else { $table->cellclass[count($table->data)][$i] = $myclass; $i++; } - if (in_array('data',$show_fields)) { + if ($fields == 'data') { $data[$i] = $event["data"]; if($data[$i] %1 == 0) $data[$i]= number_format($data[$i], 0); @@ -760,11 +764,12 @@ else { $table->cellclass[count($table->data)][$i] = $myclass; $i++; } - if (in_array('module_status',$show_fields)) { + if ($fields == 'module_status') { $data[$i] = modules_get_modules_status ($event["module_status"]); $table->cellclass[count($table->data)][$i] = $myclass; $i++; } + } if ($i != 0 && $allow_action) { //Actions diff --git a/pandora_console/operation/incidents/incident_detail.php b/pandora_console/operation/incidents/incident_detail.php index ebe6c94b90..1ed1d91383 100755 --- a/pandora_console/operation/incidents/incident_detail.php +++ b/pandora_console/operation/incidents/incident_detail.php @@ -194,6 +194,7 @@ elseif (isset ($_GET["insert_form"])) { $titulo = ui_print_truncate_text(events_get_description ($event), 'description', false, true, false); $id_grupo = events_get_group ($event); $origen = "Pandora FMS Event"; + $id_agent = db_get_value("id_agente","tevento","id_evento",$event); unset ($event); } $prioridad = 0; diff --git a/pandora_console/operation/messages/message_edit.php b/pandora_console/operation/messages/message_edit.php index ce1abf91a4..5df20ce9fe 100644 --- a/pandora_console/operation/messages/message_edit.php +++ b/pandora_console/operation/messages/message_edit.php @@ -103,22 +103,22 @@ if ($read_message) { //Start the message much like an e-mail reply $new_msg = "\n\n\nOn ".date ($config["date_format"], $message["timestamp"]).' '.$user_name.' '.__('wrote').":\n\n".$message["mensaje"]; - echo ''; + echo ''; html_print_table($table); - echo "
"; - html_print_submit_button(__('Delete'), 'delete_btn', false, 'class="sub delete"'); - echo "
"; echo ""; - echo '
'; + echo ''; html_print_input_hidden ("dst_user", $message["id_usuario_origen"]); html_print_input_hidden ("subject", $new_subj); html_print_input_hidden ("message", $new_msg); html_print_input_hidden ("orig_user", $message["id_usuario_destino"]); - echo "
"; - html_print_submit_button (__('Reply'), 'reply', false, 'class="sub next"'); - echo '
'; echo ''; + + echo "
"; + html_print_submit_button(__('Delete'), 'delete_btn', false, 'form="delete_message" class="sub delete"'); + echo " "; + html_print_submit_button (__('Reply'), 'reply', false, 'form="reply_message" class="sub next"'); + echo "
"; return; } diff --git a/pandora_console/operation/servers/recon_view.php b/pandora_console/operation/servers/recon_view.php index a60a2452d7..7738a42a62 100644 --- a/pandora_console/operation/servers/recon_view.php +++ b/pandora_console/operation/servers/recon_view.php @@ -85,6 +85,10 @@ else { $table->head = array (); $table->data = array (); $table->align = array (); + $table->headstyle = array (); + for ($i=0; $i < 9; $i++) { + $table->headstyle[$i] = 'text-align: left;'; + } $table->head[0] = __('Force'); $table->align[0] = "left"; diff --git a/pandora_console/pandora_console.redhat.spec b/pandora_console/pandora_console.redhat.spec index c73ed15420..c64d671840 100644 --- a/pandora_console/pandora_console.redhat.spec +++ b/pandora_console/pandora_console.redhat.spec @@ -3,7 +3,7 @@ # %define name pandorafms_console %define version 7.0NG.727 -%define release 180927 +%define release 181010 # User and Group under which Apache is running %define httpd_name httpd diff --git a/pandora_console/pandora_console.spec b/pandora_console/pandora_console.spec index b69742f400..380ceae1ec 100644 --- a/pandora_console/pandora_console.spec +++ b/pandora_console/pandora_console.spec @@ -3,7 +3,7 @@ # %define name pandorafms_console %define version 7.0NG.727 -%define release 180927 +%define release 181010 %define httpd_name httpd # User and Group under which Apache is running %define httpd_name apache2 diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index 655bae59bf..86bf5b116d 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -1351,7 +1351,7 @@ CREATE TABLE IF NOT EXISTS `treport_custom_sql` ( -- --------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tlayout` ( `id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, - `name` varchar(50) NOT NULL, + `name` varchar(600) NOT NULL, `id_group` INTEGER UNSIGNED NOT NULL, `background` varchar(200) NOT NULL, `height` INTEGER UNSIGNED NOT NULL default 0, @@ -1399,6 +1399,7 @@ CREATE TABLE IF NOT EXISTS `tlayout_data` ( `clock_animation` varchar(60) NOT NULL default "analogic_1", `time_format` varchar(60) NOT NULL default "time", `timezone` varchar(60) NOT NULL default "Europe/Madrid", + `show_last_value` tinyint(1) UNSIGNED NULL default '0', PRIMARY KEY(`id`) ) ENGINE = InnoDB DEFAULT CHARSET=utf8; @@ -2411,14 +2412,19 @@ CREATE TABLE IF NOT EXISTS `ttrap_custom_values` ( -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `tmetaconsole_setup` ( `id` int(10) NOT NULL auto_increment primary key, - `server_name` text default '', - `server_url` text default '', - `dbuser` text default '', - `dbpass` text default '', - `dbhost` text default '', - `dbport` text default '', - `dbname` text default '', - `auth_token` text default '', + `server_name` text, + `server_url` text, + `dbuser` text, + `dbpass` text, + `dbhost` text, + `dbport` text, + `dbname` text, + `meta_dbuser` text, + `meta_dbpass` text, + `meta_dbhost` text, + `meta_dbport` text, + `meta_dbname` text, + `auth_token` text, `id_group` int(10) unsigned NOT NULL default 0, `api_password` text NOT NULL, `disabled` tinyint(1) unsigned NOT NULL default '0', diff --git a/pandora_server/DEBIAN/control b/pandora_server/DEBIAN/control index b1bb245559..7988615950 100644 --- a/pandora_server/DEBIAN/control +++ b/pandora_server/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-server -Version: 7.0NG.727-180927 +Version: 7.0NG.727-181010 Architecture: all Priority: optional Section: admin diff --git a/pandora_server/DEBIAN/make_deb_package.sh b/pandora_server/DEBIAN/make_deb_package.sh index 4ec04ce2d1..a61d59c379 100644 --- a/pandora_server/DEBIAN/make_deb_package.sh +++ b/pandora_server/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.727-180927" +pandora_version="7.0NG.727-181010" package_cpan=0 package_pandora=1 diff --git a/pandora_server/lib/PandoraFMS/Config.pm b/pandora_server/lib/PandoraFMS/Config.pm index 5c47aaaf74..5e82d43b41 100644 --- a/pandora_server/lib/PandoraFMS/Config.pm +++ b/pandora_server/lib/PandoraFMS/Config.pm @@ -45,7 +45,7 @@ our @EXPORT = qw( # version: Defines actual version of Pandora Server for this module only my $pandora_version = "7.0NG.727"; -my $pandora_build = "180927"; +my $pandora_build = "181010"; our $VERSION = $pandora_version." ".$pandora_build; # Setup hash diff --git a/pandora_server/lib/PandoraFMS/PluginTools.pm b/pandora_server/lib/PandoraFMS/PluginTools.pm index 9c02419f5b..ec42a784a9 100644 --- a/pandora_server/lib/PandoraFMS/PluginTools.pm +++ b/pandora_server/lib/PandoraFMS/PluginTools.pm @@ -32,7 +32,7 @@ our @ISA = qw(Exporter); # version: Defines actual version of Pandora Server for this module only my $pandora_version = "7.0NG.727"; -my $pandora_build = "180927"; +my $pandora_build = "181010"; our $VERSION = $pandora_version." ".$pandora_build; our %EXPORT_TAGS = ( 'all' => [ qw() ] ); @@ -1164,6 +1164,10 @@ sub parse_arguments { my $key = trim($args[$i]); $key =~ s/^-//; + if ($key =~ /^\s*global_alerts/){ + push (@{$data{global_alerts}}, trim($args[$i+1])); + next; + } $data{$key} = trim($args[$i+1]); } diff --git a/pandora_server/lib/PandoraFMS/Tools.pm b/pandora_server/lib/PandoraFMS/Tools.pm index 1758d79459..5e5f58c4a8 100755 --- a/pandora_server/lib/PandoraFMS/Tools.pm +++ b/pandora_server/lib/PandoraFMS/Tools.pm @@ -28,6 +28,7 @@ use Socket qw(inet_ntoa inet_aton); use Sys::Syslog; use Scalar::Util qw(looks_like_number); use LWP::UserAgent; +use threads; # New in 3.2. Used to sendmail internally, without external scripts # use Module::Loaded; diff --git a/pandora_server/pandora_server.redhat.spec b/pandora_server/pandora_server.redhat.spec index 6931ad5763..487f9b8188 100644 --- a/pandora_server/pandora_server.redhat.spec +++ b/pandora_server/pandora_server.redhat.spec @@ -3,7 +3,7 @@ # %define name pandorafms_server %define version 7.0NG.727 -%define release 180927 +%define release 181010 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec index 6faf6b4207..1e9c7505e1 100644 --- a/pandora_server/pandora_server.spec +++ b/pandora_server/pandora_server.spec @@ -3,7 +3,7 @@ # %define name pandorafms_server %define version 7.0NG.727 -%define release 180927 +%define release 181010 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server_installer b/pandora_server/pandora_server_installer index 6c24fea069..25041f3501 100755 --- a/pandora_server/pandora_server_installer +++ b/pandora_server/pandora_server_installer @@ -9,7 +9,7 @@ # ********************************************************************** PI_VERSION="7.0NG.727" -PI_BUILD="180927" +PI_BUILD="181010" MODE=$1 if [ $# -gt 1 ]; then diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl index d8d7f573f1..3bb127f476 100644 --- a/pandora_server/util/pandora_db.pl +++ b/pandora_server/util/pandora_db.pl @@ -34,7 +34,7 @@ use PandoraFMS::Config; use PandoraFMS::DB; # version: define current version -my $version = "7.0NG.727 PS180927"; +my $version = "7.0NG.727 PS181010"; # Pandora server configuration my %conf; diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index 6be375e60b..606a3fcfc1 100644 --- a/pandora_server/util/pandora_manage.pl +++ b/pandora_server/util/pandora_manage.pl @@ -36,7 +36,7 @@ use Encode::Locale; Encode::Locale::decode_argv; # version: define current version -my $version = "7.0NG.727 PS180927"; +my $version = "7.0NG.727 PS181010"; # save program name for logging my $progname = basename($0); @@ -136,6 +136,7 @@ sub help_screen{ help_screen_line('--delete_cluster_agent', ' ', 'Deleting cluster agent'); help_screen_line('--delete_cluster_item', '', 'Deleting cluster item'); help_screen_line('--get_cluster_status', '', 'Getting cluster status'); + help_screen_line('--set_disabled_and_standby', ' ', 'Overwrite and disable and standby status'); print "\nMODULES:\n\n" unless $param ne ''; help_screen_line('--create_data_module', " [ \n\t \n\t \n\t \n\t \n\t ]", 'Add data server module to agent'); help_screen_line('--create_web_module', " [ \n\t \n\t \n\t \n\t \n\t \n\t ].\n\t The valid data types are web_data, web_proc, web_content_data or web_content_string", 'Add web server module to agent'); @@ -6125,6 +6126,10 @@ sub pandora_manage_main ($$$) { param_check($ltotal, 1, 0); cli_migration_agent(); } + elsif ($param eq '--set_disabled_and_standby') { + param_check($ltotal, 3, 1); + cli_set_disabled_and_standby(); + } else { print_log "[ERROR] Invalid option '$param'.\n\n"; $param = ''; @@ -6709,4 +6714,23 @@ sub cli_get_cluster_status() { else{ print "\n0\n"; } +} + +############################################################################## +# Set an agent disabled and with standby. +# Related option: --set_disabled_and_standby +############################################################################## + +sub cli_set_disabled_and_standby() { + my ($id, $id_node, $value) = @ARGV[2..4]; + $id_node = 0 unless defined($id_node); + $value = 1 unless defined($value); #Set to disabled by default + + # Call the API. + my $result = api_call( + $conf, 'set', 'disabled_and_standby', $id, $id_node, $value + ); + + my $exit_code = (defined($result) && "$result" eq "1") ? "1" : "0"; + print "\n$exit_code\n"; } \ No newline at end of file diff --git a/tests/enterprise_base/Dockerfile b/tests/enterprise_base/Dockerfile index 1da3accf48..8b0533d25c 100644 --- a/tests/enterprise_base/Dockerfile +++ b/tests/enterprise_base/Dockerfile @@ -2,7 +2,7 @@ FROM pandorafms/pandorafms-base MAINTAINER Pandora FMS Team # Pandora FMS Server dependencies -RUN yum install -y fping perl-Test-WWW-Selenium perl-Crypt-ECB perl-Net-OpenSSH +RUN yum install -y fping perl-Test-WWW-Selenium perl-Crypt-Blowfish perl-Crypt-ECB perl-Net-OpenSSH RUN ln -s /usr/bin/braa /usr/local/bin/braa
"; echo __('Search') . ' ' . html_print_input_text ('search_string', $search_string, '', 15, 255, true); + html_print_input_hidden ('search', 1); echo ""; html_print_submit_button (__('Filter'), 'filter', false, 'class="sub search"'); diff --git a/pandora_console/godmode/agentes/module_manager_editor_common.php b/pandora_console/godmode/agentes/module_manager_editor_common.php index 0b9207a817..0527bea08d 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_common.php +++ b/pandora_console/godmode/agentes/module_manager_editor_common.php @@ -160,7 +160,7 @@ else{ $table_simple->data[0][0] = __('Name'); $table_simple->data[0][1] = html_print_input_text_extended ('name', - io_safe_input(html_entity_decode($name)), 'text-name', '', 45, 100, $disabledBecauseInPolicy, '', $largeClassDisabledBecauseInPolicy, true); + io_safe_input(html_entity_decode($name, ENT_QUOTES, "UTF-8")), 'text-name', '', 45, 100, $disabledBecauseInPolicy, '', $largeClassDisabledBecauseInPolicy, true); //$table_simple->data[0][1] = html_print_input_text ('name', // io_safe_output($name), '', 45, 100, true, $disabledBecauseInPolicy); diff --git a/pandora_console/godmode/agentes/module_manager_editor_plugin.php b/pandora_console/godmode/agentes/module_manager_editor_plugin.php index e79853b30a..a5085122d0 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_plugin.php +++ b/pandora_console/godmode/agentes/module_manager_editor_plugin.php @@ -71,7 +71,7 @@ push_table_simple ($data, 'plugin_1'); $data = array (); $data[0] = 'macro_desc'; $data[0] .= ui_print_help_tip ('macro_help', true); -$data[1] = html_print_input_text ('macro_name', 'macro_value', '', 100, 255, true); +$data[1] = html_print_input_text ('macro_name', 'macro_value', '', 100, 1024, true); $table_simple->colspan['macro_field'][1] = 3; $table_simple->rowstyle['macro_field'] = 'display:none'; @@ -93,10 +93,10 @@ if (!empty($macros)) { $m_hide = $m['hide']; if ($m_hide) { - $data[1] = html_print_input_password($m['macro'], io_output_password($m['value']), '', 100, 255, true); + $data[1] = html_print_input_password($m['macro'], io_output_password($m['value']), '', 100, 1024, true); } else { - $data[1] = html_print_input_text($m['macro'], $m['value'], '', 100, 255, true, + $data[1] = html_print_input_text($m['macro'], $m['value'], '', 100, 1024, true, $disabledBecauseInPolicy, false, '', $classdisabledBecauseInPolicy); } $table_simple->colspan['macro'.$m['macro']][1] = 3; diff --git a/pandora_console/godmode/alerts/alert_list.builder.php b/pandora_console/godmode/alerts/alert_list.builder.php index 0af888b5aa..4123ff337a 100644 --- a/pandora_console/godmode/alerts/alert_list.builder.php +++ b/pandora_console/godmode/alerts/alert_list.builder.php @@ -219,7 +219,7 @@ $(document).ready (function () { $("#value", $value).append (""); } else { - $("#value", $value).append (data); + $("#value", $value).append (parseInt(data)); } $loading.hide (); $value.show (); diff --git a/pandora_console/godmode/alerts/alert_list.list.php b/pandora_console/godmode/alerts/alert_list.list.php index 0605ab2fed..1737ed1a7d 100644 --- a/pandora_console/godmode/alerts/alert_list.list.php +++ b/pandora_console/godmode/alerts/alert_list.list.php @@ -705,18 +705,26 @@ foreach ($simple_alerts as $alert) { if(check_acl_one_of_groups ($config['id_user'], $all_groups, "LW")) { $data[4] .= '  
'; if ($alert['disabled']) { - $data[4] .= html_print_image('images/add.disabled.png', - true, array('title' => __("Add action"))); + } else { $data[4] .= ''; - $data[4] .= html_print_image('images/add.png', true, array('title' => __("Add action"))); + $data[4] .= ''; } $data[4] .= html_print_input_image ('delete', 'images/cross.png', 1, '', true, array('title' => __('Delete'))); $data[4] .= html_print_input_hidden ('delete_alert', 1, true); $data[4] .= html_print_input_hidden ('id_alert', $alert['id'], true); $data[4] .= '
'; + + $data[4] .= '
'; + + $data[4] .= html_print_input_image ('update', 'images/builder.png', 1, '', true, array('title' => __('Update'))); + $data[4] .= html_print_input_hidden ('upd_alert', 1, true); + $data[4] .= html_print_input_hidden ('id_alert', $alert['id'], true); + + $data[4] .= '
'; + } if(check_acl_one_of_groups ($config['id_user'], $all_groups, "LM")) { diff --git a/pandora_console/godmode/alerts/alert_list.php b/pandora_console/godmode/alerts/alert_list.php index a65b925a44..9a6badcc24 100644 --- a/pandora_console/godmode/alerts/alert_list.php +++ b/pandora_console/godmode/alerts/alert_list.php @@ -47,6 +47,7 @@ $add_action = (bool) get_parameter ('add_action'); $update_action = (bool) get_parameter ('update_action'); $delete_action = (bool) get_parameter ('delete_action'); $delete_alert = (bool) get_parameter ('delete_alert'); +$update_alert = (bool) get_parameter ('update_alert'); //// $disable_alert = (bool) get_parameter ('disable_alert'); $enable_alert = (bool) get_parameter ('enable_alert'); $standbyon_alert = (bool) get_parameter ('standbyon_alert'); @@ -67,10 +68,32 @@ $standby = get_parameter('standby',''); $pure = get_parameter('pure', 0); $messageAction = ''; +if ($update_alert) { + + $id_alert_agent_module = (int) get_parameter ('id_alert_update'); + + $id_alert_template = (int) get_parameter ('template'); + $id_agent_module = (int) get_parameter ('id_agent_module'); + + $values_upd = array(); + + if (!empty($id_alert_template)) + $values_upd['id_agent_module'] = $id_agent_module; + + if (!empty($id_alert_template)) + $values_upd['id_alert_template'] = $id_alert_template; + + $id = alerts_update_alert_agent_module ($id_alert_agent_module, $values_upd); + + $messageAction = ui_print_result_message ($id, + __('Successfully updated'), __('Could not be updated'), '', true); + +} + if ($create_alert) { $id_alert_template = (int) get_parameter ('template'); $id_agent_module = (int) get_parameter ('id_agent_module'); - + if (db_get_value_sql("SELECT COUNT(id) FROM talert_template_modules WHERE id_agent_module = " . $id_agent_module . " @@ -81,7 +104,7 @@ if ($create_alert) { } else { $id = alerts_create_alert_agent_module ($id_agent_module, $id_alert_template); - + $alert_template_name = db_get_value ("name", "talert_templates","id", $id_alert_template); $module_name = db_get_value ("nombre", @@ -116,6 +139,7 @@ if ($create_alert) { $values['module_action_threshold'] = (int)get_parameter ('module_action_threshold'); + alerts_add_alert_agent_module_action ($id, $action_select, $values); } } diff --git a/pandora_console/godmode/events/custom_events.php b/pandora_console/godmode/events/custom_events.php index 9b519fa6dd..c8911c0f44 100644 --- a/pandora_console/godmode/events/custom_events.php +++ b/pandora_console/godmode/events/custom_events.php @@ -188,7 +188,7 @@ foreach ($fields_available as $key=>$available) { } $table->data[0][0] = '' . __('Fields available').''; -$table->data[1][0] = html_print_select ($fields_available, 'fields_available[]', true, '', '', '', true, true, false, '', false, 'width: 300px'); +$table->data[1][0] = html_print_select ($fields_available, 'fields_available[]', true, '', '', 0, true, true, false, '', false, 'width: 300px'); $table->data[1][1] = '' . html_print_image('images/darrowright.png', true, array('id' => 'right', 'title' => __('Add fields to select'))) . @@ -201,7 +201,7 @@ $table->data[1][1] .= '



' . $table->data[0][1] = ''; $table->data[0][2] = '' . __('Fields selected') . ''; $table->data[1][2] = html_print_select($result_selected, - 'fields_selected[]', true, '', '', '', true, true, false, '', false, 'width: 300px'); + 'fields_selected[]', true, '', '', 0, true, true, false, '', false, 'width: 300px'); echo '
'; html_print_table($table); @@ -223,6 +223,7 @@ $(document).ready (function () { id_field = $(value).attr('value'); $("select[name='fields_selected[]']").append($("").html(field_name).attr("value", id_field)); $("#fields_available").find("option[value='" + id_field + "']").remove(); + $("#fields_selected").find("option[value='0']").remove(); } }); }); @@ -234,11 +235,13 @@ $(document).ready (function () { id_field = $(value).attr('value'); $("select[name='fields_available[]']").append($("").val(id_field).html('' + field_name + '')); $("#fields_selected").find("option[value='" + id_field + "']").remove(); + $("#fields_available").find("option[value='0']").remove(); } }); }); $("#submit-upd_button").click(function () { + $("#fields_selected").find("option[value='0']").remove(); $('#fields_selected option').map(function() { $(this).prop('selected', true); }); diff --git a/pandora_console/godmode/massive/massive_add_profiles.php b/pandora_console/godmode/massive/massive_add_profiles.php index 253992b7f5..559ffa6291 100644 --- a/pandora_console/godmode/massive/massive_add_profiles.php +++ b/pandora_console/godmode/massive/massive_add_profiles.php @@ -48,7 +48,7 @@ if ($create_profiles) { // If the profile doesnt exist, we create it if ($profile_data === false) { db_pandora_audit("User management", - "Added profile for user ".io_safe_input($user)); + "Added profile for user ".io_safe_output($user)); $return = profile_create_user_profile ($user, $profile, $group); if ($return !== false) { $n_added ++; diff --git a/pandora_console/godmode/massive/massive_delete_modules.php b/pandora_console/godmode/massive/massive_delete_modules.php index 994b0053ad..be10127a80 100755 --- a/pandora_console/godmode/massive/massive_delete_modules.php +++ b/pandora_console/godmode/massive/massive_delete_modules.php @@ -52,6 +52,8 @@ function process_manage_delete ($module_name, $id_agents, $module_status = 'all' global $config; + $status_module = (int) get_parameter ('status_module'); + if (empty ($module_name)) { ui_print_error_message(__('No module selected')); return false; @@ -82,8 +84,13 @@ function process_manage_delete ($module_name, $id_agents, $module_status = 'all' $filter_for_module_deletion, true); } else { - $modules = agents_get_modules ($id_agents, 'id_agente_modulo', - 'tagente_modulo.nombre IN ("' . implode('","',$module_name) . '")', true); + if ($status_module != -1) { + $modules = agents_get_modules ($id_agents, 'id_agente_modulo', + sprintf('tagente_modulo.nombre IN ("%s") AND tagente_modulo.id_agente_modulo IN (SELECT id_agente_modulo FROM tagente_estado where estado = %s OR utimestamp=0 )', implode('","',$module_name), $status_module), true); + } else { + $modules = agents_get_modules ($id_agents, 'id_agente_modulo', + 'tagente_modulo.nombre IN ("' . implode('","',$module_name) . '")', true); + } } if (($module_status == 'unknown') && ($module_name[0] == "0") && (is_array($module_name)) && (count($module_name) == 1)) { diff --git a/pandora_console/godmode/massive/massive_edit_agents.php b/pandora_console/godmode/massive/massive_edit_agents.php index a6e101403c..eb6dc869f3 100755 --- a/pandora_console/godmode/massive/massive_edit_agents.php +++ b/pandora_console/godmode/massive/massive_edit_agents.php @@ -30,6 +30,7 @@ require_once ('include/functions_modules.php'); require_once ('include/functions_servers.php'); require_once ('include/functions_gis.php'); require_once ('include/functions_users.php'); +enterprise_include_once('include/functions_config_agents.php'); if (is_ajax ()) { $get_n_conf_files = (bool) get_parameter ('get_n_conf_files'); @@ -136,8 +137,11 @@ if ($update_agents) { foreach ($id_agents as $id_agent) { if (!empty($values)) { $group_old = false; - if($values['id_grupo']){ - $group_old = db_get_sql("SELECT id_grupo FROM tagente WHERE id_agente =" .$id_agent); + $disabled_old = false; + if($values['id_grupo'] || isset($values['disabled'])){ + $values_old = db_get_row_filter('tagente', array('id_agente' => $id_agent), array('id_grupo', 'disabled')); + if ($values_old['id_grupo']) $group_old = $values_old['id_grupo']; + if (isset($values['disabled'])) $disabled_old = $values_old['disabled']; } $result = db_process_sql_update ('tagente', @@ -149,7 +153,14 @@ if ($update_agents) { // Force an update of the agent cache. $result_metaconsole = agent_update_from_cache($id_agent,$values,$server_name); } - + + if ($disabled_old !== false && $disabled_old != $values['disabled']) { + enterprise_hook( + 'config_agents_update_config_token', + array($id_agent, 'standby', $values['disabled']) + ); + } + if($group_old || $result){ if ($group_old && $group_old != null) { $tpolicy_group_old = db_get_all_rows_sql("SELECT id_policy FROM tpolicy_groups @@ -422,7 +433,9 @@ $table->data[1][1] .= __('Autodisable mode').' '.html_print_radio_button_extende // Status (Disabled / Enabled) $table->data[2][0] = __('Status'); $table->data[2][1] = __('No change').' '.html_print_radio_button_extended ("disabled", -1, '', $disabled, false, '', 'style="margin-right: 40px;"', true); -$table->data[2][1] .= __('Disabled').' '.html_print_radio_button_extended ("disabled", 1, '', $disabled, false, '', 'style="margin-right: 40px;"', true); +$table->data[2][1] .= __('Disabled') . ' ' . + ui_print_help_tip(__('If the remote configuration is enabled, it will also go into standby mode when disabling it.'), true) . ' ' . + html_print_radio_button_extended ("disabled", 1, '', $disabled, false, '', 'style="margin-right: 40px;"', true); $table->data[2][1] .= __('Active').' '.html_print_radio_button_extended ("disabled", 0, '', $disabled, false, '', 'style="margin-right: 40px;"', true); // Remote configuration diff --git a/pandora_console/godmode/massive/massive_edit_modules.php b/pandora_console/godmode/massive/massive_edit_modules.php index 4ef69a581b..b12093aaf5 100755 --- a/pandora_console/godmode/massive/massive_edit_modules.php +++ b/pandora_console/godmode/massive/massive_edit_modules.php @@ -47,17 +47,21 @@ $update = (bool) get_parameter_post ('update'); if ($update) { $agents_ = ''; if ($selection_mode == 'modules') { + + $agents_ = array(); + $force = get_parameter('force_type', false); if ($agents_select == false) { $agents_select = array(); - $agents_ = array(); } foreach ($agents_select as $agent_name) { $agents_[] = agents_get_agent_id($agent_name); } + $modules_ = $module_name; + } else if ($selection_mode == 'agents') { $force = get_parameter('force_group', false); @@ -75,6 +79,7 @@ if ($update) { // If the option to select all of one group or module type is checked if ($force) { if ($force == 'type') { + $type_condition = ''; if ($module_type != 0) $type_condition = "AND tam.id_tipo_modulo = $module_type"; @@ -141,12 +146,11 @@ if ($update) { else { // Standard procedure foreach ($agents_ as $agent_) { - + if ($modules_ == false) $modules_ = array(); foreach ($modules_ as $module_) { - $result = process_manage_edit ($module_, $agent_, $modules_selection_mode); $count++; $success += (int)$result; @@ -331,6 +335,7 @@ $table->data['form_modules_2'][2] .= html_print_select ( 'all' => __('Show all agents')), 'agents_selection_mode', 'common', false, '', '', true); + $table->data['form_modules_2'][3] = html_print_select (array(), 'agents[]', $agents_select, false, __('None'), 0, true, true, false); @@ -1540,12 +1545,14 @@ function process_manage_edit ($module_name, $agents_select = null, $module_statu $update_tags = get_parameter('id_tag', false); if (array_search(0, $agents_select) !== false) { + //Apply at All agents. $modules = db_get_all_rows_filter ('tagente_modulo', $filter_modules, array ('id_agente_modulo')); } else { + if ($module_name == "0") { //Any module $modules = db_get_all_rows_filter ('tagente_modulo', @@ -1559,7 +1566,8 @@ function process_manage_edit ($module_name, $agents_select = null, $module_statu array ('id_agente_modulo')); } } - + + if ($modules === false) return false; @@ -1575,16 +1583,16 @@ function process_manage_edit ($module_name, $agents_select = null, $module_statu } $modules = $modules_to_delete; } - + foreach ($modules as $module) { $result = modules_update_agent_module( $module['id_agente_modulo'], $values, true, $update_tags); - if (is_error($result)) { - + + if (is_error($result)) return false; - } + } return true; diff --git a/pandora_console/godmode/modules/manage_network_components_form_plugin.php b/pandora_console/godmode/modules/manage_network_components_form_plugin.php index a037e578e6..4b10cdaaea 100755 --- a/pandora_console/godmode/modules/manage_network_components_form_plugin.php +++ b/pandora_console/godmode/modules/manage_network_components_form_plugin.php @@ -34,7 +34,7 @@ push_table_row ($data, 'plugin_1'); $data = array (); $data[0] = 'macro_desc'; $data[0] .= ui_print_help_tip ('macro_help', true); -$data[1] = html_print_input_text ('macro_name', 'macro_value', '', 100, 255, true); +$data[1] = html_print_input_text ('macro_name', 'macro_value', '', 100, 1024, true); $table->colspan['macro_field'][1] = 3; $table->rowstyle['macro_field'] = 'display:none'; @@ -51,9 +51,9 @@ if (!empty($macros)) { $data[0] .= ui_print_help_tip ($m['help'], true); } if ($m['hide'] == 1) { - $data[1] = html_print_input_text($m['macro'], $m['value'], '', 15, 60, true); + $data[1] = html_print_input_text($m['macro'], $m['value'], '', 100, 1024, true); } else { - $data[1] = html_print_input_text($m['macro'], io_output_password($m['value']), '', 15, 60, true); + $data[1] = html_print_input_text($m['macro'], io_output_password($m['value']), '', 100, 1024, true); } $table->colspan['macro'.$m['macro']][1] = 3; $table->rowclass['macro'.$m['macro']] = 'macro_field'; diff --git a/pandora_console/godmode/reporting/reporting_builder.php b/pandora_console/godmode/reporting/reporting_builder.php index 067b756908..144f3be45d 100755 --- a/pandora_console/godmode/reporting/reporting_builder.php +++ b/pandora_console/godmode/reporting/reporting_builder.php @@ -2075,9 +2075,9 @@ else { $buttons = null; $buttons = array( 'main' => array('active' => true, - 'text' => '' . - html_print_image("images/op_reporting.png", true, array ("title" => __('Main data'))) .'')); - $textReportName = ''; + 'text' => '' . + html_print_image("images/report_list.png", true, array ("title" => __('Reports list'))) .'')); + $textReportName = __('Create Custom Report'); } // Page header for metaconsole diff --git a/pandora_console/godmode/reporting/visual_console_builder.editor.js b/pandora_console/godmode/reporting/visual_console_builder.editor.js index d32b15e1aa..8d92642f52 100755 --- a/pandora_console/godmode/reporting/visual_console_builder.editor.js +++ b/pandora_console/godmode/reporting/visual_console_builder.editor.js @@ -870,6 +870,7 @@ function readFields() { values['time_format'] = $("select[name=time_format]").val(); values['timezone'] = $("select[name=timezone]").val(); values['clock_animation'] = $("select[name=clock_animation]").val(); + values['show_last_value'] = $("select[name=last_value]").val(); if (is_metaconsole()) { values['metaconsole'] = 1; @@ -1380,7 +1381,6 @@ function loadFieldsFromDB(item) { } }); - parameter = Array(); parameter.push ({name: "page", value: "include/ajax/visual_console_builder.ajax"}); @@ -1459,26 +1459,26 @@ function loadFieldsFromDB(item) { $("select[name=type_graph]").val(val); } - if (key == 'label_position') { - if($("#hidden-metaconsole").val() == 1){ - $('#labelposup'+" img").attr('src','../../images/label_up.png'); - $('#labelposdown'+" img").attr('src','../../images/label_down.png'); - $('#labelposleft'+" img").attr('src','../../images/label_left.png'); - $('#labelposright'+" img").attr('src','../../images/label_right.png'); - $('.labelpos').attr('sel','no'); - $('#labelpos'+val+" img").attr('src','../../images/label_'+$('#labelpos'+val).attr('id').replace('labelpos','')+'_2.png'); - $('#labelpos'+val).attr('sel','yes'); - } - else{ - $('#labelposup'+" img").attr('src','images/label_up.png'); - $('#labelposdown'+" img").attr('src','images/label_down.png'); - $('#labelposleft'+" img").attr('src','images/label_left.png'); - $('#labelposright'+" img").attr('src','images/label_right.png'); - $('.labelpos').attr('sel','no'); - $('#labelpos'+val+" img").attr('src','images/label_'+$('#labelpos'+val).attr('id').replace('labelpos','')+'_2.png'); - $('#labelpos'+val).attr('sel','yes'); - } + if (key == 'label_position') { + if($("#hidden-metaconsole").val() == 1){ + $('#labelposup'+" img").attr('src','../../images/label_up.png'); + $('#labelposdown'+" img").attr('src','../../images/label_down.png'); + $('#labelposleft'+" img").attr('src','../../images/label_left.png'); + $('#labelposright'+" img").attr('src','../../images/label_right.png'); + $('.labelpos').attr('sel','no'); + $('#labelpos'+val+" img").attr('src','../../images/label_'+$('#labelpos'+val).attr('id').replace('labelpos','')+'_2.png'); + $('#labelpos'+val).attr('sel','yes'); } + else{ + $('#labelposup'+" img").attr('src','images/label_up.png'); + $('#labelposdown'+" img").attr('src','images/label_down.png'); + $('#labelposleft'+" img").attr('src','images/label_left.png'); + $('#labelposright'+" img").attr('src','images/label_right.png'); + $('.labelpos').attr('sel','no'); + $('#labelpos'+val+" img").attr('src','images/label_'+$('#labelpos'+val).attr('id').replace('labelpos','')+'_2.png'); + $('#labelpos'+val).attr('sel','yes'); + } + } if (key == 'image') { //Load image preview @@ -1590,6 +1590,10 @@ function loadFieldsFromDB(item) { .css('background-color', val); } + if (key == 'show_last_value') { + $("select[name=last_value]").val(val); + } + if (key == 'clock_animation') $("select[name=clock_animation]").val(val); if (key == 'time_format') @@ -1852,6 +1856,9 @@ function hiddenFields(item) { $("#percentile_bar_row_2").css('display', 'none'); $("#percentile_bar_row_2." + item).css('display', ''); + + $("#show_last_value_row").css('display', 'none'); + $("#show_last_value_row." + item).css('display', ''); $("#percentile_item_row_3").css('display', 'none'); $("#percentile_item_row_3." + item).css('display', ''); diff --git a/pandora_console/godmode/users/configure_user.php b/pandora_console/godmode/users/configure_user.php index f5b7fdc5bc..6bc2e973e4 100644 --- a/pandora_console/godmode/users/configure_user.php +++ b/pandora_console/godmode/users/configure_user.php @@ -253,7 +253,7 @@ if ($create_user) { db_pandora_audit("User management", - "Created user ".io_safe_input($id), false, false, $info); + "Created user ".io_safe_output($id), false, false, $info); ui_print_result_message ($result, __('Successfully created'), @@ -405,7 +405,7 @@ if ($update_user) { } - db_pandora_audit("User management", "Updated user ".io_safe_input($id), + db_pandora_audit("User management", "Updated user ".io_safe_output($id), false, false, $info); ui_print_result_message ($res1, @@ -463,7 +463,7 @@ if ($add_profile) { $tags = implode(',', $tags); db_pandora_audit("User management", - "Added profile for user ".io_safe_input($id2), false, false, 'Profile: ' . $profile2 . ' Group: ' . $group2 . ' Tags: ' . $tags); + "Added profile for user ".io_safe_output($id2), false, false, 'Profile: ' . $profile2 . ' Group: ' . $group2 . ' Tags: ' . $tags); $return = profile_create_user_profile($id2, $profile2, $group2, false, $tags, $no_hierarchy); ui_print_result_message ($return, __('Profile added successfully'), @@ -479,7 +479,7 @@ if ($delete_profile) { $perfil = db_get_row('tperfil', 'id_perfil', $id_perfil); db_pandora_audit("User management", - "Deleted profile for user ".io_safe_input($id2), false, false, 'The profile with id ' . $id_perfil . ' in the group ' . $perfilUser['id_grupo']); + "Deleted profile for user ".io_safe_output($id2), false, false, 'The profile with id ' . $id_perfil . ' in the group ' . $perfilUser['id_grupo']); $return = profile_delete_user_profile ($id2, $id_up); ui_print_result_message ($return, diff --git a/pandora_console/images/service_map.png b/pandora_console/images/service_map.png new file mode 100644 index 0000000000..c1ee8f42cb Binary files /dev/null and b/pandora_console/images/service_map.png differ diff --git a/pandora_console/include/ajax/visual_console_builder.ajax.php b/pandora_console/include/ajax/visual_console_builder.ajax.php index 90a13ff3a0..7bdddf50b9 100755 --- a/pandora_console/include/ajax/visual_console_builder.ajax.php +++ b/pandora_console/include/ajax/visual_console_builder.ajax.php @@ -164,6 +164,8 @@ $clock_animation = get_parameter('clock_animation', 'analogic_1'); $time_format = get_parameter('time_format', 'time'); $timezone = get_parameter('timezone', 'Europe/Madrid'); +$show_last_value = get_parameter('show_last_value', null); + switch ($action) { case 'get_font': $return = array(); @@ -785,6 +787,9 @@ switch ($action) { if ($height !== null) { $values['height'] = $height; } + if ($show_last_value !== null) { + $values['show_last_value'] = $show_last_value; + } break; case 'simple_value': if ($action == 'update') { @@ -1280,6 +1285,7 @@ switch ($action) { $values['image'] = $image; $values['width'] = $width; $values['height'] = $height; + $values['show_last_value'] = $show_last_value; break; case 'group_item': $values['type'] = GROUP_ITEM; diff --git a/pandora_console/include/auth/mysql.php b/pandora_console/include/auth/mysql.php index 835a709ba8..ffd618fb65 100644 --- a/pandora_console/include/auth/mysql.php +++ b/pandora_console/include/auth/mysql.php @@ -269,6 +269,56 @@ function process_user_login_remote ($login, $pass, $api = false) { else { delete_user_pass_ldap ($login); } + + $permissions = array(); + if($config['ldap_advanced_config']){ + $i = 0; + + $ldap_adv_perms = json_decode(io_safe_output($config['ldap_adv_perms']), true); + foreach ($ldap_adv_perms as $ldap_adv_perm) { + $attributes = $ldap_adv_perm['groups_ldap']; + + foreach ($attributes as $attr) { + $attr = explode('=', $attr, 2); + foreach ($sr[$attr[0]] as $s_attr) { + if(preg_match('/' . $attr[1] . '/', $s_attr)){ + $permissions[$i]["profile"] = $ldap_adv_perm['profile']; + $permissions[$i]["groups"] = $ldap_adv_perm['group']; + $permissions[$i]["tags"] = implode(",",$ldap_adv_perm['tags']); + $i++; + } + } + } + } + } else { + $permissions[0]["profile"] = $config['default_remote_profile']; + $permissions[0]["groups"][] = $config['default_remote_group']; + $permissions[0]["tags"] = $config['default_assign_tags']; + } + if(empty($permissions)) { + $config["auth_error"] = __("User not found in database or incorrect password"); + return false; + + } else { + // check permissions + $result = check_permission_ad ($login, $pass, false, + $permissions, defined('METACONSOLE')); + + if ($return === "error_permissions") { + $config["auth_error"] = + __("Problems with configuration permissions. Please contact with Administrator"); + return false; + } + else { + if ($return === "permissions_changed") { + $config["auth_error"] = + __("Your permissions have changed. Please, login again."); + return false; + } + } + + + } } return $login; diff --git a/pandora_console/include/class/TreeGroup.class.php b/pandora_console/include/class/TreeGroup.class.php index af5542e396..ced6b8d442 100644 --- a/pandora_console/include/class/TreeGroup.class.php +++ b/pandora_console/include/class/TreeGroup.class.php @@ -20,6 +20,7 @@ require_once($config['homedir']."/include/class/Tree.class.php"); class TreeGroup extends Tree { protected $propagateCounters = true; + protected $displayAllGroups = false; public function __construct($type, $rootType = '', $id = -1, $rootID = -1, $serverID = false, $childrenMethod = "on_demand", $access = 'AR') { @@ -44,6 +45,10 @@ class TreeGroup extends Tree { $this->propagateCounters = (bool)$value; } + public function setDisplayAllGroups($value) { + $this->displayAllGroups = (bool)$value; + } + protected function getData() { if ($this->id == -1) { $this->getFirstLevel(); @@ -132,12 +137,13 @@ class TreeGroup extends Tree { return !$group['have_parent']; }); // Propagate child counters to her parents + if ($this->propagateCounters) { TreeGroup::processCounters($groups); // Filter groups and eliminates the reference to empty groups - $groups = TreeGroup::deleteEmptyGroups($groups); + $groups = $this->deleteEmptyGroups($groups); } else { - $groups = TreeGroup::deleteEmptyGroupsNotPropagate($groups); + $groups = $this->deleteEmptyGroupsNotPropagate($groups); } usort($groups, array("Tree", "cmpSortNames")); @@ -345,7 +351,8 @@ class TreeGroup extends Tree { * * @return new_groups A new groups structure without empty groups */ - protected static function deleteEmptyGroups ($groups) { + protected function deleteEmptyGroups ($groups) { + if($this->displayAllGroups) return $groups; $new_groups = array(); foreach ($groups as $group) { // If a group is empty, do not add to new_groups. @@ -354,7 +361,7 @@ class TreeGroup extends Tree { } // Tray to remove the children groups if (!empty($group['children'])) { - $children = TreeGroup::deleteEmptyGroups ($group['children']); + $children = $this->deleteEmptyGroups ($group['children']); if (empty($children)) unset($group['children']); else $group['children'] = $children; } @@ -363,12 +370,13 @@ class TreeGroup extends Tree { return $new_groups; } - protected static function deleteEmptyGroupsNotPropagate ($groups) { + protected function deleteEmptyGroupsNotPropagate ($groups) { + if($this->displayAllGroups) return $groups; $new_groups = array(); foreach ($groups as $group) { // Tray to remove the children groups if (!empty($group['children'])) { - $children = TreeGroup::deleteEmptyGroupsNotPropagate ($group['children']); + $children = $this->deleteEmptyGroupsNotPropagate ($group['children']); if (empty($children)) { unset($group['children']); // If a group is empty, do not add to new_groups. diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index d0a1fe004a..42ecad8677 100644 --- a/pandora_console/include/config_process.php +++ b/pandora_console/include/config_process.php @@ -22,7 +22,7 @@ /** * Pandora build version and version */ -$build_version = 'PC180927'; +$build_version = 'PC181010'; $pandora_version = 'v7.0NG.727'; // Do not overwrite default timezone set if defined. diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php index c31a4d5449..2e9ef1f55f 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -336,32 +336,39 @@ function agents_get_agents ($filter = false, $fields = false, if (isset($filter['status'])) { switch ($filter['status']) { case AGENT_STATUS_NORMAL: - $status_sql = - "normal_count = total_count - AND notinit_count <> total_count"; + $status_sql = "( + critical_count = 0 + AND warning_count = 0 + AND unknown_count = 0 + AND normal_count > 0)"; break; case AGENT_STATUS_WARNING: - $status_sql = - "critical_count = 0 AND warning_count > 0"; + $status_sql = "( + critical_count = 0 + AND warning_count > 0 + AND total_count > 0)"; break; case AGENT_STATUS_CRITICAL: - $status_sql = - "critical_count > 0"; + $status_sql = "critical_count > 0"; break; case AGENT_STATUS_UNKNOWN: - $status_sql = - "critical_count = 0 AND warning_count = 0 - AND unknown_count > 0"; + $status_sql = "( + critical_count = 0 + AND warning_count = 0 + AND unknown_count > 0)"; break; case AGENT_STATUS_NOT_NORMAL: - $status_sql = - "( - normal_count <> total_count - AND - (normal_count + notinit_count) <> total_count)"; + $status_sql = "( + critical_count > 0 + OR warning_count > 0 + OR unknown_count > 0 + OR total_count = 0 + OR total_count = notinit_count)"; break; case AGENT_STATUS_NOT_INIT: - $status_sql = "notinit_count = total_count"; + $status_sql = "( + total_count = 0 + OR total_count = notinit_count)"; break; } unset($filter['status']); @@ -915,23 +922,39 @@ function agents_get_group_agents ( if (isset($search['status'])) { switch ($search['status']) { case AGENT_STATUS_NORMAL: - $filter[] = "normal_count = total_count"; + $filter[] = "( + critical_count = 0 + AND warning_count = 0 + AND unknown_count = 0 + AND normal_count > 0)"; break; case AGENT_STATUS_WARNING: - $filter[] = "(critical_count = 0 AND warning_count > 0)"; + $filter[] = "( + critical_count = 0 + AND warning_count > 0 + AND total_count > 0)"; break; case AGENT_STATUS_CRITICAL: $filter[] = "critical_count > 0"; break; case AGENT_STATUS_UNKNOWN: - $filter[] = "(critical_count = 0 AND warning_count = 0 AND unknown_count > 0)"; + $filter[] = "( + critical_count = 0 + AND warning_count = 0 + AND unknown_count > 0)"; break; case AGENT_STATUS_NOT_NORMAL: - $filter[] = "normal_count <> total_count - AND critical_count = 0 AND warning_count = 0"; + $filter[] = "( + critical_count > 0 + OR warning_count > 0 + OR unknown_count > 0 + OR total_count = 0 + OR total_count = notinit_count)"; break; case AGENT_STATUS_NOT_INIT: - $filter[] = "notinit_count = total_count"; + $filter[] = "( + total_count = 0 + OR total_count = notinit_count)"; break; } unset($search['status']); @@ -2732,7 +2755,7 @@ function agents_get_status_clause($state, $show_not_init = true) { )"; case AGENT_STATUS_NOT_INIT: return $show_not_init - ? "(ta.total_count = ta.notinit_count)" + ? "(ta.total_count = ta.notinit_count OR ta.total_count = 0)" : "1=0"; case AGENT_STATUS_NORMAL: return "( diff --git a/pandora_console/include/functions_alerts.php b/pandora_console/include/functions_alerts.php index b81dcb802b..17cc0c8bde 100644 --- a/pandora_console/include/functions_alerts.php +++ b/pandora_console/include/functions_alerts.php @@ -1019,14 +1019,16 @@ function alerts_create_alert_agent_module ($id_agent_module, $id_alert_template, * @return mixed Affected rows or false if something goes wrong. */ function alerts_update_alert_agent_module ($id_alert_agent_module, $values) { - if (empty ($id_agent_module)) + + if (empty ($id_alert_agent_module)) return false; + if (! is_array ($values)) return false; - + return (@db_process_sql_update ('talert_template_modules', $values, - array ('id' => $id_alert_template))) !== false; + array ('id' => $id_alert_agent_module))) !== false; } /** @@ -1311,13 +1313,25 @@ function alerts_delete_alert_agent_module_action ($id_alert_agent_module_action) * * @return mixed Actions associated or false if something goes wrong. */ -function alerts_get_alert_agent_module_actions ($id_alert_agent_module, $fields = false) { +function alerts_get_alert_agent_module_actions ($id_alert_agent_module, $fields = false, $server_id = -1) { if (empty ($id_alert_agent_module)) return false; - - $actions = db_get_all_rows_filter ('talert_template_module_actions', - array ('id_alert_template_module' => $id_alert_agent_module), - $fields); + + if (defined('METACONSOLE')) { + $server = db_get_row ('tmetaconsole_setup', 'id', $server_id); + + if (metaconsole_connect($server) == NOERR) { + $actions = db_get_all_rows_filter ('talert_template_module_actions', + array ('id_alert_template_module' => $id_alert_agent_module), + $fields); + + metaconsole_restore_db (); + } + } else { + $actions = db_get_all_rows_filter ('talert_template_module_actions', + array ('id_alert_template_module' => $id_alert_agent_module), + $fields); + } if ($actions === false) return array (); diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index 189cc4203b..b71306456e 100644 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -1175,11 +1175,14 @@ function api_set_update_agent($id_agent, $thrash2, $other, $thrash3) { return; } } + $values_old = db_get_row_filter('tagente', + array('id_agente' => $id_agent), + array('id_grupo', 'disabled') + ); + $tpolicy_group_old = db_get_all_rows_sql("SELECT id_policy FROM tpolicy_groups + WHERE id_group = ".$values_old['id_grupo']); - $group_old = db_get_sql("SELECT id_grupo FROM tagente WHERE id_agente =" .$id_agent); - $tpolicy_group_old = db_get_all_rows_sql("SELECT id_policy FROM tpolicy_groups - WHERE id_group = ".$group_old); - + $return = db_process_sql_update('tagente', array('alias' => $alias, 'direccion' => $ip, @@ -1200,8 +1203,16 @@ function api_set_update_agent($id_agent, $thrash2, $other, $thrash3) { // register ip for this agent in 'taddress' agents_add_address ($id_agent, $ip); } - + if($return){ + // Update config file + if (isset($disabled) && $values_old['disabled'] != $disabled) { + enterprise_hook( + 'config_agents_update_config_token', + array($id_agent, 'standby', $disabled) + ); + } + if($tpolicy_group_old){ foreach ($tpolicy_group_old as $key => $value) { $tpolicy_agents_old= db_get_sql("SELECT * FROM tpolicy_agents @@ -1391,6 +1402,68 @@ function api_set_new_agent($thrash1, $thrash2, $other, $thrash3) { } } + +function api_set_create_os($thrash1, $thrash2, $other, $thrash3) { + global $config; + + + if (!check_acl($config['id_user'], 0, "AW")) { + returnError('forbidden', 'string'); + return; + } + + if (defined ('METACONSOLE')) { + return; + } + + $values = array(); + + $values['name'] = $other['data'][0]; + $values['description'] = $other['data'][1]; + + if (($other['data'][2] !== 0) && ($other['data'][2] != '')) { + $values['icon_name'] = $other['data'][2]; + } + + + + $resultOrId = false; + if ($other['data'][0] != '') { + $resultOrId = db_process_sql_insert('tconfig_os', $values); + } + +} + +function api_set_update_os($id_os, $thrash2, $other, $thrash3) { + global $config; + + if (defined ('METACONSOLE')) { + return; + } + + if (!check_acl($config['id_user'], 0, "AW")) { + returnError('forbidden', 'string'); + return; + } + + $values = array(); + $values['name'] = $other['data'][0]; + $values['description'] = $other['data'][1]; + + if (($other['data'][2] !== 0) && ($other['data'][2] != '')) { + $values['icon_name'] = $other['data'][2];; + } + $result = false; + + + if ($other['data'][0] != '') { + + $result = db_process_sql_update('tconfig_os', $values, array('id_os' => $id_os)); + } + +} + + /** * * Creates a custom field @@ -1547,10 +1620,6 @@ function api_set_delete_agent($id, $thrash1, $thrast2, $thrash3) { function api_get_all_agents($thrash1, $thrash2, $other, $returnType) { global $config; - if (defined ('METACONSOLE')) { - return; - } - // Error if user cannot read agents. if (!check_acl($config['id_user'], 0, "AR")) { returnError('forbidden', $returnType); @@ -1599,13 +1668,25 @@ function api_get_all_agents($thrash1, $thrash2, $other, $returnType) { // Initialization of array $result_agents = array(); // Filter by state - $sql = "SELECT id_agente, alias, direccion, comentarios, + + if (defined ('METACONSOLE')) { + $sql = "SELECT id_agente, alias, direccion, comentarios, tconfig_os.name, url_address, nombre - FROM tconfig_os, tagente + FROM tconfig_os, tmetaconsole_agent LEFT JOIN tagent_secondary_group - ON tagente.id_agente = tagent_secondary_group.id_agent - WHERE tagente.id_os = tconfig_os.id_os + ON tmetaconsole_agent.id_agente = tagent_secondary_group.id_agent + WHERE tmetaconsole_agent.id_os = tconfig_os.id_os AND disabled = 0 $where AND $groups"; + } + else{ + $sql = "SELECT id_agente, alias, direccion, comentarios, + tconfig_os.name, url_address, nombre + FROM tconfig_os, tagente + LEFT JOIN tagent_secondary_group + ON tagente.id_agente = tagent_secondary_group.id_agent + WHERE tagente.id_os = tconfig_os.id_os + AND disabled = 0 $where AND $groups"; + } $all_agents = db_get_all_rows_sql($sql); @@ -1674,6 +1755,18 @@ function api_get_all_agents($thrash1, $thrash2, $other, $returnType) { $result_agents = $all_agents; } + if (empty($returnType)) { + $returnType = "string"; + } + + if (empty($separator)) { + $separator = ";"; + } + + foreach ($result_agents as $key => $value) { + $result_agents[$key]['status'] = agents_get_status($result_agents[$key]['id_agente'], true); + } + if (count($result_agents) > 0 and $result_agents !== false) { $data = array('type' => 'array', 'data' => $result_agents); returnData($returnType, $data, $separator); @@ -7007,10 +7100,11 @@ function otherParameter2Filter($other, $return_as_array = false) { $idAgent = null; if (isset($other['data'][2]) && $other['data'][2] != '') { - $idAgent = agents_get_agent_id($other['data'][2]); + $idAgents = agents_get_agent_id_by_alias($other['data'][2]); if (!empty($idAgent)) { - $filter['id_agente'] = $idAgent; + + $filter[] = "id_agente IN (" . explode(",", $idAgents) .")"; } else { $filter['sql'] = "1=0"; diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index fd9460819c..4bb4a26b47 100644 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -2457,7 +2457,7 @@ function grafico_incidente_prioridad () { } return pie3d_graph($config['flash_charts'], $data, 320, 200, - __('Other'), '', $water_mark, + __('Other'), '', '', $config['fontpath'], $config['font_size']); } @@ -2498,7 +2498,7 @@ function graph_incidents_status () { } return pie3d_graph($config['flash_charts'], $data, 320, 200, - __('Other'), '', $water_mark, + __('Other'), '', '', $config['fontpath'], $config['font_size']); } @@ -2554,7 +2554,7 @@ function graphic_incident_group () { } return pie3d_graph($config['flash_charts'], $data, 320, 200, - __('Other'), '', $water_mark, + __('Other'), '', '', $config['fontpath'], $config['font_size']); } @@ -2609,7 +2609,7 @@ function graphic_incident_user () { } return pie3d_graph($config['flash_charts'], $data, 320, 200, - __('Other'), '', $water_mark, + __('Other'), '', '', $config['fontpath'], $config['font_size']); } @@ -2663,7 +2663,7 @@ function graphic_incident_source($width = 320, $height = 200) { } return pie3d_graph($config['flash_charts'], $data, $width, $height, - __('Other'), '', $water_mark, + __('Other'), '', '', $config['fontpath'], $config['font_size']); } diff --git a/pandora_console/include/functions_modules.php b/pandora_console/include/functions_modules.php index ac4d11b4ab..78cb1e8c96 100755 --- a/pandora_console/include/functions_modules.php +++ b/pandora_console/include/functions_modules.php @@ -439,9 +439,9 @@ function modules_update_agent_module ($id, $values, } $result = @db_process_sql_update ('tagente_modulo', $values, $where); - + if ($result == false) { - if ($result_disable == ERR_GENERIC ){ + if ($result_disable === ERR_GENERIC ){ return ERR_DB; } else{ @@ -2685,8 +2685,14 @@ function get_module_realtime_link_graph ($module) { * with some user action through the console * @param int New status * @param int Agent module to force new status + * @param int Agent id to force state recalculations */ -function force_set_module_status ($status, $id_agent_module) { +function force_set_module_status ($status, $id_agent_module, $id_agent) { + // Force recalculate counters + db_process_sql_update('tagente', + array('update_module_count' => 1), + array('id_agente' => $id_agent) + ); return db_process_sql_update( 'tagente_estado', array( 'estado' => $status, diff --git a/pandora_console/include/functions_networkmap.php b/pandora_console/include/functions_networkmap.php index 8078fdfc59..35c0763c45 100644 --- a/pandora_console/include/functions_networkmap.php +++ b/pandora_console/include/functions_networkmap.php @@ -29,10 +29,6 @@ require_once($config['homedir'] . "/include/functions_modules.php"); require_once($config['homedir'] . "/include/functions_groups.php"); ui_require_css_file ('cluetip'); -/** - * Definitions - */ -define('DEFAULT_NETWORKMAP_CENTER_LOGO', 'images/networkmap/bola_pandora_network_maps.png'); // Check if a node descends from a given node function networkmap_is_descendant ($node, $ascendant, $parents) { diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index 0b24819347..668e576c64 100755 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -6277,6 +6277,11 @@ function reporting_custom_graph($report, $content, $type = 'dinamic', else { $content['name'] = __('Simple graph'); } + } else { + if ($type_report == "custom_graph") { + $graphs = db_get_all_rows_field_filter ("tgraph", "id_graph", $content['id_gs']); + $id_graph = $content['id_gs']; + } } $return['title'] = $content['name']; diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index 54334e4ecf..9a21a9899c 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -823,10 +823,26 @@ function ui_format_alert_row ($alert, $agent = true, $url = '', $agent_style = f else return array ("", "", "", "", "", "", ""); } - - // Get agent id - $id_agent = modules_get_agentmodule_agent ($alert['id_agent_module']); - $agente = db_get_row ('tagente', 'id_agente', $id_agent); + + + if (defined('METACONSOLE')) { + + $server = db_get_row ('tmetaconsole_setup', 'id', $alert['server_data']['id']); + + if (metaconsole_connect($server) == NOERR) { + + // Get agent data from node + $agente = db_get_row ('tagente', 'id_agente', $alert['id_agent']); + + metaconsole_restore_db (); + } + + } else { + // Get agent id + $id_agent = modules_get_agentmodule_agent ($alert['id_agent_module']); + $agente = db_get_row ('tagente', 'id_agente', $id_agent); + } + $template = alerts_get_alert_template ($alert['id_alert_template']); $description = io_safe_output($template['name']); @@ -934,7 +950,7 @@ function ui_format_alert_row ($alert, $agent = true, $url = '', $agent_style = f ui_print_truncate_text (io_safe_output($description), 'description', false, true, true, '[…]', 'font-size: 7.1pt') . $disabledHtmlEnd; - $actions = alerts_get_alert_agent_module_actions ($alert['id'], false); + $actions = alerts_get_alert_agent_module_actions ($alert['id'], false, $alert['server_data']['id']); if (!empty($actions)) { $actionText = '
    '; @@ -4052,7 +4068,7 @@ function ui_get_logo_to_center_networkmap () { global $config; if ((!enterprise_installed()) || empty($config['custom_network_center_logo'])) { - return DEFAULT_NETWORKMAP_CENTER_LOGO; + return 'images/networkmap/bola_pandora_network_maps.png'; } return 'enterprise/images/custom_general_logos/' . $config['custom_support_logo']; diff --git a/pandora_console/include/functions_visual_map.php b/pandora_console/include/functions_visual_map.php index b92f17e230..e8cc2cb4c4 100755 --- a/pandora_console/include/functions_visual_map.php +++ b/pandora_console/include/functions_visual_map.php @@ -487,7 +487,7 @@ function visual_map_print_item($mode = "read", $layoutData, else { $url = ui_meta_get_url_console_child( $layoutData['id_metaconsole'], - "estado", "operation/agentes/ver_agente&id_agente=" . $layoutData['id_agent']); + "estado", "operation/agentes/ver_agente&id_agente=" . $layoutData['id_agent'], null, null, null, $isExternalLink); } } else { @@ -499,7 +499,7 @@ function visual_map_print_item($mode = "read", $layoutData, else { $url = ui_meta_get_url_console_child( $layoutData['id_metaconsole'], - "estado", "operation/agentes/ver_agente&id_agente=" . $layoutData['id_agent']); + "estado", "operation/agentes/ver_agente&id_agente=" . $layoutData['id_agent'], null, null, null, $isExternalLink); } } } @@ -662,7 +662,7 @@ function visual_map_print_item($mode = "read", $layoutData, else { $url = ui_meta_get_url_console_child( $layoutData['id_metaconsole'], - "estado", "operation/agentes/ver_agente&id_agente=" . $layoutData['id_agent']); + "estado", "operation/agentes/ver_agente&id_agente=" . $layoutData['id_agent'], null, null, null, $isExternalLink); } } break; @@ -724,7 +724,7 @@ function visual_map_print_item($mode = "read", $layoutData, else { $url = ui_meta_get_url_console_child( $layoutData['id_metaconsole'], - "estado", 'operation/agentes/ver_agente&id_agente='.$layoutData['id_agent']); + "estado", 'operation/agentes/ver_agente&id_agente='.$layoutData['id_agent'], null, null, null, $isExternalLink); } } } @@ -779,7 +779,7 @@ function visual_map_print_item($mode = "read", $layoutData, else { $url = ui_meta_get_url_console_child( $layoutData['id_metaconsole'], - "estado", 'operation/agentes/ver_agente&id_agente='.$layoutData["id_agent"].'&tab=data'); + "estado", 'operation/agentes/ver_agente&id_agente='.$layoutData["id_agent"].'&tab=data', null, null, null, $isExternalLink); } } } @@ -1775,16 +1775,25 @@ function visual_map_print_item($mode = "read", $layoutData, $value = format_for_graph($value, 2); } - if (!empty($unit_text)) - $value .= " " . $unit_text; - // Hide value on boolean modules - if (!modules_is_boolean($layoutData['id_agente_modulo'])) { - $img_style_title .= - "
    " . __("Last value: ") - . remove_right_zeros(number_format($value, $config['graph_precision'])).$unit_text; + if ($layoutData['show_last_value'] != 2) { + if ((!modules_is_boolean($layoutData['id_agente_modulo'])) || + (modules_is_boolean($layoutData['id_agente_modulo']) && $layoutData['show_last_value'] != 0)){ + if (is_numeric($value)) { + $img_style_title .= + "
    " . __("Last value: ") + . remove_right_zeros(number_format($value, $config['graph_precision'])); + } else { + $img_style_title .= + "
    " . __("Last value: ") + . $value; + } + } } + if (!empty($unit_text)) + $img_style_title .= " " . $unit_text; + if ($layoutData['id_metaconsole'] != 0) { //Restore db connection metaconsole_restore_db(); @@ -1792,7 +1801,7 @@ function visual_map_print_item($mode = "read", $layoutData, } if(get_parameter('action') == 'edit'){ - $img_style_title = ''; + $img_style_title = ''; } } diff --git a/pandora_console/include/functions_visual_map_editor.php b/pandora_console/include/functions_visual_map_editor.php index a20a8c5e42..8bc8665a9d 100755 --- a/pandora_console/include/functions_visual_map_editor.php +++ b/pandora_console/include/functions_visual_map_editor.php @@ -590,6 +590,15 @@ function visual_map_editor_print_item_palette($visualConsole_id, $background) {
' . html_print_checkbox('show_on_top', 1, '', true) . '' . __('Show last value') . '' . + html_print_select($show_last_value, 'last_value', 0, '', '', '', true) . + '' . __('Size') . '