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 55b882a8a0..5b682cd793 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 +Version: 7.0NG.727-181001 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 de63328356..0651f8af81 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" +pandora_version="7.0NG.727-181001" 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 c3fdb9804e..8f86156cb3 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 => '180913'; +use constant AGENT_BUILD => '181001'; # 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 fda93a3acf..5c1495e65b 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 1 +%define release 181001 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 27c67ebe7b..2866f56ab5 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 1 +%define release 181001 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 483ae6db77..155129ebb1 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="180913" +PI_BUILD="181001" 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 49a8479e92..68f7962de6 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{180913} +{181001} ViewReadme {Yes} @@ -2387,7 +2387,7 @@ Windows,BuildSeparateArchives {No} Windows,Executable -{<%AppName%>-Setup<%Ext%>} +{<%AppName%>-<%Version%>-Setup<%Ext%>} Windows,FileDescription {<%AppName%> <%Version%> Setup} diff --git a/pandora_agents/win32/modules/pandora_data.cc b/pandora_agents/win32/modules/pandora_data.cc index 6b9390f3f7..be891414ba 100644 --- a/pandora_agents/win32/modules/pandora_data.cc +++ b/pandora_agents/win32/modules/pandora_data.cc @@ -32,7 +32,7 @@ using namespace Pandora; */ Pandora_Data::Pandora_Data (string value) { this->value = value; - GetSystemTime (&(this->timestamp)); + GetLocalTime (&(this->timestamp)); this->data_origin = pandora_data_unknown_source; } @@ -68,7 +68,7 @@ Pandora_Data::Pandora_Data (string value, SYSTEMTIME *system_time) { */ Pandora_Data::Pandora_Data (string value, string data_origin) { this->value = value; - GetSystemTime (&(this->timestamp)); + GetLocalTime (&(this->timestamp)); this->data_origin = data_origin; } @@ -99,7 +99,7 @@ Pandora_Data::Pandora_Data (string value, SYSTEMTIME *system_time, string data_o */ Pandora_Data::Pandora_Data () { this->value = ""; - GetSystemTime (&(this->timestamp)); + GetLocalTime (&(this->timestamp)); this->data_origin = ""; } 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 f4d398ca2b..f327f6eed2 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 180913)") +#define PANDORA_VERSION ("7.0NG.727(Build 181001)") 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 3045efe943..a58170949b 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 180913))" + VALUE "ProductVersion", "(7.0NG.727(Build 181001))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index 85868c04a3..3538caa4bf 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.727 +Version: 7.0NG.727-181001 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 f8d7a26315..41b517b407 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" +pandora_version="7.0NG.727-181001" 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..c617d6425e 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,229 @@ 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 + 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 + 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 +270,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/20.sql b/pandora_console/extras/mr/20.sql index 58aa5bf708..a36a832839 100644 --- a/pandora_console/extras/mr/20.sql +++ b/pandora_console/extras/mr/20.sql @@ -24,4 +24,26 @@ ALTER TABLE `tlayout_template_data` ADD COLUMN `linked_layout_node_id` INT(10) N ALTER TABLE `treport` ADD COLUMN `hidden` tinyint(1) NOT NULL DEFAULT 0; +ALTER TABLE `trecon_task` ADD COLUMN `snmp_version` varchar(5) NOT NULL default '1'; +ALTER TABLE `trecon_task` ADD COLUMN `snmp_auth_user` varchar(255) NOT NULL default ''; +ALTER TABLE `trecon_task` ADD COLUMN `snmp_auth_pass` varchar(255) NOT NULL default ''; +ALTER TABLE `trecon_task` ADD COLUMN `snmp_auth_method` varchar(25) NOT NULL default ''; +ALTER TABLE `trecon_task` ADD COLUMN `snmp_privacy_method` varchar(25) NOT NULL default ''; +ALTER TABLE `trecon_task` ADD COLUMN `snmp_privacy_pass` varchar(255) NOT NULL default ''; +ALTER TABLE `trecon_task` ADD COLUMN `snmp_security_level` varchar(25) NOT NULL default ''; +ALTER TABLE `tpolicy_modules_inventory` ADD COLUMN `custom_fields` MEDIUMBLOB NOT NULL; + +CREATE TABLE IF NOT EXISTS `tlog_graph_models` ( + `id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, + `title` TEXT NOT NULL, + `regexp` TEXT NOT NULL, + `fields` TEXT NOT NULL, + `average` tinyint(1) NOT NULL default '0', + PRIMARY KEY(`id`) +) ENGINE = InnoDB DEFAULT CHARSET=utf8; + +INSERT INTO tlog_graph_models VALUES (1, 'Apache log model', + '^.*?\s+.*".*?\s(\/.*?)\?.*1.1"\s+(.*?)\s+(.*?)\s+', + 'pagina, html_err_code, _tiempo_', 1); + COMMIT; \ No newline at end of file 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 dd39b6159f..29c5bb4f8b 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 @@ -1175,13 +1175,13 @@ ALTER TABLE titem MODIFY `source_data` int(10) unsigned; INSERT INTO `tconfig` (`token`, `value`) VALUES ('big_operation_step_datos_purge', '100'); INSERT INTO `tconfig` (`token`, `value`) VALUES ('small_operation_step_datos_purge', '1000'); INSERT INTO `tconfig` (`token`, `value`) VALUES ('days_autodisable_deletion', '30'); -INSERT INTO `tconfig` (`token`, `value`) VALUES ('MR', 19); +INSERT INTO `tconfig` (`token`, `value`) VALUES ('MR', 20); INSERT INTO `tconfig` (`token`, `value`) VALUES ('custom_docs_logo', 'default_docs.png'); INSERT INTO `tconfig` (`token`, `value`) VALUES ('custom_support_logo', 'default_support.png'); INSERT INTO `tconfig` (`token`, `value`) VALUES ('custom_logo_white_bg_preview', 'pandora_logo_head_white_bg.png'); UPDATE tconfig SET value = 'https://licensing.artica.es/pandoraupdate7/server.php' WHERE token='url_update_manager'; DELETE FROM `tconfig` WHERE `token` = 'current_package_enterprise'; -INSERT INTO `tconfig` (`token`, `value`) VALUES ('current_package_enterprise', '726'); +INSERT INTO `tconfig` (`token`, `value`) VALUES ('current_package_enterprise', '727'); -- --------------------------------------------------------------------- -- Table `tconfig_os` @@ -1769,8 +1769,32 @@ CREATE TABLE IF NOT EXISTS `tlayout_template_data` ( FOREIGN KEY (`id_layout_template`) REFERENCES tlayout_template(`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE = InnoDB DEFAULT CHARSET=utf8; +-- --------------------------------------------------------------------- +-- Table `tlog_graph_models` +-- --------------------------------------------------------------------- +CREATE TABLE IF NOT EXISTS `tlog_graph_models` ( + `id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, + `title` TEXT NOT NULL, + `regexp` TEXT NOT NULL, + `fields` TEXT NOT NULL, + `average` tinyint(1) NOT NULL default '0', + PRIMARY KEY(`id`) +) ENGINE = InnoDB DEFAULT CHARSET=utf8; + +INSERT INTO tlog_graph_models VALUES (1, 'Apache log model', + '^.*?\s+.*".*?\s(\/.*?)\?.*1.1"\s+(.*?)\s+(.*?)\s+', + 'pagina, html_err_code, _tiempo_', 1); + -- ----------------------------------------------------- -- Add column in table `treport` -- ----------------------------------------------------- ALTER TABLE `treport` ADD COLUMN `hidden` tinyint(1) NOT NULL DEFAULT 0; + +ALTER TABLE `trecon_task` ADD COLUMN `snmp_version` varchar(5) NOT NULL default '1'; +ALTER TABLE `trecon_task` ADD COLUMN `snmp_auth_user` varchar(255) NOT NULL default ''; +ALTER TABLE `trecon_task` ADD COLUMN `snmp_auth_pass` varchar(255) NOT NULL default ''; +ALTER TABLE `trecon_task` ADD COLUMN `snmp_auth_method` varchar(25) NOT NULL default ''; +ALTER TABLE `trecon_task` ADD COLUMN `snmp_privacy_method` varchar(25) NOT NULL default ''; +ALTER TABLE `trecon_task` ADD COLUMN `snmp_privacy_pass` varchar(255) NOT NULL default ''; +ALTER TABLE `trecon_task` ADD COLUMN `snmp_security_level` varchar(25) NOT NULL default ''; 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 b0999eb638..3a208e1f7c 100644 --- a/pandora_console/godmode/agentes/configurar_agente.php +++ b/pandora_console/godmode/agentes/configurar_agente.php @@ -760,7 +760,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(); @@ -860,11 +860,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 @@ -1713,12 +1723,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"]); } + + } // MODULE DUPLICATION @@ -1936,11 +1952,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", @@ -1970,11 +1986,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_editor_common.php b/pandora_console/godmode/agentes/module_manager_editor_common.php index 61a5a23d32..9208c8fd77 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/alerts/alert_list.builder.php b/pandora_console/godmode/alerts/alert_list.builder.php index 0440ca8350..fc2b3574c4 100644 --- a/pandora_console/godmode/alerts/alert_list.builder.php +++ b/pandora_console/godmode/alerts/alert_list.builder.php @@ -218,7 +218,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/groups/group_list.php b/pandora_console/godmode/groups/group_list.php index d6efbc2d5f..0efe11ad31 100644 --- a/pandora_console/godmode/groups/group_list.php +++ b/pandora_console/godmode/groups/group_list.php @@ -215,20 +215,57 @@ if (! check_acl($config['id_user'], 0, "PM")) { return; } +$sec = defined('METACONSOLE') ? 'advanced' : 'gagente'; +$url_tree = "index.php?sec=$sec&sec2=godmode/groups/group_list&tab=tree"; +$url_groups = "index.php?sec=$sec&sec2=godmode/groups/group_list&tab=groups"; +$buttons['tree'] = array( + 'active' => false, + 'text' => "" . + html_print_image( + "images/gm_massive_operations.png", + true, + array ( + "title" => __('Tree Group view') + ) + ) . "" +); + +$buttons['groups'] = array( + 'active' => false, + 'text' => "" . + html_print_image( + "images/group.png", + true, + array( + "title" => __('Group view') + ) + ) . "" +); + +$tab = (string)get_parameter('tab', 'groups'); + +// Marks correct tab +switch ($tab) { + case 'tree': + $buttons['tree']['active'] = true; + break; + case 'groups': + default: + $buttons['groups']['active'] = true; + break; +} + // Header if (defined('METACONSOLE')) { agents_meta_print_header(); - $sec = 'advanced'; echo '
'; echo __("Edit or delete groups can cause problems with synchronization"); echo '
'; -} -else { +} else { ui_print_page_header ( __("Groups defined in %s", get_product_name()), - "images/group.png", false, "", true, "" + "images/group.png", false, "", true, $buttons ); - $sec = 'gagente'; } $create_group = (bool) get_parameter ('create_group'); @@ -365,148 +402,158 @@ if (($delete_group) && (check_acl($config['id_user'], 0, "PM"))) { } } -$acl=''; -$search_name = ''; -$offset = (int)get_parameter('offset', 0); -$search = (string)get_parameter('search', ''); -$block_size = $config['block_size']; +if($tab == 'tree'){ + echo html_print_image('images/spinner.gif', true, + array('class' => "loading_tree", + 'style' => 'display: none;')); + echo "
"; -if(!empty($search)){ - $search_name = "AND t.nombre LIKE '%$search%'"; } +else{ + $acl=''; + $search_name = ''; + $offset = (int)get_parameter('offset', 0); + $search = (string)get_parameter('search', ''); + $block_size = $config['block_size']; -if (!users_can_manage_group_all("AR")){ - $user_groups_acl = users_get_groups(false, "AR"); - $groups_acl = implode(",", $user_groups_ACL); - if(empty($groups_acl)) return ui_print_info_message ( array('no_close'=>true, 'message'=> __('There are no defined groups') ) ); + if(!empty($search)){ + $search_name = "AND t.nombre LIKE '%$search%'"; + } - $acl = "AND t.id_grupo IN ($groups_acl)"; -} + if (!users_can_manage_group_all("AR")){ + $user_groups_acl = users_get_groups(false, "AR"); + $groups_acl = implode(",", $user_groups_ACL); + if(empty($groups_acl)) return ui_print_info_message ( array('no_close'=>true, 'message'=> __('There are no defined groups') ) ); -$form = ""; - $form .= ""; - $form .= ""; - $form .= "
" . __('Search') . ' '; - $form .= html_print_input_text ("search", $search, '', 100, 100, true); - $form .= ""; - $form .= ""; - $form .= "
"; -$form .= "
"; + $acl = "AND t.id_grupo IN ($groups_acl)"; + } -echo $form; + $form = "
"; + $form .= ""; + $form .= ""; + $form .= "
" . __('Search') . ' '; + $form .= html_print_input_text ("search", $search, '', 100, 100, true); + $form .= ""; + $form .= ""; + $form .= "
"; + $form .= "
"; -$groups_sql = - "SELECT t.*, - p.nombre AS parent_name, - IF(t.parent=p.id_grupo, 1, 0) AS has_child - FROM tgrupo t - LEFT JOIN tgrupo p - ON t.parent=p.id_grupo - WHERE 1=1 - $acl - $search_name - ORDER BY nombre - LIMIT $offset, $block_size -"; + echo $form; -$groups = db_get_all_rows_sql($groups_sql); - -if (!empty($groups)) { - //Count all groups for pagination only saw user and filters - $groups_sql_count = "SELECT count(*) + $groups_sql = + "SELECT t.*, + p.nombre AS parent_name, + IF(t.parent=p.id_grupo, 1, 0) AS has_child FROM tgrupo t + LEFT JOIN tgrupo p + ON t.parent=p.id_grupo WHERE 1=1 $acl $search_name + ORDER BY nombre + LIMIT $offset, $block_size "; - $groups_count = db_get_value_sql($groups_sql_count); - $table = new StdClass(); - $table->width = '100%'; - $table->class = "databox data"; - $table->head = array (); - $table->head[0] = __('ID'); - $table->head[1] = __('Name'); - $table->head[2] = __('Icon'); - $table->head[3] = __('Alerts'); - $table->head[4] = __('Parent'); - $table->head[5] = __('Description'); - $table->head[6] = __('Actions'); - $table->align = array (); - $table->align[0] = 'right'; - $table->align[2] = 'left'; - $table->align[6] = 'left'; - $table->size[5] = '30%'; - $table->size[6] = '10%'; - $table->data = array (); + $groups = db_get_all_rows_sql($groups_sql); - foreach ($groups as $key => $group) { - $url = "index.php?sec=gagente&sec2=godmode/groups/configure_group&id_group=".$group['id_grupo']; - $url_delete = "index.php?sec=gagente&sec2=godmode/groups/group_list&delete_group=1&id_group=" . $group['id_grupo']; - $table->data[$key][0] = $group['id_grupo']; - $table->data[$key][1] = "" . $group['nombre'] . ""; - $table->data[$key][2] = html_print_image( - "images/groups_small/" . $group['icon'] . ".png", - true, - array( - "style" => '', - "class" => "bot", - "alt" => $group['nombre'], - "title" => $group['nombre'], - false, false, false, true - ) - ); + if (!empty($groups)) { + //Count all groups for pagination only saw user and filters + $groups_sql_count = "SELECT count(*) + FROM tgrupo t + WHERE 1=1 + $acl + $search_name + "; + $groups_count = db_get_value_sql($groups_sql_count); - //reporting_get_group_stats - $table->data[$key][3] = $group['disabled'] ? __('Disabled') : __('Enabled'); - $table->data[$key][4] = $group['parent_name']; - $table->data[$key][5] = $group['description']; - $table->data[$key][6] = "" . - html_print_image( - "images/config.png", + $table = new StdClass(); + $table->width = '100%'; + $table->class = "databox data"; + $table->head = array (); + $table->head[0] = __('ID'); + $table->head[1] = __('Name'); + $table->head[2] = __('Icon'); + $table->head[3] = __('Alerts'); + $table->head[4] = __('Parent'); + $table->head[5] = __('Description'); + $table->head[6] = __('Actions'); + $table->align = array (); + $table->align[0] = 'left'; + $table->align[2] = 'left'; + $table->align[6] = 'left'; + $table->size[0] = '3%'; + $table->size[5] = '30%'; + $table->size[6] = '5%'; + $table->data = array (); + + foreach ($groups as $key => $group) { + $url = "index.php?sec=gagente&sec2=godmode/groups/configure_group&id_group=".$group['id_grupo']; + $url_delete = "index.php?sec=gagente&sec2=godmode/groups/group_list&delete_group=1&id_group=" . $group['id_grupo']; + $table->data[$key][0] = $group['id_grupo']; + $table->data[$key][1] = "" . $group['nombre'] . ""; + $table->data[$key][2] = html_print_image( + "images/groups_small/" . $group['icon'] . ".png", true, array( - "alt" => __('Edit'), - "title" => __('Edit'), - "border" => '0' + "style" => '', + "class" => "bot", + "alt" => $group['nombre'], + "title" => $group['nombre'], + false, false, false, true ) - ) . - ""; + ); + + //reporting_get_group_stats + $table->data[$key][3] = $group['disabled'] ? __('Disabled') : __('Enabled'); + $table->data[$key][4] = $group['parent_name']; + $table->data[$key][5] = $group['description']; + $table->data[$key][6] = "" . + html_print_image( + "images/config.png", + true, + array( + "alt" => __('Edit'), + "title" => __('Edit'), + "border" => '0' + ) + ) . + ""; + + $confirm_message = __('Are you sure?'); + if ($group['has_child']) { + $confirm_message = __('The child groups will be updated to use the parent id of the deleted group') . ". " . $confirm_message; + } + + $table->data[$key][6] .= '  ' . + '' . + html_print_image( + "images/cross.png", + true, + array( + "alt" => __('Delete'), + "title" => __('Delete'), + "border" => '0' + ) + ) . + ""; - $confirm_message = __('Are you sure?'); - if ($group['has_child']) { - $confirm_message = __('The child groups will be updated to use the parent id of the deleted group') . ". " . $confirm_message; } - $table->data[$key][6] .= '  ' . - '' . - html_print_image( - "images/cross.png", - true, - array( - "alt" => __('Delete'), - "title" => __('Delete'), - "border" => '0' - ) - ) . - ""; - + echo ui_pagination( + $groups_count, false, + $offset, $block_size, + true, 'offset', false + ); + html_print_table ($table); + echo ui_pagination( + $groups_count, false, + $offset, $block_size, + true, 'offset', true + ); + } + else { + ui_print_info_message ( array('no_close'=>true, 'message'=> __('There are no defined groups') ) ); } - - echo ui_pagination( - $groups_count, false, - $offset, $block_size, - true, 'offset', false - ); - html_print_table ($table); - echo ui_pagination( - $groups_count, false, - $offset, $block_size, - true, 'offset', true - ); -} -else { - ui_print_info_message ( array('no_close'=>true, 'message'=> __('There are no defined groups') ) ); } if (check_acl($config['id_user'], 0, "PM")) { @@ -517,5 +564,101 @@ if (check_acl($config['id_user'], 0, "PM")) { echo ''; } +ui_require_javascript_file("TreeController", "include/javascript/tree/"); + enterprise_hook('close_meta_frame'); +$tab = "group_edition"; + ?> + + + + + + + + diff --git a/pandora_console/godmode/massive/massive_delete_modules.php b/pandora_console/godmode/massive/massive_delete_modules.php index d1dd485db2..4646dea1a8 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; @@ -212,8 +214,10 @@ function process_manage_delete ($module_name, $id_agents, $module_status = 'all' } } else { - $modules = agents_get_modules ($id_agents, 'id_agente_modulo', - sprintf('nombre IN ("%s")', implode('","',$module_name)), true); + if ($status_module != -1) // If module status filter has been applied + $modules = agents_get_modules ($id_agents, 'id_agente_modulo', sprintf('nombre IN ("%s") AND 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', sprintf('nombre IN ("%s")', implode('","',$module_name)), true); } } diff --git a/pandora_console/godmode/massive/massive_edit_agents.php b/pandora_console/godmode/massive/massive_edit_agents.php index f543772648..3f78d8c88c 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 @@ -421,7 +432,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 e7f92d4594..2367ad05d9 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/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 7d3021bfd2..d32b15e1aa 100755 --- a/pandora_console/godmode/reporting/visual_console_builder.editor.js +++ b/pandora_console/godmode/reporting/visual_console_builder.editor.js @@ -1543,8 +1543,16 @@ function loadFieldsFromDB(item) { $("select[name=parent]").val(val); if (key == 'linked_layout_status_type') $("select[name=linked_map_status_calculation_type]").val(val).change(); - if (key == 'id_layout_linked') - $("select[name=map_linked]").val(val).change(); + if (key == 'id_layout_linked') { + if (data['linked_layout_node_id'] == null) { + $("select[name=map_linked]").val(val).change(); + } + else { + var $option = $("select[name=map_linked] > option[data-node-id=" + data['linked_layout_node_id'] + "][value=" + val + "]"); + if ($option.length === 0) $option = $("select[name=map_linked] > option[value=" + val + "]"); + $option.prop("selected", true).parent().change(); + } + } if (key == 'linked_layout_node_id') $("input[name=linked_map_node_id]").val(val); if (key == 'id_layout_linked_weight') diff --git a/pandora_console/godmode/servers/manage_recontask.php b/pandora_console/godmode/servers/manage_recontask.php index 2b9527704d..1d5dc69c89 100644 --- a/pandora_console/godmode/servers/manage_recontask.php +++ b/pandora_console/godmode/servers/manage_recontask.php @@ -97,7 +97,15 @@ if ((isset ($_GET["update"])) OR ((isset ($_GET["create"])))) { $field2 = get_parameter ("_field2_", ""); $field3 = get_parameter ("_field3_", ""); $field4 = get_parameter ("_field4_", ""); - + $snmp_version = get_parameter_post ("snmp_version"); + $snmp3_auth_user = get_parameter_post ("snmp_auth_user"); + $snmp3_auth_pass = get_parameter_post ("snmp_auth_pass"); + $snmp3_privacy_method = get_parameter_post ("snmp_privacy_method"); + $snmp3_privacy_pass = get_parameter_post ("snmp_privacy_pass"); + $snmp3_auth_method = get_parameter_post ("snmp_auth_method"); + $snmp3_security_level = get_parameter_post ("snmp_security_level"); + + if ($mode == "network_sweep") $id_recon_script = 0; else @@ -154,8 +162,30 @@ if (isset($_GET["update"])) { 'macros' => $macros, 'alias_as_name' => $alias_as_name, 'snmp_enabled' => $snmp_enabled, - 'vlan_enabled' => $vlan_enabled + 'vlan_enabled' => $vlan_enabled, + 'snmp_version' => $snmp_version ); + + $values_v3 = array( + 'snmp_auth_user' => $snmp3_auth_user, + 'snmp_auth_pass' => $snmp3_auth_pass, + 'snmp_privacy_method' => $snmp3_privacy_method, + 'snmp_privacy_pass' => $snmp3_privacy_pass, + 'snmp_auth_method' => $snmp3_auth_method, + 'snmp_security_level' => $snmp3_security_level + ); + if($values['snmp_version'] == '1' || $values['snmp_version'] == '2' || $values['snmp_version'] == '2c'){ + $values_v3 = array( + 'snmp_auth_user' => '', + 'snmp_auth_pass' => '', + 'snmp_privacy_method' => '', + 'snmp_privacy_pass' => '', + 'snmp_auth_method' => '', + 'snmp_security_level' => '' + ); + } + + $values = array_merge($values, $values_v3); $where = array('id_rt' => $id); @@ -217,13 +247,37 @@ if (isset($_GET["create"])) { 'macros' => $macros, 'alias_as_name' => $alias_as_name, 'snmp_enabled' => $snmp_enabled, - 'vlan_enabled' => $vlan_enabled + 'vlan_enabled' => $vlan_enabled, + 'snmp_version' => $snmp_version ); + $values_v3 = array( + 'snmp_auth_user' => $snmp3_auth_user, + 'snmp_auth_pass' => $snmp3_auth_pass, + 'snmp_privacy_method' => $snmp3_privacy_method, + 'snmp_privacy_pass' => $snmp3_privacy_pass, + 'snmp_auth_method' => $snmp3_auth_method, + 'snmp_security_level' => $snmp3_security_level + ); + if($values['snmp_version'] == '1' || $values['snmp_version'] == '2' || $values['snmp_version'] == '2c'){ + $values_v3 = array( + 'snmp_auth_user' => '', + 'snmp_auth_pass' => '', + 'snmp_privacy_method' => '', + 'snmp_privacy_pass' => '', + 'snmp_auth_method' => '', + 'snmp_security_level' => '' + ); + } + if ($values['snmp_version'] == '3'){ + $values['vlan_enabled'] = 0; + } + + $values = array_merge($values, $values_v3); + $name = io_safe_output($name); $name = trim($name, ' '); $name = io_safe_input($name); - $reason = ""; if ($name != "") { @@ -293,7 +347,7 @@ else { $color=1; if ($result !== false) { $table = new StdClass(); - $table->head = array (__('Name'), __('Network'), __('Mode'), __('Group'), __('Incident'), __('OS'), __('Interval'), __('Ports'), __('Action')); + $table->head = array (__('Name'), __('Network'), __('Mode'), __('Group'), __('SNMP Version'), __('Incident'), __('OS'), __('Interval'), __('Ports'), __('Action')); $table->align = array ("left","left","left","left","left","left","left","left"); $table->width = "100%"; $table->cellpadding = 4; @@ -336,48 +390,64 @@ if ($result !== false) { $data[3] = "-"; } + //SNMP VERSION + if ($row["snmp_version"] == '1'){ + $data[4] = "v. 1"; + } + elseif($row["snmp_version"] == '2'){ + $data[4] = "v. 2"; + } + elseif($row["snmp_version"] == '2c'){ + $data[4] = "v. 2c"; + } + elseif($row["snmp_version"] == '3'){ + $data[4] = "v. 3"; + } + + + // INCIDENT - $data[4] = (($row["create_incident"] == 1) ? __('Yes') : __('No')); + $data[5] = (($row["create_incident"] == 1) ? __('Yes') : __('No')); // OS if ($row["id_recon_script"] == 0) { - $data[5] =(($row["id_os"] > 0) ? ui_print_os_icon ($row["id_os"], false, true) : __('Any')); + $data[6] =(($row["id_os"] > 0) ? ui_print_os_icon ($row["id_os"], false, true) : __('Any')); } else { - $data[5] = "-"; + $data[6] = "-"; } // INTERVAL if ($row["interval_sweep"]==0) - $data[6] = __("Manual"); + $data[7] = __("Manual"); else - $data[6] =human_time_description_raw($row["interval_sweep"]); + $data[7] =human_time_description_raw($row["interval_sweep"]); // PORTS if ($row["id_recon_script"] == 0) { - $data[7] = substr($row["recon_ports"],0,15); + $data[8] = substr($row["recon_ports"],0,15); } else { - $data[7] = "-"; + $data[8] = "-"; } // ACTION $task_group = $row["id_group"]; if (in_array($task_group, $user_groups_w)){ - $data[8] = '' . html_print_image("images/eye.png", true) . ''; - $data[8] .= '' . html_print_image("images/cross.png", true, array("border" => '0')) . ''; + $data[9] = '' . html_print_image("images/eye.png", true) . ''; + $data[9] .= '' . html_print_image("images/cross.png", true, array("border" => '0')) . ''; if($mode_name != 'IPAM Recon'){ - $data[8] .= '' .html_print_image("images/config.png", true) . ''; + $data[9] .= '' .html_print_image("images/config.png", true) . ''; } else { $sql_ipam = 'select id from tipam_network where id_recon_task =' . $row["id_rt"]; $id_recon_ipam = db_get_sql($sql_ipam); - $data[8] .= '' . html_print_image("images/config.png", true) . ''; + $data[9] .= '' . html_print_image("images/config.png", true) . ''; } if($row["disabled"] == 0) { - $data[8] .= '' .html_print_image("images/lightbulb.png", true) . ''; + $data[9] .= '' .html_print_image("images/lightbulb.png", true) . ''; } else { - $data[8] .= '' .html_print_image("images/lightbulb_off.png", true) . ''; + $data[9] .= '' .html_print_image("images/lightbulb_off.png", true) . ''; } } diff --git a/pandora_console/godmode/servers/manage_recontask_form.php b/pandora_console/godmode/servers/manage_recontask_form.php index d33e0ee19c..f5865d1470 100644 --- a/pandora_console/godmode/servers/manage_recontask_form.php +++ b/pandora_console/godmode/servers/manage_recontask_form.php @@ -108,6 +108,13 @@ if (isset($_GET["update"]) || (isset($_GET["upd"]))) { $id_os = $row["id_os"]; $recon_ports = $row["recon_ports"]; $snmp_community = $row["snmp_community"]; + $snmp_version = $row["snmp_version"]; + $snmp3_auth_user = $row["snmp_auth_user"]; + $snmp3_auth_pass = $row["snmp_auth_pass"]; + $snmp3_privacy_method = $row["snmp_privacy_method"]; + $snmp3_privacy_pass = $row["snmp_privacy_pass"]; + $snmp3_auth_method = $row["snmp_auth_method"]; + $snmp3_security_level = $row["snmp_security_level"]; $id_recon_script = $row["id_recon_script"]; $field1 = $row["field1"]; $field2 = $row["field2"]; @@ -156,6 +163,13 @@ elseif (isset($_GET["create"]) || isset($_GET["crt"])) { $id_group = 0; $create_incident = 1; $snmp_community = "public"; + $snmp3_auth_user = ''; + $snmp3_auth_pass = ''; + $snmp_version = 1; + $snmp3_privacy_method = ''; + $snmp3_privacy_pass = ''; + $snmp3_auth_method = ''; + $snmp3_security_level = ''; $id_network_profile = 0; $id_os = -1; // Any $recon_ports = ""; // Any @@ -212,6 +226,13 @@ $table->rowclass[20] = "network_sweep"; $table->rowclass[21] = "network_sweep"; $table->rowclass[22] = "network_sweep"; $table->rowclass[23] = "network_sweep"; +$table->rowclass[24] = "network_sweep"; +$table->rowclass[25] = "network_sweep recon_v3"; +$table->rowclass[26] = "network_sweep recon_v3"; +$table->rowclass[27] = "network_sweep recon_v3"; +$table->rowclass[28] = "network_sweep recon_v3"; +$table->rowclass[29] = "network_sweep recon_v3"; +$table->rowclass[30] = "network_sweep recon_v3"; $table->rowclass[6] = "recon_script"; $table->rowclass[13] = "recon_script"; @@ -327,6 +348,34 @@ $table->data[12][0] = "".__('SNMP Default community'); $table->data[12][0] .= ui_print_help_tip (__('You can specify several values, separated by commas, for example: public,mysecret,1234'), true); $table->data[12][1] = html_print_input_text ('snmp_community', $snmp_community, '', 35, 0, true); +//SNMP version + +$snmp_versions['1'] = 'v. 1'; +$snmp_versions['2'] = 'v. 2'; +$snmp_versions['2c'] = 'v. 2c'; +$snmp_versions['3'] = 'v. 3'; +$table->data[24][0] ="". _('SNMP version'); +$table->data[24][1] = html_print_select ($snmp_versions, 'snmp_version', $snmp_version, '', '', 0, true); + +$table->data[25][0] ="".__('Auth user'); +$table->data[25][1] = html_print_input_text ('snmp_auth_user', $snmp3_auth_user, '', 15, 60, true, '', + false, '', ''); +$table->data[26][0] ="". __('Auth password') . ui_print_help_tip(__("The pass length must be eight character minimum."), true); +$table->data[26][1] = html_print_input_password ('snmp_auth_pass', $snmp3_auth_pass, '', 15, 60, true, '', + false, ''); +$table->data[26][1] .= html_print_input_hidden_extended('active_snmp_v3', 0, 'active_snmp_v3_mmen', true); + +$table->data[27][0] ="". __('Privacy method'); +$table->data[27][1] = html_print_select(array('DES' => __('DES'), 'AES' => __('AES')), 'snmp_privacy_method', $snmp3_privacy_method, '', '', '', true, false, false, '', ''); +$table->data[28][0] ="". __('Privacy pass') . ui_print_help_tip(__("The pass length must be eight character minimum."), true); +$table->data[28][1] = html_print_input_password ('snmp_privacy_pass', $snmp3_privacy_pass, '', 15, 60, true, '', + false, ''); +$table->data[29][0] ="". __('Auth method'); +$table->data[29][1] = html_print_select(array('MD5' => __('MD5'), 'SHA' => __('SHA')), 'snmp_auth_method', $snmp3_auth_method, '', '', '', true, false, false, '', ''); +$table->data[30][0] ="". __('Security level'); +$table->data[30][1] = html_print_select(array('noAuthNoPriv' => __('Not auth and not privacy method'), + 'authNoPriv' => __('Auth and not privacy method'), 'authPriv' => __('Auth and privacy method')), 'snmp_security_level', $snmp3_security_level, '', '', '', true, false, false, '', ''); + // Explanation $explanation = db_get_value('description', 'trecon_script', 'id_recon_script', $id_recon_script); @@ -461,9 +510,24 @@ $('select#id_recon_script').change(function() { get_explanation_recon_script($(this).val()); }); +$('select#snmp_version').change(function () { + if (this.value == "3") { + $(".recon_v3").show(); + $("input[name=active_snmp_v3]").val(1); + $("input[name=snmp_community]").attr("disabled", true); + $("input[name=vlan_enabled]").removeAttr("checked"); + $("input[name=vlan_enabled]").attr("disabled", true); + } + else { + $(".recon_v3").hide(); + $("input[name=active_snmp_v3]").val(0); + $("input[name=snmp_community]").removeAttr('disabled'); + $("input[name=vlan_enabled]").removeAttr('disabled'); + } +}); + $('select#mode').change(function() { var type = $(this).val(); - if (type == 'recon_script') { $(".recon_script").show(); $(".network_sweep").hide(); @@ -474,6 +538,7 @@ $('select#mode').change(function() { $(".recon_script").hide(); $(".network_sweep").show(); $('.macro_field').remove(); + $('select#snmp_version').trigger('change'); } }).change(); @@ -543,5 +608,5 @@ function get_explanation_recon_script (id) { }); taskManager.addTask(xhr); } -/* ]]> */ + diff --git a/pandora_console/godmode/users/configure_user.php b/pandora_console/godmode/users/configure_user.php index f5b7fdc5bc..cd8c981c8e 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'), diff --git a/pandora_console/include/ajax/tree.ajax.php b/pandora_console/include/ajax/tree.ajax.php index c2e051c3f4..07435d9109 100644 --- a/pandora_console/include/ajax/tree.ajax.php +++ b/pandora_console/include/ajax/tree.ajax.php @@ -43,6 +43,7 @@ if (is_ajax ()) { require_once($config['homedir'] . "/include/class/TreeModule.class.php"); require_once($config['homedir'] . "/include/class/TreeTag.class.php"); require_once($config['homedir'] . "/include/class/TreeGroup.class.php"); + require_once($config['homedir'] . "/include/class/TreeGroupEdition.class.php"); enterprise_include_once("include/class/TreePolicies.class.php"); enterprise_include_once("include/class/TreeGroupMeta.class.php"); require_once($config['homedir'] . "/include/functions_reporting.php"); @@ -104,6 +105,9 @@ if (is_ajax ()) { if (!class_exists('TreePolicies')) break; $tree = new TreePolicies($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access); break; + case 'group_edition': + $tree = new TreeGroupEdition($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access); + break; default: // FIXME. No error handler return; diff --git a/pandora_console/include/ajax/visual_console_builder.ajax.php b/pandora_console/include/ajax/visual_console_builder.ajax.php index d472542390..98be4f174b 100755 --- a/pandora_console/include/ajax/visual_console_builder.ajax.php +++ b/pandora_console/include/ajax/visual_console_builder.ajax.php @@ -101,7 +101,7 @@ $height = get_parameter('height', null); $parent = get_parameter('parent', null); $map_linked = get_parameter('map_linked', null); $linked_map_node_id = get_parameter('linked_map_node_id', null); -$linked_map_status_calculation_type = get_parameter('linked_map_status_calculation_type', 'default'); +$linked_map_status_calculation_type = get_parameter('linked_map_status_calculation_type', null); $map_linked_weight = get_parameter('map_linked_weight', null); if ($map_linked_weight !== null) { @@ -615,8 +615,8 @@ switch ($action) { $values['id_agent'] = $id_agent; } - if ($linked_map_node_id) { - $values['linked_layout_node_id'] = $linked_map_node_id; + if ($linked_map_node_id !== null) { + $values['linked_layout_node_id'] = (int) $linked_map_node_id; } } else if ($id_agent == 0) { 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/Tree.class.php b/pandora_console/include/class/Tree.class.php index e18cfb599e..b72e3ec216 100644 --- a/pandora_console/include/class/Tree.class.php +++ b/pandora_console/include/class/Tree.class.php @@ -93,12 +93,12 @@ class Tree { if (empty($this->filter['searchModule'])) { return ""; } - return " AND tam.nombre LIKE '%".$this->filter['searchModule']."%' "; + return " AND tam.nombre LIKE '%%".$this->filter['searchModule']."%%' "; } protected function getAgentSearchFilter() { if (empty($this->filter['searchAgent'])) return ""; - return " AND LOWER(ta.alias) LIKE LOWER('%".$this->filter['searchAgent']."%')"; + return " AND LOWER(ta.alias) LIKE LOWER('%%".$this->filter['searchAgent']."%%')"; } @@ -268,7 +268,7 @@ class Tree { protected function getGroupSearchFilter() { if (empty($this->filter['searchGroup'])) return ""; - return " AND tg.nombre LIKE '%" . $this->filter['searchGroup'] . "%'"; + return " AND tg.nombre LIKE '%%" . $this->filter['searchGroup'] . "%%'"; } static function cmpSortNames($a, $b) { 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/class/TreeGroupEdition.class.php b/pandora_console/include/class/TreeGroupEdition.class.php new file mode 100644 index 0000000000..dea62da238 --- /dev/null +++ b/pandora_console/include/class/TreeGroupEdition.class.php @@ -0,0 +1,108 @@ +id == -1) { + $this->getFirstLevel(); + } + } + + protected function getProcessedGroups () { + $processed_groups = array(); + // Index and process the groups + $groups = $this->getGroupCounters(); + + // If user have not permissions in parent, set parent node to 0 (all) + // Avoid to do foreach for admins + if (!users_can_manage_group_all("AR")) { + foreach ($groups as $id => $group) { + if (!isset($this->userGroups[$groups[$id]['parent']])) { + $groups[$id]['parent'] = 0; + } + } + } + // Build the group hierarchy + foreach ($groups as $id => $group) { + if (isset($groups[$id]['parent']) && ($groups[$id]['parent'] != 0)) { + $parent = $groups[$id]['parent']; + // Parent exists + if (!isset($groups[$parent]['children'])) { + $groups[$parent]['children'] = array(); + } + // Store a reference to the group into the parent + $groups[$parent]['children'][] = &$groups[$id]; + // This group was introduced into a parent + $groups[$id]['have_parent'] = true; + } + } + + // Sort the children groups + foreach ($groups as $id => $group) { + if (isset($groups[$id]['children'])) { + usort($groups[$id]['children'], array("Tree", "cmpSortNames")); + } + } + //Filter groups and eliminates the reference to children groups out of her parent + $groups = array_filter($groups, function ($group) { + return !$group['have_parent']; + }); + + usort($groups, array("Tree", "cmpSortNames")); + return $groups; + } + + + protected function getGroupCounters() { + $messages = array( + 'confirm' => __('Confirm'), + 'cancel' => __('Cancel'), + 'messg' => __('Are you sure?') + ); + $sql = "SELECT id_grupo AS gid, + nombre as name, parent, icon + FROM tgrupo + "; + + $stats = db_get_all_rows_sql($sql); + $group_stats = array(); + foreach ($stats as $group) { + $group_stats[$group['gid']]['name'] = $group['name']; + $group_stats[$group['gid']]['parent'] = $group['parent']; + $group_stats[$group['gid']]['icon'] = $group['icon']; + $group_stats[$group['gid']]['id'] = $group['gid']; + $group_stats[$group['gid']]['type'] = 'group'; + + $group_stats[$group['gid']] = $this->getProcessedItem($group_stats[$group['gid']]); + $group_stats[$group['gid']]['delete']['messages'] = $messages; + $group_stats[$group['gid']]['edit'] = 1; + $group_stats[$group['gid']]['alerts'] = ''; + } + + return $group_stats; + } +} + +?> + diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index dcad6d4aab..100c12c8fd 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 = 'PC180913'; +$build_version = 'PC181001'; $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 5bdd03a418..426a5c2e6b 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -915,7 +915,7 @@ function agents_get_group_agents ( if (isset($search['status'])) { switch ($search['status']) { case AGENT_STATUS_NORMAL: - $filter[] = "normal_count = total_count"; + $filter[] = "(normal_count = total_count AND notinit_count <> total_count)"; break; case AGENT_STATUS_WARNING: $filter[] = "(critical_count = 0 AND warning_count > 0)"; @@ -2025,11 +2025,17 @@ function agents_get_agentmodule_group ($id_module) { * This function gets the group for a given agent * * @param int The agent id + * @param bool True to use the metaconsole tables * * @return int The group id */ -function agents_get_agent_group ($id_agent) { - return (int) db_get_value ('id_grupo', "tagente", 'id_agente', (int) $id_agent); +function agents_get_agent_group ($id_agent, $force_meta = false) { + return (int) db_get_value ( + 'id_grupo', + $force_meta ? "tmetaconsole_agent" : "tagente", + 'id_agente', + (int) $id_agent + ); } /** @@ -2680,20 +2686,21 @@ function agents_generate_name ($alias, $address = '') { * * @param int $id_agent * @param int $id_group. By default it will search for it in dtabase + * @param bool True to use the metaconsole tables * * @return Array with the main and secondary groups */ -function agents_get_all_groups_agent ($id_agent, $group = false) { +function agents_get_all_groups_agent ($id_agent, $group = false, $force_meta = false) { // Cache the agent id groups static $cache = array(); if (isset($cache[$id_agent])) return $cache[$id_agent]; // Get the group if is not defined - if ($group === false) $group = agents_get_agent_group($id_agent); + if ($group === false) $group = agents_get_agent_group($id_agent, $force_meta); // If cannot retrieve the group, it means that agent does not exist if (!$group) return array(); - $secondary_groups = enterprise_hook('agents_get_secondary_groups', array($id_agent)); + $secondary_groups = enterprise_hook('agents_get_secondary_groups', array($id_agent, $force_meta)); // Return only an array with the group in open version if ($secondary_groups == ENTERPRISE_NOT_HOOK) return array($group); diff --git a/pandora_console/include/functions_alerts.php b/pandora_console/include/functions_alerts.php index 322b3a7602..52c0338eb4 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 (); @@ -1638,23 +1652,13 @@ function get_agent_alert_fired ($id_agent, $id_alert, $period, $date = 0) { * * @return array An array with all the events happened. */ -function get_module_alert_fired ($id_agent_module, $id_alert, $period, $date = 0) { +function get_module_alert_fired ($id_agent_module, $id_alert) { - if (!is_numeric ($date)) { - $date = time_w_fixed_tz($date); - } - if (empty ($date)) { - $date = get_system_time(); - } - - $datelimit = $date - $period; - - $sql = sprintf ('SELECT timestamp + $sql = sprintf ('SELECT * FROM tevento - WHERE id_agentmodule = %d AND utimestamp > %d - AND utimestamp <= %d + WHERE id_agentmodule = %d AND id_alert_am = %d - ORDER BY timestamp DESC', $id_agent_module, $datelimit, $date, $id_alert); + ORDER BY timestamp DESC', $id_agent_module, $id_alert); return db_get_all_rows_sql ($sql); } diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index 189cc4203b..e66fb3dcaf 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 @@ -7007,10 +7080,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 33118d39c2..ff15c53525 100644 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -513,6 +513,8 @@ function grafico_modulo_sparse_data( } $period_time_interval = $period_time_interval - $params['time_interval']; } + //drag the last value to paint the graph correctly + $acum_array_data[]= array( 0 => $start_period, 1 => $acum_array_data[$i-1][1]); $array_data['sum1']['data'] = $acum_array_data; } @@ -3034,7 +3036,7 @@ function grafico_incidente_prioridad () { } return pie3d_graph($config['flash_charts'], $data, 320, 200, - __('Other'), '', $water_mark, + __('Other'), '', '', $config['fontpath'], $config['font_size']); } @@ -3075,7 +3077,7 @@ function graph_incidents_status () { } return pie3d_graph($config['flash_charts'], $data, 320, 200, - __('Other'), '', $water_mark, + __('Other'), '', '', $config['fontpath'], $config['font_size']); } @@ -3131,7 +3133,7 @@ function graphic_incident_group () { } return pie3d_graph($config['flash_charts'], $data, 320, 200, - __('Other'), '', $water_mark, + __('Other'), '', '', $config['fontpath'], $config['font_size']); } @@ -3186,7 +3188,7 @@ function graphic_incident_user () { } return pie3d_graph($config['flash_charts'], $data, 320, 200, - __('Other'), '', $water_mark, + __('Other'), '', '', $config['fontpath'], $config['font_size']); } @@ -3240,7 +3242,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_html.php b/pandora_console/include/functions_html.php index 783f1a9cab..932e8a3457 100644 --- a/pandora_console/include/functions_html.php +++ b/pandora_console/include/functions_html.php @@ -47,13 +47,13 @@ else{ /** * Prints the print_r with < pre > tags */ -function html_debug_print ($var, $file = '') { +function html_debug_print ($var, $file = '', $oneline = false) { $more_info = ''; if (is_string($var)) { $more_info = 'size: ' . strlen($var); } elseif (is_bool($var)) { - $more_info = 'val: ' . + $more_info = 'val: ' . ($var ? 'true' : 'false'); } elseif (is_null($var)) { @@ -62,10 +62,13 @@ function html_debug_print ($var, $file = '') { elseif (is_array($var)) { $more_info = count($var); } - + if ($file === true) $file = '/tmp/logDebug'; - + + if($oneline && is_string($var)) + $var = preg_replace("/[\t|\n| ]+/", " ", $var); + if (strlen($file) > 0) { $f = fopen($file, "a"); ob_start(); @@ -85,8 +88,13 @@ function html_debug_print ($var, $file = '') { } // Alias for "html_debug_print" -function html_debug ($var, $file = '') { - html_debug_print ($var, $file); +function html_debug ($var, $file = '', $oneline = false) { + html_debug_print ($var, $file, $oneline); +} + +// Alias for "html_debug_print" +function hd ($var, $file = '', $oneline = false) { + html_debug_print ($var, $file, $oneline); } function html_f2str($function, $params) { diff --git a/pandora_console/include/functions_modules.php b/pandora_console/include/functions_modules.php index f8e632dad4..1349b6dadd 100755 --- a/pandora_console/include/functions_modules.php +++ b/pandora_console/include/functions_modules.php @@ -441,9 +441,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{ @@ -2687,8 +2687,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 4e4ad37cee..eff9444824 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 4cc8315b0b..1f019934e9 100755 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -1552,7 +1552,7 @@ function reporting_event_report_group($report, $content, function reporting_event_report_module($report, $content, $type = 'dinamic', $force_width_chart = null, $force_height_chart = null, $pdf=0) { - + global $config; if($pdf){ @@ -1563,20 +1563,29 @@ function reporting_event_report_module($report, $content, } $return['type'] = 'event_report_module'; - + if (empty($content['name'])) { $content['name'] = __('Event Report Module'); } - + + $id_server = false; + if(is_metaconsole()){ + $id_server = metaconsole_get_id_server($content["server_name"]); + metaconsole_connect(null, $id_server); + } + $return['title'] = $content['name']; - $return['subtitle'] = agents_get_alias($content['id_agent']) . - " - " . - io_safe_output( - modules_get_agentmodule_name($content['id_agent_module'])); + $return['subtitle'] = agents_get_alias($content['id_agent']) . " - " . + io_safe_output(modules_get_agentmodule_name($content['id_agent_module'])); + + if(is_metaconsole()){ + metaconsole_restore_db(); + } + $return["description"] = $content["description"]; $return["date"] = reporting_get_date_text($report, $content); $return['label'] = (isset($content['style']['label'])) ? $content['style']['label'] : ''; - + $event_filter = $content['style']; $return['show_summary_group'] = $event_filter['show_summary_group']; //filter @@ -1585,22 +1594,18 @@ function reporting_event_report_module($report, $content, $filter_event_type = json_decode($event_filter['filter_event_type'],true); $filter_event_status = json_decode($event_filter['filter_event_status'],true); $filter_event_filter_search = $event_filter['event_filter_search']; - + //graphs $event_graph_by_user_validator = $event_filter['event_graph_by_user_validator']; $event_graph_by_criticity = $event_filter['event_graph_by_criticity']; $event_graph_validated_vs_unvalidated = $event_filter['event_graph_validated_vs_unvalidated']; - - $id_server = false; - if(is_metaconsole()){ - $id_server = metaconsole_get_id_server($content["server_name"]); - } + //data events $data = reporting_get_module_detailed_event ( - $content['id_agent_module'], $content['period'], $report["datetime"], - $show_summary_group, $filter_event_severity, $filter_event_type, + $content['id_agent_module'], $content['period'], $report["datetime"], + $show_summary_group, $filter_event_severity, $filter_event_type, $filter_event_status, $filter_event_filter_search, $force_width_chart, - $event_graph_by_user_validator, $event_graph_by_criticity, + $event_graph_by_user_validator, $event_graph_by_criticity, $event_graph_validated_vs_unvalidated, $ttl, $id_server); if (empty($data)) { @@ -1608,7 +1613,7 @@ function reporting_event_report_module($report, $content, } else { $return['data'] = array_reverse($data); - } + } if ($config['metaconsole']) { metaconsole_restore_db(); @@ -1621,7 +1626,7 @@ function reporting_event_report_module($report, $content, else{ $return['total_events'] = 0; } - + return reporting_check_structure_content($return); } @@ -2865,14 +2870,27 @@ function reporting_alert_get_fired($id_agent_module, $id_alert_template_module, $id_alert_template_module, $period, $datetime); + + if (!is_numeric ($datetime)) { + $datetime = time_w_fixed_tz($datetime); + } + if (empty ($datetime)) { + $datetime = get_system_time(); + } + + $datelimit = $datetime - $period; + $empty = '----------------------------'; if (empty($firedTimes)) { $firedTimes = array(); - $firedTimes[0]['timestamp'] = null; + $firedTimes[0]['timestamp'] = $empty; } foreach ($firedTimes as $fireTime) { + if($fireTime['utimestamp'] > $datelimit && $fireTime['utimestamp'] <= $datetime) $fired[] = $fireTime['timestamp']; + else + $fired[] = $empty; } return $fired; @@ -2955,6 +2973,16 @@ function reporting_alert_report_group($report, $content) { foreach ($alerts as $template => $actions) { + $datetime = (int) $report["datetime"]; + if (!is_numeric ($datetime)) { + $datetime = time_w_fixed_tz($datetime); + } + if (empty ($datetime)) { + $datetime = get_system_time(); + } + $period = (int) $content["period"]; + $datelimit = $datetime - $period; + $data_action = array(); $data_action['actions'] = array(); @@ -2963,7 +2991,7 @@ function reporting_alert_report_group($report, $content) { foreach ($actions["custom"] as $action) { $data_action[$naction]["name"] = $action["name"]; $fired = $action["fired"]; - if ($fired == 0){ + if ($fired == 0 || ($fired <= $datelimit || $fired > $datetime)){ $data_action[$naction]['fired'] = '----------------------------'; } else { @@ -2976,7 +3004,7 @@ function reporting_alert_report_group($report, $content) { foreach ($actions["default"] as $action) { $data_action[$naction]["name"] = $action["name"]; $fired = $action["fired"]; - if ($fired == 0){ + if ($fired == 0 || ($fired <= $datelimit || $fired > $datetime)){ $data_action[$naction]['fired'] = '----------------------------'; } else { @@ -2989,7 +3017,7 @@ function reporting_alert_report_group($report, $content) { foreach ($actions["unavailable"] as $action) { $data_action[$naction]["name"] = $action["name"]; $fired = $action["fired"]; - if ($fired == 0){ + if ($fired == 0 || ($fired <= $datelimit || $fired > $datetime)){ $data_action[$naction]['fired'] = '----------------------------'; } else { @@ -3009,10 +3037,7 @@ function reporting_alert_report_group($report, $content) { (int) $report["datetime"]); $module_actions["actions"] = $data_action; - if ($module_actions["template_fired"][0] !== null) $data_row['alerts'][$ntemplates] = $module_actions; - else - $data_row = null; $ntemplates++; } @@ -3075,6 +3100,16 @@ function reporting_alert_report_agent($report, $content) { foreach ($alerts as $template => $actions) { + $datetime = (int) $report["datetime"]; + if (!is_numeric ($datetime)) { + $datetime = time_w_fixed_tz($datetime); + } + if (empty ($datetime)) { + $datetime = get_system_time(); + } + $period = (int) $content["period"]; + $datelimit = $datetime - $period; + $data_action = array(); $data_action['actions'] = array(); @@ -3083,7 +3118,7 @@ function reporting_alert_report_agent($report, $content) { foreach ($actions["custom"] as $action) { $data_action[$naction]["name"] = $action["name"]; $fired = $action["fired"]; - if ($fired == 0){ + if ($fired == 0 || ($fired <= $datelimit || $fired > $datetime)){ $data_action[$naction]['fired'] = '----------------------------'; } else { @@ -3096,7 +3131,7 @@ function reporting_alert_report_agent($report, $content) { foreach ($actions["default"] as $action) { $data_action[$naction]["name"] = $action["name"]; $fired = $action["fired"]; - if ($fired == 0){ + if ($fired == 0 || ($fired <= $datelimit || $fired > $datetime)){ $data_action[$naction]['fired'] = '----------------------------'; } else { @@ -3109,7 +3144,7 @@ function reporting_alert_report_agent($report, $content) { foreach ($actions["unavailable"] as $action) { $data_action[$naction]["name"] = $action["name"]; $fired = $action["fired"]; - if ($fired == 0){ + if ($fired == 0 || ($fired <= $datelimit || $fired > $datetime)){ $data_action[$naction]['fired'] = '----------------------------'; } else { @@ -3129,10 +3164,7 @@ function reporting_alert_report_agent($report, $content) { (int) $report["datetime"]); $module_actions["actions"] = $data_action; - if ($module_actions["template_fired"][0] !== null) $data_row['alerts'][$ntemplates] = $module_actions; - else - $data_row = null; $ntemplates++; } @@ -3191,13 +3223,18 @@ function reporting_alert_report_module($report, $content) { // Alerts over $id_agent_module $alerts = alerts_get_effective_alert_actions($content['id_agent_module']); - if ($alerts === false){ - return; - } - $ntemplates = 0; foreach ($alerts as $template => $actions) { + $datetime = (int) $report["datetime"]; + if (!is_numeric ($datetime)) { + $datetime = time_w_fixed_tz($datetime); + } + if (empty ($datetime)) { + $datetime = get_system_time(); + } + $period = (int) $content["period"]; + $datelimit = $datetime - $period; $data_action = array(); $data_action['actions'] = array(); @@ -3207,7 +3244,7 @@ function reporting_alert_report_module($report, $content) { foreach ($actions["custom"] as $action) { $data_action[$naction]["name"] = $action["name"]; $fired = $action["fired"]; - if ($fired == 0){ + if ($fired == 0 || ($fired <= $datelimit || $fired > $datetime)){ $data_action[$naction]['fired'] = '----------------------------'; } else { @@ -3220,7 +3257,7 @@ function reporting_alert_report_module($report, $content) { foreach ($actions["default"] as $action) { $data_action[$naction]["name"] = $action["name"]; $fired = $action["fired"]; - if ($fired == 0){ + if ($fired == 0 || ($fired <= $datelimit || $fired > $datetime)){ $data_action[$naction]['fired'] = '----------------------------'; } else { @@ -3233,7 +3270,7 @@ function reporting_alert_report_module($report, $content) { foreach ($actions["unavailable"] as $action) { $data_action[$naction]["name"] = $action["name"]; $fired = $action["fired"]; - if ($fired == 0){ + if ($fired == 0 || ($fired <= $datelimit || $fired > $datetime)){ $data_action[$naction]['fired'] = '----------------------------'; } else { @@ -3253,10 +3290,7 @@ function reporting_alert_report_module($report, $content) { (int) $report["datetime"]); $module_actions["actions"] = $data_action; - if ($module_actions["template_fired"][0] !== null) $data_row['alerts'][$ntemplates] = $module_actions; - else - $data_row = null; $ntemplates++; } @@ -3816,114 +3850,114 @@ function reporting_value($report, $content, $type,$pdf) { 'type_graph' => $config['type_module_charts'], 'time_interval' => $content['lapse'], 'server_id' => $id_meta, - 'height' => $config['graph_image_height'] + 'height' => $config['graph_image_height'], + 'fullscale' => true ); switch ($type) { case 'max': - if($content['lapse_calc'] == 0){ - $value = reporting_get_agentmodule_data_max( - $content['id_agent_module'], $content['period'], $report["datetime"]); - if (!$config['simple_module_value']) { - $formated_value = $value; + if($content['lapse_calc'] == 0){ + $value = reporting_get_agentmodule_data_max( + $content['id_agent_module'], $content['period'], $report["datetime"]); + if (!$config['simple_module_value']) { + $formated_value = $value; + } + else { + $formated_value = format_for_graph($value, $config['graph_precision']) . " " . $unit; + } } - else { - $formated_value = format_for_graph($value, $config['graph_precision']) . " " . $unit; - } - } - else{ - $value = ' - - - - - - - - - -
'; - if($content['visual_format'] == 1 || $content['visual_format'] == 2 || $content['visual_format'] == 3){ + else{ + $value = ' + + + + + + +
'; + if($content['visual_format'] == 1 || $content['visual_format'] == 2 || $content['visual_format'] == 3){ + + $value .= ' + + + + + + + + + + +
+ '.__("Agent").' + + '.__("Module").' + + '.__("Maximum").' +
+ '.$agent_name.' + + '.$module_name.' + + '.format_for_graph(reporting_get_agentmodule_data_max( + $content['id_agent_module'], $content['period'], $report["datetime"]), $config['graph_precision']) . ' ' . $unit.' +
'; + } + + $value .= ' +
+ '; + + if($content['visual_format'] == 2 || $content['visual_format'] == 3){ + $params['force_interval'] = 'max_only'; + $value .= grafico_modulo_sparse($params); + } $value .= ' - + + + + + '; + $time_begin = db_get_row_sql('select utimestamp from tagente_datos where id_agente_modulo ='.$content['id_agent_module'], true); + $date_reference = getdate(); + + for ($i=$date_reference[0]; $i > ($date_reference[0]-$content["period"]); $i -= $content["lapse"]) { + + $value .= ''; + } else { + $value .= 'N/A'; + } + + } + + $value .='
'; + + if($content['visual_format'] == 1 || $content['visual_format'] == 3){ + + $value .= ' + - - - - - -
- '.__("Agent").' - - '.__("Module").' + '.__("Lapse").' '.__("Maximum").'
- '.$agent_name.' - - '.$module_name.' - - '.format_for_graph(reporting_get_agentmodule_data_max( - $content['id_agent_module'], $content['period'], $report["datetime"]), $config['graph_precision']) . ' ' . $unit.' -
'; +
'. date("Y-m-d H:i:s", ($i-$content["lapse"]+1)).' to '.date("Y-m-d H:i:s",$i).''; + + if ($i>$time_begin['utimestamp']) { + $value .= format_for_graph(reporting_get_agentmodule_data_max( + $content['id_agent_module'], $content["lapse"], $i), $config['graph_precision']) . ' ' . $unit.'
'; } + $value .= ' +
'; - $value .= ' -
- '; + $formated_value = $value; + } - if($content['visual_format'] == 2 || $content['visual_format'] == 3){ - $params['force_interval'] = 'max_only'; - $value .= grafico_modulo_sparse($params); - } - - $value .= ' - -
'; - - if($content['visual_format'] == 1 || $content['visual_format'] == 3){ - - $value .= ' - - - - - - '; - $time_begin = db_get_row_sql('select utimestamp from tagente_datos where id_agente_modulo ='.$content['id_agent_module']); - $date_reference = getdate(); - - for ($i=$date_reference[0]; $i > ($date_reference[0]-$content["period"]); $i -= $content["lapse"]) { - - $value .= ''; - } - else{ - $value .= 'N/A'; - } - - } - - $value .='
- '.__("Lapse").' - - '.__("Maximum").' -
'. date("Y-m-d H:i:s", ($i-$content["lapse"]+1)).' to '.date("Y-m-d H:i:s",$i).''; - - if($i>$time_begin['utimestamp']){ - $value .= format_for_graph(reporting_get_agentmodule_data_max( - $content['id_agent_module'], $content["lapse"], $i), $config['graph_precision']) . ' ' . $unit.'
'; - } - $value .= ' -
'; - - $formated_value = $value; - } - - break; + break; case 'min': if($content['lapse_calc'] == 0){ $value = reporting_get_agentmodule_data_min( @@ -4034,111 +4068,111 @@ function reporting_value($report, $content, $type,$pdf) { break; case 'avg': - if($content['lapse_calc'] == 0){ - $value = reporting_get_agentmodule_data_average( - $content['id_agent_module'], $content['period'], $report["datetime"]); - if (!$config['simple_module_value']) { - $formated_value = $value; + if($content['lapse_calc'] == 0){ + $value = reporting_get_agentmodule_data_average( + $content['id_agent_module'], $content['period'], $report["datetime"]); + if (!$config['simple_module_value']) { + $formated_value = $value; + } + else { + $formated_value = format_for_graph($value, $config['graph_precision']) . " " . $unit; + } } - else { - $formated_value = format_for_graph($value, $config['graph_precision']) . " " . $unit; - } - } - else{ - $value = ' - - - - - - - -
'; + else{ + $value = ' + + + + + - - + +
'; + + if($content['visual_format'] == 1 || $content['visual_format'] == 2 || $content['visual_format'] == 3){ + $value .= ' + + + + + + + + + + +
+ '.__("Agent").' + + '.__("Module").' + + '.__("Average").' +
+ '.$agent_name.' + + '.$module_name.' + + '.format_for_graph(reporting_get_agentmodule_data_average( + $content['id_agent_module'], $content['period'], $report["datetime"]), $config['graph_precision']) . ' ' . $unit.' +
'; + + } + + $value .= ' +
+ '; + if($content['visual_format'] == 2 || $content['visual_format'] == 3){ + $params['force_interval'] = 'avg_only'; + $value .= grafico_modulo_sparse($params); + } - if($content['visual_format'] == 1 || $content['visual_format'] == 2 || $content['visual_format'] == 3){ $value .= ' - + + + + + '; + $time_begin = db_get_row_sql('select utimestamp from tagente_datos where id_agente_modulo ='.$content['id_agent_module']); + $date_reference = getdate(); + + for ($i=$date_reference[0]; $i > ($date_reference[0]-$content["period"]); $i -= $content["lapse"]) { + + $value .= ''; + } + else{ + $value .= 'N/A'; + } + + } + + $value .='
'; + + if($content['visual_format'] == 1 || $content['visual_format'] == 3){ + + $value .= ' + - - - - - -
- '.__("Agent").' - - '.__("Module").' + '.__("Lapse").' '.__("Average").'
- '.$agent_name.' - - '.$module_name.' - - '.format_for_graph(reporting_get_agentmodule_data_average( - $content['id_agent_module'], $content['period'], $report["datetime"]), $config['graph_precision']) . ' ' . $unit.' -
'; - +
'. date("Y-m-d H:i:s", ($i-$content["lapse"]+1)).' to '.date("Y-m-d H:i:s",$i).''; + + if($i>$time_begin['utimestamp']){ + $value .= format_for_graph(reporting_get_agentmodule_data_average( + $content['id_agent_module'], $content["lapse"], $i), $config['graph_precision']) . ' ' . $unit.'
'; } - $value .= ' -
- '; - if($content['visual_format'] == 2 || $content['visual_format'] == 3){ - $params['force_interval'] = 'avg_only'; - $value .= grafico_modulo_sparse($params); - } + $value .= ' + +
'; - $value .= ' - -
'; - - if($content['visual_format'] == 1 || $content['visual_format'] == 3){ - - $value .= ' - - - - - - '; - $time_begin = db_get_row_sql('select utimestamp from tagente_datos where id_agente_modulo ='.$content['id_agent_module']); - $date_reference = getdate(); - - for ($i=$date_reference[0]; $i > ($date_reference[0]-$content["period"]); $i -= $content["lapse"]) { - - $value .= ''; - } - else{ - $value .= 'N/A'; - } - - } - - $value .='
- '.__("Lapse").' - - '.__("Average").' -
'. date("Y-m-d H:i:s", ($i-$content["lapse"]+1)).' to '.date("Y-m-d H:i:s",$i).''; - - if($i>$time_begin['utimestamp']){ - $value .= format_for_graph(reporting_get_agentmodule_data_average( - $content['id_agent_module'], $content["lapse"], $i), $config['graph_precision']) . ' ' . $unit.'
'; - } - - $value .= ' - -
'; + $formated_value = $value; - $formated_value = $value; - - } - break; + } + break; case 'sum': $value = reporting_get_agentmodule_data_sum( @@ -6246,6 +6280,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_reporting_html.php b/pandora_console/include/functions_reporting_html.php index 9ed6ab16e1..fd4d0a2c76 100644 --- a/pandora_console/include/functions_reporting_html.php +++ b/pandora_console/include/functions_reporting_html.php @@ -1960,6 +1960,12 @@ function reporting_html_alert_report($table, $item, $pdf = 0) { $table1->data = array (); $table1->rowspan = array(); $table1->valign = array(); + + if ($item['data'] == null) { + $table->data['alerts']['cell'] = ui_print_empty_data ( __('No alerts defined') , '', true) ; + return true; + } + $table1->head['agent'] = __('Agent'); $table1->head['module'] = __('Module'); $table1->head['template'] = __('Template'); diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index 54334e4ecf..ee0cbca2de 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -823,10 +823,6 @@ 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); $template = alerts_get_alert_template ($alert['id_alert_template']); $description = io_safe_output($template['name']); @@ -934,7 +930,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 +4048,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_users.php b/pandora_console/include/functions_users.php index c11fff79fd..43603663a1 100755 --- a/pandora_console/include/functions_users.php +++ b/pandora_console/include/functions_users.php @@ -418,10 +418,13 @@ function users_get_first_group ($id_user = false, $privilege = "AR", $all_group * @param int Agent id. * @param string Access mode to be checked. Default AR (Agent reading) * @param string User id. Current user by default + * @param bool True to use the metaconsole tables * * @return bool Access to that agent (false not, true yes) */ -function users_access_to_agent ($id_agent, $mode = "AR", $id_user = false) { +function users_access_to_agent ( + $id_agent, $mode = "AR", $id_user = false, $force_meta = false +) { if (empty ($id_agent)) return false; @@ -432,7 +435,7 @@ function users_access_to_agent ($id_agent, $mode = "AR", $id_user = false) { return (bool) check_acl_one_of_groups ( $id_user, - agents_get_all_groups_agent((int)$id_agent), + agents_get_all_groups_agent((int)$id_agent, false, $force_meta), $mode); } diff --git a/pandora_console/include/functions_visual_map.php b/pandora_console/include/functions_visual_map.php index b92f17e230..71cf0e6047 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); } } } diff --git a/pandora_console/include/functions_visual_map_editor.php b/pandora_console/include/functions_visual_map_editor.php index abbc179c61..a20a8c5e42 100755 --- a/pandora_console/include/functions_visual_map_editor.php +++ b/pandora_console/include/functions_visual_map_editor.php @@ -700,7 +700,7 @@ function visual_map_editor_print_item_palette($visualConsole_id, $background) { $visual_maps = db_get_all_rows_filter("tlayout", "id != " . (int) $visualConsole_id, array("id", "name")); $form_items_advance['map_linked_row']['html'] = '' - . __('Linked map') + . __('Linked visual console') . '' . ''; @@ -727,7 +727,7 @@ function visual_map_editor_print_item_palette($visualConsole_id, $background) { return $arr; }, array()); - $form_items_advance['map_linked_row']['html'] .= html_print_select_from_sql( + $form_items_advance['map_linked_row']['html'] .= html_print_select( array(), 'map_linked', 0, 'onLinkedMapChange(event)', __('None'), 0, true ); $form_items_advance['map_linked_row']['html'] .= html_print_input_hidden( @@ -773,7 +773,11 @@ function visual_map_editor_print_item_palette($visualConsole_id, $background) { $form_items_advance['map_linked_row']['html'] .= ob_get_clean(); } else { - $form_items_advance['map_linked_row']['html'] .= html_print_select_from_sql( + $visual_maps = array_reduce($visual_maps, function ($all, $item) { + $all[$item["id"]] = $item["name"]; + return $all; + }, array()); + $form_items_advance['map_linked_row']['html'] .= html_print_select( $visual_maps, 'map_linked', 0, 'onLinkedMapChange(event)', __('None'), 0, true ); } @@ -790,7 +794,7 @@ function visual_map_editor_print_item_palette($visualConsole_id, $background) { 'percentile_item', 'module_graph', 'simple_value', 'icon', 'label', 'datos', 'donut_graph'); $form_items_advance['linked_map_status_calculation_row']['html'] = ''. - __('Type of the status calculation of the linked map') . '' + __('Type of the status calculation of the linked visual console') . '' . '' . html_print_select( $status_type_select_items, @@ -803,6 +807,7 @@ function visual_map_editor_print_item_palette($visualConsole_id, $background) { false, false ) + . ui_print_help_icon("linked_map_status_calc", true) . ''; $form_items_advance['map_linked_weight'] = array(); @@ -811,13 +816,12 @@ function visual_map_editor_print_item_palette($visualConsole_id, $background) { 'percentile_item', 'module_graph', 'simple_value', 'icon', 'label', 'datos', 'donut_graph'); $form_items_advance['map_linked_weight']['html'] = '' - . __('Linked map weight') . '' + . __('Linked visual console weight') . '' . '' . html_print_input_text( 'map_linked_weight', 80, '', 5, 5, true, false, false, "", "type_number percentage" ) . '%' - . ui_print_help_icon("linked_map_weight", true) . ''; $form_items_advance['linked_map_status_service_critical_row'] = array(); diff --git a/pandora_console/include/help/en/help_linked_map_status_calc.php b/pandora_console/include/help/en/help_linked_map_status_calc.php new file mode 100644 index 0000000000..96602eb262 --- /dev/null +++ b/pandora_console/include/help/en/help_linked_map_status_calc.php @@ -0,0 +1,36 @@ + +

    Ways to calculate the status of the linked visual console

    + +

    By Default

    +

    + It calculates the status based on the status of all elements, as an agent would do. +

    + +

    By weight

    +

    + It calculates the status of the elements that have a visual console, a module or an agent assigned in relation to a percentage of elements configured by the user. This percentage is the one that has to exceed the number of elements of a non-normal status with respect to the number of elements taken into account in the calculation for that status to change. +

    + +

    + For example, given an element with a percentage of 50% and a visual console linked with 5 elements: +

    +
      +
    • 1 critical, 1 warning y 3 normal -> Status normal.
    • +
    • 2 critical, 2 warning y 1 normal -> Status normal.
    • +
    • 1 critical, 3 warning y 1 normal -> Status warning.
    • +
    • 3 critical, 1 warning y 1 normal -> Status critical.
    • +
    • 1 critical, 1 warning y 3 unknown -> Status unknown.
    • +
    + +

    + If several statuses exceed the weight, the priority is the same as in the rest of the status calculation (critical > warning > unknown). If there are no elements to perform the calculation, the status becomes unknown. +

    + +

    By critical elements

    +

    + It calculates the status using the elements in critical status and the percentages of the thresholds defined by the user. If the number of elements in critical status with respect to the number of elements taken into account in the calculation exceeds the percentage assigned as warning, the status becomes warning. The same applies to the percentage assigned as critical, which also has preference. +

    diff --git a/pandora_console/include/help/en/help_log_viewer.php b/pandora_console/include/help/en/help_log_viewer.php new file mode 100644 index 0000000000..6e1708246c --- /dev/null +++ b/pandora_console/include/help/en/help_log_viewer.php @@ -0,0 +1,56 @@ + +

    Modelos de captura de datos

    +

    +Se pueden realizar graficas extrayendo información +de los logs, clasificando la información en base a modelos de captura de datos. +

    +

    +Estos modelos de captura de datos son básicamente expresiones regulares e +identificadores, que nos permitirán analizar los orígenes de datos y mostrarlos como un gráfico. +

    +

    +Podemos seleccionar el modelo de captura. +El modelo por defecto, Apache log model, ofrece la posibilidad de parsear logs de Apache +en formato estándar (access_log), pudiendo extraer gráficas comparativas de tiempo de respuesta, +agrupando por página visitada y código de respuesta. +

    +

    +Al pulsar en el botón de editar editaremos el modelo de captura seleccionado. +Con el botón de crear agregaremos un nuevo modelo de captura. +En el formulario que aparece, podremos elegir: +

    +

    Título

    +Un nombre para el modelo de captura +

    +

    Expresión regular

    +Cada campo a extraer se identifica con la subexpresión entre los paréntesis (expresión a capturar). +

    +

    Los campos

    +En el orden en que los hemos capturado con la expresión regular. +Los resultados se agruparán por la concatenación de los campos clave, que son aquellos +cuyo nombre no esté entre guiones bajos: +

    +

    clave, _valor_

    +

    Observación: Si no especificamos un campo valor, será automáticamente el conteo de apariciones +que coinciden con la expresión regular.

    + +

    Observación 2: Si especificamos una columna valor podremos elegir entre representar el valor acumulado +(comportamiento por defecto) o marcar el checkbox para representar el promedio.

    + +

    Ejemplo

    +

    Si quisiéramos extraer entradas de un log con el siguiente formato:

    +

    Sep 19 12:05:01 nova systemd: Starting Session 6132 of user root.

    + +

    Para contar el número de veces que se ha iniciado sesión, agrupando por usuario, usaremos la expresion regular:

    +

    Starting Session \d+ of user (.*?)\.

    + +

    y de campo:

    +

    username

    + +

    Este modelo de captura nos devolverá una grafica con el número de inicios de sesión por usuario +en el intervalo de tiempo que seleccionemos.

    + diff --git a/pandora_console/include/help/es/help_linked_map_status_calc.php b/pandora_console/include/help/es/help_linked_map_status_calc.php new file mode 100644 index 0000000000..40c5682d7a --- /dev/null +++ b/pandora_console/include/help/es/help_linked_map_status_calc.php @@ -0,0 +1,36 @@ + +

    Formas de calcular el estado de la consola visual enlazada

    + +

    Por defecto

    +

    + Calcula el estado a partir del estado de todos los elementos, como lo haría un agente. +

    + +

    Por peso

    +

    + Calcula el estado de los elementos que tienen asignados una consola visual, un módulo o un agente en relación a un porcentaje de elementos configurado por el usuario. Este porcentaje es el que tiene que superar el número de elementos de un estado no normal respecto al número de elementos tenidos en cuenta en el cálculo para que el ese estado cambie. +

    + +

    + Por ejemplo, dado un elemento con un porcentaje del 50% y una consola visual enlazada con 5 elementos: +

    +
      +
    • 1 critical, 1 warning y 3 normal -> Estado normal.
    • +
    • 2 critical, 2 warning y 1 normal -> Estado normal.
    • +
    • 1 critical, 3 warning y 1 normal -> Estado warning.
    • +
    • 3 critical, 1 warning y 1 normal -> Estado critical.
    • +
    • 1 critical, 1 warning y 3 unknown -> Estado unknown.
    • +
    + +

    + Si varios estados superan el peso, la prioridad es igual que en el resto de cálculo de estados (critical > warning > unknown). Si no hay elementos para realizar el cálculo, el estado pasa a ser unknown. +

    + +

    Por elementos críticos

    +

    + Calcula el estado usando los elementos en estado critical y los porcentajes de los umbrales definidos por el usuario. Si el número de los elementos en estado critical respecto al número de elementos tenidos en cuenta en el cálculo supera el porcentaje asignado como warning, el estado pasa a ser warning. Lo mismo para el porcentaje asignado como critical, que además tiene preferencia. +

    diff --git a/pandora_console/include/help/es/help_log_viewer.php b/pandora_console/include/help/es/help_log_viewer.php new file mode 100644 index 0000000000..dfdd818541 --- /dev/null +++ b/pandora_console/include/help/es/help_log_viewer.php @@ -0,0 +1,56 @@ + +

    Visualización y búsqueda avanzadas

    +

    +Se pueden realizar graficas extrayendo información +de los logs, clasificando la información en base a modelos de captura de datos. +

    +

    +Estos modelos de captura de datos son básicamente expresiones regulares e +identificadores, que nos permitirán analizar los orígenes de datos y mostrarlos como un gráfico. +

    +

    +Podemos seleccionar el modelo de captura. +El modelo por defecto, Apache log model, ofrece la posibilidad de parsear logs de Apache +en formato estándar (access_log), pudiendo extraer gráficas comparativas de tiempo de respuesta, +agrupando por página visitada y código de respuesta. +

    +

    +Al pulsar en el botón de editar editaremos el modelo de captura seleccionado. +Con el botón de crear agregaremos un nuevo modelo de captura. +En el formulario que aparece, podremos elegir: +

    +

    Título

    +Un nombre para el modelo de captura +

    +

    Expresión regular

    +Cada campo a extraer se identifica con la subexpresión entre los paréntesis (expresión a capturar). +

    +

    Los campos

    +En el orden en que los hemos capturado con la expresión regular. +Los resultados se agruparán por la concatenación de los campos clave, que son aquellos +cuyo nombre no esté entre guiones bajos: +

    +

    clave, _valor_

    +

    Observación: Si no especificamos un campo valor, será automáticamente el conteo de apariciones +que coinciden con la expresión regular.

    + +

    Observación 2: Si especificamos una columna valor podremos elegir entre representar el valor acumulado +(comportamiento por defecto) o marcar el checkbox para representar el promedio.

    + +

    Ejemplo

    +

    Si quisiéramos extraer entradas de un log con el siguiente formato:

    +

    Sep 19 12:05:01 nova systemd: Starting Session 6132 of user root.

    + +

    Para contar el número de veces que se ha iniciado sesión, agrupando por usuario, usaremos la expresion regular:

    +

    Starting Session \d+ of user (.*?)\.

    + +

    y de campo:

    +

    username

    + +

    Este modelo de captura nos devolverá una grafica con el número de inicios de sesión por usuario +en el intervalo de tiempo que seleccionemos.

    + diff --git a/pandora_console/include/help/ja/help_log_viewer.php b/pandora_console/include/help/ja/help_log_viewer.php new file mode 100644 index 0000000000..65696bba38 --- /dev/null +++ b/pandora_console/include/help/ja/help_log_viewer.php @@ -0,0 +1,55 @@ + +

    Visualización y búsqueda avanzadas

    +

    +Se pueden realizar graficas extrayendo información +de los logs, clasificando la información en base a modelos de captura de datos. +

    +

    +Estos modelos de captura de datos son básicamente expresiones regulares e +identificadores, que nos permitirán analizar los orígenes de datos y mostrarlos como un gráfico. +

    +

    +Podemos seleccionar el modelo de captura. +El modelo por defecto, Apache log model, ofrece la posibilidad de parsear logs de Apache +en formato estándar (access_log), pudiendo extraer gráficas comparativas de tiempo de respuesta, +agrupando por página visitada y código de respuesta. +

    +

    +Al pulsar en el botón de editar editaremos el modelo de captura seleccionado. +Con el botón de crear agregaremos un nuevo modelo de captura. +En el formulario que aparece, podremos elegir: +

    +

    Título

    +Un nombre para el modelo de captura +

    +

    Expresión regular

    +Cada campo a extraer se identifica con la subexpresión entre los paréntesis (expresión a capturar). +

    +

    Los campos

    +En el orden en que los hemos capturado con la expresión regular. +Los resultados se agruparán por la concatenación de los campos clave, que son aquellos +cuyo nombre no esté entre guiones bajos: +

    +

    clave, _valor_

    +

    Observación: Si no especificamos un campo valor, será automáticamente el conteo de apariciones +que coinciden con la expresión regular.

    + +

    Observación 2: Si especificamos una columna valor podremos elegir entre representar el valor acumulado +(comportamiento por defecto) o marcar el checkbox para representar el promedio.

    + +

    Ejemplo

    +

    Si quisiéramos extraer entradas de un log con el siguiente formato:

    +

    Sep 19 12:05:01 nova systemd: Starting Session 6132 of user root.

    + +

    Para contar el número de veces que se ha iniciado sesión, agrupando por usuario, usaremos la expresion regular:

    +

    Starting Session \d+ of user (.*?)\.

    + +

    y de campo:

    +

    username

    + +

    Este modelo de captura nos devolverá una grafica con el número de inicios de sesión por usuario +en el intervalo de tiempo que seleccionemos.

    \ No newline at end of file diff --git a/pandora_console/include/javascript/pandora.js b/pandora_console/include/javascript/pandora.js index bc8432ae48..7a23b2a36c 100644 --- a/pandora_console/include/javascript/pandora.js +++ b/pandora_console/include/javascript/pandora.js @@ -529,7 +529,7 @@ function module_changed_by_multiple_modules (event, id_module, selected) { jQuery.each (data, function (i, val) { s = js_html_entity_decode(val); $('#agents') - .append ($('').html (s).attr ("value", val)); + .append ($('').html (s).attr ("value", i)); $('#agents').fadeIn ('normal'); }); @@ -1585,6 +1585,10 @@ function display_confirm_dialog (message, ok_text, cancel_text, ok_function) { clean_function(); } + var buttons_obj = {}; + buttons_obj[cancel_text] = clean_function; + buttons_obj[ok_text] = ok_function_clean; + // Display the dialog $("body").append('

    ' + message + '

    '); $("#pandora_confirm_dialog_text").dialog({ @@ -1598,10 +1602,7 @@ function display_confirm_dialog (message, ok_text, cancel_text, ok_function) { }, closeOnEscape: true, modal: true, - buttons: { - Cancel: clean_function, - "Confirm": ok_function_clean - } + buttons: buttons_obj }); } diff --git a/pandora_console/include/javascript/tree/TreeController.js b/pandora_console/include/javascript/tree/TreeController.js index 409fc517d1..13a0b31cd4 100644 --- a/pandora_console/include/javascript/tree/TreeController.js +++ b/pandora_console/include/javascript/tree/TreeController.js @@ -55,7 +55,7 @@ var TreeController = { } container.append($group); - + _.each(elements, function(element) { element.jqObject = _processNode($group, element); }); @@ -279,14 +279,13 @@ var TreeController = { // Load leaf function _processNode (container, element) { - // type, [id], [serverID], callback function _getTreeDetailData (type, id, serverID, callback) { var lastParam = arguments[arguments.length - 1]; var callback; if (typeof lastParam === 'function') callback = lastParam; - + var serverID; if (arguments.length >= 4) serverID = arguments[2]; @@ -296,23 +295,23 @@ var TreeController = { var type; if (arguments.length >= 2) type = arguments[0]; - + if (typeof type === 'undefined') throw new TypeError('Type required'); if (typeof callback === 'undefined') throw new TypeError('Callback required'); - + var postData = { page: controller.ajaxPage, getDetail: 1, type: type } - + if (typeof id !== 'undefined') postData.id = id; if (typeof serverID !== 'undefined') postData.serverID = serverID; - + $.ajax({ url: controller.ajaxURL, type: 'POST', @@ -346,6 +345,36 @@ var TreeController = { $content.append(element.iconHTML + " "); } $content.append(element.name); + + if(typeof element.edit != 'undefined'){ + var url_edit = controller.baseURL + "index.php?sec=gagente&sec2=godmode/groups/configure_group&tab=tree&id_group=" + element.id; + var $updateicon = $('') + var $updatebtn = $('') + .append($updateicon); + $content.append($updatebtn); + } + + if(typeof element.delete != 'undefined'){ + var url_delete = controller.baseURL + "index.php?sec=gagente&sec2=godmode/groups/group_list&tab=tree&delete_group=1&id_group=" + element.id; + var $deleteBtn = $(''); + $deleteBtn.click(function (event){ + var ok_function = function(){ + window.location.replace(url_delete); + }; + display_confirm_dialog( + element.delete.messages.messg, + element.delete.messages.confirm, + element.delete.messages.cancel, + ok_function + ) + }); + $content.append($deleteBtn); + } + + if(typeof element.alerts != 'undefined'){ + $content.append(element.alerts); + } + break; case 'agent': // Is quiet @@ -583,95 +612,99 @@ var TreeController = { if (typeof(public_user) === 'undefined') public_user = 0; if (typeof element.searchChildren != 'undefined' && element.searchChildren) { - $node - .removeClass("leaf-empty") - .addClass("leaf-closed"); + if(element.rootType == "group_edition" + && typeof element.children == 'undefined'){ + $node.addClass("leaf-empty"); + } + else{ + $node + .removeClass("leaf-empty") + .addClass("leaf-closed"); + $leafIcon.click(function (e) { + e.preventDefault(); - $leafIcon.click(function (e) { - e.preventDefault(); - - if (!$node.hasClass("leaf-loading") && !$node.hasClass("children-loaded") && !$node.hasClass("leaf-empty")) { - $node - .removeClass("leaf-closed") - .removeClass("leaf-error") - .addClass("leaf-loading"); - - $.ajax({ - url: controller.ajaxURL, - type: 'POST', - dataType: 'json', - data: { - page: controller.ajaxPage, - getChildren: 1, - id: element.id, - type: element.type, - rootID: element.rootID, - serverID: element.serverID, - rootType: element.rootType, - filter: controller.filter, - hash: public_hash, - id_user: public_user - }, - complete: function(xhr, textStatus) { - $node.removeClass("leaf-loading"); - $node.addClass("children-loaded"); - }, - success: function(data, textStatus, xhr) { - if (data.success) { - var $group = $node.children("ul.tree-group"); - - if ((typeof data.tree != 'undefined' && data.tree.length > 0) || $group.length > 0) { - $node.addClass("leaf-open"); - - if ($group.length <= 0) { - $group = $("
      "); - $group - .addClass("tree-group") - .hide(); - $node.append($group); - } - - _.each(data.tree, function(element) { - element.jqObject = _processNode($group, element); - }); - - $group.slideDown(); - - $node.data('children', $group); - - // Add again the hover event to the 'force_callback' elements - forced_title_callback(); - } - else { - $node.addClass("leaf-empty"); - } - } - else { - $node.addClass("leaf-error"); - } - }, - error: function(xhr, textStatus, errorThrown) { - $node.addClass("leaf-error"); - } - }); - } - else if (! $node.hasClass("leaf-empty")) { - if ($node.hasClass("leaf-open")) { - $node - .removeClass("leaf-open") - .addClass("leaf-closed") - .data('children') - .slideUp(); - } - else { + if (!$node.hasClass("leaf-loading") && !$node.hasClass("children-loaded") && !$node.hasClass("leaf-empty")) { $node .removeClass("leaf-closed") - .addClass("leaf-open") - .data('children') - .slideDown(); + .removeClass("leaf-error") + .addClass("leaf-loading"); + + $.ajax({ + url: controller.ajaxURL, + type: 'POST', + dataType: 'json', + data: { + page: controller.ajaxPage, + getChildren: 1, + id: element.id, + type: element.type, + rootID: element.rootID, + serverID: element.serverID, + rootType: element.rootType, + filter: controller.filter, + hash: public_hash, + id_user: public_user + }, + complete: function(xhr, textStatus) { + $node.removeClass("leaf-loading"); + $node.addClass("children-loaded"); + }, + success: function(data, textStatus, xhr) { + if (data.success) { + var $group = $node.children("ul.tree-group"); + if ((typeof data.tree != 'undefined' && data.tree.length > 0) || $group.length > 0) { + $node.addClass("leaf-open"); + + if ($group.length <= 0) { + $group = $("
        "); + $group + .addClass("tree-group") + .hide(); + $node.append($group); + } + + _.each(data.tree, function(element) { + element.jqObject = _processNode($group, element); + }); + + $group.slideDown(); + + $node.data('children', $group); + + // Add again the hover event to the 'force_callback' elements + forced_title_callback(); + } + else { + $node.addClass("leaf-empty"); + } + } + else { + $node.addClass("leaf-error"); + } + }, + error: function(xhr, textStatus, errorThrown) { + $node.addClass("leaf-error"); + } + }); } - } - }); + else if (! $node.hasClass("leaf-empty")) { + if ($node.hasClass("leaf-open")) { + $node + .removeClass("leaf-open") + .addClass("leaf-closed") + .data('children') + .slideUp(); + } + else { + $node + .removeClass("leaf-closed") + .addClass("leaf-open") + .data('children') + .slideDown(); + } + } + }); + } } return $node; diff --git a/pandora_console/include/styles/jquery-ui-1.10.0.custom.css b/pandora_console/include/styles/jquery-ui-1.10.0.custom.css index b2af3fd6e1..2f7b9a2023 100644 --- a/pandora_console/include/styles/jquery-ui-1.10.0.custom.css +++ b/pandora_console/include/styles/jquery-ui-1.10.0.custom.css @@ -817,7 +817,7 @@ body .ui-tooltip { } .ui-widget-content { border: 1px solid #aaaaaa; - background: #ffffff url(images/ui-bg_flat_75_ffffff_40x100.png) 50% 50% repeat-x; + background: #e8e8e8 url(images/ui-bg_flat_75_e8e8e8_40x100.png) 50% 50% repeat-x; color: #222222; } .ui-widget-content a { diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index 08c1e2fd8d..a09df577a1 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -3709,6 +3709,57 @@ div.simple_value > a > span.text p color:white; } +.modaldeletebutton{ + transition-property: background-color, color; + transition-duration: 1s; + transition-timing-function: ease-out; + -webkit-transition-property: background-color, color; + -webkit-transition-duration: 1s; + -o-transition-property: background-color, color; + -o-transition-duration: 1s; + cursor:pointer; + text-align:center; + margin-left:45px; + float:left; + -moz-border-radius: 3px; + -webkit-border-radius: 3px; + margin-bottom:30px; + border-radius: 3px;width:90px;height:30px;background-color:white;border: 1px solid #FA5858; +} + +.modaldeletebuttontext{ + transition-property: background-color, color; + transition-duration: 1s; + transition-timing-function: ease-out; + -webkit-transition-property: background-color, color; + -webkit-transition-duration: 1s; + -o-transition-property: background-color, color; + -o-transition-duration: 1s; + color:#FA5858;font-family:Nunito;font-size:10pt;position:relative;top:6px; +} + +.modaldeletebutton:hover .modaldeletebuttontext { + transition-property: background-color, color; + transition-duration: 1s; + transition-timing-function: ease-out; + -webkit-transition-property: background-color, color; + -webkit-transition-duration: 1s; + -o-transition-property: background-color, color; + -o-transition-duration: 1s; + color:white; +} + +.modaldeletebutton:hover { + transition-property: background-color, color; + transition-duration: 1s; + transition-timing-function: ease-out; + -webkit-transition-property: background-color, color; + -webkit-transition-duration: 1s; + -o-transition-property: background-color, color; + -o-transition-duration: 1s; + background-color:#FA5858; +} + .modalgobutton{ transition-property: background-color, color; transition-duration: 1s; @@ -4691,5 +4742,25 @@ tr:last-child > td > a.down_arrow, tr:first-child > td > a.up_arrow { text-align: left; display: block; vertical-align: middle; - line-height: 20px; + 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 1a8188f862..95d08aa70f 100755 --- a/pandora_console/install.php +++ b/pandora_console/install.php @@ -71,7 +71,7 @@
        " . __("Last position in ") . - $dataLastPosition['start_timestamp'] . ": " . - $dataLastPosition['stored_longitude'] . ", " . $dataLastPosition['stored_latitude'] . ", " . $dataLastPosition['stored_altitude']; -} - +echo "
        "; echo "
        "; echo ""; -echo "
        " . __("Period to show data as path") . ": "; +echo "
        " . __("Period to show data as path"); echo ""; html_print_extended_select_for_time ('period', $period, '', '', '0', 10); echo ""; html_print_submit_button(__('Refresh path'), 'refresh', false, 'class = "sub upd" style="margin-top:0px"'); echo "
        "; -echo "

        " . __("Positional data from the last") . " " . human_time_description_raw ($period) ."

        "; /* Get the total number of Elements for the pagination */ $sqlCount = sprintf ("SELECT COUNT(*) FROM tgis_data_history WHERE tagente_id_agente = %d AND end_timestamp > FROM_UNIXTIME(%d) ORDER BY end_timestamp DESC", $agentId, get_system_time () - $period); -$countData = db_get_value_sql($sqlCount); - +$countData = (int) db_get_value_sql($sqlCount); /* Get the elements to present in this page */ switch ($config["dbtype"]) { @@ -141,9 +127,7 @@ switch ($config["dbtype"]) { $result = db_get_all_rows_sql ($sql, true); - if ($result === false) { - $sql2 = sprintf (" SELECT current_longitude AS longitude, current_latitude AS latitude, current_altitude AS altitude, start_timestamp, description, number_of_packages, manual_placement @@ -163,10 +147,11 @@ if ($result === false) { } if ($result !== false) { - if(!$countData){ - $countData = 1; - } - ui_pagination ($countData, false) ; + echo "

        " . __("Positional data from the last") . " " . human_time_description_raw($period) ."

        "; + + if ($countData > 0) ui_pagination($countData, false); + + $table = new StdClass(); $table->data = array(); foreach ($result as $key => $row) { $distance = 0; @@ -187,9 +172,13 @@ if ($result !== false) { $rowdata = array( $row['longitude'], $row['latitude'], - $row['altitude'], - $row['start_timestamp'], - $row['end_timestamp'], + (int) $row['altitude'] . " m", + is_numeric($row['start_timestamp']) + ? date($config["date_format"], $row['start_timestamp']) + : date_w_fixed_tz($row['start_timestamp']), + is_numeric($row['end_timestamp']) + ? date($config["date_format"], $row['end_timestamp']) + : date_w_fixed_tz($row['end_timestamp']), $row['description'], sprintf(__('%s Km'), $distance), $row['number_of_packages'], @@ -206,13 +195,12 @@ if ($result !== false) { __('Distance'), __("# of Packages"), __("Manual placement")); - $table->class = 'position_data_table'; + $table->class = 'databox data'; $table->id = $agent_name.'_position_data_table'; - $table->title = $agent_alias . " " . __("positional data"); - $table->titlestyle = "background-color:#799E48;"; - html_print_table($table); unset($table); + $table->width = '100%'; + html_print_table($table); + unset($table); - ui_pagination ($countData, false) ; - echo "

        " . __('Total') . ' ' . $countData . ' ' . __('Data') . "

        "; + if ($countData > 0) ui_pagination($countData, false); } ?> diff --git a/pandora_console/operation/agentes/ver_agente.php b/pandora_console/operation/agentes/ver_agente.php index 805db88671..49011d540d 100644 --- a/pandora_console/operation/agentes/ver_agente.php +++ b/pandora_console/operation/agentes/ver_agente.php @@ -207,7 +207,7 @@ if (is_ajax ()) { $groups = users_get_groups ($config["id_user"], "AW", false); $group_id_list = ($groups ? join(",",array_keys($groups)):"0"); - $sql = 'SELECT DISTINCT(t1.alias) as name + $sql = 'SELECT DISTINCT(t1.nombre) as name, t1.alias FROM tagente t1, tagente_modulo t2 WHERE t1.id_agente = t2.id_agente AND t1.id_grupo IN (' . $group_id_list .') @@ -254,10 +254,9 @@ if (is_ajax ()) { if ($nameAgents == false) $nameAgents = array(); - foreach ($nameAgents as $nameAgent) { - $names[] = io_safe_output($nameAgent['name']); - } - + foreach ($nameAgents as $nameAgent) + $names[$nameAgent['name']] = io_safe_output($nameAgent['alias']); + echo json_encode($names); return; } diff --git a/pandora_console/operation/gis_maps/render_view.php b/pandora_console/operation/gis_maps/render_view.php index eabefebbfe..de453a5a81 100644 --- a/pandora_console/operation/gis_maps/render_view.php +++ b/pandora_console/operation/gis_maps/render_view.php @@ -108,6 +108,9 @@ $layers = gis_get_layers($idMap); // Render map +$has_management_acl = check_acl($config["id_user"], $map['group_id'], "MW") + || check_acl ($config["id_user"], $map['group_id'], "MM"); + $buttons = array(); if ($config["pure"] == 0) { @@ -119,22 +122,14 @@ else { html_print_image ("images/normalscreen.png", true, array ("title" => __('Back to normal mode'))) . ""; } -if (check_acl ($config["id_user"], $map['group_id'], "MW") || check_acl ($config["id_user"], $map['group_id'], "MM")) { - $buttons['setup']['text'] = ''.html_print_image ("images/setup.png", true, array ("title" => __('Setup'))).''; - $buttons['setup']['godmode'] = 1; - - +if ($has_management_acl) { $hash = md5($config["dbpass"] . $idMap . $config["id_user"]); - $buttons['public_link']['text'] = ''. html_print_image ("images/camera_mc.png", true, array ("title" => __('Show link to public Visual Console'))).''; } -$buttonsString = '' . - html_print_image("images/bricks.png", true, array("class" => "top", "border" => '0')) . '  Agent - test_gis1