Merge remote-tracking branch 'origin/develop' into ent-2740-servicios-favoritos

Conflicts:
	pandora_console/extras/mr/21.sql
	pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql
	pandora_console/pandoradb_data.sql
This commit is contained in:
fermin831 2018-10-16 11:35:14 +02:00
commit aff2879340
121 changed files with 2060 additions and 3774 deletions

View File

@ -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

View File

@ -1,5 +1,5 @@
package: pandorafms-agent-unix
Version: 7.0NG.727
Version: 7.0NG.727-181016
Architecture: all
Priority: optional
Section: admin

View File

@ -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-181016"
echo "Test if you has the tools for to make the packages."
whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -42,7 +42,7 @@ my $Sem = undef;
my $ThreadSem = undef;
use constant AGENT_VERSION => '7.0NG.727';
use constant AGENT_BUILD => '180918';
use constant AGENT_BUILD => '181016';
# 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__

View File

@ -3,7 +3,7 @@
#
%define name pandorafms_agent_unix
%define version 7.0NG.727
%define release 1
%define release 181016
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

View File

@ -3,7 +3,7 @@
#
%define name pandorafms_agent_unix
%define version 7.0NG.727
%define release 1
%define release 181016
Summary: Pandora FMS Linux agent, PERL version
Name: %{name}

View File

@ -10,7 +10,7 @@
# **********************************************************************
PI_VERSION="7.0NG.727"
PI_BUILD="180918"
PI_BUILD="181016"
OS_NAME=`uname -s`
FORCE=0

View File

@ -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

View File

@ -186,7 +186,7 @@ UpgradeApplicationID
{}
Version
{180918}
{181016}
ViewReadme
{Yes}
@ -2387,7 +2387,7 @@ Windows,BuildSeparateArchives
{No}
Windows,Executable
{<%AppName%>-Setup<%Ext%>}
{<%AppName%>-<%Version%>-Setup<%Ext%>}
Windows,FileDescription
{<%AppName%> <%Version%> Setup}

View File

@ -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) {

View File

@ -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);

View File

@ -30,7 +30,7 @@ using namespace Pandora;
using namespace Pandora_Strutils;
#define PATH_SIZE _MAX_PATH+1
#define PANDORA_VERSION ("7.0NG.727(Build 180918)")
#define PANDORA_VERSION ("7.0NG.727(Build 181016)")
string pandora_path;
string pandora_dir;

View File

@ -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 ()) {

View File

@ -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 180918))"
VALUE "ProductVersion", "(7.0NG.727(Build 181016))"
VALUE "FileVersion", "1.0.0.0"
END
END

View File

@ -1,5 +1,5 @@
package: pandorafms-console
Version: 7.0NG.727
Version: 7.0NG.727-181016
Architecture: all
Priority: optional
Section: admin

View File

@ -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-181016"
package_pear=0
package_pandora=1

View File

@ -1,2 +1,3 @@
Order deny,allow
Deny from All
Allow from localhost

View File

@ -70,7 +70,7 @@ function mainAgentsModules() {
$hor_offset = (int)get_parameter('hor_offset', 0);
$block = $config['block_size'];
if(get_parameter('modulegroup') != null){
$agents_id = (array)get_parameter('id_agents2', -1);
$agents_id = (array)get_parameter('id_agents2', null);
}
$selection_a_m = (int)get_parameter('selection_agent_module');
$modules_selected = (array)get_parameter('module', 0);
@ -100,6 +100,9 @@ function mainAgentsModules() {
if($agents_id[0] != -1 ){
serialize_in_temp($agents_id, $config['id_user']."_agents", 1);
}
//if($agents_id != -1) $agents_id = null;
if ($config["pure"] == 0) {
if($modules_selected[0] && $agents_id[0]){
@ -132,8 +135,6 @@ function mainAgentsModules() {
}
}
$groups = users_get_groups ();
//groups
$filter_groups_label = '<b>'.__('Group').'</b>';
$filter_groups = html_print_select_groups(false, "AR", true, 'group_id', $group_id, '', '', '', true, false, true, '', false , 'width: auto;');
@ -144,18 +145,7 @@ function mainAgentsModules() {
$filter_module_groups_label = '<b>'.__('Module group').'</b>';
$filter_module_groups = html_print_select_from_sql ("SELECT * FROM tmodule_group ORDER BY name",
'modulegroup', $modulegroup, '',__('All'), 0, true, false, true, false, 'width: auto;');
$agents_select = array();
if (is_array($id_agents) || is_object($id_agents)){
foreach ($id_agents as $id) {
foreach ($agents as $key => $a) {
if ($key == (int)$id) {
$agents_select[$key] = $key;
}
}
}
}
//agent
$agents = agents_get_group_agents($group_id);
if ((empty($agents)) || $agents == -1) $agents = array();
@ -293,6 +283,7 @@ function mainAgentsModules() {
$count = 0;
foreach ($agents as $agent) {
// TODO TAGS agents_get_modules
$module = agents_get_modules($agent, false,
$filter_module_group, true, true);
if ($module == false) {
@ -301,7 +292,6 @@ function mainAgentsModules() {
$count++;
}
$total_pagination = count($agents);
if($agents_id[0] != -1){
$all_modules = array();
foreach ($modules_selected as $key => $value) {
@ -332,11 +322,11 @@ function mainAgentsModules() {
foreach ($result_sql as $key => $value) {
$all_modules[$value['id_agente_modulo']] = io_safe_output($name);
}
}
// $all_modules[$value] = modules_get_agentmodule_name($value);
}
}
} else {
// TODO TAGS agents_get_modules
$all_modules = agents_get_modules($agents, false,
$filter_module_group, true, true);
}
@ -346,7 +336,6 @@ function mainAgentsModules() {
$modules_by_name = array();
$name = '';
$cont = 0;
foreach ($all_modules as $key => $module) {
if ($module == $name) {
$modules_by_name[$cont-1]['id'][] = $key;
@ -358,7 +347,6 @@ function mainAgentsModules() {
$cont ++;
}
}
if ($config["pure"] == 1) {
$block = count($modules_by_name);
}
@ -381,7 +369,10 @@ function mainAgentsModules() {
$filter_groups['id_grupo'] = $group_id;
}
}
$agents = agents_get_agents ($filter_groups);
if (!empty($filter_groups['id_agente'])) {
$agents = agents_get_agents ($filter_groups);
}
$nagents = count($agents);
if ($all_modules == false || $agents == false) {
@ -499,10 +490,10 @@ function mainAgentsModules() {
<a class='$rowcolor' href='index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=".$agent['id_agente']."'>" .
$alias['alias'] .
"</a></td>";
// TODO TAGS agents_get_modules
$agent_modules = agents_get_modules($agent['id_agente'], false, $filter_module_group, true, true);
$nmodules = 0;
foreach ($modules_by_name as $module) {
$nmodules++;

View File

@ -32,26 +32,17 @@ if (is_ajax()) {
$limit = (int) get_parameter("limit", 5);
$tags_condition = tags_get_acl_tags($config['id_user'], 0, 'ER', 'event_condition', 'AND');
$filter = "estado<>1 $tags_condition";
$filter = "estado <> 1 $tags_condition";
switch ($config["dbtype"]) {
case "mysql":
case "postgresql":
$sql = sprintf ("SELECT id_agente, evento, utimestamp
FROM tevento
WHERE %s
ORDER BY utimestamp DESC LIMIT %d",
$filter, $limit);
break;
case "oracle":
$sql = sprintf ("SELECT *
FROM tevento
WHERE %s
AND rownum <= %d
ORDER BY utimestamp DESC",
$filter, $limit);
break;
}
$sql = sprintf ("SELECT id_agente, evento, utimestamp
FROM tevento
LEFT JOIN tagent_secondary_group
ON tevento.id_agente = tagent_secondary_group.id_agent
WHERE %s
ORDER BY utimestamp DESC LIMIT %d",
$filter, $limit);
$result = db_get_all_rows_sql ($sql);
$events = array();

View File

@ -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 '<strong>' . __('Number fired of alerts').': </strong> ' . $alert["times_fired"] . '<br />';
$agent = db_get_row('tagente', 'id_agente', $module['id_agente']);
echo '<strong>' . __('Agent').': </strong>';
echo io_safe_output($agent['nombre']) . '<br />';
echo '<strong>' . __('Module') . ': </strong>';
echo io_safe_output($module['nombre']) . '<br />';
$template = db_get_row('talert_templates', 'id' , $alert['id_alert_template']);
echo '<strong>' . __('Alert template') . ': </strong>';
echo io_safe_output($template['name']) . '<br />';
// 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 '<strong>' . __('Actions') . ': </strong>' . '<br />';
echo '<ul style="margin-top: 0px; margin-left: 30px;">';
foreach ($actions as $action) {
echo '<li style="list-style: disc;">';
if ($default_action)
echo 'Default:&nbsp;';
echo $action['name'] . '</li>';
}
echo '</ul>';
if ($alert != end($alerts)) {
echo '<hr />';
}
}
}
}
if (!$data) {
echo '<i>These module/s have no alerts or alert/s are not fired</i>';
}
}
else {
echo '<i>No available data</i>';
}
}
else {
echo '<i>No available data</i>';
}
}
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 "<ul class='tooltip_counters'><h3>" . __('Counters Module') . "</h3>";
echo "<li><div style='background-color: " . COL_ALERTFIRED . ";'></div>" . __('Alerts_Fired') . ": " . $send_tooltip['alerts_module_count'] . "</li>";
echo "<li><div style='background-color: " . COL_CRITICAL . ";'></div>" . __('Critical') . ": " . $send_tooltip['critical_module_count'] . "</li>";
echo "<li><div style='background-color: " . COL_WARNING . ";'></div>" . __('warning') . ": " . $send_tooltip['warning_module_count'] . "</li>";
echo "<li><div style='background-color: " . COL_UNKNOWN . ";'></div>" . __('Unknown') . ": " . $send_tooltip['unknown_module_count'] . "</li>";
echo "<li><div style='background-color: " . COL_NORMAL . ";'></div>" . __('OK') . ": " . $send_tooltip['normal_module_count'] . "</li>";
echo "<li><div style='background-color: " . COL_MAINTENANCE . ";'></div>" . __('Not_init') . ": " . $send_tooltip['notInit_module_count'] . "</li></ul>";
}
}
/**
@ -121,169 +39,231 @@ function translate(&$item, $key) {
* execute the code.
*/
function mainModuleGroups() {
global $config; //the useful global var of Pandora Console, it has many data can you use
require_once ('include/functions_reporting.php');
require_once($config['homedir'] . "/include/functions_agents.php");
require_once($config['homedir'] . "/include/functions_users.php");
//The big query
$sql = "SELECT COUNT(id_agente) AS count, case utimestamp when 0 then 5 else estado end as estado
FROM tagente_estado
WHERE id_agente IN
(SELECT id_agente
FROM tagente ta LEFT JOIN tagent_secondary_group tasg
ON ta.id_agente = tasg.id_agent
WHERE (ta.id_grupo = %d OR tasg.id_group = %d) AND disabled IS FALSE
)
AND id_agente_modulo IN
(SELECT id_agente_modulo
FROM tagente_modulo
WHERE id_module_group = %d AND disabled IS FALSE AND delete_pending IS FALSE)
GROUP BY estado";
global $config;
require_once($config['homedir'] . "/include/class/TreeGroup.class.php");
require_once($config['homedir'] . "/include/functions_groupview.php");
$tree_group = new TreeGroup("group", "group");
$tree_group->setPropagateCounters(false);
$tree_group->setDisplayAllGroups(true);
$tree_group->setFilter( array(
'searchAgent' => '',
'statusAgent' => AGENT_STATUS_ALL,
'searchModule' => '',
'statusModule' => -1,
'groupID' => 0,
'tagID' => 0,
'show_not_init_agents' => 1,
'show_not_init_modules' => 1
));
$info = $tree_group->getArray();
$info = groupview_plain_groups($info);
$counter = count($info);
$offset = get_parameter('offset', 0);
$groups_view = $is_not_paginated
? $info
: array_slice($info, $offset, $config['block_size']);
$agents_counters = array_reduce($groups_view, function($carry, $item){
$carry[$item['id']] = $item;
return $carry;
}, array());
$ids_array = array_keys($agents_counters);
$ids_group = implode(',', $ids_array);
$condition_critical = modules_get_state_condition(AGENT_MODULE_STATUS_CRITICAL_ALERT);
$condition_warning = modules_get_state_condition(AGENT_MODULE_STATUS_WARNING_ALERT);
$condition_unknown = modules_get_state_condition(AGENT_MODULE_STATUS_UNKNOWN);
$condition_not_init = modules_get_state_condition(AGENT_MODULE_STATUS_NO_DATA);
$condition_normal = modules_get_state_condition(AGENT_MODULE_STATUS_NORMAL);
$array_for_defect = array();
$array_module_group = array();
$array_data = array();
$sql = "SELECT id_mg, `name` FROM tmodule_group";
$array_mod= db_get_all_rows_sql($sql);
foreach ($array_mod as $key => $value) {
$array_module_group[$value['id_mg']] = $value['name'];
}
$array_module_group[0] = 'Nothing';
foreach ($agents_counters as $key => $value) {
$array_for_defect[$key]['gm'] = $array_module_group;
$array_for_defect[$key]['data']['name'] = $value['name'];
$array_for_defect[$key]['data']['parent'] = $value['parent'];
$array_for_defect[$key]['data']['icon'] = $value['icon'];
}
$sql =
"SELECT SUM(IF(tae.alert_fired <> 0, 1, 0)) AS alerts_module_count,
SUM(IF($condition_warning, 1, 0)) AS warning_module_count,
SUM(IF($condition_unknown, 1, 0)) AS unknown_module_count,
SUM(IF($condition_not_init, 1, 0)) AS notInit_module_count,
SUM(IF($condition_critical, 1, 0)) AS critical_module_count,
SUM(IF($condition_normal, 1, 0)) AS normal_module_count,
COUNT(tae.id_agente_modulo) AS total_count,
tmg.id_mg,
tmg.name as n,
tg.id_grupo
FROM (
SELECT tam.id_agente_modulo,
tam.id_module_group,
ta.id_grupo AS g,
tae.estado,
SUM(IF(tatm.last_fired <> 0, 1, 0)) AS alert_fired
FROM tagente_modulo tam
LEFT JOIN talert_template_modules tatm
ON tatm.id_agent_module = tam.id_agente_modulo
AND tatm.times_fired = 1
LEFT JOIN tagente_estado tae
ON tae.id_agente_modulo = tam.id_agente_modulo
INNER JOIN tagente ta
ON ta.id_agente = tam.id_agente
WHERE ta.disabled = 0
AND tam.disabled = 0
AND tam.delete_pending = 0
AND ta.id_grupo IN ($ids_group)
GROUP BY tam.id_agente_modulo
UNION ALL
SELECT tam.id_agente_modulo,
tam.id_module_group,
tasg.id_group AS g,
tae.estado,
SUM(IF(tatm.last_fired <> 0, 1, 0)) AS alert_fired
FROM tagente_modulo tam
LEFT JOIN talert_template_modules tatm
ON tatm.id_agent_module = tam.id_agente_modulo
AND tatm.times_fired = 1
LEFT JOIN tagente_estado tae
ON tae.id_agente_modulo = tam.id_agente_modulo
INNER JOIN tagente ta
ON ta.id_agente = tam.id_agente
INNER JOIN tagent_secondary_group tasg
ON ta.id_agente = tasg.id_agent
WHERE ta.disabled = 0
AND tam.disabled = 0
AND tam.delete_pending = 0
AND tasg.id_group IN ($ids_group)
GROUP BY tam.id_agente_modulo, tasg.id_group
) AS tae
RIGHT JOIN tgrupo tg
ON tg.id_grupo = tae.g
INNER JOIN (
SELECT * FROM tmodule_group
UNION ALL
SELECT 0 AS 'id_mg', 'Nothing' AS 'name'
) AS tmg
ON tae.id_module_group = tmg.id_mg
GROUP BY tae.g, tmg.id_mg";
$array_data_prev = db_get_all_rows_sql($sql);
foreach ($array_data_prev as $key => $value) {
$array_data[$value['id_grupo']][$value['id_mg']] = $value;
}
ui_print_page_header (__("Combined table of agent group and module group"), "images/module_group.png", false, "", false, '');
ui_print_info_message ( array('no_close'=>true, 'message'=>
__("This table shows in columns the modules group and in rows agents group. The cell shows all modules") )
);
$agentGroups = users_get_groups ($config['id_user'], "AR", false);
$modelGroups = users_get_all_model_groups();
if (!empty($agentGroups) && !empty($modelGroups)) {
array_walk($modelGroups, 'translate'); //Translate all head titles to language is set
$table = null;
$table->headstyle[] = "width: 20%";
foreach ($modelGroups as $i => $n) {
$table->headstyle[] = "min-width: 60px;max-width: 5%;text-align:center;";
$modelGroups[$i] = ui_print_truncate_text($n, GENERIC_SIZE_TEXT, true, true, true, '&hellip;', 'color:#FFF');
}
$head = $modelGroups;
array_unshift($head, '&nbsp;');
//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, '&hellip;', '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 = '<a class="info_cell" rel="ajax.php?page=extensions/module_groups&get_info_alert_module_group=1&module_group=' .
$idModelGroup . '&id_agent_group=' . $idAgentGroup . '"href="index.php?sec=estado&sec2=operation/agentes/status_monitor&status=-1&ag_group=' .
$idAgentGroup . '&modulegroup=' . $idModelGroup . '" style="color: ' . $font_color . '; font-size: 18px;";>';
$alinkEnd = '</a>';
}
array_push($row,
'<div
style="background: ' . $color . ';
height: 20px;min-width: 60px;max-width:5%;overflow:hidden;
margin-left: auto; margin-right: auto;
text-align: center; padding: 5px;padding-bottom:10px;font-size: 18px;line-height:25px;">
' . $alinkStart . $count . $alinkEnd . '</div>');
}
array_push($tableData,$row);
}
$table->data = $tableData;
echo "<div style='width:100%; overflow-x:auto;'>";
html_print_table($table);
echo "</div>";
echo "<div class='legend_basic' style='width: 98.6%'>";
echo "<table >";
echo "<tr><td colspan='2' style='padding-bottom: 10px;'><b>" . __('Legend') . "</b></td></tr>";
echo "<tr><td class='legend_square_simple'><div style='background-color: " . COL_ALERTFIRED . ";'></div></td><td>" . __("Orange cell when the module group and agent have at least one alarm fired.") . "</td></tr>";
echo "<tr><td class='legend_square_simple'><div style='background-color: " . COL_CRITICAL . ";'></div></td><td>" . __("Red cell when the module group and agent have at least one module in critical status and the others in any status") . "</td></tr>";
echo "<tr><td class='legend_square_simple'><div style='background-color: " . COL_WARNING . ";'></div></td><td>" . __("Yellow cell when the module group and agent have at least one in warning status and the others in grey or green status") . "</td></tr>";
echo "<tr><td class='legend_square_simple'><div style='background-color: " . COL_NORMAL . ";'></div></td><td>" . __("Green cell when the module group and agent have all modules in OK status") . "</td></tr>";
echo "<tr><td class='legend_square_simple'><div style='background-color: " . COL_UNKNOWN . ";'></div></td><td>" . __("Grey cell when the module group and agent have at least one in unknown status and the others in green status") . "</td></tr>";
echo "<tr><td class='legend_square_simple'><div style='background-color: " . COL_MAINTENANCE . ";'></div></td><td>" .__("Blue cell when the module group and agent have all modules in not init status.") . "</td></tr>";
echo "</table>";
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, '&hellip;', '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, '&hellip;', '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] ="<div style='background:$color; height: 20px;min-width: 60px;max-width:5%;overflow:hidden; margin-left: auto; margin-right: auto; text-align: center; padding: 5px;padding-bottom:10px;font-size: 18px;line-height:25px;'>";
$data[$i][$j] .= "<a class='info_cell' rel='$rel' href='$url' style='color:white;font-size: 18px;'>";
$data[$i][$j] .= $array_data[$key][$k]['total_count'];
$data[$i][$j] .= "</a></div>";
}
else{
$data[$i][$j] ="<div style='background:white; height: 20px;min-width: 60px;max-width:5%;overflow:hidden; margin-left: auto; margin-right: auto; text-align: center; padding: 5px;padding-bottom:10px;font-size: 18px;line-height:25px;'>";
$data[$i][$j] .= 0;
$data[$i][$j] .= "</div>";
}
$j++;
}
}
else{
foreach ($value['gm'] as $k => $v) {
$data[$i][$j] ="<div style='background:white; height: 20px;min-width: 60px;max-width:5%;overflow:hidden; margin-left: auto; margin-right: auto; text-align: center; padding: 5px;padding-bottom:10px;font-size: 18px;line-height:25px;'>";
$data[$i][$j] .= 0;
$data[$i][$j] .= "</div>";
$j++;
}
}
$i++;
}
$table->head = $head;
$table->headstyle = $headstyle;
$table->data = $data;
ui_pagination($counter);
echo "<div style='width:100%; overflow-x:auto;'>";
html_print_table($table);
echo "</div>";
ui_pagination($counter);
echo "<div class='legend_basic' style='width: 98.6%'>";
echo "<table >";
echo "<tr><td colspan='2' style='padding-bottom: 10px;'><b>" . __('Legend') . "</b></td></tr>";
echo "<tr><td class='legend_square_simple'><div style='background-color: " . COL_ALERTFIRED . ";'></div></td><td>" . __("Orange cell when the module group and agent have at least one alarm fired.") . "</td></tr>";
echo "<tr><td class='legend_square_simple'><div style='background-color: " . COL_CRITICAL . ";'></div></td><td>" . __("Red cell when the module group and agent have at least one module in critical status and the others in any status") . "</td></tr>";
echo "<tr><td class='legend_square_simple'><div style='background-color: " . COL_WARNING . ";'></div></td><td>" . __("Yellow cell when the module group and agent have at least one in warning status and the others in grey or green status") . "</td></tr>";
echo "<tr><td class='legend_square_simple'><div style='background-color: " . COL_UNKNOWN . ";'></div></td><td>" . __("Grey cell when the module group and agent have at least one in unknown status and the others in green status") . "</td></tr>";
echo "<tr><td class='legend_square_simple'><div style='background-color: " . COL_NORMAL . ";'></div></td><td>" . __("Green cell when the module group and agent have all modules in OK status") . "</td></tr>";
echo "<tr><td class='legend_square_simple'><div style='background-color: " . COL_MAINTENANCE . ";'></div></td><td>" .__("Blue cell when the module group and agent have all modules in not init status.") . "</td></tr>";
echo "</table>";
echo "</div>";
}
else {
echo "<div class='nf'>".__('There are no defined groups or module groups')."</div>";
ui_print_info_message ( array('no_close'=>true, 'message'=> __("This table shows in columns the modules group and in rows agents group. The cell shows all modules") ));
ui_print_info_message ( array('no_close'=>true, 'message'=> __('There are no defined groups or module groups') ));
}
ui_require_css_file('cluetip');
ui_require_jquery_file('cluetip');
?>
@ -292,7 +272,8 @@ function mainModuleGroups() {
$("a.info_cell").cluetip ({
arrows: true,
attribute: 'rel',
cluetipClass: 'default'
cluetipClass: 'default',
width: '200px'
});
});
</script>

View File

@ -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();
});

View File

@ -3,4 +3,13 @@ START TRANSACTION;
ALTER TABLE `tservice` ADD COLUMN `is_favourite` tinyint(1) NOT NULL default 0;
UPDATE tservice SET `is_favourite` = 1 WHERE `name` REGEXP '^[_|.|\[|\(]';
COMMIT;
ALTER TABLE tlayout_data ADD COLUMN `show_last_value` tinyint(1) UNSIGNED NULL default '0';
ALTER TABLE tlayout MODIFY `name` varchar(600) NOT NULL;
ALTER TABLE tmetaconsole_setup ADD COLUMN `meta_dbuser` text;
ALTER TABLE tmetaconsole_setup ADD COLUMN `meta_dbpass` text;
ALTER TABLE tmetaconsole_setup ADD COLUMN `meta_dbhost` text;
ALTER TABLE tmetaconsole_setup ADD COLUMN `meta_dbport` text;
ALTER TABLE tmetaconsole_setup ADD COLUMN `meta_dbname` text;
COMMIT;

View File

@ -341,13 +341,18 @@ CREATE TABLE IF NOT EXISTS `ttrap_custom_values` (
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `tmetaconsole_setup` (
`id` int(10) NOT NULL auto_increment primary key,
`server_name` text default '',
`server_url` text default '',
`dbuser` text default '',
`dbpass` text default '',
`dbhost` text default '',
`dbport` text default '',
`dbname` text default '',
`server_name` text,
`server_url` text,
`dbuser` text,
`dbpass` text,
`dbhost` text,
`dbport` text,
`dbname` text,
`meta_dbuser` text,
`meta_dbpass` text,
`meta_dbhost` text,
`meta_dbport` text,
`meta_dbname` text,
`auth_token` text default '',
`id_group` int(10) unsigned NOT NULL default 0,
`api_password` text NOT NULL,
@ -1281,6 +1286,7 @@ UPDATE tservice SET `is_favourite` = 1 WHERE `name` REGEXP '^[_|.|\[|\(]';
-- ---------------------------------------------------------------------
ALTER TABLE tlayout ADD `background_color` varchar(50) NOT NULL default '#FFF';
ALTER TABLE tlayout ADD `is_favourite` int(1) NOT NULL DEFAULT 0;
ALTER TABLE tlayout MODIFY `name` varchar(600) NOT NULL;
UPDATE tlayout SET is_favourite = 1 WHERE name REGEXP '^&#40;' OR name REGEXP '^\\[';
@ -1296,6 +1302,7 @@ ALTER TABLE tlayout_data ADD COLUMN `show_on_top` tinyint(1) NOT NULL default '0
ALTER TABLE tlayout_data ADD COLUMN `clock_animation` varchar(60) NOT NULL default "analogic_1";
ALTER TABLE tlayout_data ADD COLUMN `time_format` varchar(60) NOT NULL default "time";
ALTER TABLE tlayout_data ADD COLUMN `timezone` varchar(60) NOT NULL default "Europe/Madrid";
ALTER TABLE tlayout_data ADD COLUMN `show_last_value` tinyint(1) UNSIGNED NULL default '0';
-- ---------------------------------------------------------------------
-- Table `tagent_custom_fields`

View File

@ -72,38 +72,49 @@ config_check();
$table->width = "100%";
$table->styleTable = 'margin: auto; margin-top: 0px;';
$table->rowclass[0] = '';
$table->data[0][11] = ui_print_help_tip (__("Blank characters are used as AND conditions"), true);
// Search bar
$search_bar = '<form method="get" style="display: inline;" name="quicksearch" action="">';
if (!isset($config['search_keywords'])) {
$search_bar .= '<script type="text/javascript"> var fieldKeyWordEmpty = true; </script>';
$acl_head_search = true;
if ($config["acl_enterprise"] == 1 && !users_is_admin()) {
$acl_head_search = db_get_sql("SELECT sec FROM tusuario
INNER JOIN tusuario_perfil ON tusuario.id_user = tusuario_perfil.id_usuario
INNER JOIN tprofile_view ON tprofile_view.id_profile = tusuario_perfil.id_perfil
WHERE tusuario.id_user = '".$config['id_user']."' AND (sec = '*' OR sec = 'head_search')");
}
else {
if (strlen($config['search_keywords']) == 0)
if ($acl_head_search) {
$table->data[0][11] = ui_print_help_tip (__("Blank characters are used as AND conditions"), true);
// Search bar
$search_bar = '<form method="get" style="display: inline;" name="quicksearch" action="">';
if (!isset($config['search_keywords'])) {
$search_bar .= '<script type="text/javascript"> var fieldKeyWordEmpty = true; </script>';
}
else {
if (strlen($config['search_keywords']) == 0)
$search_bar .= '<script type="text/javascript"> var fieldKeyWordEmpty = true; </script>';
else
$search_bar .= '<script type="text/javascript"> var fieldKeyWordEmpty = false; </script>';
}
$search_bar .= '<input type="text" id="keywords" name="keywords"';
if (!isset($config['search_keywords']))
$search_bar .= "value='" . __("Enter keywords to search") . "'";
else if (strlen($config['search_keywords']) == 0)
$search_bar .= "value='" . __("Enter keywords to search") . "'";
else
$search_bar .= '<script type="text/javascript"> var fieldKeyWordEmpty = false; </script>';
$search_bar .= "value='" . $config['search_keywords'] . "'";
$search_bar .= 'onfocus="javascript: if (fieldKeyWordEmpty) $(\'#keywords\').val(\'\');"
onkeyup="javascript: fieldKeyWordEmpty = false;"
style="margin-top:5px;" class="search_input" />';
//$search_bar .= 'onClick="javascript: document.quicksearch.submit()"';
$search_bar .= "<input type='hidden' name='head_search_keywords' value='abc' />";
$search_bar .= '</form>';
$table->data[0]['searchbar'] = $search_bar;
}
$search_bar .= '<input type="text" id="keywords" name="keywords"';
if (!isset($config['search_keywords']))
$search_bar .= "value='" . __("Enter keywords to search") . "'";
else if (strlen($config['search_keywords']) == 0)
$search_bar .= "value='" . __("Enter keywords to search") . "'";
else
$search_bar .= "value='" . $config['search_keywords'] . "'";
$search_bar .= 'onfocus="javascript: if (fieldKeyWordEmpty) $(\'#keywords\').val(\'\');"
onkeyup="javascript: fieldKeyWordEmpty = false;"
style="margin-top:5px;" class="search_input" />';
//$search_bar .= 'onClick="javascript: document.quicksearch.submit()"';
$search_bar .= "<input type='hidden' name='head_search_keywords' value='abc' />";
$search_bar .= '</form>';
$table->data[0]['searchbar'] = $search_bar;
// Servers check
$servers = array();
$servers["all"] = (int) db_get_value ('COUNT(id_server)','tserver');

View File

@ -106,8 +106,6 @@ $form .= html_print_table($table, true);
$form .= '</form>';
ui_toggle($form, __("Filter"), "", false);
// ui_toggle(graphic_user_activity(400, 150), __("Chart"));
$filter = "1=1";
if (!empty($filter_type)) {

View File

@ -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);

View File

@ -207,11 +207,6 @@ if ($create_agent) {
$agent_creation_error = __('No agent alias specified');
$agent_created_ok = 0;
}
/*elseif (agents_get_agent_id ($nombre_agente)) {
$agent_creation_error =
__('There is already an agent in the database with this name');
$agent_created_ok = 0;
}*/
else {
if($alias_as_name){
$sql = 'SELECT nombre FROM tagente WHERE nombre = "' . $alias . '"';
@ -760,7 +755,7 @@ if ($update_agent) { // if modified some agent paramenter
$quiet = (int) get_parameter("quiet", 0);
$cps = (int) get_parameter("cps", 0);
$old_interval = db_get_value('intervalo', 'tagente', 'id_agente', $id_agente);
$old_values = db_get_row('tagente', 'id_agente', $id_agente);
$fields = db_get_all_fields_in_table('tagent_custom_fields');
if ($fields === false) $fields = array();
@ -860,11 +855,21 @@ if ($update_agent) { // if modified some agent paramenter
// Update the agent from the metaconsole cache
enterprise_include_once('include/functions_agents.php');
enterprise_hook ('agent_update_from_cache', array($id_agente, $values,$server_name));
if ($old_interval != $intervalo) {
enterprise_hook('config_agents_update_config_interval', array($id_agente, $intervalo));
# Update the configuration files
if ($old_values['intervalo'] != $intervalo) {
enterprise_hook(
'config_agents_update_config_token',
array($id_agente, 'interval', $intervalo)
);
}
if ($old_values['disabled'] != $disabled) {
enterprise_hook(
'config_agents_update_config_token',
array($id_agente, 'standby', $disabled ? "1" : "0")
);
}
if($tpolicy_group_old){
foreach ($tpolicy_group_old as $key => $value) {
$tpolicy_agents_old= db_get_sql("SELECT * FROM tpolicy_agents
@ -919,8 +924,9 @@ if ($update_agent) { // if modified some agent paramenter
enterprise_hook ('update_agent', array ($id_agente));
ui_print_success_message (__('Successfully updated'));
$unsafe_alias = io_safe_output($alias);
db_pandora_audit("Agent management",
"Updated agent $alias", false, false, $info);
"Updated agent $unsafe_alias", false, false, $info);
}
}
@ -1421,7 +1427,7 @@ if ($update_module) {
$edit_module = true;
db_pandora_audit("Agent management",
"Fail to try update module '$name' for agent " . $agent["alias"]);
"Fail to try update module '".io_safe_output($name)."' for agent " . io_safe_output($agent["alias"]));
}
else {
if ($prediction_module == 3) {
@ -1439,7 +1445,7 @@ if ($update_module) {
$agent = db_get_row ('tagente', 'id_agente', $id_agente);
db_pandora_audit("Agent management",
"Updated module '$name' for agent ".$agent["alias"], false, false, io_json_mb_encode($values));
"Updated module '".io_safe_output($name)."' for agent ". io_safe_output($agent["alias"]), false, false, io_json_mb_encode($values));
}
}
@ -1580,7 +1586,7 @@ if ($create_module) {
$edit_module = true;
$moduletype = $id_module;
db_pandora_audit("Agent management",
"Fail to try added module '$name' for agent ".$agent["alias"]);
"Fail to try added module '".io_safe_output($name)."' for agent ".io_safe_output($agent["alias"]));
}
else {
if ($prediction_module == 3) {
@ -1598,7 +1604,7 @@ if ($create_module) {
$agent = db_get_row ('tagente', 'id_agente', $id_agente);
db_pandora_audit("Agent management",
"Added module '$name' for agent ".$agent["alias"], false, true, io_json_mb_encode($values));
"Added module '".io_safe_output($name)."' for agent ".io_safe_output($agent["alias"]), false, true, io_json_mb_encode($values));
}
}
@ -1713,12 +1719,18 @@ if ($delete_module) { // DELETE agent module !
ui_print_error_message(__('There was a problem deleting the module'));
}
else {
ui_print_success_message(__('Module deleted succesfully'));
echo '<script type="text/javascript">
location="index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=module&id_agente='.$id_agente.'";
alert("'.__('Module deleted succesfully').'");
</script>';
$agent = db_get_row ('tagente', 'id_agente', $id_agente);
db_pandora_audit("Agent management",
"Deleted module '".$module_data["nombre"]."' for agent ".$agent["alias"]);
"Deleted module '".io_safe_output($module_data["nombre"])."' for agent ".io_safe_output($agent["alias"]));
}
}
// MODULE DUPLICATION
@ -1748,11 +1760,11 @@ if (!empty($duplicate_module)) { // DUPLICATE agent module !
if ($result) {
db_pandora_audit("Agent management",
"Duplicate module '".$id_duplicate_module."' for agent " . $agent["alias"] . " with the new id for clon " . $result);
"Duplicate module '".$id_duplicate_module."' for agent " . io_safe_output($agent["alias"]) . " with the new id for clon " . $result);
}
else {
db_pandora_audit("Agent management",
"Fail to try duplicate module '".$id_duplicate_module."' for agent " . $agent["alias"]);
"Fail to try duplicate module '".$id_duplicate_module."' for agent " . io_safe_output($agent["alias"]));
}
}
@ -1936,11 +1948,11 @@ switch ($tab) {
resizable: true,
draggable: true,
modal: true,
height: 220,
height: 240,
width: 600,
title: 'Changing the module name of a satellite agent',
open: function(){
$('#dialog').html('<br><img src="images/icono-warning-triangulo.png" style="float:left;margin-left:25px;"><p style="float:right;font-style:nunito;font-size:11pt;margin-right:50px;"><span style="font-weight:bold;font-size:12pt;">Warning</span> <br>The names of the modules of a satellite should not be <br> altered manually. Unless you are absolutely certain of <br> the process, do not alter these names.</p>');
$('#dialog').html('<br><table><tr><td><img src="images/icono-warning-triangulo.png" style="float:left;margin-left:25px;"></td><td><p style="float:right;font-style:nunito;font-size:11pt;margin-right:50px;margin-left:40px;"><span style="font-weight:bold;font-size:12pt;">Warning</span> <br>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.</p></td></tr></table>');
},
buttons: [{
text: "Ok",
@ -1970,11 +1982,11 @@ switch ($tab) {
resizable: true,
draggable: true,
modal: true,
height: 280,
width: 670,
height: 240,
width: 650,
title: 'Changing snmp module name',
open: function(){
$('#dialog').html('<br><img src="images/icono-warning-triangulo.png" style="float:left;margin-left:25px;margin-top:30px;"><p style="float:right;font-style:nunito;font-size:11pt;margin-right:50px;"><span style="font-weight:bold;font-size:12pt;">Warning</span> <br> If you change the name of this module, various features <br> associated with this module, such as network maps, <br> interface graphs or other network modules, may no longer <br> work. If you are not completely sure of the process, please <br> do not change the name of the module. </p>');
$('#dialog').html('<br><table><tr><td><img src="images/icono-warning-triangulo.png" style="float:left;margin-left:25px;margin-top:30px;"></td><td><p style="float:right;font-style:nunito;font-size:11pt;margin-right:50px;margin-left:40px;"><span style="font-weight:bold;font-size:12pt;">Warning</span> <br> 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. </p></td></tr></table>');
},
buttons: [{
text: "Ok",

View File

@ -43,6 +43,7 @@ echo '<table width="100%" cellpadding="2" cellspacing="2" class="databox filters
echo "<tr><td class='datos' style='width:20%; font-weight: bold;'>";
echo __('Search') . ' ' .
html_print_input_text ('search_string', $search_string, '', 15, 255, true);
html_print_input_hidden ('search', 1);
echo "</td>";
echo "<td class='datos' style='width:10%'>";
html_print_submit_button (__('Filter'), 'filter', false, 'class="sub search"');
@ -423,9 +424,11 @@ foreach ($order as $ord) {
$limit = (int) $config["block_size"];
$offset = (int) get_parameter ('offset');
$params = implode(',',
$params = ($checked)
? "tagente_modulo.*, tmodule_group.*"
: implode(',',
array(
'id_agente_modulo',
'tagente_modulo.id_agente_modulo',
'id_tipo_modulo',
'descripcion',
'nombre',
@ -452,80 +455,46 @@ $search_string_entities = io_safe_input($search_string);
$basic_where = sprintf("(nombre LIKE '%%%s%%' OR nombre LIKE '%%%s%%' OR descripcion LIKE '%%%s%%' OR descripcion LIKE '%%%s%%') AND", $search_string, $search_string_entities, $search_string, $search_string_entities);
$where_tags = tags_get_acl_tags($config['id_user'], 0, 'AR', 'module_condition', 'AND', 'tagente_modulo');
// Tags acl
$agent_tags = tags_get_user_applied_agent_tags($id_agente);
if ($agent_tags !== true) {
$where_tags = " AND ttag_module.id_tag IN (" . implode(',', $agent_tags) . ")";
}
$paginate_module = false;
if (isset($config['paginate_module']))
$paginate_module = $config['paginate_module'];
switch ($config["dbtype"]) {
case "postgresql":
if ($paginate_module) {
$limit_sql = " LIMIT $limit OFFSET $offset ";
}
else {
$limit_sql = '';
}
case "mysql":
if ($paginate_module) {
if (!isset($limit_sql)) {
$limit_sql = " LIMIT $offset, $limit ";
}
}
else {
$limit_sql = '';
}
if ($checked) {
$sql = sprintf("SELECT *
FROM tagente_modulo
LEFT JOIN tmodule_group
ON tagente_modulo.id_module_group = tmodule_group.id_mg
WHERE %s %s %s %s %s",
$basic_where, $where, $where_tags, $order_sql, $limit_sql);
}
else {
$sql = sprintf("SELECT %s
FROM tagente_modulo
LEFT JOIN tmodule_group
ON tagente_modulo.id_module_group = tmodule_group.id_mg
WHERE %s %s %s %s %s",
$params, $basic_where, $where, $where_tags, $order_sql, $limit_sql);
}
$modules = db_get_all_rows_sql($sql);
break;
case "oracle":
$set = array();
if ($paginate_module) {
$set['limit'] = $limit;
$set['offset'] = $offset;
}
if ($checked) {
$sql = sprintf("SELECT *
FROM tagente_modulo
LEFT JOIN tmodule_group
ON tmodule_group.id_mg = tagente_modulo.id_module_group
WHERE %s %s %s %s",
$basic_where, $where, $where_tags, $order_sql);
}
else {
$sql = sprintf("SELECT %s
FROM tagente_modulo
LEFT JOIN tmodule_group
ON tmodule_group.id_mg = tagente_modulo.id_module_group
WHERE %s %s %s %s",
$params, $basic_where, $where, $where_tags, $order_sql);
}
$modules = oracle_recode_query ($sql, $set, 'AND', false);
break;
if ($paginate_module) {
if (!isset($limit_sql)) {
$limit_sql = " LIMIT $offset, $limit ";
}
}
else {
$limit_sql = '';
}
$sql = sprintf("SELECT tagente_modulo.*, tmodule_group.*
FROM tagente_modulo
LEFT JOIN tmodule_group
ON tagente_modulo.id_module_group = tmodule_group.id_mg
LEFT JOIN ttag_module
ON ttag_module.id_agente_modulo = tagente_modulo.id_agente_modulo
WHERE %s %s %s
GROUP BY tagente_modulo.id_agente_modulo
%s %s",
$basic_where, $where, $where_tags,
$order_sql, $limit_sql
);
$sql_total_modules = sprintf("SELECT count(*)
$modules = db_get_all_rows_sql($sql);
$sql_total_modules = sprintf(
"SELECT count(DISTINCT(tagente_modulo.id_agente_modulo))
FROM tagente_modulo
WHERE %s %s %s", $basic_where, $where, $where_tags);
LEFT JOIN ttag_module
ON ttag_module.id_agente_modulo = tagente_modulo.id_agente_modulo
WHERE %s %s %s", $basic_where, $where, $where_tags
);
$total_modules = db_get_value_sql($sql_total_modules);

View File

@ -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);
@ -189,9 +189,23 @@ $table_simple->data[0][3] .= html_print_select_from_sql ('SELECT id_mg, name FRO
$in_policy = strstr($page, "policy_modules");
if (!$in_policy) {
// Cannot select the current module to be itself parent
$module_parent_filter = $id_agent_module
? array("tagente_modulo.id_agente_modulo" => "<>$id_agent_module")
: "";
$table_simple->data[1][0] = __('Module parent');
$table_simple->data[1][1] .= html_print_select_from_sql ('SELECT id_agente_modulo, nombre FROM tagente_modulo WHERE id_agente = ' . $id_agente . ' ORDER BY nombre',
'parent_module_id', $parent_module_id, '', __('Not assigned'), '0', true, false, true);
$modules_can_be_parent = agents_get_modules($id_agente, false, $module_parent_filter);
// If the user cannot have access to parent module, only print the name
if ($parent_module_id != 0 && !in_array($parent_module_id, array_keys($modules_can_be_parent))) {
$table_simple->data[1][1] = db_get_value(
'nombre', 'tagente_modulo', 'id_agente_modulo', $parent_module_id
);
} else {
$table_simple->data[1][1] = html_print_select (
$modules_can_be_parent, 'parent_module_id', $parent_module_id, '',
__('Not assigned'), '0', true
);
}
}
$table_simple->data[2][0] = __('Type').' ' . ui_print_help_icon ('module_type', true);

View File

@ -71,7 +71,7 @@ push_table_simple ($data, 'plugin_1');
$data = array ();
$data[0] = 'macro_desc';
$data[0] .= ui_print_help_tip ('macro_help', true);
$data[1] = html_print_input_text ('macro_name', 'macro_value', '', 100, 255, true);
$data[1] = html_print_input_text ('macro_name', 'macro_value', '', 100, 1024, true);
$table_simple->colspan['macro_field'][1] = 3;
$table_simple->rowstyle['macro_field'] = 'display:none';
@ -93,10 +93,10 @@ if (!empty($macros)) {
$m_hide = $m['hide'];
if ($m_hide) {
$data[1] = html_print_input_password($m['macro'], io_output_password($m['value']), '', 100, 255, true);
$data[1] = html_print_input_password($m['macro'], io_output_password($m['value']), '', 100, 1024, true);
}
else {
$data[1] = html_print_input_text($m['macro'], $m['value'], '', 100, 255, true,
$data[1] = html_print_input_text($m['macro'], $m['value'], '', 100, 1024, true,
$disabledBecauseInPolicy, false, '', $classdisabledBecauseInPolicy);
}
$table_simple->colspan['macro'.$m['macro']][1] = 3;

View File

@ -70,6 +70,7 @@ if (! $id_agente) {
$table->data[0][0] = __('Module');
$modules = array ();
if ($id_agente)
$modules = agents_get_modules ($id_agente, false, array("delete_pending" => 0));
@ -136,21 +137,25 @@ if (check_acl ($config['id_user'], 0, "LM")) {
$table->data[3][1] .= ' ' . __('seconds') . ui_print_help_icon ('action_threshold', true);
echo '<form class="add_alert_form" method="post">';
html_print_table ($table);
if (!isset($step) || $step!=5) {
echo '<form class="add_alert_form" method="post">';
html_print_table ($table);
}
echo '<div class="action-buttons" style="width: '.$table->width.'">';
if($id_cluster){
echo "<input onclick='window.location.replace(\"index.php?sec=reporting&sec2=enterprise/godmode/reporting/cluster_view&id=".$id_cluster."\");' type=button style='float:right;margin-left:20px;' name='store' class='sub upd' value='".__('Finish and view cluster')."'>";
if (!isset($step) || $step!=5) {
if($id_cluster){
echo "<input onclick='window.location.replace(\"index.php?sec=reporting&sec2=enterprise/godmode/reporting/cluster_view&id=".$id_cluster."\");' type=button style='float:right;margin-left:20px;' name='store' class='sub upd' value='".__('Finish and view cluster')."'>";
}
html_print_submit_button (__('Add alert'), 'add', false, 'class="sub wand"');
html_print_input_hidden ('create_alert', 1);
echo '</div></form>';
}
html_print_submit_button (__('Add alert'), 'add', false, 'class="sub wand"');
html_print_input_hidden ('create_alert', 1);
echo '</div></form>';
ui_require_css_file ('cluetip');
ui_require_jquery_file ('cluetip');
ui_require_jquery_file ('pandora.controls');
@ -218,7 +223,7 @@ $(document).ready (function () {
$("#value", $value).append ("<em><?php echo __('Empty') ?></em>");
}
else {
$("#value", $value).append (data);
$("#value", $value).append (parseInt(data));
}
$loading.hide ();
$value.show ();

View File

@ -705,18 +705,26 @@ foreach ($simple_alerts as $alert) {
if(check_acl_one_of_groups ($config['id_user'], $all_groups, "LW")) {
$data[4] .= '&nbsp;&nbsp;<form class="delete_alert_form" action="' . $url . '" method="post" style="display: inline;">';
if ($alert['disabled']) {
$data[4] .= html_print_image('images/add.disabled.png',
true, array('title' => __("Add action")));
}
else {
$data[4] .= '<a href="javascript:show_add_action(\'' . $alert['id'] . '\');">';
$data[4] .= html_print_image('images/add.png', true, array('title' => __("Add action")));
$data[4] .= '</a>';
}
$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] .= '</form>';
$data[4] .= '<form class="view_alert_form" method="post" style="display: inline;">';
$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] .= '</form>';
}
if(check_acl_one_of_groups ($config['id_user'], $all_groups, "LM")) {

View File

@ -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);
}
}

View File

@ -188,7 +188,7 @@ foreach ($fields_available as $key=>$available) {
}
$table->data[0][0] = '<b>' . __('Fields available').'</b>';
$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] = '<a href="javascript:">' .
html_print_image('images/darrowright.png', true,
array('id' => 'right', 'title' => __('Add fields to select'))) .
@ -201,7 +201,7 @@ $table->data[1][1] .= '<br><br><br><br><a href="javascript:">' .
$table->data[0][1] = '';
$table->data[0][2] = '<b>' . __('Fields selected') . '</b>';
$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 '<form id="custom_events" method="post" action="index.php?sec=geventos&sec2=godmode/events/events&section=fields&amp;pure='.$config['pure'].'">';
html_print_table($table);
@ -223,6 +223,7 @@ $(document).ready (function () {
id_field = $(value).attr('value');
$("select[name='fields_selected[]']").append($("<option></option>").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($("<option></option>").val(id_field).html('<i>' + field_name + '</i>'));
$("#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);
});

View File

@ -399,9 +399,8 @@ if (!is_metaconsole()) {
$text_module, false, true, '', array(), true, $id_agent_module);
}
$sources = events_get_all_source();
$table ->data[22][0] = '<b>' . __('Source') . '</b>';
$table ->data[22][1] = html_print_select ($sources, 'source', $source, '', '', '', true);
$table ->data[22][1] = html_print_input_text ('source', $source, '', 35, 255, true);
$table ->data[23][0] = '<b>' . __('Extra ID') . '</b>';
$table ->data[23][1] = html_print_input_text ('id_extra', $id_extra, '', 11, 255, true);

View File

@ -48,7 +48,7 @@ if ($create_profiles) {
// If the profile doesnt exist, we create it
if ($profile_data === false) {
db_pandora_audit("User management",
"Added profile for user ".io_safe_input($user));
"Added profile for user ".io_safe_output($user));
$return = profile_create_user_profile ($user, $profile, $group);
if ($return !== false) {
$n_added ++;

View File

@ -1,249 +0,0 @@
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2009 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation for version 2.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Load global vars
check_login ();
if (! check_acl ($config['id_user'], 0, "AW")) {
db_pandora_audit("ACL Violation",
"Trying to access massive tag addition");
require ("general/noaccess.php");
return;
}
require_once ('include/functions_agents.php');
require_once ('include/functions_tags.php');
function process_manage_add ($id_agents, $modules, $id_tags) {
if (empty ($id_agents) || $id_agents[0] == 0) {
ui_print_error_message(__('No agents selected'));
return false;
}
if (empty ($modules)) {
ui_print_error_message(__('No modules selected'));
return false;
}
if (empty ($id_tags)) {
ui_print_error_message(__('No tags selected'));
return false;
}
$modules_id = array();
foreach ($modules as $module) {
foreach ($id_agents as $id_agent) {
$module_id = modules_get_agentmodule_id($module, $id_agent);
$modules_id[] = $module_id['id_agente_modulo'];
}
}
if (count($modules) == 1 && $modules[0] == '0') {
foreach ($id_agents as $id_agent) {
$modules_temp = agents_get_modules($id_agent);
foreach ($modules_temp as $id_module => $name_module) {
$modules_id[] = $id_module;
}
}
}
$conttotal = 0;
$contsuccess = 0;
foreach ($modules_id as $id_module) {
$err_count = tags_insert_module_tag($id_module, $id_tags);
if ($err_count == 0) {
$contsuccess ++;
}
$conttotal ++;
}
if ($contsuccess > 0) {
db_pandora_audit("Massive management", "Add tags", false, false,
"");
}
else {
db_pandora_audit("Massive management", "Fail try to add tags",
false, false, "");
}
ui_print_result_message ($contsuccess > 0,
__('Successfully added') . "(" . $contsuccess . "/" . $conttotal . ")",
__('Could not be added'));
}
$id_agents = get_parameter ('id_agents');
$id_tags = get_parameter ('id_tags');
$modules = get_parameter ('module');
$add = (bool) get_parameter_post ('add');
if ($add) {
process_manage_add ($id_agents, $modules, $id_tags);
}
$groups = users_get_groups ();
$own_info = get_user_info($config['id_user']);
if (!$own_info['is_admin'] && !check_acl ($config['id_user'], 0, "AW"))
$return_all_group = false;
else
$return_all_group = true;
$table->id = 'add_table';
$table->width = '98%';
$table->data = array ();
$table->style = array ();
$table->style[0] = 'font-weight: bold; vertical-align:top';
$table->style[2] = 'font-weight: bold; vertical-align:top';
$table->size = array ();
$table->size[0] = '15%';
$table->size[1] = '40%';
$table->size[2] = '15%';
$table->size[3] = '40%';
$table->data = array ();
$table->data[0][0] = __('Group');
$table->data[0][1] = html_print_select_groups(false, "AW",
$return_all_group, 'id_group', 0, '', 'Select', -1, true, false,
true, '', false, 'width:180px;');
$table->data[1][0] = __('Agents');
$table->data[1][0] .= '<span id="agent_loading" class="invisible">';
$table->data[1][0] .= html_print_image('images/spinner.png', true);
$table->data[1][0] .= '</span>';
$agents = agents_get_group_agents(
array_keys(users_get_groups ($config["id_user"], "AW", false)));
$table->data[1][1] = html_print_select ($agents,
'id_agents[]', '', '', '', '', true, true, true, '', false, 'width:180px;');
$table->data[1][2] = __('Modules');
$table->data[1][2] .= '<span id="module_loading" class="invisible">';
$table->data[1][2] .= html_print_image('images/spinner.png', true);
$table->data[1][2] .= '</span>';
$table->data[1][3] = '<input type="hidden" id="modules_selection_mode" value="all" />' .
html_print_select (array(), 'module[]', '', false, '', '', true, true, false, '', false, 'width:180px;');
$table->data[2][0] = __('Tags');
$tags = tags_get_all_tags();
$table->data[2][1] = html_print_select ($tags,
'id_tags[]', '', '', '', '', true, true, true, '', false, 'width:180px;');
echo '<form method="post"
id="form_tags"
action="index.php?sec=gmassive&sec2=godmode/massive/massive_operations&option=add_tags">';
html_print_table ($table);
echo '<div class="action-buttons" style="width: '.$table->width.'" onsubmit="if (!confirm(\' '.__('Are you sure?').'\')) return false;">';
html_print_input_hidden ('add', 1);
html_print_submit_button (__('Add'), 'go', false, 'class="sub add"');
echo '</div>';
echo '</form>';
// TODO: Change to iu_print_error system
echo '<h3 class="error invisible" id="message"> </h3>';
//Hack to translate text "none" in PHP to javascript
echo '<span id ="none_text" style="display: none;">' . __('None') . '</span>';
ui_require_jquery_file ('form');
ui_require_jquery_file ('pandora.controls');
?>
<script type="text/javascript">
/* <![CDATA[ */
$(document).ready (function () {
$("#checkbox-recursion").click(function () {
$("#id_group").trigger("change");
});
$("#id_agents").change(agent_changed_by_multiple_agents);
$("#id_group").change (function () {
var $select = $("#id_agents").enable ();
$("#agent_loading").show ();
$("option", $select).remove ();
jQuery.post ("ajax.php",
{
"page" : "godmode/massive/massive_add_alerts",
"get_agents" : 1,
"id_group" : this.value,
"recursion" : $("#checkbox-recursion").is(":checked") ? 1 : 0,
// Add a key prefix to avoid auto sorting in js object conversion
"keys_prefix" : "_"
},
function (data, status) {
options = "";
jQuery.each (data, function (id, value) {
// Remove keys_prefix from the index
id = id.substring(1);
options += "<option value=\""+id+"\">"+value+"</option>";
});
$("#id_agents").append (options);
$("#agent_loading").hide ();
$select.enable ();
},
"json"
);
});
$("#id_group").value = "0";
$("#id_group").click (
function () {
$(this).css ("width", "auto");
});
$("#id_group").blur (function () {
$(this).css ("width", "180px");
});
$("#id_agents").click (
function () {
$(this).css ("width", "auto");
});
$("#id_agents").blur (function () {
$(this).css ("width", "180px");
});
$("#module").click (
function () {
$(this).css ("width", "auto");
});
$("#module").blur (function () {
$(this).css ("width", "180px");
});
$("#modules_selection_mode").change (function() {
$("#id_agents").trigger('change');
});
});
/* ]]> */
</script>

View File

@ -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;
@ -76,144 +78,18 @@ function process_manage_delete ($module_name, $id_agents, $module_status = 'all'
if (($module_name[0] == "0") and (is_array($module_name)) and (count($module_name) == 1))
$filter_for_module_deletion = false;
else
$filter_for_module_deletion = sprintf('nombre IN ("%s")', implode('","', $module_name));
$filter_for_module_deletion = sprintf('tagente_modulo.nombre IN ("%s")', implode('","', $module_name));
if ($config['dbtype'] == "oracle") {
$all_agent_modules = false;
if (($module_name[0] == "0") and (is_array($module_name)) and (count($module_name) == 1)) {
$all_agent_modules = true;
}
$names_to_long = array();
$i = 0;
foreach ($module_name as $name) {
if (strlen($name) > 30) {
$original_names[] = $module_name[$i];
unset($module_name[$i]);
$names_to_long[] = substr($name, 0, 28) . "%";
}
$i++;
}
$modules = "SELECT id_agente_modulo, nombre FROM tagente_modulo WHERE";
$modules .= sprintf(" id_agente IN (%s)", implode(",", $id_agents));
if (!empty($module_name) && (!$all_agent_modules)) {
$modules .= sprintf(" AND nombre IN ('%s')", implode("','", $module_name));
}
$modules = db_get_all_rows_sql($modules);
$modules2 = "";
if (!empty($names_to_long) && (!$all_agent_modules)) {
$modules2 = "SELECT id_agente_modulo, nombre FROM tagente_modulo WHERE";
$modules2 .= sprintf(" id_agente IN (%s) AND (", implode(",", $id_agents));
$j = 0;
foreach ($names_to_long as $name) {
if ($j == 0) {
$modules2 .= "nombre LIKE ('" . $name . "')";
}
else {
$modules2 .= " OR nombre LIKE ('" . $name . "')";
}
$j++;
}
$modules2 .= ")";
$modules2 = db_get_all_rows_sql($modules2);
$modules = array_merge($modules, $modules2);
}
$all_names = array();
foreach ($modules as $module) {
$all_modules[] = $module['id_agente_modulo'];
$all_names[] = $module['nombre'];
}
$modules = $all_modules;
$modules = array_unique($modules);
if (!empty($names_to_long) && (!$all_agent_modules)) {
$j = 0;
foreach ($all_names as $name) {
if (strlen($name) > 30) {
if (!in_array($name, $original_names)) {
unset($modules[$j]);
}
}
$j++;
}
}
}
else {
$modules = agents_get_modules ($id_agents, 'id_agente_modulo',
$filter_for_module_deletion, true);
}
$modules = agents_get_modules ($id_agents, 'id_agente_modulo',
$filter_for_module_deletion, true);
}
else {
if ($config['dbtype'] == "oracle") {
$all_agent_modules = false;
$names_to_long = array();
if (($module_name[0] == "0") and (is_array($module_name)) and (count($module_name) == 1)) {
$all_agent_modules = true;
}
$i = 0;
foreach ($module_name as $name) {
if (strlen($name) > 30) {
$original_names[] = $module_name[$i];
unset($module_name[$i]);
$names_to_long[] = substr($name, 0, 28) . "%";
}
$i++;
}
$modules = "SELECT id_agente_modulo, nombre FROM tagente_modulo WHERE";
$any_agent = false;
if ($id_agents == null) {
$any_agent = true;
}
if (!empty($id_agents)) {
$modules .= sprintf(" id_agente IN (%s)", implode(",", $id_agents));
$agents_selected = true;
}
if (!empty($module_name) && (!$all_agent_modules)) {
if ($any_agent) {
$modules .= sprintf(" nombre IN ('%s')", implode("','", $module_name));
}
else {
$modules .= sprintf(" AND nombre IN ('%s')", implode("','", $module_name));
}
}
$modules = db_get_all_rows_sql($modules);
if (!empty($names_to_long) && (!$all_agent_modules)) {
$modules2 = "SELECT id_agente_modulo, nombre FROM tagente_modulo WHERE";
$modules2 .= sprintf(" id_agente IN (%s) AND (", implode(",", $id_agents));
$j = 0;
foreach ($names_to_long as $name) {
if ($j == 0) {
$modules2 .= "nombre LIKE ('" . $name . "')";
}
else {
$modules2 .= " OR nombre LIKE ('" . $name . "')";
}
$j++;
}
$modules2 .= ")";
$modules2 = db_get_all_rows_sql($modules2);
$modules = array_merge($modules, $modules2);
}
$all_names = array();
foreach ($modules as $module) {
$all_modules[] = $module['id_agente_modulo'];
$all_names[] = $module['nombre'];
}
$modules = $all_modules;
$modules = array_unique($modules);
if (!empty($names_to_long) && (!$all_agent_modules)) {
$j = 0;
foreach ($all_names as $name) {
if (strlen($name) > 30) {
if (!in_array($name, $original_names)) {
unset($modules[$j]);
}
}
$j++;
}
}
}
else {
if ($status_module != -1) {
$modules = agents_get_modules ($id_agents, 'id_agente_modulo',
sprintf('nombre IN ("%s")', implode('","',$module_name)), true);
sprintf('tagente_modulo.nombre IN ("%s") AND tagente_modulo.id_agente_modulo IN (SELECT id_agente_modulo FROM tagente_estado where estado = %s OR utimestamp=0 )', implode('","',$module_name), $status_module), true);
} else {
$modules = agents_get_modules ($id_agents, 'id_agente_modulo',
'tagente_modulo.nombre IN ("' . implode('","',$module_name) . '")', true);
}
}
@ -232,12 +108,7 @@ function process_manage_delete ($module_name, $id_agents, $module_status = 'all'
}
$count_deleted_modules = count($modules);
if ($config['dbtype'] == "oracle") {
$success = db_process_sql(sprintf("DELETE FROM tagente_modulo WHERE id_agente_modulo IN (%s)", implode(",", $modules)));
}
else {
$success = modules_delete_agent_module ($modules);
}
$success = modules_delete_agent_module ($modules);
if (! $success) {
ui_print_error_message(
@ -254,8 +125,6 @@ function process_manage_delete ($module_name, $id_agents, $module_status = 'all'
}
$module_type = (int) get_parameter ('module_type');
$idGroupMassive = (int) get_parameter('id_group_massive');
$idAgentMassive = (int) get_parameter('id_agent_massive');
$group_select = get_parameter('groups_select');
$delete = (bool) get_parameter_post ('delete');
@ -277,9 +146,7 @@ if ($delete) {
$agents_ = array();
}
foreach ($agents_select as $agent_name) {
$agents_[] = agents_get_agent_id(io_safe_output($agent_name));
}
$agents_ = $agents_select;
$modules_ = $module_name;
break;
case 'agents':
@ -362,35 +229,18 @@ $groups = users_get_groups ();
$agents = agents_get_group_agents (array_keys (users_get_groups ()),
false, "none");
switch ($config["dbtype"]) {
case "mysql":
$module_types = db_get_all_rows_filter ('tagente_modulo,ttipo_modulo',
array ('tagente_modulo.id_tipo_modulo = ttipo_modulo.id_tipo',
'id_agente' => array_keys ($agents),
'disabled' => 0,
'order' => 'ttipo_modulo.nombre'),
array ('DISTINCT(id_tipo)',
'CONCAT(ttipo_modulo.descripcion," (",ttipo_modulo.nombre,")") AS description'));
break;
case "oracle":
$module_types = db_get_all_rows_filter ('tagente_modulo,ttipo_modulo',
array ('tagente_modulo.id_tipo_modulo = ttipo_modulo.id_tipo',
'id_agente' => array_keys ($agents),
'disabled' => 0,
'order' => 'ttipo_modulo.nombre'),
array ('ttipo_modulo.id_tipo',
'ttipo_modulo.descripcion || \' (\' || ttipo_modulo.nombre || \')\' AS description'));
break;
case "postgresql":
$module_types = db_get_all_rows_filter ('tagente_modulo,ttipo_modulo',
array ('tagente_modulo.id_tipo_modulo = ttipo_modulo.id_tipo',
'id_agente' => array_keys ($agents),
'disabled' => 0,
'order' => 'description'),
array ('DISTINCT(id_tipo)',
'ttipo_modulo.descripcion || \' (\' || ttipo_modulo.nombre || \')\' AS description'));
break;
}
$module_types = db_get_all_rows_filter (
'tagente_modulo,ttipo_modulo',
array (
'tagente_modulo.id_tipo_modulo = ttipo_modulo.id_tipo',
'id_agente' => array_keys ($agents),
'disabled' => 0,
'order' => 'ttipo_modulo.nombre'
), array (
'DISTINCT(id_tipo)',
'CONCAT(ttipo_modulo.descripcion," (",ttipo_modulo.nombre,")") AS description'
)
);
if ($module_types === false)
$module_types = array ();
@ -406,16 +256,12 @@ $table->data = array ();
$table->style[0] = 'font-weight: bold';
$table->style[2] = 'font-weight: bold';
$table->data['selection_mode'][0] = __('Selection mode');
$table->data['selection_mode'][1] = '<span style="width:110px;display:inline-block;">'.__('Select modules first ') . '</span>' .
html_print_radio_button_extended ("selection_mode", 'modules', '', $selection_mode, false, '', 'style="margin-right: 40px;"', true).'<br>';
$table->data['selection_mode'][1] .= '<span style="width:110px;display:inline-block;">'.__('Select agents first ') . '</span>' .
html_print_radio_button_extended ("selection_mode", 'agents', '', $selection_mode, false, '', 'style="margin-right: 40px;"', true);
$table->rowclass['form_modules_1'] = 'select_modules_row';
$table->data['form_modules_1'][0] = __('Module type');
$table->data['form_modules_1'][0] .= '<span id="module_loading" class="invisible">';
@ -430,8 +276,6 @@ $table->data['form_modules_1'][3] = __('Select all modules of this type') . ' '
html_print_checkbox_extended("force_type", 'type', '', '', false,
'', 'style="margin-right: 40px;"', true);
$modules = array ();
if ($module_type != '') {
$filter = array ('id_tipo_modulo' => $module_type);
@ -439,9 +283,8 @@ if ($module_type != '') {
else {
$filter = false;
}
$names = agents_get_modules (array_keys ($agents),
'DISTINCT(nombre)', $filter, false);
'DISTINCT(tagente_modulo.nombre)', $filter, false);
foreach ($names as $name) {
$modules[$name['nombre']] = $name['nombre'];
}

View File

@ -1,305 +0,0 @@
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2009 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation for version 2.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Load global vars
check_login ();
if (! check_acl ($config['id_user'], 0, "AW")) {
db_pandora_audit("ACL Violation",
"Trying to access massive tag deletion");
require ("general/noaccess.php");
return;
}
require_once ('include/functions_agents.php');
require_once ('include/functions_tags.php');
if (is_ajax ()) {
$get_agents = (bool)get_parameter('get_agents', false);
$get_modules = (bool)get_parameter('get_modules', false);
if ($get_agents) {
$id_tag = (int)get_parameter('id_tag', 0);
$agents = tags_get_agents($id_tag);
if (!empty($agents)) {
$temp = array();
foreach ($agents as $id_agent) {
$temp[$id_agent] = agents_get_name($id_agent);
}
$agents = $temp;
}
echo json_encode($agents);
return;
}
if ($get_modules) {
$id_tag = (int)get_parameter('id_tag', 0);
$id_agents = (array)get_parameter('id_agents', array());
if (!empty($id_agents)) {
foreach ($id_agents as $key => $id) {
$id_agents[$key] = (int)$id;
}
$data = db_get_all_rows_sql("
SELECT nombre
FROM tagente_modulo
WHERE id_agente IN (" . implode(',', $id_agents) . ")
AND id_agente_modulo IN (
SELECT t1.id_agente_modulo
FROM ttag_module t1
WHERE id_tag = " . $id_tag . "
AND id_policy_module = 0)
GROUP BY nombre;");
if (empty($data)) {
echo json_encode(array());
}
else {
$modules = array();
foreach ($data as $row) {
$modules[] = $row['nombre'];
}
echo json_encode($modules);
}
}
else {
echo json_encode(array());
}
return;
}
return;
}
function process_manage_delete ($id_agents, $modules, $id_tag) {
if (empty ($id_agents) || $id_agents[0] == 0) {
ui_print_error_message(__('No agents selected'));
return false;
}
if (empty ($modules) || $modules[0] == "0") {
ui_print_error_message(__('No modules selected'));
return false;
}
if (empty ($id_tag)) {
ui_print_error_message(__('No tag selected'));
return false;
}
$modules_id = array();
foreach ($modules as $module) {
$data = db_get_all_rows_sql("
SELECT id_agente_modulo
FROM tagente_modulo
WHERE nombre = '" . $module . "'
AND id_agente IN (" . implode(",", $id_agents) . ")
");
if (empty($data)) {
$data = array();
}
foreach ($data as $row) {
$modules_id[$row['id_agente_modulo']] = $row['id_agente_modulo'];
}
}
$conttotal = 0;
$contsuccess = 0;
foreach ($modules_id as $id_module) {
$success = tags_remove_tag($id_tag, $id_module);
if ($success) {
$contsuccess ++;
}
$conttotal ++;
}
if ($contsuccess > 0) {
db_pandora_audit("Massive management", "Delete tags", false, false,
"");
}
else {
db_pandora_audit("Massive management", "Fail try to delete tags",
false, false, "");
}
ui_print_result_message ($contsuccess > 0,
__('Successfully deleted') . "(" . $contsuccess . "/" . $conttotal . ")",
__('Could not be deleted'));
}
$id_agents = get_parameter ('id_agents');
$id_tag = (int)get_parameter ('id_tag');
$modules = get_parameter ('modules');
$delete = (bool) get_parameter_post ('delete');
if ($delete) {
process_manage_delete ($id_agents, $modules, $id_tag);
}
$groups = users_get_groups ();
$own_info = get_user_info($config['id_user']);
if (!$own_info['is_admin'] && !check_acl ($config['id_user'], 0, "AW"))
$return_all_group = false;
else
$return_all_group = true;
$table->id = 'add_table';
$table->width = '98%';
$table->data = array ();
$table->style = array ();
$table->style[0] = 'font-weight: bold; vertical-align:top';
$table->style[2] = 'font-weight: bold; vertical-align:top';
$table->size = array ();
$table->size[0] = '15%';
$table->size[1] = '40%';
$table->size[2] = '15%';
$table->size[3] = '40%';
$table->data = array ();
$table->data[0][0] = __('Tags');
$tags = tags_get_all_tags();
$table->data[0][1] = html_print_select ($tags,
'id_tag', '', '', '', '', true, false, true, '', false, 'min-width:180px;');
$table->data[1][0] = __('Agents');
$table->data[1][0] .= '<span id="agent_loading" class="invisible">';
$table->data[1][0] .= html_print_image('images/spinner.png', true);
$table->data[1][0] .= '</span>';
$table->data[1][1] = html_print_select (array(),
'id_agents[]', '', '', '', '', true, true, true, '', false, 'min-width:180px;');
$table->data[2][0] = __('Modules');
$table->data[2][0] .= '<span id="modules_loading" class="invisible">';
$table->data[2][0] .= html_print_image('images/spinner.png', true);
$table->data[2][0] .= '</span>';
$table->data[2][1] = '<input type="hidden" id="modules_selection_mode" value="all" />' .
html_print_select (array(), 'modules[]', '', false, '', '', true, true, false, '', false, 'min-width:180px;');
echo '<form method="post"
id="form_tags"
action="index.php?sec=gmassive&sec2=godmode/massive/massive_operations&option=delete_tags">';
html_print_table ($table);
echo '<div class="action-buttons" style="width: '.$table->width.'" onsubmit="if (!confirm(\' '.__('Are you sure?').'\')) return false;">';
html_print_input_hidden ('delete', 1);
html_print_submit_button (__('Delete'), 'go', false, 'class="sub delete"');
echo '</div>';
echo '</form>';
// TODO: Change to iu_print_error system
echo '<h3 class="error invisible" id="message"> </h3>';
//Hack to translate text "none" in PHP to javascript
echo '<span id ="none_text" style="display: none;">' . __('None') . '</span>';
ui_require_jquery_file ('form');
ui_require_jquery_file ('pandora.controls');
?>
<script type="text/javascript">
/* <![CDATA[ */
$(document).ready (function () {
$("#id_tag").change(function() {
$("#agent_loading").show();
jQuery.post ("ajax.php",
{
"page" : "godmode/massive/massive_delete_tags",
"get_agents" : 1,
"id_tag" : this.value,
},
function (data, status) {
$("#id_agents").empty();
options = "";
jQuery.each (data, function (id, value) {
options += "<option value=\""+id+"\">"+value+"</option>";
});
if (options == "") {
$("#id_agents").append(
"<option value=\"0\"><?php echo __('None');?></option>");
}
else {
$("#id_agents").append (options);
}
$("#agent_loading").hide ();
$("#id_agents").trigger('change');
},
"json"
);
});
//~ $("#id_agents").change(agent_changed_by_multiple_agents);
$("#id_agents").change(function() {
//Fill modules
$("#modules_loading").show();
jQuery.post ("ajax.php",
{
"page" : "godmode/massive/massive_delete_tags",
"get_modules" : 1,
"id_tag": $("#id_tag").val(),
"id_agents[]" : $("#id_agents").val(),
},
function (data, status) {
$("#modules").empty();
options = "";
jQuery.each (data, function (id, value) {
options += "<option value=\""+value+"\">"+value+"</option>";
});
if (options == "") {
$("#modules").append(
"<option value=\"0\"><?php echo __('None');?></option>");
}
else {
$("#modules").append (options);
}
$("#modules_loading").hide ();
},
"json"
);
});
$("#id_tag").trigger('change');
});
/* ]]> */
</script>

View File

@ -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
@ -327,6 +338,7 @@ $agents = agents_get_group_agents (array_keys ($groups));
$modules = db_get_all_rows_sql("SELECT id_agente_modulo as id_module, nombre as name FROM tagente_modulo
WHERE id_agente = " . $id_parent);
if ($modules === false) $modules = array();
$modules_values = array();
$modules_values[0] = __('Any');
@ -421,7 +433,9 @@ $table->data[1][1] .= __('Autodisable mode').' '.html_print_radio_button_extende
// Status (Disabled / Enabled)
$table->data[2][0] = __('Status');
$table->data[2][1] = __('No change').' '.html_print_radio_button_extended ("disabled", -1, '', $disabled, false, '', 'style="margin-right: 40px;"', true);
$table->data[2][1] .= __('Disabled').' '.html_print_radio_button_extended ("disabled", 1, '', $disabled, false, '', 'style="margin-right: 40px;"', true);
$table->data[2][1] .= __('Disabled') . ' ' .
ui_print_help_tip(__('If the remote configuration is enabled, it will also go into standby mode when disabling it.'), true) . ' ' .
html_print_radio_button_extended ("disabled", 1, '', $disabled, false, '', 'style="margin-right: 40px;"', true);
$table->data[2][1] .= __('Active').' '.html_print_radio_button_extended ("disabled", 0, '', $disabled, false, '', 'style="margin-right: 40px;"', true);
// Remote configuration

View File

@ -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;
@ -278,7 +282,7 @@ else {
}
$names = agents_get_modules (array_keys ($agents),
'DISTINCT(nombre)', $filter, false);
'DISTINCT(tagente_modulo.nombre)', $filter, false);
foreach ($names as $name) {
$modules[$name['nombre']] = $name['nombre'];
}
@ -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;

View File

@ -34,7 +34,7 @@ push_table_row ($data, 'plugin_1');
$data = array ();
$data[0] = 'macro_desc';
$data[0] .= ui_print_help_tip ('macro_help', true);
$data[1] = html_print_input_text ('macro_name', 'macro_value', '', 100, 255, true);
$data[1] = html_print_input_text ('macro_name', 'macro_value', '', 100, 1024, true);
$table->colspan['macro_field'][1] = 3;
$table->rowstyle['macro_field'] = 'display:none';
@ -51,9 +51,9 @@ if (!empty($macros)) {
$data[0] .= ui_print_help_tip ($m['help'], true);
}
if ($m['hide'] == 1) {
$data[1] = html_print_input_text($m['macro'], $m['value'], '', 15, 60, true);
$data[1] = html_print_input_text($m['macro'], $m['value'], '', 100, 1024, true);
} else {
$data[1] = html_print_input_text($m['macro'], io_output_password($m['value']), '', 15, 60, true);
$data[1] = html_print_input_text($m['macro'], io_output_password($m['value']), '', 100, 1024, true);
}
$table->colspan['macro'.$m['macro']][1] = 3;
$table->rowclass['macro'.$m['macro']] = 'macro_field';

View File

@ -66,7 +66,6 @@ if ($enterpriseEnable) {
}
$subsection = reporting_enterprise_add_graph_template_subsection('', $buttons);
reporting_enterprise_select_graph_template_tab();
$buttons['graph_container'] = array('active' => true,
'text' => '<a href="index.php?sec=reporting&sec2=godmode/reporting/graph_container">' .

View File

@ -2075,9 +2075,9 @@ else {
$buttons = null;
$buttons = array(
'main' => array('active' => true,
'text' => '<a href="index.php?sec=reporting&sec2=godmode/reporting/reporting_builder&tab=main&action=new&pure=' .$pure.'">' .
html_print_image("images/op_reporting.png", true, array ("title" => __('Main data'))) .'</a>'));
$textReportName = '';
'text' => '<a href="index.php?sec=reporting&sec2=godmode/reporting/reporting_builder&pure=' .$pure.'">' .
html_print_image("images/report_list.png", true, array ("title" => __('Reports list'))) .'</a>'));
$textReportName = __('Create Custom Report');
}
// Page header for metaconsole

View File

@ -870,6 +870,7 @@ function readFields() {
values['time_format'] = $("select[name=time_format]").val();
values['timezone'] = $("select[name=timezone]").val();
values['clock_animation'] = $("select[name=clock_animation]").val();
values['show_last_value'] = $("select[name=last_value]").val();
if (is_metaconsole()) {
values['metaconsole'] = 1;
@ -1380,7 +1381,6 @@ function loadFieldsFromDB(item) {
}
});
parameter = Array();
parameter.push ({name: "page",
value: "include/ajax/visual_console_builder.ajax"});
@ -1459,26 +1459,26 @@ function loadFieldsFromDB(item) {
$("select[name=type_graph]").val(val);
}
if (key == 'label_position') {
if($("#hidden-metaconsole").val() == 1){
$('#labelposup'+" img").attr('src','../../images/label_up.png');
$('#labelposdown'+" img").attr('src','../../images/label_down.png');
$('#labelposleft'+" img").attr('src','../../images/label_left.png');
$('#labelposright'+" img").attr('src','../../images/label_right.png');
$('.labelpos').attr('sel','no');
$('#labelpos'+val+" img").attr('src','../../images/label_'+$('#labelpos'+val).attr('id').replace('labelpos','')+'_2.png');
$('#labelpos'+val).attr('sel','yes');
}
else{
$('#labelposup'+" img").attr('src','images/label_up.png');
$('#labelposdown'+" img").attr('src','images/label_down.png');
$('#labelposleft'+" img").attr('src','images/label_left.png');
$('#labelposright'+" img").attr('src','images/label_right.png');
$('.labelpos').attr('sel','no');
$('#labelpos'+val+" img").attr('src','images/label_'+$('#labelpos'+val).attr('id').replace('labelpos','')+'_2.png');
$('#labelpos'+val).attr('sel','yes');
}
if (key == 'label_position') {
if($("#hidden-metaconsole").val() == 1){
$('#labelposup'+" img").attr('src','../../images/label_up.png');
$('#labelposdown'+" img").attr('src','../../images/label_down.png');
$('#labelposleft'+" img").attr('src','../../images/label_left.png');
$('#labelposright'+" img").attr('src','../../images/label_right.png');
$('.labelpos').attr('sel','no');
$('#labelpos'+val+" img").attr('src','../../images/label_'+$('#labelpos'+val).attr('id').replace('labelpos','')+'_2.png');
$('#labelpos'+val).attr('sel','yes');
}
else{
$('#labelposup'+" img").attr('src','images/label_up.png');
$('#labelposdown'+" img").attr('src','images/label_down.png');
$('#labelposleft'+" img").attr('src','images/label_left.png');
$('#labelposright'+" img").attr('src','images/label_right.png');
$('.labelpos').attr('sel','no');
$('#labelpos'+val+" img").attr('src','images/label_'+$('#labelpos'+val).attr('id').replace('labelpos','')+'_2.png');
$('#labelpos'+val).attr('sel','yes');
}
}
if (key == 'image') {
//Load image preview
@ -1544,13 +1544,14 @@ function loadFieldsFromDB(item) {
if (key == 'linked_layout_status_type')
$("select[name=linked_map_status_calculation_type]").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 (val != 0) {
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')
@ -1590,6 +1591,10 @@ function loadFieldsFromDB(item) {
.css('background-color', val);
}
if (key == 'show_last_value') {
$("select[name=last_value]").val(val);
}
if (key == 'clock_animation')
$("select[name=clock_animation]").val(val);
if (key == 'time_format')
@ -1852,6 +1857,9 @@ function hiddenFields(item) {
$("#percentile_bar_row_2").css('display', 'none');
$("#percentile_bar_row_2." + item).css('display', '');
$("#show_last_value_row").css('display', 'none');
$("#show_last_value_row." + item).css('display', '');
$("#percentile_item_row_3").css('display', 'none');
$("#percentile_item_row_3." + item).css('display', '');

View File

@ -420,9 +420,11 @@ foreach ($layoutDatas as $layoutData) {
}
else {
if ($layoutData['id_agent'] != 0) {
$modules = agents_meta_get_modules(
$layoutData['id_metaconsole'],
$layoutData['id_agent']);
$server = db_get_row('tmetaconsole_setup', 'id', $layoutData['id_metaconsole']);
if (metaconsole_connect($server) == NOERR) {
$modules = agents_get_modules($layoutData['id_agent']);
metaconsole_restore_db();
}
}
}

View File

@ -560,7 +560,6 @@ switch ($activeTab) {
foreach ($name_modules as $mod) {
foreach ($id_agents as $ag) {
$id_module = agents_get_modules($ag,
array('id_agente_modulo'),
array('nombre' => $mod));

View File

@ -253,7 +253,7 @@ if ($create_user) {
db_pandora_audit("User management",
"Created user ".io_safe_input($id), false, false, $info);
"Created user ".io_safe_output($id), false, false, $info);
ui_print_result_message ($result,
__('Successfully created'),
@ -405,7 +405,7 @@ if ($update_user) {
}
db_pandora_audit("User management", "Updated user ".io_safe_input($id),
db_pandora_audit("User management", "Updated user ".io_safe_output($id),
false, false, $info);
ui_print_result_message ($res1,
@ -463,7 +463,7 @@ if ($add_profile) {
$tags = implode(',', $tags);
db_pandora_audit("User management",
"Added profile for user ".io_safe_input($id2), false, false, 'Profile: ' . $profile2 . ' Group: ' . $group2 . ' Tags: ' . $tags);
"Added profile for user ".io_safe_output($id2), false, false, 'Profile: ' . $profile2 . ' Group: ' . $group2 . ' Tags: ' . $tags);
$return = profile_create_user_profile($id2, $profile2, $group2, false, $tags, $no_hierarchy);
ui_print_result_message ($return,
__('Profile added successfully'),
@ -479,7 +479,7 @@ if ($delete_profile) {
$perfil = db_get_row('tperfil', 'id_perfil', $id_perfil);
db_pandora_audit("User management",
"Deleted profile for user ".io_safe_input($id2), false, false, 'The profile with id ' . $id_perfil . ' in the group ' . $perfilUser['id_grupo']);
"Deleted profile for user ".io_safe_output($id2), false, false, 'The profile with id ' . $id_perfil . ' in the group ' . $perfilUser['id_grupo']);
$return = profile_delete_user_profile ($id2, $id_up);
ui_print_result_message ($return,

Binary file not shown.

After

Width:  |  Height:  |  Size: 440 B

View File

@ -555,7 +555,7 @@ if ($table_events) {
// Fix: for tag functionality groups have to be all user_groups (propagate ACL funct!)
$groups = users_get_groups($config["id_user"]);
$tags_condition = tags_get_acl_tags($config['id_user'],
array_keys($groups), 'ER', 'event_condition', 'AND');
echo '<div id="div_all_events_24h">';

View File

@ -74,9 +74,9 @@ if ($search_modules) {
$id_agents = json_decode(io_safe_output(get_parameter('id_agents')));
$filter = '%' . get_parameter('q', '') . '%';
$other_filter = json_decode(io_safe_output(get_parameter('other_filter')), true);
// TODO TAGS agents_get_modules
$modules = agents_get_modules($id_agents, false,
(array('nombre' => $filter) + $other_filter));
(array('tagente_modulo.nombre' => $filter) + $other_filter));
if ($modules === false) $modules = array();
@ -550,10 +550,18 @@ if ($list_modules) {
// Fix: for tag functionality groups have to be all user_groups (propagate ACL funct!)
$groups = users_get_groups($config["id_user"], $access);
if($cluster_list != 1){
$tags_sql = tags_get_acl_tags($config['id_user'],
array_keys($groups), $access, 'module_condition', 'AND',
'tagente_modulo', false, array(), true);
$tags_join = "";
$tags_sql = "";
if($cluster_list != 1) {
$tags = tags_get_user_applied_agent_tags ($id_agent, $access);
if ($tags === false) {
$tags_sql = " AND 1=0";
}
elseif (is_array($tags)) {
$tags_sql = " AND ttag_module.id_tag IN (" . implode(',', $tags) . ")";
$tags_join = "LEFT JOIN ttag_module
ON ttag_module.id_agente_modulo = tagente_modulo.id_agente_modulo";
}
}
$status_filter_monitor = (int)get_parameter('status_filter_monitor', -1);
@ -571,10 +579,10 @@ if ($list_modules) {
}
if ($status_module_group != -1) {
$status_module_group_filter = 'id_module_group = ' . $status_module_group;
$status_module_group_filter = 'tagente_modulo.id_module_group = ' . $status_module_group;
}
else {
$status_module_group_filter = 'id_module_group >= 0';
$status_module_group_filter = 'tagente_modulo.id_module_group >= 0';
}
$status_text_monitor_sql = '%';
@ -590,66 +598,22 @@ if ($list_modules) {
}
//Count monitors/modules
switch ($config["dbtype"]) {
case "mysql":
$sql = sprintf("
SELECT COUNT(*)
FROM tagente_estado,
(SELECT *
FROM tagente_modulo
WHERE id_agente = %d AND nombre LIKE \"%s\" AND delete_pending = 0
AND disabled = 0 AND %s) tagente_modulo
LEFT JOIN tmodule_group
ON tagente_modulo.id_module_group = tmodule_group.id_mg
WHERE tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo
AND %s %s
AND tagente_estado.estado != %d
AND tagente_modulo.%s
ORDER BY tagente_modulo.id_module_group , %s %s",
$id_agente, $status_text_monitor_sql,$status_module_group_filter,$status_filter_sql, $tags_sql, $monitor_filter,
$status_module_group_filter, $order['field'], $order['order']);
break;
case "postgresql":
$sql = sprintf("
SELECT COUNT(DISTINCT tagente_modulo.id_module_group)
FROM tagente_estado,
(SELECT *
FROM tagente_modulo
WHERE id_agente = %d AND nombre LIKE '%s'
AND delete_pending = 0
AND disabled = 0 AND %s) tagente_modulo
LEFT JOIN tmodule_group
ON tagente_modulo.id_module_group = tmodule_group.id_mg
WHERE tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo
AND %s %s
AND tagente_estado.estado != %d
AND tagente_modulo.%s
GROUP BY tagente_modulo.id_module_group,
tagente_modulo.nombre
ORDER BY tagente_modulo.id_module_group , %s %s",
$id_agente, $status_text_monitor_sql,$status_module_group_filter,$status_filter_sql,
$tags_sql, $monitor_filter,$status_module_group_filter,$order['field'],
$order['order']);
break;
case "oracle":
$sql = sprintf ("
SELECT COUNT(*)" .
" FROM tagente_estado, tagente_modulo
LEFT JOIN tmodule_group
ON tmodule_group.id_mg = tagente_modulo.id_module_group
WHERE tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo
AND tagente_modulo.id_agente = %d
AND tagente_modulo.nombre LIKE '%s'
AND %s %s
AND tagente_modulo.delete_pending = 0
AND tagente_modulo.disabled = 0
AND tagente_estado.estado != %d
AND tagente_modulo.%s
ORDER BY tagente_modulo.id_module_group , %s %s
", $id_agente, $status_text_monitor_sql, $status_filter_sql, $tags_sql, $monitor_filter,
$status_module_group_filter,$order['field'], $order['order']);
break;
}
$order_sql = $order['field'] . " " . $order['order'];
$sql = "SELECT COUNT(*)
FROM tagente_modulo
$tags_join
INNER JOIN tagente_estado
ON tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo
LEFT JOIN tmodule_group
ON tagente_modulo.id_module_group = tmodule_group.id_mg
WHERE tagente_modulo.id_agente = $id_agente
AND nombre LIKE '$status_text_monitor_sql'
AND delete_pending = 0
AND $status_filter_sql
$tags_sql
AND tagente_estado.estado != $monitor_filter
GROUP BY tagente_modulo.id_agente_modulo
";
$count_modules = db_get_all_rows_sql($sql);
if (isset($count_modules[0]))
@ -659,68 +623,22 @@ if ($list_modules) {
//Get monitors/modules
// Get all module from agent
switch ($config["dbtype"]) {
case "mysql":
$sql = sprintf("
SELECT *
FROM tagente_estado,
(SELECT *
FROM tagente_modulo
WHERE id_agente = %d AND nombre LIKE \"%s\" AND delete_pending = 0
AND disabled = 0 AND %s) tagente_modulo
LEFT JOIN tmodule_group
ON tagente_modulo.id_module_group = tmodule_group.id_mg
WHERE tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo
AND %s %s
AND tagente_estado.estado != %d
AND tagente_modulo.%s
ORDER BY tmodule_group.name , %s %s",
$id_agente, $status_text_monitor_sql,$status_module_group_filter,$status_filter_sql, $tags_sql, $monitor_filter,
$status_module_group_filter, $order['field'], $order['order']);
break;
case "postgresql":
$sql = sprintf("
SELECT *
FROM tagente_estado,
(SELECT *
FROM tagente_modulo
WHERE id_agente = %d AND nombre LIKE '%s' AND delete_pending = 0
AND disabled = 0 AND %s) tagente_modulo
LEFT JOIN tmodule_group
ON tagente_modulo.id_module_group = tmodule_group.id_mg
WHERE tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo
AND %s %s
AND tagente_estado.estado != %d
AND tagente_modulo.%s
ORDER BY tmodule_group.name , %s %s",
$id_agente, $status_text_monitor_sql,$status_module_group_filter,$status_filter_sql, $tags_sql, $monitor_filter,
$status_module_group_filter, $order['field'], $order['order']);
break;
// If Dbms is Oracle then field_list in sql statement has to be recoded. See oracle_list_all_field_table()
case "oracle":
$fields_tagente_estado = oracle_list_all_field_table('tagente_estado', 'string');
$fields_tagente_modulo = oracle_list_all_field_table('tagente_modulo', 'string');
$fields_tmodule_group = oracle_list_all_field_table('tmodule_group', 'string');
$sql = sprintf ("
SELECT " . $fields_tagente_estado . ', ' . $fields_tagente_modulo . ', ' . $fields_tmodule_group .
" FROM tagente_estado, tagente_modulo
LEFT JOIN tmodule_group
ON tmodule_group.id_mg = tagente_modulo.id_module_group
WHERE tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo
AND tagente_modulo.id_agente = %d
AND tagente_modulo.nombre LIKE '%s'
AND %s %s
AND tagente_modulo.delete_pending = 0
AND tagente_modulo.disabled = 0
AND tagente_estado.estado != %d
AND tagente_modulo.%s
ORDER BY tmodule_group.name , %s %s
", $id_agente, $status_text_monitor_sql, $tags_sql, $status_filter_sql, $monitor_filter,
$status_module_group_filter, $order['field'], $order['order']);
break;
}
$sql = "SELECT tagente_estado.*, tagente_modulo.*, tmodule_group.*
FROM tagente_modulo
$tags_join
INNER JOIN tagente_estado
ON tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo
LEFT JOIN tmodule_group
ON tagente_modulo.id_module_group = tmodule_group.id_mg
WHERE tagente_modulo.id_agente = $id_agente
AND nombre LIKE '$status_text_monitor_sql'
AND delete_pending = 0
AND $status_filter_sql
$tags_sql
AND tagente_estado.estado != $monitor_filter
GROUP BY tagente_modulo.id_agente_modulo
ORDER BY tmodule_group.name, $order_sql
";
if ($monitors_change_filter) {
$limit = " LIMIT " . $config['block_size'] . " OFFSET 0";

View File

@ -164,6 +164,8 @@ $clock_animation = get_parameter('clock_animation', 'analogic_1');
$time_format = get_parameter('time_format', 'time');
$timezone = get_parameter('timezone', 'Europe/Madrid');
$show_last_value = get_parameter('show_last_value', null);
switch ($action) {
case 'get_font':
$return = array();
@ -785,6 +787,9 @@ switch ($action) {
if ($height !== null) {
$values['height'] = $height;
}
if ($show_last_value !== null) {
$values['show_last_value'] = $show_last_value;
}
break;
case 'simple_value':
if ($action == 'update') {
@ -988,7 +993,6 @@ switch ($action) {
if (isset($elementFields["linked_layout_status_as_service_warning"])) {
$elementFields["linked_layout_status_as_service_warning"] = (float) $elementFields["linked_layout_status_as_service_warning"];
}
switch ($type) {
case 'auto_sla_graph':
$elementFields['event_max_time_row'] = $elementFields['period'];
@ -1054,7 +1058,7 @@ switch ($action) {
$elementFields['id_agent'], false,
array('disabled' => 0,
'id_agente' => $elementFields['id_agent'],
'tagente_modulo.id_tipo_modulo IN' => "(17,23,3,10,33)"));
'tagente_modulo.id_tipo_modulo IN' => "(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,18,17,23,3,10,33)"));
$elementFields['modules_html'] = '<option value="0">--</option>';
foreach ($modules as $id => $name) {
@ -1281,6 +1285,7 @@ switch ($action) {
$values['image'] = $image;
$values['width'] = $width;
$values['height'] = $height;
$values['show_last_value'] = $show_last_value;
break;
case 'group_item':
$values['type'] = GROUP_ITEM;

View File

@ -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;

View File

@ -28,7 +28,6 @@ class Tree {
protected $userGroups;
protected $userGroupsArray;
protected $acltags = false;
protected $access = false;
protected $L1fieldName = '';
@ -69,8 +68,6 @@ class Tree {
enterprise_include_once("include/functions_agents.php");
if (is_metaconsole()) enterprise_include_once("meta/include/functions_ui_meta.php");
$this->acltags = tags_get_user_groups_and_tags($config['id_user'], $this->access);
}
public function setFilter($filter) {
@ -93,12 +90,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']."%%')";
}
@ -205,26 +202,19 @@ class Tree {
return "AND ta.$field_filter > 0" . $show_init_condition;
}
// FIXME: Separate and condition from inner join
protected function getTagJoin () {
// $parent is the agent id
$group_id = (int) db_get_value('id_grupo', 'tagente', 'id_agente', $this->id);
$tag_join = '';
if (empty($group_id)) {
// ACL error, this will restrict the module search
$tag_join = 'INNER JOIN ttag_module tta
ON 1=0';
}
else if (!empty($this->acltags) && isset($this->acltags[$group_id])) {
$tags_str = $this->acltags[$group_id];
return 'INNER JOIN ttag_module ttm
ON tam.id_agente_modulo = ttm.id_agente_modulo';
}
if (!empty($tags_str)) {
$tag_join = sprintf('INNER JOIN ttag_module ttm
ON tam.id_agente_modulo = ttm.id_agente_modulo
AND ttm.id_tag IN (%s)', $tags_str);
}
}
return $tag_join;
protected function getTagCondition () {
$tags = tags_get_user_applied_agent_tags($this->id, "AR");
// All tags permision, returns no condition
if ($tags === true) return "";
// No permision, do not show anything
if ($tags === false) return " AND 1=0";
$tags_sql = implode(',', $tags);
return "AND ttm.id_tag IN ($tags_sql)";;
}
protected function getModuleStatusFilterFromTestado ($state = false, $without_ands = false) {
@ -268,7 +258,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) {
@ -900,7 +890,8 @@ class Tree {
$module_search_filter = $this->getModuleSearchFilter();
$module_status_filter = $this->getModuleStatusFilterFromTestado();
$agent_filter = "AND ta.id_agente = " . $this->id;
$tag_join = $this->getTagJoin();
$tag_condition = $this->getTagCondition();
$tag_join = empty($tag_condition) ? '' : $this->getTagJoin();
$condition = $this->L2condition;
$inner = $this->L2inner;
@ -909,9 +900,6 @@ class Tree {
tam.id_tipo_modulo, tam.id_modulo, tae.estado, tae.datos,
tam.parent_module_id AS parent, tatm.id AS alerts';
// has any of this tags.
$tag_join = '';
$sql = "SELECT $columns
FROM tagente_modulo tam
$tag_join
@ -932,6 +920,7 @@ class Tree {
$agent_status_filter
$module_status_filter
$module_search_filter
$tag_condition
ORDER BY tam.nombre ASC, tam.id_agente_modulo ASC";
return $sql;
}

View File

@ -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.

View File

@ -48,6 +48,14 @@ class TreeTag extends Tree {
$this->getThirdLevel();
}
}
protected function getTagJoin () {
return '';
}
protected function getTagCondition () {
return '';
}
}
?>

View File

@ -22,7 +22,7 @@
/**
* Pandora build version and version
*/
$build_version = 'PC180918';
$build_version = 'PC181016';
$pandora_version = 'v7.0NG.727';
// Do not overwrite default timezone set if defined.

View File

@ -336,32 +336,39 @@ function agents_get_agents ($filter = false, $fields = false,
if (isset($filter['status'])) {
switch ($filter['status']) {
case AGENT_STATUS_NORMAL:
$status_sql =
"normal_count = total_count
AND notinit_count <> total_count";
$status_sql = "(
critical_count = 0
AND warning_count = 0
AND unknown_count = 0
AND normal_count > 0)";
break;
case AGENT_STATUS_WARNING:
$status_sql =
"critical_count = 0 AND warning_count > 0";
$status_sql = "(
critical_count = 0
AND warning_count > 0
AND total_count > 0)";
break;
case AGENT_STATUS_CRITICAL:
$status_sql =
"critical_count > 0";
$status_sql = "critical_count > 0";
break;
case AGENT_STATUS_UNKNOWN:
$status_sql =
"critical_count = 0 AND warning_count = 0
AND unknown_count > 0";
$status_sql = "(
critical_count = 0
AND warning_count = 0
AND unknown_count > 0)";
break;
case AGENT_STATUS_NOT_NORMAL:
$status_sql =
"(
normal_count <> total_count
AND
(normal_count + notinit_count) <> total_count)";
$status_sql = "(
critical_count > 0
OR warning_count > 0
OR unknown_count > 0
OR total_count = 0
OR total_count = notinit_count)";
break;
case AGENT_STATUS_NOT_INIT:
$status_sql = "notinit_count = total_count";
$status_sql = "(
total_count = 0
OR total_count = notinit_count)";
break;
}
unset($filter['status']);
@ -592,7 +599,6 @@ function agents_process_manage_config ($source_id_agent, $destiny_id_agents, $co
$module = modules_get_agentmodule ($id_agent_module);
if ($module === false)
return false;
$modules = agents_get_modules ($id_destiny_agent, false,
array ('nombre' => $module['nombre'], 'disabled' => false));
@ -818,8 +824,9 @@ function agents_get_group_agents (
$filter = array();
if (!$noACL) {
$id_group = groups_safe_acl($config["id_user"], $id_group, "AR");
$id_group = $id_group == 0
? array_keys(users_get_groups(false, "AR", false))
: groups_safe_acl($config["id_user"], $id_group, "AR");
if (empty ($id_group)) {
//An empty array means the user doesn't have access
return array ();
@ -915,23 +922,39 @@ function agents_get_group_agents (
if (isset($search['status'])) {
switch ($search['status']) {
case AGENT_STATUS_NORMAL:
$filter[] = "normal_count = total_count";
$filter[] = "(
critical_count = 0
AND warning_count = 0
AND unknown_count = 0
AND normal_count > 0)";
break;
case AGENT_STATUS_WARNING:
$filter[] = "(critical_count = 0 AND warning_count > 0)";
$filter[] = "(
critical_count = 0
AND warning_count > 0
AND total_count > 0)";
break;
case AGENT_STATUS_CRITICAL:
$filter[] = "critical_count > 0";
break;
case AGENT_STATUS_UNKNOWN:
$filter[] = "(critical_count = 0 AND warning_count = 0 AND unknown_count > 0)";
$filter[] = "(
critical_count = 0
AND warning_count = 0
AND unknown_count > 0)";
break;
case AGENT_STATUS_NOT_NORMAL:
$filter[] = "normal_count <> total_count
AND critical_count = 0 AND warning_count = 0";
$filter[] = "(
critical_count > 0
OR warning_count > 0
OR unknown_count > 0
OR total_count = 0
OR total_count = notinit_count)";
break;
case AGENT_STATUS_NOT_INIT:
$filter[] = "notinit_count = total_count";
$filter[] = "(
total_count = 0
OR total_count = notinit_count)";
break;
}
unset($search['status']);
@ -1054,7 +1077,8 @@ function agents_get_modules ($id_agent = null, $details = false,
if (empty($userGroups)) {
return array();
}
$id_userGroups = $id_groups = array_keys($userGroups);
$id_groups = array_keys($userGroups);
$id_groups_sql = implode(',', $id_groups);
// =================================================================
// When there is not a agent id. Get a agents of groups that the
@ -1084,49 +1108,25 @@ function agents_get_modules ($id_agent = null, $details = false,
if (!is_array($id_agent)) {
$id_agent = safe_int ($id_agent, 1);
}
$where = "(
1 = (
SELECT is_admin
FROM tusuario
WHERE id_user = '" . $config['id_user'] . "'
)
OR
tagente_modulo.id_agente IN (
SELECT id_agente
FROM tagente tas LEFT JOIN tagent_secondary_group tasgs
ON tas.id_agente = tasgs.id_agent
WHERE (tas.id_grupo IN (
" . implode(',', $id_userGroups) . "
) OR
tasgs.id_group IN (
" . implode(',', $id_userGroups) . "
)
)
)
OR 0 IN (
SELECT id_grupo
FROM tusuario_perfil
WHERE id_usuario = '" . $config['id_user'] . "'
AND id_perfil IN (
SELECT id_perfil
FROM tperfil WHERE agent_view = 1
)
)
$where = "1 = 1 ";
// Groups ACL only when user is not empty
if (!users_can_manage_group_all("AR")) {
$where = "(
tagente.id_grupo IN ($id_groups_sql) OR tasg.id_group IN ($id_groups_sql)
)";
if (! empty ($id_agent)) {
$where .= sprintf (' AND id_agente IN (%s)', implode (",", (array) $id_agent));
}
$where .= ' AND delete_pending = 0 ';
if (! empty ($id_agent)) {
$id_agent_sql = implode (",", (array)$id_agent);
$where .= " AND tagente.id_agente IN ($id_agent_sql) ";
}
if (! empty ($filter)) {
$where .= ' AND ';
if (is_array ($filter)) {
$fields = array ();
//----------------------------------------------------------
// Code for filters as array of arrays
// for example:
@ -1151,11 +1151,10 @@ function agents_get_modules ($id_agent = null, $details = false,
}
}
//----------------------------------------------------------
foreach ($list_filter as $item) {
$field = $item['field'];
$value = $item['value'];
//Check <> operator
$operatorDistin = false;
if (strlen($value) > 2) {
@ -1163,119 +1162,91 @@ function agents_get_modules ($id_agent = null, $details = false,
$operatorDistin = true;
}
}
if ($value[0] == '%') {
switch ($config['dbtype']) {
case "mysql":
case "postgresql":
array_push ($fields,
$field . ' LIKE "' . $value . '"');
break;
case "oracle":
array_push ($fields,
$field . ' LIKE \'' . $value . '\'');
break;
}
array_push ($fields,
$field . ' LIKE "' . $value . '"');
}
else if ($operatorDistin) {
array_push($fields, $field.' <> ' . substr($value, 2));
}
else if (substr($value, -1) == '%') {
switch ($config['dbtype']) {
case "mysql":
case "postgresql":
array_push ($fields, $field.' LIKE "'.$value.'"');
break;
case "oracle":
array_push ($fields, $field.' LIKE \''.$value.'\'');
break;
}
array_push ($fields, $field.' LIKE "'.$value.'"');
}
//else if (strstr($value, '666=666', true) == '') {
else if (strncmp($value, '666=666', 7) == 0) {
switch ($config['dbtype']) {
case "mysql":
case "postgresql":
array_push ($fields, ' '.$value);
break;
case "oracle":
array_push ($fields, ' '.$value);
break;
}
array_push ($fields, ' '.$value);
}
else if (preg_match('/\bin\b/i',$field)) {
array_push ($fields, $field.' '.$value);
}
else {
switch ($config["dbtype"]) {
case "mysql":
array_push ($fields, $field.' = "'.$value.'"');
break;
case "postgresql":
array_push ($fields, $field.' = \''.$value.'\'');
break;
case "oracle":
if (is_int ($value) || is_float ($value) || is_double ($value))
array_push ($fields, $field.' = '.$value.'');
else
array_push ($fields, $field.' = \''.$value.'\'');
break;
}
array_push ($fields, 'tagente_modulo.' . $field.' = "'.$value.'"');
}
}
$where .= implode (' AND ', $fields);
$where .= implode (' AND ', $fields);
}
else {
$where .= $filter;
}
}
$stored_details = $details;
if (empty ($details)) {
$details = "nombre";
$details = "tagente_modulo.nombre";
$stored_details = "nombre";
}
else {
else {
$details = (array)$details;
$details = io_safe_input ($details);
$details = array_map(function ($a) {
return preg_match('/tagente_modulo./i', $a) ? $a : 'tagente_modulo.' . $a;
},$details
);
}
//$where .= " AND id_policy_module = 0 ";
$sql_tags_join = "";
if (tags_has_user_acl_tags($config['id_user'])){
$where_tags = tags_get_acl_tags($config['id_user'], $id_groups, 'AR',
'module_condition', 'AND', 'tagente_modulo', false, array(),
true);
true);
$where .= "\n\n" . $where_tags;
$sql_tags_join = "INNER JOIN ttag_module
ON ttag_module.id_agente_modulo = tagente_modulo.id_agente_modulo";
}
$sql = sprintf ('SELECT %s%s
FROM tagente_modulo
WHERE
%s
ORDER BY nombre',
($details != '*' && $indexed) ? 'id_agente_modulo,' : '',
%s
INNER JOIN tagente
ON tagente.id_agente = tagente_modulo.id_agente
LEFT JOIN tagent_secondary_group tasg
ON tagente.id_agente = tasg.id_agent
WHERE tagente_modulo.delete_pending = 0
AND %s
GROUP BY tagente_modulo.id_agente_modulo
ORDER BY tagente_modulo.nombre',
($details != 'tagente_modulo.*' && $indexed) ? 'tagente_modulo.id_agente_modulo,' : '',
io_safe_output(implode (",", (array) $details)),
$sql_tags_join,
$where);
$result = db_get_all_rows_sql ($sql);
if (empty ($result)) {
return array ();
}
if (! $indexed)
return $result;
$modules = array ();
foreach ($result as $module) {
if ($get_not_init_modules || modules_get_agentmodule_is_init($module['id_agente_modulo'])) {
if (is_array ($details) || $details == '*') {
if (is_array ($stored_details) || $stored_details == '*') {
//Just stack the information in array by ID
$modules[$module['id_agente_modulo']] = $module;
}
else {
$modules[$module['id_agente_modulo']] = $module[$details];
$modules[$module['id_agente_modulo']] = $module[$stored_details];
}
}
}
@ -1377,55 +1348,6 @@ function agents_get_alias_by_name ($name, $case = 'none') {
}
}
/**
* Get the number of pandora data packets in the database.
*
* In case an array is passed, it will have a value for every agent passed
* incl. a total otherwise it will just return the total
*
* @param mixed Agent id or array of agent id's, 0 for all
*
* @return mixed The number of data in the database
*/
function agents_get_modules_data_count ($id_agent = 0) {
$id_agent = safe_int ($id_agent, 1);
if (empty ($id_agent)) {
$id_agent = array ();
}
else {
$id_agent = (array) $id_agent;
}
$count = array ();
$count["total"] = 0;
$query[0] = "SELECT COUNT(*) FROM tagente_datos";
foreach ($id_agent as $agent_id) {
//Init value
$count[$agent_id] = 0;
$modules = array_keys (agents_get_modules ($agent_id));
foreach ($query as $sql) {
//Add up each table's data
//Avoid the count over empty array
if (!empty($modules))
$count[$agent_id] += (int) db_get_sql ($sql .
" WHERE id_agente_modulo IN (".implode (",", $modules).")", 0, true);
}
//Add total agent count to total count
$count["total"] += $count[$agent_id];
}
if ($count["total"] == 0) {
foreach ($query as $sql) {
$count["total"] += (int) db_get_sql ($sql, 0, true);
}
}
return $count; //Return the array
}
/**
* Check if an agent has alerts fired.
*
@ -2025,11 +1947,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
);
}
/**
@ -2173,23 +2101,6 @@ function agents_monitor_total ($id_agent, $filter = '', $disabled = false) {
return db_get_sql ($sql);
}
//Get alert fired for this agent
function agents_get_alerts_fired ($id_agent, $filter="") {
$modules_agent = agents_get_modules($id_agent, "id_agente_modulo", $filter);
if (empty($modules_agent)) {
return 0;
}
$mod_clause = "(".implode(",", $modules_agent).")";
return db_get_sql ("SELECT COUNT(times_fired)
FROM talert_template_modules
WHERE times_fired != 0 AND id_agent_module IN ".$mod_clause);
}
//Returns the alert image to display tree view
function agents_tree_view_alert_img ($alert_fired) {
@ -2424,8 +2335,7 @@ function agents_get_network_interfaces ($agents = false, $agents_filter = false)
else
$columns[] = 'descripcion';
$filter = " id_agente = $agent_id AND disabled = 0 AND id_tipo_modulo IN (".implode(",", $accepted_module_types).") AND (nombre LIKE '%_ifOperStatus' OR nombre LIKE 'ifOperStatus_%')";
$filter = " tagente_modulo.id_agente = $agent_id AND tagente_modulo.disabled = 0 AND tagente_modulo.id_tipo_modulo IN (".implode(",", $accepted_module_types).") AND (tagente_modulo.nombre LIKE '%_ifOperStatus' OR tagente_modulo.nombre LIKE 'ifOperStatus_%')";
$modules = agents_get_modules($agent_id, $columns, $filter, true, false);
if (!empty($modules)) {
@ -2491,10 +2401,10 @@ function agents_get_network_interfaces ($agents = false, $agents_filter = false)
);
if($type_interface){
$interface_traffic_modules = agents_get_modules($agent_id, $columns, "nombre LIKE '". $interface_name . "_if%Octets'");
$interface_traffic_modules = agents_get_modules($agent_id, $columns, "tagente_modulo.nombre LIKE '". $interface_name . "_if%Octets'");
}
else{
$interface_traffic_modules = agents_get_modules($agent_id, $columns, "nombre LIKE 'if%Octets_$interface_name'");
$interface_traffic_modules = agents_get_modules($agent_id, $columns, "tagente_modulo.nombre LIKE 'if%Octets_$interface_name'");
}
if (!empty($interface_traffic_modules) && count($interface_traffic_modules) >= 2) {
@ -2582,85 +2492,173 @@ function agents_get_agent_custom_field ($agent_id, $custom_field_name) {
return db_get_value_sql($sql);
}
function select_modules_for_agent_group($id_group, $id_agents,
$selection, $return = true) {
$agents = implode(",", $id_agents);
function select_modules_for_agent_group(
$id_group, $id_agents, $selection, $return = true, $index_by_name = false
) {
global $config;
$agents = (empty($id_agents)) ? array() : implode(",", $id_agents);
$filter_agent_group = "";
$filter_group = "";
$filter_agent = "";
$selection_filter = "";
$sql_conditions_tags = "";
$sql_tags_inner = "";
$groups = array_keys(users_get_groups(false, "AR", false));
if ($id_group != 0) {
$filter_group = " AND id_module_group = ". $id_group;
$filter_group = " AND tagente_modulo.id_module_group = ". $id_group;
}
if ($agents != null) {
$filter_agent = " AND id_agente IN (" . $agents . ")";
$filter_agent = " AND tagente.id_agente IN (" . $agents . ")";
}
if (!users_can_manage_group_all("AR")) {
$group_string = implode(',', $groups);
$filter_agent_group = " AND (
tagente.id_grupo IN ($group_string)
OR tasg.id_group IN ($group_string)
)";
}
if (!$selection && $agents != null) {
$number_agents = count($id_agents);
$selection_filter = "HAVING COUNT(id_agente_modulo) = $number_agents";
}
if ($selection == 1 || (count($id_agents) == 1)) {
$modules = db_get_all_rows_sql("SELECT DISTINCT nombre, id_agente_modulo
FROM tagente_modulo
WHERE 1 = 1" . $filter_agent . $filter_group);
if (empty($modules)) $modules = array();
$found = array();
foreach ($modules as $i=>$row) {
$check = $row['nombre'];
if (@$found[$check]++) {
unset($modules[$i]);
}
}
if (tags_has_user_acl_tags(false)){
$sql_conditions_tags = tags_get_acl_tags(
$config['id_user'], $groups, 'AR',
'module_condition', 'AND', 'tagente_modulo', true, array(),
false);
$sql_tags_inner = "INNER JOIN ttag_module
ON ttag_module.id_agente_modulo = tagente_modulo.id_agente_modulo";
}
else {
$modules = db_get_all_rows_sql("SELECT nombre, id_agente_modulo
FROM tagente_modulo
WHERE 1 = 1" . $filter_agent . $filter_group);
if (empty($modules)) $modules = array();
$sql = "SELECT * FROM
(
SELECT DISTINCT(tagente_modulo.id_agente_modulo), tagente_modulo.nombre
FROM tagente_modulo
$sql_tags_inner
INNER JOIN tagente
ON tagente.id_agente = tagente_modulo.id_agente
LEFT JOIN tagent_secondary_group tasg
ON tagente.id_agente = tasg.id_agent
WHERE tagente.disabled = 0
AND tagente_modulo.disabled = 0
$filter_agent_group
$filter_group
$filter_agent
$sql_conditions_tags
) x
GROUP BY nombre
$selection_filter";
foreach ($modules as $m) {
$is_in_all_agents = true;
$module_name = $m['nombre'];
foreach ($id_agents as $a) {
$module_in_agent = db_get_value_filter('id_agente_modulo',
'tagente_modulo', array('id_agente' => $a, 'nombre' => $module_name));
if (!$module_in_agent) {
$is_in_all_agents = false;
}
}
if ($is_in_all_agents) {
$modules_to_report[] = $m;
}
}
$modules = $modules_to_report;
$modules = db_get_all_rows_sql($sql);
if ($modules === false) $modules = array();
$found = array();
if (is_array($modules) || is_object($modules)){
foreach ($modules as $i=>$row) {
$check = $row['nombre'];
if (@$found[$check]++) {
unset($modules[$i]);
}
}
}
}
if (is_array($modules) || is_object($modules)){
foreach ($modules as $k => $v) {
$modules[$k] = io_safe_output($v);
}
}
if($return == false){
foreach ($modules as $value) {
$modules_array[$value['id_agente_modulo']] = $value['nombre'];
}
return $modules_array;
}
else{
if ($return) {
echo json_encode($modules);
return;
}
$modules_array = array();
foreach ($modules as $value) {
if($index_by_name) {
$modules_array[io_safe_output($value['nombre'])] =
ui_print_truncate_text(
io_safe_output($value['nombre']), 'module_medium', false, true
);
} else {
$modules_array[$value['id_agente_modulo']] = $value['nombre'];
}
}
return $modules_array;
}
function select_agents_for_module_group(
$module_names, $selection, $filter, $access = "AR"
) {
global $config;
$default_filter = array (
'status' => null
);
$filter = array_merge($default_filter, $filter);
$module_names_condition = "";
$filter_agent_group = "";
$selection_filter = "";
$sql_conditions_tags = "";
$sql_tags_inner = "";
$status_filter = "";
$module_type_filter = "";
$groups = array_keys(users_get_groups(false, $access, false));
// Name
if (!users_can_manage_group_all($access)) {
$group_string = implode(',', $groups);
$filter_agent_group = " AND (
tagente.id_grupo IN ($group_string)
OR tasg.id_group IN ($group_string)
)";
}
// Name filter
if ($module_names) {
$module_names_sql = implode("','", $module_names);
$module_names_condition = " AND tagente_modulo.nombre IN ('$module_names_sql') ";
}
// Common or all modules filter
if (!$selection) {
$number_modules = count($module_names);
$selection_filter = "HAVING COUNT(id_agente) = $number_modules";
}
// Status filter
if ($filter['status'] != null) {
$status_filter = " AND " . modules_get_state_condition(
$filter['status'], "tagente_estado"
);
}
// Tags input and ACL conditions
if (tags_has_user_acl_tags(false) || $filter['tags'] != null){
$sql_conditions_tags = tags_get_acl_tags(
$config['id_user'], $groups, $access,
'module_condition', 'AND', 'tagente_modulo', true, array(),
false);
$sql_tags_inner = "INNER JOIN ttag_module
ON ttag_module.id_agente_modulo = tagente_modulo.id_agente_modulo";
}
$sql = "SELECT * FROM
(
SELECT tagente.id_agente, tagente.alias
FROM tagente
LEFT JOIN tagent_secondary_group tasg
ON tagente.id_agente = tasg.id_agent
INNER JOIN tagente_modulo
ON tagente.id_agente = tagente_modulo.id_agente
$sql_tags_inner
LEFT JOIN tagente_estado
ON tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo
WHERE tagente.disabled = 0
AND tagente_modulo.disabled = 0
$module_names_condition
$filter_agent_group
$sql_conditions_tags
$status_filter
$module_type_filter
GROUP BY tagente_modulo.id_agente_modulo
) x
GROUP BY id_agente
$selection_filter";
$modules = db_get_all_rows_sql($sql);
if ($modules === false) return array();
return index_array(db_get_all_rows_sql($sql), 'id_agente', 'alias');
}
/**
@ -2680,20 +2678,22 @@ 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));
enterprise_include_once('include/functions_agents.php');
$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);
@ -2755,7 +2755,7 @@ function agents_get_status_clause($state, $show_not_init = true) {
)";
case AGENT_STATUS_NOT_INIT:
return $show_not_init
? "(ta.total_count = ta.notinit_count)"
? "(ta.total_count = ta.notinit_count OR ta.total_count = 0)"
: "1=0";
case AGENT_STATUS_NORMAL:
return "(

View File

@ -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 ();
@ -1810,23 +1824,6 @@ function get_group_alerts($id_group, $filter = '', $options = false,
FROM tagente_modulo WHERE delete_pending = 0';
}
if ($strict_user) {
$groups = users_get_groups($config["id_user"]);
if ($idGroup !== 0) {
$where_tags = tags_get_acl_tags($config['id_user'], $idGroup, 'AR', 'module_condition', 'AND', 'tagente_modulo', true, array(), true);
} else {
$where_tags = tags_get_acl_tags($config['id_user'], array_keys($groups), 'AR', 'module_condition', 'AND', 'tagente_modulo', true, array(), true);
}
// If there are any errors add imposible condition
if (in_array($where_tags, array(ERR_WRONG_PARAMETERS, ERR_ACL))) {
$subQuery .= ' AND 1 = 0';
}
else {
$subQuery .= $where_tags;
}
}
}
else {
if ($allModules)

View File

@ -1175,11 +1175,14 @@ function api_set_update_agent($id_agent, $thrash2, $other, $thrash3) {
return;
}
}
$values_old = db_get_row_filter('tagente',
array('id_agente' => $id_agent),
array('id_grupo', 'disabled')
);
$tpolicy_group_old = db_get_all_rows_sql("SELECT id_policy FROM tpolicy_groups
WHERE id_group = ".$values_old['id_grupo']);
$group_old = db_get_sql("SELECT id_grupo FROM tagente WHERE id_agente =" .$id_agent);
$tpolicy_group_old = db_get_all_rows_sql("SELECT id_policy FROM tpolicy_groups
WHERE id_group = ".$group_old);
$return = db_process_sql_update('tagente',
array('alias' => $alias,
'direccion' => $ip,
@ -1200,8 +1203,16 @@ function api_set_update_agent($id_agent, $thrash2, $other, $thrash3) {
// register ip for this agent in 'taddress'
agents_add_address ($id_agent, $ip);
}
if($return){
// Update config file
if (isset($disabled) && $values_old['disabled'] != $disabled) {
enterprise_hook(
'config_agents_update_config_token',
array($id_agent, 'standby', $disabled)
);
}
if($tpolicy_group_old){
foreach ($tpolicy_group_old as $key => $value) {
$tpolicy_agents_old= db_get_sql("SELECT * FROM tpolicy_agents
@ -1391,6 +1402,68 @@ function api_set_new_agent($thrash1, $thrash2, $other, $thrash3) {
}
}
function api_set_create_os($thrash1, $thrash2, $other, $thrash3) {
global $config;
if (!check_acl($config['id_user'], 0, "AW")) {
returnError('forbidden', 'string');
return;
}
if (defined ('METACONSOLE')) {
return;
}
$values = array();
$values['name'] = $other['data'][0];
$values['description'] = $other['data'][1];
if (($other['data'][2] !== 0) && ($other['data'][2] != '')) {
$values['icon_name'] = $other['data'][2];
}
$resultOrId = false;
if ($other['data'][0] != '') {
$resultOrId = db_process_sql_insert('tconfig_os', $values);
}
}
function api_set_update_os($id_os, $thrash2, $other, $thrash3) {
global $config;
if (defined ('METACONSOLE')) {
return;
}
if (!check_acl($config['id_user'], 0, "AW")) {
returnError('forbidden', 'string');
return;
}
$values = array();
$values['name'] = $other['data'][0];
$values['description'] = $other['data'][1];
if (($other['data'][2] !== 0) && ($other['data'][2] != '')) {
$values['icon_name'] = $other['data'][2];;
}
$result = false;
if ($other['data'][0] != '') {
$result = db_process_sql_update('tconfig_os', $values, array('id_os' => $id_os));
}
}
/**
*
* Creates a custom field
@ -1547,10 +1620,6 @@ function api_set_delete_agent($id, $thrash1, $thrast2, $thrash3) {
function api_get_all_agents($thrash1, $thrash2, $other, $returnType) {
global $config;
if (defined ('METACONSOLE')) {
return;
}
// Error if user cannot read agents.
if (!check_acl($config['id_user'], 0, "AR")) {
returnError('forbidden', $returnType);
@ -1599,13 +1668,25 @@ function api_get_all_agents($thrash1, $thrash2, $other, $returnType) {
// Initialization of array
$result_agents = array();
// Filter by state
$sql = "SELECT id_agente, alias, direccion, comentarios,
if (defined ('METACONSOLE')) {
$sql = "SELECT id_agente, alias, direccion, comentarios,
tconfig_os.name, url_address, nombre
FROM tconfig_os, tagente
FROM tconfig_os, tmetaconsole_agent
LEFT JOIN tagent_secondary_group
ON tagente.id_agente = tagent_secondary_group.id_agent
WHERE tagente.id_os = tconfig_os.id_os
ON tmetaconsole_agent.id_agente = tagent_secondary_group.id_agent
WHERE tmetaconsole_agent.id_os = tconfig_os.id_os
AND disabled = 0 $where AND $groups";
}
else{
$sql = "SELECT id_agente, alias, direccion, comentarios,
tconfig_os.name, url_address, nombre
FROM tconfig_os, tagente
LEFT JOIN tagent_secondary_group
ON tagente.id_agente = tagent_secondary_group.id_agent
WHERE tagente.id_os = tconfig_os.id_os
AND disabled = 0 $where AND $groups";
}
$all_agents = db_get_all_rows_sql($sql);
@ -1674,6 +1755,18 @@ function api_get_all_agents($thrash1, $thrash2, $other, $returnType) {
$result_agents = $all_agents;
}
if (empty($returnType)) {
$returnType = "string";
}
if (empty($separator)) {
$separator = ";";
}
foreach ($result_agents as $key => $value) {
$result_agents[$key]['status'] = agents_get_status($result_agents[$key]['id_agente'], true);
}
if (count($result_agents) > 0 and $result_agents !== false) {
$data = array('type' => 'array', 'data' => $result_agents);
returnData($returnType, $data, $separator);
@ -7007,10 +7100,11 @@ function otherParameter2Filter($other, $return_as_array = false) {
$idAgent = null;
if (isset($other['data'][2]) && $other['data'][2] != '') {
$idAgent = agents_get_agent_id($other['data'][2]);
$idAgents = agents_get_agent_id_by_alias($other['data'][2]);
if (!empty($idAgent)) {
$filter['id_agente'] = $idAgent;
$filter[] = "id_agente IN (" . explode(",", $idAgents) .")";
}
else {
$filter['sql'] = "1=0";

View File

@ -1531,30 +1531,6 @@ function events_get_all_status ($report = false) {
return $fields;
}
/**
* Return all event source.
*
* @return array event source array.
*/
function events_get_all_source () {
$event_table = events_get_events_table(is_metaconsole(),false);
$fields = array ();
$fields[''] = __('All');
if (users_is_admin()) {
$sources = db_get_all_rows_sql("SELECT DISTINCT(source) FROM ". $event_table);
} else {
$groups_user = users_get_groups ($config['id_user'], "ER", true);
$sources = db_get_all_rows_sql("SELECT DISTINCT(source) FROM ". $event_table. " WHERE id_grupo IN (" .implode(",",array_keys($groups_user)) .")");
}
foreach ($sources as $key => $source) {
$fields[$source['source']] = $source['source'];
}
return $fields;
}
/**
* Decode a numeric status into status description.
*
@ -2240,12 +2216,7 @@ function events_page_details ($event, $server = "") {
$strict_user = (bool) db_get_value("strict_acl", "tusuario", "id_user", $config['id_user']);
if (!empty($agent['id_grupo'])) {
if ($strict_user) {
$acl_graph = tags_check_acl_by_module($module["id_agente_modulo"], $config['id_user'], 'RR') === true;
}
else {
$acl_graph = check_acl($config['id_user'], $agent['id_grupo'], "RR");
}
$acl_graph = check_acl($config['id_user'], $agent['id_grupo'], "RR");
}
if ($acl_graph) {
@ -3554,7 +3525,6 @@ function events_sql_events_grouped_agents($id_agent, $server_id = -1,
else {
$group_array = array_keys($groups);
}
$tags_acls_condition = tags_get_acl_tags($id_user, $group_array, 'ER',
'event_condition', 'AND', '', $meta, array(), true); //FORCE CHECK SQL "(TAG = tag1 AND id_grupo = 1)"
@ -3600,6 +3570,8 @@ function events_list_events_grouped_agents($sql) {
$table = events_get_events_table(is_metaconsole(), $history);
$sql = "select * from $table
LEFT JOIN tagent_secondary_group
ON tagent_secondary_group.id_agent = tevento.id_agente
WHERE $sql";
$result = db_get_all_rows_sql ($sql);

View File

@ -20,210 +20,6 @@ include_once($config['homedir'] . "/include/functions_agents.php");
include_once($config['homedir'] . "/include/functions_modules.php");
include_once($config['homedir'] . "/include/functions_users.php");
function get_graph_statistics ($chart_array) {
global $config;
/// IMPORTANT!
///
/// The calculus for AVG, MIN and MAX values are in this function
/// because it must be done based on graph array data not using reporting
/// function to get coherent data between stats and graph visualization
$stats = array ();
$count = 0;
$size = sizeof($chart_array);
//Initialize stats array
$stats = array ("avg" => 0, "min" => null, "max" => null, "last" => 0);
foreach ($chart_array as $item) {
//Sum all values later divide by the number of elements
$stats['avg'] = $stats['avg'] + $item;
//Get minimum
if ($stats['min'] == null) {
$stats['min'] = $item;
}
else if ($item < $stats['min']) {
$stats['min'] = $item;
}
//Get maximum
if ($stats['max'] == null) {
$stats['max'] = $item;
}
else if ($item > $stats['max']) {
$stats['max'] = $item;
}
$count++;
//Get last data
if ($count == $size) {
$stats['last'] = $item;
}
}
//End the calculus for average
if ($count > 0) {
$stats['avg'] = $stats['avg'] / $count;
}
//Format stat data to display properly
$stats['last'] = remove_right_zeros(number_format($stats['last'], $config['graph_precision']));
$stats['avg'] = remove_right_zeros(number_format($stats['avg'], $config['graph_precision']));
$stats['min'] = remove_right_zeros(number_format($stats['min'], $config['graph_precision']));
$stats['max'] = remove_right_zeros(number_format($stats['max'], $config['graph_precision']));
return $stats;
}
function get_statwin_graph_statistics ($chart_array, $series_suffix = '') {
/// IMPORTANT!
///
/// The calculus for AVG, MIN and MAX values are in this function
/// because it must be done based on graph array data not using reporting
/// function to get coherent data between stats and graph visualization
$stats = array ();
$count = 0;
$size = sizeof($chart_array);
//Initialize stats array
$stats['sum'] = array ("avg" => 0, "min" => null, "max" => null, "last" => 0);
$stats['min'] = array ("avg" => 0, "min" => null, "max" => null, "last" => 0);
$stats['max'] = array ("avg" => 0, "min" => null, "max" => null, "last" => 0);
foreach ($chart_array as $item) {
if ($series_suffix != '') {
if (isset($item['sum' . $series_suffix]))
$item['sum'] = $item['sum' . $series_suffix];
if (isset($item['min' . $series_suffix]))
$item['min'] = $item['min' . $series_suffix];
if (isset($item['max' . $series_suffix]))
$item['max'] = $item['max' . $series_suffix];
}
//Get stats for normal graph
if (isset($item['sum']) && $item['sum']) {
//Sum all values later divide by the number of elements
$stats['sum']['avg'] = $stats['sum']['avg'] + $item['sum'];
//Get minimum
if ($stats['sum']['min'] == null) {
$stats['sum']['min'] = $item['sum'];
}
else if ($item['sum'] < $stats['sum']['min']) {
$stats['sum']['min'] = $item['sum'];
}
//Get maximum
if ($stats['sum']['max'] == null) {
$stats['sum']['max'] = $item['sum'];
}
else if ($item['sum'] > $stats['sum']['max']) {
$stats['sum']['max'] = $item['sum'];
}
}
//Get stats for min graph
if (isset($item['min']) && $item['min']) {
//Sum all values later divide by the number of elements
$stats['min']['avg'] = $stats['min']['avg'] + $item['min'];
//Get minimum
if ($stats['min']['min'] == null) {
$stats['min']['min'] = $item['min'];
}
else if ($item['min'] < $stats['min']['min']) {
$stats['min']['min'] = $item['min'];
}
//Get maximum
if ($stats['min']['max'] == null) {
$stats['min']['max'] = $item['min'];
}
else if ($item['min'] > $stats['min']['max']) {
$stats['min']['max'] = $item['min'];
}
}
//Get stats for max graph
if (isset($item['max']) && $item['max']) {
//Sum all values later divide by the number of elements
$stats['max']['avg'] = $stats['max']['avg'] + $item['max'];
//Get minimum
if ($stats['max']['min'] == null) {
$stats['max']['min'] = $item['max'];
}
else if ($item['max'] < $stats['max']['min']) {
$stats['max']['min'] = $item['max'];
}
//Get maximum
if ($stats['max']['max'] == null) {
$stats['max']['max'] = $item['max'];
}
else if ($item['max'] > $stats['max']['max']) {
$stats['max']['max'] = $item['max'];
}
}
//Count elements
$count++;
//Get last data
if ($count == $size) {
if (isset($item['sum']) && $item['sum']) {
$stats['sum']['last'] = $item['sum'];
}
if (isset($item['min']) && $item['min']) {
$stats['min']['last'] = $item['min'];
}
if (isset($item['max']) && $item['max']) {
$stats['max']['last'] = $item['max'];
}
}
}
//End the calculus for average
if ($count > 0) {
$stats['sum']['avg'] = $stats['sum']['avg'] / $count;
$stats['min']['avg'] = $stats['min']['avg'] / $count;
$stats['max']['avg'] = $stats['max']['avg'] / $count;
}
//Format stat data to display properly
$stats['sum']['last'] = round($stats['sum']['last'], 2);
$stats['sum']['avg'] = round($stats['sum']['avg'], 2);
$stats['sum']['min'] = round($stats['sum']['min'], 2);
$stats['sum']['max'] = round($stats['sum']['max'], 2);
$stats['min']['last'] = round($stats['min']['last'], 2);
$stats['min']['avg'] = round($stats['min']['avg'], 2);
$stats['min']['min'] = round($stats['min']['min'], 2);
$stats['min']['max'] = round($stats['min']['max'], 2);
$stats['max']['last'] = round($stats['max']['last'], 2);
$stats['max']['avg'] = round($stats['max']['avg'], 2);
$stats['max']['min'] = round($stats['max']['min'], 2);
$stats['max']['max'] = round($stats['max']['max'], 2);
return $stats;
}
function grafico_modulo_sparse_data_chart (
$agent_module_id,
$date_array,
@ -2471,6 +2267,7 @@ function graph_event_module ($width = 300, $height = 200, $id_agent) {
// Fix: tag filters implemented! for tag functionality groups have to be all user_groups (propagate ACL funct!)
$groups = users_get_groups($config["id_user"]);
$tags_condition = tags_get_acl_tags($config['id_user'], array_keys($groups), 'ER', 'event_condition', 'AND');
$data = array ();
@ -2623,382 +2420,6 @@ function graph_sla_slicebar ($id, $period, $sla_min, $sla_max, $date, $daysWeek
$config['fontpath'], $round_corner, $home_url, $ttl);
}
/**
* Print a pie graph with purge data of agent
*
* @param integer id_agent ID of agent to show
* @param integer width pie graph width
* @param integer height pie graph height
*/
function grafico_db_agentes_purge ($id_agent, $width = 380, $height = 300) {
global $config;
global $graphic_type;
$filter = array();
if ($id_agent < 1) {
$query = "";
}
else {
$modules = agents_get_modules($id_agent);
$module_ids = array_keys($modules);
if (!empty($module_ids))
$filter['id_agente_modulo'] = $module_ids;
}
// All data (now)
$time_now = time();
// 1 day ago
$time_1day = $time_now - SECONDS_1DAY;
// 1 week ago
$time_1week = $time_now - SECONDS_1WEEK;
// 1 month ago
$time_1month = $time_now - SECONDS_1MONTH;
// Three months ago
$time_3months = $time_now - SECONDS_3MONTHS;
$query_error = false;
// Data from 1 day ago
$num_1day = 0;
$num_1day += (int) db_get_sql('SELECT COUNT(*)
FROM tagente_datos
WHERE utimestamp > ' . $time_1day);
$num_1day += (int) db_get_sql('SELECT COUNT(*)
FROM tagente_datos_string
WHERE utimestamp > ' . $time_1day);
$num_1day += (int) db_get_sql('SELECT COUNT(*)
FROM tagente_datos_log4x
WHERE utimestamp > ' . $time_1day);
if ($num_1day >= 0) {
// Data from 1 week ago
$num_1week = 0;
$num_1week += (int) db_get_sql('SELECT COUNT(*)
FROM tagente_datos
WHERE utimestamp > ' . $time_1week . '
AND utimestamp < ' . $time_1day);
$num_1week += (int) db_get_sql('SELECT COUNT(*)
FROM tagente_datos_string
WHERE utimestamp > ' . $time_1week . '
AND utimestamp < ' . $time_1day);
$num_1week += (int) db_get_sql('SELECT COUNT(*)
FROM tagente_datos_log4x
WHERE utimestamp > ' . $time_1week . '
AND utimestamp < ' . $time_1day);
if ($num_1week >= 0) {
if ($num_1week > 0) {
$num_1week = 0;
$num_1week += (int) db_get_sql('SELECT COUNT(*)
FROM tagente_datos
WHERE utimestamp > ' . $time_1week);
$num_1week += (int) db_get_sql('SELECT COUNT(*)
FROM tagente_datos_string
WHERE utimestamp > ' . $time_1week);
$num_1week += (int) db_get_sql('SELECT COUNT(*)
FROM tagente_datos_log4x
WHERE utimestamp > ' . $time_1week);
}
// Data from 1 month ago
$num_1month = 0;
$num_1month += (int) db_get_sql('SELECT COUNT(*)
FROM tagente_datos
WHERE utimestamp > ' . $time_1month . '
AND utimestamp < ' . $time_1week);
$num_1month += (int) db_get_sql('SELECT COUNT(*)
FROM tagente_datos_string
WHERE utimestamp > ' . $time_1month . '
AND utimestamp < ' . $time_1week);
$num_1month += (int) db_get_sql('SELECT COUNT(*)
FROM tagente_datos_log4x
WHERE utimestamp > ' . $time_1month . '
AND utimestamp < ' . $time_1week);
if ($num_1month >= 0) {
if ($num_1month > 0) {
$num_1month = 0;
$num_1month += (int) db_get_sql('SELECT COUNT(*)
FROM tagente_datos
WHERE utimestamp > ' . $time_1month);
$num_1month += (int) db_get_sql('SELECT COUNT(*)
FROM tagente_datos_string
WHERE utimestamp > ' . $time_1month);
$num_1month += (int) db_get_sql('SELECT COUNT(*)
FROM tagente_datos_log4x
WHERE utimestamp > ' . $time_1month);
}
// Data from 3 months ago
$num_3months = 0;
$num_3months += (int) db_get_sql('SELECT COUNT(*)
FROM tagente_datos
WHERE utimestamp > ' . $time_3months . '
AND utimestamp < ' . $time_1month);
$num_3months += (int) db_get_sql('SELECT COUNT(*)
FROM tagente_datos
WHERE utimestamp > ' . $time_3months . '
AND utimestamp < ' . $time_1month);
$num_3months += (int) db_get_sql('SELECT COUNT(*)
FROM tagente_datos
WHERE utimestamp > ' . $time_3months . '
AND utimestamp < ' . $time_1month);
if ($num_3months >= 0) {
if ($num_3months > 0) {
$num_3months = 0;
$num_3months += (int) db_get_sql('SELECT COUNT(*)
FROM tagente_datos
WHERE utimestamp > ' . $time_3months);
$num_3months += (int) db_get_sql('SELECT COUNT(*)
FROM tagente_datos
WHERE utimestamp > ' . $time_3months);
$num_3months += (int) db_get_sql('SELECT COUNT(*)
FROM tagente_datos
WHERE utimestamp > ' . $time_3months);
}
// All data
$num_all = 0;
$num_all += (int) db_get_sql('SELECT COUNT(*)
FROM tagente_datos
WHERE utimestamp < ' . $time_3months);
$num_all += (int) db_get_sql('SELECT COUNT(*)
FROM tagente_datos
WHERE utimestamp < ' . $time_3months);
$num_all += (int) db_get_sql('SELECT COUNT(*)
FROM tagente_datos
WHERE utimestamp < ' . $time_3months);
if ($num_all >= 0) {
$num_older = $num_all - $num_3months;
if ($config['history_db_enabled'] == 1) {
// All data in common and history database
$num_all_w_history = 0;
$num_all_w_history += (int) db_get_sql('SELECT COUNT(*)
FROM tagente_datos
WHERE utimestamp < ' . $time_3months);
$num_all_w_history += (int) db_get_sql('SELECT COUNT(*)
FROM tagente_datos
WHERE utimestamp < ' . $time_3months);
$num_all_w_history += (int) db_get_sql('SELECT COUNT(*)
FROM tagente_datos
WHERE utimestamp < ' . $time_3months);
if ($num_all_w_history >= 0) {
$num_history = $num_all_w_history - $num_all;
}
}
}
}
}
}
}
else if (($num_1day == 0) && ($num_1week == 0) && ($num_1month == 0) && ($num_3months == 0) && ($num_all == 0)) {
//If no data, returns empty
$query_error = true;
}
// Error
if ($query_error || $num_older < 0 || ($config['history_db_enabled'] == 1 && $num_history < 0)
|| (empty($num_1day) && empty($num_1week) && empty($num_1month)
&& empty($num_3months) && empty($num_all)
&& ($config['history_db_enabled'] == 1 && empty($num_all_w_history)))) {
return html_print_image('images/image_problem_area_small.png', true);
}
// Data indexes
$str_1day = __("Today");
$str_1week = "1 ".__("Week");
$str_1month = "1 ".__("Month");
$str_3months = "3 ".__("Months");
$str_older = "> 3 ".__("Months");
// Filling the data array
$data = array();
if (!empty($num_1day))
$data[$str_1day] = $num_1day;
if (!empty($num_1week))
$data[$str_1week] = $num_1week;
if (!empty($num_1month))
$data[$str_1month] = $num_1month;
if (!empty($num_3months))
$data[$str_3months] = $num_3months;
if (!empty($num_older))
$data[$str_older] = $num_older;
if ($config['history_db_enabled'] == 1 && !empty($num_history)) {
// In this pie chart only 5 elements are shown, so we need to remove
// an element. With a history db enabled the >3 months element are dispensable
if (count($data) >= 5 && isset($data[$str_3months]))
unset($data[$str_3months]);
$time_historic_db = time() - ((int)$config['history_db_days'] * SECONDS_1DAY);
$date_human = human_time_comparation($time_historic_db);
$str_history = "> $date_human (".__("History db").")";
$data[$str_history] = $num_history;
}
$water_mark = array(
'file' => $config['homedir'] . "/images/logo_vertical_water.png",
'url' => ui_get_full_url("images/logo_vertical_water.png", false, false, false)
);
return pie3d_graph($config['flash_charts'], $data, $width, $height,
__('Other'), '', $water_mark, $config['fontpath'], $config['font_size']);
}
/**
* Print a horizontal bar graph with packets data of agents
*
* @param integer width pie graph width
* @param integer height pie graph height
*/
function grafico_db_agentes_paquetes($width = 380, $height = 300) {
global $config;
global $graphic_type;
$data = array ();
$legend = array ();
$agents = agents_get_group_agents (array_keys (users_get_groups (false, 'RR')), false, "none");
$count = agents_get_modules_data_count (array_keys ($agents));
unset ($count["total"]);
arsort ($count, SORT_NUMERIC);
$count = array_slice ($count, 0, 8, true);
foreach ($count as $agent_id => $value) {
$data[$agents[$agent_id]]['g'] = $value;
}
if($config["fixed_graph"] == false){
$water_mark = array('file' =>
$config['homedir'] . "/images/logo_vertical_water.png",
'url' => ui_get_full_url("images/logo_vertical_water.png", false, false, false));
}
return hbar_graph($config['flash_charts'], $data, $width, $height, array(),
$legend, "", "", true, "", $water_mark,
$config['fontpath'], $config['font_size'], false, 1, $config['homeurl'],
'white',
'black');
}
/**
* Print a horizontal bar graph with modules data of agents
*
* @param integer height graph height
* @param integer width graph width
*/
function graph_db_agentes_modulos($width, $height) {
global $config;
global $graphic_type;
$data = array ();
switch ($config['dbtype']) {
case "mysql":
case "postgresql":
$modules = db_get_all_rows_sql ('
SELECT COUNT(id_agente_modulo), id_agente
FROM tagente_modulo
WHERE delete_pending = 0
GROUP BY id_agente
ORDER BY 1 DESC LIMIT 10');
break;
case "oracle":
$modules = db_get_all_rows_sql ('
SELECT COUNT(id_agente_modulo), id_agente
FROM tagente_modulo
WHERE rownum <= 10
AND delete_pending = 0
GROUP BY id_agente
ORDER BY 1 DESC');
break;
}
if ($modules === false)
$modules = array ();
$data = array();
foreach ($modules as $module) {
$agent_name = agents_get_name ($module['id_agente'], "none");
if (empty($agent_name)) {
continue;
}
switch ($config['dbtype']) {
case "mysql":
case "postgresql":
$data[$agent_name]['g'] = $module['COUNT(id_agente_modulo)'];
break;
case "oracle":
$data[$agent_name]['g'] = $module['count(id_agente_modulo)'];
break;
}
}
if($config["fixed_graph"] == false){
$water_mark = array('file' =>
$config['homedir'] . "/images/logo_vertical_water.png",
'url' => ui_get_full_url("images/logo_vertical_water.png", false, false, false));
}
return hbar_graph($config['flash_charts'],
$data, $width, $height, array(),
array(), "", "", true, "",
$water_mark,
$config['fontpath'], $config['font_size'], false, 1, $config['homeurl'],
'white',
'black');
}
/**
* Print a pie graph with users activity in a period of time
*
* @param integer width pie graph width
* @param integer height pie graph height
* @param integer period time period
*/
function graphic_user_activity ($width = 350, $height = 230) {
global $config;
global $graphic_type;
$data = array ();
$max_items = 5;
switch ($config['dbtype']) {
case "mysql":
case "postgresql":
$sql = sprintf ('SELECT COUNT(id_usuario) n_incidents, id_usuario
FROM tsesion
GROUP BY id_usuario
ORDER BY 1 DESC LIMIT %d', $max_items);
break;
case "oracle":
$sql = sprintf ('SELECT COUNT(id_usuario) n_incidents, id_usuario
FROM tsesion
WHERE rownum <= %d
GROUP BY id_usuario
ORDER BY 1 DESC', $max_items);
break;
}
$logins = db_get_all_rows_sql ($sql);
if ($logins == false) {
$logins = array();
}
foreach ($logins as $login) {
$data[$login['id_usuario']] = $login['n_incidents'];
}
if($config["fixed_graph"] == false){
$water_mark = array('file' =>
$config['homedir'] . "/images/logo_vertical_water.png",
'url' => ui_get_full_url("images/logo_vertical_water.png", false, false, false));
}
return pie3d_graph($config['flash_charts'], $data, $width, $height,
__('Other'), '', $water_mark,
$config['fontpath'], $config['font_size']);
}
/**
* Print a pie graph with priodity incident
*/
@ -3036,7 +2457,7 @@ function grafico_incidente_prioridad () {
}
return pie3d_graph($config['flash_charts'], $data, 320, 200,
__('Other'), '', $water_mark,
__('Other'), '', '',
$config['fontpath'], $config['font_size']);
}
@ -3077,7 +2498,7 @@ function graph_incidents_status () {
}
return pie3d_graph($config['flash_charts'], $data, 320, 200,
__('Other'), '', $water_mark,
__('Other'), '', '',
$config['fontpath'], $config['font_size']);
}
@ -3133,7 +2554,7 @@ function graphic_incident_group () {
}
return pie3d_graph($config['flash_charts'], $data, 320, 200,
__('Other'), '', $water_mark,
__('Other'), '', '',
$config['fontpath'], $config['font_size']);
}
@ -3188,7 +2609,7 @@ function graphic_incident_user () {
}
return pie3d_graph($config['flash_charts'], $data, 320, 200,
__('Other'), '', $water_mark,
__('Other'), '', '',
$config['fontpath'], $config['font_size']);
}
@ -3242,7 +2663,7 @@ function graphic_incident_source($width = 320, $height = 200) {
}
return pie3d_graph($config['flash_charts'], $data, $width, $height,
__('Other'), '', $water_mark,
__('Other'), '', '',
$config['fontpath'], $config['font_size']);
}
@ -3425,70 +2846,6 @@ function grafico_eventos_grupo ($width = 300, $height = 200, $url = "", $meta =
$config['fontpath'], $config['font_size'], 1, 'bottom');
}
function grafico_eventos_agente ($width = 300, $height = 200, $result = false, $meta = false, $history = false) {
global $config;
global $graphic_type;
//It was urlencoded, so we urldecode it
//$url = html_entity_decode (rawurldecode ($url), ENT_QUOTES);
$data = array ();
$loop = 0;
if ($result === false) {
$result = array();
}
$system_events = 0;
$other_events = 0;
$total = array();
$i = 0;
foreach ($result as $row) {
if ($meta) {
$count[] = $row["agent_name"];
}
else {
if ($row["id_agente"] == 0) {
$count[] = __('SYSTEM');
}
else
$count[] = agents_get_alias($row["id_agente"]) ;
}
}
$total = array_count_values($count);
foreach ($total as $key => $total) {
if ($meta) {
$name = $key." (".$total.")";
}
else {
$name = $key." (".$total.")";
}
$data[$name] = $total;
}
/*
if ($other_events > 0) {
$name = __('Other')." (".$other_events.")";
$data[$name] = $other_events;
}
*/
// Sort the data
arsort($data);
if($config["fixed_graph"] == false){
$water_mark = array('file' =>
$config['homedir'] . "/images/logo_vertical_water.png",
'url' => ui_get_full_url("images/logo_vertical_water.png", false, false, false));
}
return pie3d_graph($config['flash_charts'], $data, $width, $height,
__('Others'), '', $water_mark,
$config['fontpath'], $config['font_size'], 1, 'bottom');
}
/**
* Print a pie graph with events data in 320x200 size
*
@ -3514,8 +2871,11 @@ function grafico_eventos_total($filter = "", $width = 320, $height = 200, $noWat
}
$sql = sprintf("SELECT criticity, COUNT(id_evento) events
FROM tevento %s
GROUP BY criticity ORDER BY events DESC", $where);
FROM tevento
LEFT JOIN tagent_secondary_group tasg
ON tevento.id_agente = tasg.id_agent
%s %s
GROUP BY criticity ORDER BY events DESC", $where , $filter);
$criticities = db_get_all_rows_sql ($sql, false, false);
@ -4824,12 +4184,11 @@ function graph_monitor_wheel ($width = 550, $height = 600, $filter = false) {
if (!empty($agents)) {
$agents_id = array();
$agents_aux = array();
foreach ($agents as $key => $agent) {
foreach ($agents as $key => $agent) {
$agents_aux[$agent['id_agente']] = $agent;
}
$agents = $agents_aux;
$agents_aux = null;
$fields = array('id_agente_modulo', 'id_agente', 'id_module_group', 'nombre');
$module_groups = modules_get_modulegroups();
$module_groups[0] = __('Not assigned');

View File

@ -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) {

View File

@ -142,14 +142,12 @@ function modules_copy_agent_module_to_agent ($id_agent_module, $id_destiny_agent
if ($forced_name !== false)
$module['nombre'] = $forced_name;
$modules = agents_get_modules ($id_destiny_agent, false,
array ('nombre' => $module['nombre'], 'disabled' => false));
// The module already exist in the target
if (! empty ($modules))
return array_pop (array_keys ($modules));
$modulesDisabled = agents_get_modules ($id_destiny_agent, false,
array ('nombre' => $module['nombre'], 'disabled' => true));
@ -441,9 +439,9 @@ function modules_update_agent_module ($id, $values,
}
$result = @db_process_sql_update ('tagente_modulo', $values, $where);
if ($result == false) {
if ($result_disable == ERR_GENERIC ){
if ($result_disable === ERR_GENERIC ){
return ERR_DB;
}
else{
@ -2687,8 +2685,14 @@ function get_module_realtime_link_graph ($module) {
* with some user action through the console
* @param int New status
* @param int Agent module to force new status
* @param int Agent id to force state recalculations
*/
function force_set_module_status ($status, $id_agent_module) {
function force_set_module_status ($status, $id_agent_module, $id_agent) {
// Force recalculate counters
db_process_sql_update('tagente',
array('update_module_count' => 1),
array('id_agente' => $id_agent)
);
return db_process_sql_update( 'tagente_estado',
array(
'estado' => $status,
@ -2776,33 +2780,38 @@ function modules_get_counter_by_states($state) {
return false;
}
function modules_get_state_condition($state) {
function modules_get_state_condition($state, $prefix = "tae") {
switch ($state) {
case AGENT_MODULE_STATUS_CRITICAL_ALERT:
case AGENT_MODULE_STATUS_CRITICAL_BAD:
return "(
tae.estado = ".AGENT_MODULE_STATUS_CRITICAL_ALERT."
OR tae.estado = ".AGENT_MODULE_STATUS_CRITICAL_BAD."
$prefix.estado = ".AGENT_MODULE_STATUS_CRITICAL_ALERT."
OR $prefix.estado = ".AGENT_MODULE_STATUS_CRITICAL_BAD."
)";
case AGENT_MODULE_STATUS_WARNING_ALERT:
case AGENT_MODULE_STATUS_WARNING:
return "(
tae.estado = ".AGENT_MODULE_STATUS_WARNING_ALERT."
OR tae.estado = ".AGENT_MODULE_STATUS_WARNING."
$prefix.estado = ".AGENT_MODULE_STATUS_WARNING_ALERT."
OR $prefix.estado = ".AGENT_MODULE_STATUS_WARNING."
)";
case AGENT_MODULE_STATUS_UNKNOWN:
return "tae.estado = ".AGENT_MODULE_STATUS_UNKNOWN." ";
return "$prefix.estado = ".AGENT_MODULE_STATUS_UNKNOWN." ";
case AGENT_MODULE_STATUS_NO_DATA:
case AGENT_MODULE_STATUS_NOT_INIT:
return "(
tae.estado = ".AGENT_MODULE_STATUS_NO_DATA."
OR tae.estado = ".AGENT_MODULE_STATUS_NOT_INIT."
$prefix.estado = ".AGENT_MODULE_STATUS_NO_DATA."
OR $prefix.estado = ".AGENT_MODULE_STATUS_NOT_INIT."
)";
case AGENT_MODULE_STATUS_NORMAL_ALERT:
case AGENT_MODULE_STATUS_NORMAL:
return "(
tae.estado = ".AGENT_MODULE_STATUS_NORMAL_ALERT."
OR tae.estado = ".AGENT_MODULE_STATUS_NORMAL."
$prefix.estado = ".AGENT_MODULE_STATUS_NORMAL_ALERT."
OR $prefix.estado = ".AGENT_MODULE_STATUS_NORMAL."
)";
case AGENT_MODULE_STATUS_NOT_NORMAL:
return "(
$prefix.estado <> " . AGENT_MODULE_STATUS_NORMAL . "
AND $prefix.estado <> " . AGENT_MODULE_STATUS_NORMAL_ALERT . "
)";
}
// If the state is not an expected state, return no condition

View File

@ -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) {
@ -260,7 +256,7 @@ function networkmap_generate_dot ($pandora_name, $group = 0,
$relative = false, $text_filter = '', $ip_mask = null,
$dont_show_subgroups = false, $strict_user = false, $size_canvas = null,
$old_mode = false, $map_filter = array()) {
global $config;
$nooverlap = 1;
@ -271,17 +267,8 @@ function networkmap_generate_dot ($pandora_name, $group = 0,
$filter['disabled'] = 0;
if (!empty($text_filter)) {
switch ($config['dbtype']) {
case "mysql":
case "postgresql":
$filter[] =
'(nombre COLLATE utf8_general_ci LIKE "%' . $text_filter . '%")';
break;
case "oracle":
$filter[] =
'(upper(nombre) LIKE upper(\'%' . $text_filter . '%\'))';
break;
}
$filter[] =
'(nombre COLLATE utf8_general_ci LIKE "%' . $text_filter . '%")';
}
if ($group >= 1) {
@ -305,33 +292,11 @@ function networkmap_generate_dot ($pandora_name, $group = 0,
//foreach loop are without parent (id_parent = 0)
// Get agents data
if ($strict_user) {
if ($dont_show_subgroups)
$filter['id_group'] = $group;
else {
if (!empty($childrens)) {
foreach ($childrens as $children) {
$filter_id_groups[$children] = $children;
}
}
$filter_id_groups[$group] = $group;
$filter['id_group'] = implode(',', $filter_id_groups);
}
$filter['group_by'] = 'tagente.id_agente';
$fields = array ('tagente.id_grupo, tagente.nombre, tagente.id_os, tagente.id_parent, tagente.id_agente,
tagente.normal_count, tagente.warning_count, tagente.critical_count,
tagente.unknown_count, tagente.total_count, tagente.notinit_count');
$acltags = tags_get_user_groups_and_tags ($config['id_user'],'AR', $strict_user);
$agents = tags_get_all_user_agents (false, $config['id_user'], $acltags, $filter, $fields, false, $strict_user, true);
}
else {
$agents = agents_get_agents ($filter,
array ('id_grupo, nombre, id_os, id_parent, id_agente,
normal_count, warning_count, critical_count,
unknown_count, total_count, notinit_count'), 'AR',
array('field' => 'id_parent', 'order' => 'ASC'));
}
$agents = agents_get_agents ($filter,
array ('id_grupo, nombre, id_os, id_parent, id_agente,
normal_count, warning_count, critical_count,
unknown_count, total_count, notinit_count'), 'AR',
array('field' => 'id_parent', 'order' => 'ASC'));
}
else if ($group == -666) {
$agents = false;
@ -343,21 +308,11 @@ function networkmap_generate_dot ($pandora_name, $group = 0,
unknown_count, total_count, notinit_count'), $strict_user);
}
else {
if ($strict_user) {
$filter['group_by'] = 'tagente.id_agente';
$fields = array ('tagente.id_grupo, tagente.nombre, tagente.id_os, tagente.id_parent, tagente.id_agente,
tagente.normal_count, tagente.warning_count, tagente.critical_count,
tagente.unknown_count, tagente.total_count, tagente.notinit_count');
$acltags = tags_get_user_groups_and_tags ($config['id_user'],'AR', $strict_user);
$agents = tags_get_all_user_agents (false, $config['id_user'], $acltags, $filter, $fields, false, $strict_user, true);
}
else {
$agents = agents_get_agents ($filter,
array ('id_grupo, nombre, id_os, id_parent, id_agente,
normal_count, warning_count, critical_count,
unknown_count, total_count, notinit_count'), 'AR',
array('field' => 'id_parent', 'order' => 'ASC'));
}
$agents = agents_get_agents ($filter,
array ('id_grupo, nombre, id_os, id_parent, id_agente,
normal_count, warning_count, critical_count,
unknown_count, total_count, notinit_count'), 'AR',
array('field' => 'id_parent', 'order' => 'ASC'));
}
if ($agents === false)
@ -390,15 +345,10 @@ function networkmap_generate_dot ($pandora_name, $group = 0,
$filter = array();
$filter['disabled'] = 0;
// Get agent modules data
if ($strict_user) {
$modules = tags_get_agent_modules ($agent['id_agente'], false, $acltags, false, $filter, false);
}
else {
$modules = agents_get_modules($agent['id_agente'], '*', $filter, true, true);
}
$modules = agents_get_modules($agent['id_agente'], '*', $filter, true, true);
if ($modules === false)
$modules = array();
@ -619,264 +569,6 @@ function networkmap_generate_dot ($pandora_name, $group = 0,
return $graph;
}
// Generate a dot graph definition for graphviz with groups
function networkmap_generate_dot_groups ($pandora_name, $group = 0,
$simple = 0, $font_size = 12, $layout = 'radial', $nooverlap = 0,
$zoom = 1, $ranksep = 2.5, $center = 0, $regen = 1, $pure = 0,
$modwithalerts = 0, $module_group = 0, $hidepolicymodules = 0,
$depth = 'all', $id_networkmap = 0, $dont_show_subgroups = 0,
$text_filter = '', $strict_user = false, $size_canvas = null) {
global $config;
if ($strict_user) {
$acltags = tags_get_user_groups_and_tags ($config['id_user'],'AR', $strict_user);
}
$parents = array();
$orphans = array();
$filter = array ();
$filter['disabled'] = 0;
if (!empty($text_filter)) {
switch ($config['dbtype']) {
case "mysql":
case "postgresql":
$filter[] =
'(nombre COLLATE utf8_general_ci LIKE "%' . $text_filter . '%")';
break;
case "oracle":
$filter[] =
'(upper(nombre) LIKE upper(\'%' . $text_filter . '%\'))';
break;
}
}
// Get groups data
if ($group > 0) {
$groups = array();
$id_groups = groups_get_id_recursive($group, true);
foreach($id_groups as $id_group) {
$add = false;
if (check_acl($config["id_user"], $id_group, 'AR')) {
$add = true;
}
if ($add) {
$groups[] = db_get_row ('tgrupo', 'id_grupo', $id_group);
}
}
$filter['id_grupo'] = $id_groups;
}
else {
if ($strict_user) {
$groups = users_get_groups ($config['id_user'],"AR", false, true);
}
else {
$groups = db_get_all_rows_in_table ('tgrupo');
}
if ($groups === false) {
$groups = array();
}
}
// Open Graph
$graph = networkmap_open_graph ($layout, $nooverlap, $pure, $zoom,
$ranksep, $font_size, $size_canvas);
$node_count = 0;
// Parse groups
$nodes = array ();
$nodes_groups = array();
foreach ($groups as $group2) {
$node_count ++;
$group2['type'] = 'group';
$group2['id_node'] = $node_count;
// Add node
$nodes_groups[$group2['id_grupo']] = $group2;
}
$node_count = 0;
$groups_hiden = array();
foreach ($nodes_groups as $node_group) {
$node_count++;
// Save node parent information to define edges later
if ($node_group['parent'] != "0" && $node_group['id_grupo'] != $group) {
if ((!$dont_show_subgroups) || ($group == 0)) {
$parents[$node_count] = $nodes_groups[$node_group['parent']]['id_node'];
}
else {
$groups_hiden[$node_group['id_grupo']] = 1;
continue;
}
}
else {
$orphans[$node_count] = 1;
}
$nodes[$node_count] = $node_group;
}
if ($depth != 'group') {
if ($strict_user) {
$filter['group_by'] = 'tagente.nombre';
$filter['id_group'] = $filter['id_grupo'];
$fields = array ('tagente.id_grupo, tagente.nombre, tagente.id_os, tagente.id_agente,
tagente.normal_count, tagente.warning_count, tagente.critical_count,
tagente.unknown_count, tagente.total_count, tagente.notinit_count');
$agents = tags_get_all_user_agents (false, $config['id_user'], $acltags, $filter, $fields, false, $strict_user, true);
unset($filter['id_group']);
}
else {
// Get agents data
$agents = agents_get_agents ($filter,
array ('id_grupo, nombre, id_os, id_agente,
normal_count, warning_count, critical_count,
unknown_count, total_count, notinit_count'));
}
if ($agents === false)
$agents = array();
// Parse agents
$nodes_agents = array();
foreach ($agents as $agent) {
if ($dont_show_subgroups) {
if (!empty($groups_hiden[$agent['id_grupo']])) {
continue;
}
}
// If only agents with alerts => agents without alerts discarded
$alert_agent = agents_get_alerts($agent['id_agente']);
if ($modwithalerts and empty($alert_agent['simple'])) {
continue;
}
$node_count ++;
// Save node parent information to define edges later
$parents[$node_count] = $agent['parent'] = $nodes_groups[$agent['id_grupo']]['id_node'];
$agent['id_node'] = $node_count;
$agent['type'] = 'agent';
// Add node
$nodes[$node_count] = $nodes_agents[$agent['id_agente']] = $agent;
if ($depth == 'agent') {
continue;
}
// Get agent modules data
if ($strict_user) {
$filter['disabled'] = 0;
$modules = tags_get_agent_modules ($agent['id_agente'], false, $acltags, false, $filter, false);
} else {
$modules = agents_get_modules ($agent['id_agente'], false, array('disabled' => 0), true, false);
}
// Parse modules
foreach ($modules as $key => $module) {
$node_count ++;
$agent_module = modules_get_agentmodule($key);
$alerts_module = db_get_sql('SELECT count(*) AS num
FROM talert_template_modules
WHERE id_agent_module = ' . $key);
if ($alerts_module == 0 && $modwithalerts) {
continue;
}
if ($agent_module['id_module_group'] != $module_group &&
$module_group != 0) {
continue;
}
if ($hidepolicymodules && $config['enterprise_installed']) {
enterprise_include_once('include/functions_policies.php');
if (policies_is_module_in_policy($key)) {
continue;
}
}
// Save node parent information to define edges later
$parents[$node_count] = $agent_module['parent'] = $agent['id_node'];
$agent_module['id_node'] = $node_count;
$agent_module['type'] = 'module';
// Add node
$nodes[$node_count] = $agent_module;
}
}
}
if (empty ($nodes)) {
return false;
}
// Create void statistics array
$stats = array();
// Create nodes
foreach ($nodes as $node_id => $node) {
if ($center > 0 && ! networkmap_is_descendant ($node_id, $center, $parents)) {
unset ($parents[$node_id]);
unset ($orphans[$node_id]);
unset ($nodes[$node_id]);
continue;
}
switch ($node['type']) {
case 'group':
$graph .= networkmap_create_group_node ($node , $simple, $font_size, $metaconsole = false, null, $strict_user) .
"\n\t\t";
$stats['groups'][] = $node['id_grupo'];
break;
case 'agent':
$graph .= networkmap_create_agent_node ($node , $simple, $font_size, true, true) .
"\n\t\t";
$stats['agents'][] = $node['id_agente'];
break;
case 'module':
$graph .= networkmap_create_module_node ($node , $simple, $font_size) .
"\n\t\t";
$stats['modules'][] = $node['id_agente_modulo'];
break;
}
}
// Define edges
foreach ($parents as $node => $parent_id) {
// Verify that the parent is in the graph
if (isset ($nodes[$parent_id])) {
$graph .= networkmap_create_edge ($node, $parent_id, $layout, $nooverlap, $pure, $zoom, $ranksep, $simple, $regen, $font_size, $group, 'operation/agentes/networkmap', 'groups', $id_networkmap);
}
else {
$orphans[$node] = 1;
}
}
// Create a central node if orphan nodes exist
if (count ($orphans)) {
$graph .= networkmap_create_pandora_node ($pandora_name, $font_size, $simple, $stats);
}
// Define edges for orphan nodes
foreach (array_keys($orphans) as $node) {
$graph .= networkmap_create_edge ('0', $node, $layout, $nooverlap, $pure, $zoom, $ranksep, $simple, $regen, $font_size, $group, 'operation/agentes/networkmap', 'groups', $id_networkmap);
}
// Close graph
$graph .= networkmap_close_graph ();
return $graph;
}
// Returns an edge definition
function networkmap_create_edge ($head, $tail, $layout, $nooverlap, $pure, $zoom, $ranksep, $simple, $regen, $font_size, $group, $sec2 = 'operation/agentes/networkmap', $tab = 'topology', $id_networkmap = 0) {
if (defined("METACONSOLE")) {

View File

@ -1800,7 +1800,6 @@ function reporting_agent_module($report, $content) {
$row = array();
$row['agent_status'][$agent] = agents_get_status($agent);
$row['agent_name'] = agents_get_alias($agent);
$agent_modules = agents_get_modules($agent);
$row['modules'] = array();
@ -3079,7 +3078,6 @@ function reporting_alert_report_agent($report, $content) {
$return["description"] = $content["description"];
$return["date"] = reporting_get_date_text($report, $content);
$return['label'] = (isset($content['style']['label'])) ? $content['style']['label'] : '';
$module_list = agents_get_modules($content['id_agent']);
$data = array();
@ -3223,10 +3221,6 @@ 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) {
@ -3673,7 +3667,6 @@ function reporting_agent_configuration($report, $content) {
$agent_configuration['description'] = $agent_data['comentarios'];
$agent_configuration['enabled'] = (int)!$agent_data['disabled'];
$agent_configuration['group'] = $report["group"];
$modules = agents_get_modules ($content['id_agent']);
$agent_configuration['modules'] = array();
@ -6284,6 +6277,11 @@ function reporting_custom_graph($report, $content, $type = 'dinamic',
else {
$content['name'] = __('Simple graph');
}
} else {
if ($type_report == "custom_graph") {
$graphs = db_get_all_rows_field_filter ("tgraph", "id_graph", $content['id_gs']);
$id_graph = $content['id_gs'];
}
}
$return['title'] = $content['name'];
@ -8292,11 +8290,10 @@ function reporting_get_agentmodule_ttr ($id_agent_module, $period = 0, $date = 0
* Get a detailed report of the modules of the agent
*
* @param int $id_agent Agent id to get the report for.
* @param string $filter filter for get partial modules.
*
* @return array An array
*/
function reporting_get_agent_module_info ($id_agent, $filter = false) {
function reporting_get_agent_module_info ($id_agent) {
global $config;
$return = array ();
@ -8312,12 +8309,7 @@ function reporting_get_agent_module_info ($id_agent, $filter = false) {
return $return;
}
if ($filter != '') {
$filter = 'AND ';
}
$filter = 'disabled = 0';
$filter = array('disabled' => 0);
$modules = agents_get_modules($id_agent, false, $filter, true, false);
if ($modules === false) {
@ -8415,33 +8407,6 @@ function reporting_tiny_stats ($counts_info, $return = false, $type = 'agent', $
break;
}
if ($strict_user && $type == 'agent') {
$acltags = tags_get_user_groups_and_tags ($config['id_user'],'AR', $strict_user);
$filter['disabled'] = 0;
$id_agent = $counts_info['id_agente'];
$counts_info = array();
$counts_info['normal_count'] = count(tags_get_agent_modules ($id_agent, false, $acltags, false, $filter, false, AGENT_MODULE_STATUS_NORMAL));
$counts_info['warning_count'] = count(tags_get_agent_modules ($id_agent, false, $acltags, false, $filter, false, AGENT_MODULE_STATUS_WARNING));
$counts_info['critical_count'] = count(tags_get_agent_modules ($id_agent, false, $acltags, false, $filter, false, AGENT_MODULE_STATUS_CRITICAL_BAD));
$counts_info['notinit_count'] = count(tags_get_agent_modules ($id_agent, false, $acltags, false, $filter, false, AGENT_MODULE_STATUS_NOT_INIT));
$counts_info['unknown_count'] = count(tags_get_agent_modules ($id_agent, false, $acltags, false, $filter, false, AGENT_MODULE_STATUS_UNKNOWN));
$counts_info['total_count'] = $counts_info['normal_count'] + $counts_info['warning_count'] + $counts_info['critical_count'] + $counts_info['unknown_count'] + $counts_info['notinit_count'];
$all_agent_modules = tags_get_agent_modules ($id_agent, false, $acltags, false, $filter);
if (!empty($all_agent_modules)) {
$mod_clause = "(".implode(',', array_keys($all_agent_modules)).")";
$counts_info['fired_count'] = (int) db_get_sql ("SELECT COUNT(times_fired)
FROM talert_template_modules
WHERE times_fired != 0 AND id_agent_module IN ".$mod_clause);
}
else {
$counts_info['fired_count'] = 0;
}
}
// Store the counts in a data structure to print hidden divs with titles
$stats = array();

View File

@ -192,11 +192,13 @@ function tags_get_modules_count ($id) {
* @return int Local module tag's count.
*/
function tags_get_local_modules_count ($id) {
$field = 'COUNT(id_tag)';
$field = 'COUNT(DISTINCT(tagente_modulo.id_agente_modulo))';
$filter = array('id_tag' => $id);
$num_modules = (int) db_get_value_filter($field, 'ttag_module', $filter);
$num_modules = (int) db_get_value_filter(
$field,
'ttag_module INNER JOIN tagente_modulo ON ttag_module.id_agente_modulo = tagente_modulo.id_agente_modulo',
$filter
);
return $num_modules;
}
@ -457,7 +459,7 @@ function tags_get_module_tags ($id, $policy = false) {
$tags = db_get_all_rows_filter('ttag_module',
array('id_agente_modulo' => $id), false);
}
if ($tags === false)
return array();
@ -722,124 +724,37 @@ function tags_get_acl_tags_module_condition($acltags, $modules_table = '') {
$condition = '';
$group_conditions = array();
$without_tags = array();
$has_secondary = enterprise_hook('agents_is_using_secondary_groups');
// The acltags array contains the groups with the acl propagation applied
// after the changes done into the 'tags_get_user_groups_and_tags' function.
foreach ($acltags as $group_id => $group_tags) {
$tag_join = '';
if (!empty($group_tags)) {
$tag_join = sprintf('INNER JOIN ttag_module ttmc
ON tamc.id_agente_modulo = ttmc.id_agente_modulo
AND ttmc.id_tag IN (%s)',
is_array($group_tags) ? implode(',', $group_tags) : $group_tags);
$tag_join = sprintf('AND ttag_module.id_tag IN (%s)',is_array($group_tags) ? implode(',', $group_tags) : $group_tags);
if($has_secondary){
$agent_condition = sprintf('((tagente.id_grupo = %d OR tasg.id_group = %d) %s)',$group_id,$group_id,$tag_join);
} else {
$agent_condition = sprintf('((tagente.id_grupo = %d %s))',$group_id,$tag_join);
}
$group_conditions[] = $agent_condition;
} else {
$without_tags[] = $group_id;
}
// FIXME: Not properly way to increse performance
if(enterprise_hook('agents_is_using_secondary_groups')){
$agent_condition = sprintf('SELECT tamc.id_agente_modulo
FROM tagente_modulo tamc
%s
INNER JOIN tagente tac
ON tamc.id_agente = tac.id_agente
LEFT JOIN tagent_secondary_group tasg
ON tasg.id_agent = tac.id_agente
WHERE (tac.id_grupo = %d OR tasg.id_group = %d)',
$tag_join, $group_id, $group_id);
}
else{
$agent_condition = sprintf('SELECT tamc.id_agente_modulo
FROM tagente_modulo tamc
%s
INNER JOIN tagente tac
ON tamc.id_agente = tac.id_agente
AND tac.id_grupo = %d',
$tag_join, $group_id);
}
$sql_condition = sprintf('(%sid_agente_modulo IN (%s))', $modules_table, $agent_condition);
$group_conditions[] = $sql_condition;
$i++;
}
if (!empty($group_conditions))
if (!empty($group_conditions)) {
$condition = implode(' OR ', $group_conditions);
$condition = !empty($condition) ? "($condition)" : '';
return $condition;
}
// The old function will be keeped to serve as reference of the changes done
/**
* Transform the acl_groups data into a SQL condition
*
* @param mixed acl_groups data calculated in tags_get_acl_tags function
*
* @return string SQL condition for tagente_module
*/
function tags_get_acl_tags_module_condition_old($acltags, $modules_table = '') {
if (!empty($modules_table)) {
$modules_table .= '.';
}
$condition = '';
// Fix: Wrap SQL expression with "()" to avoid bad SQL sintax that makes Pandora retrieve all modules without taking care of id_agent => id_agent = X AND (sql_tag_expression)
$i = 0;
foreach ($acltags as $group_id => $group_tags) {
if ($condition != '') {
if (!empty($without_tags)) {
if (!empty($condition)) {
$condition .= ' OR ';
}
// Fix: Wrap SQL expression with "()" to avoid bad SQL sintax that makes Pandora retrieve all modules without taking care of id_agent => id_agent = X AND (sql_tag_expression)
if ($i == 0)
$condition .= ' ( ' . "\n";
// Group condition (The module belongs to an agent of the group X)
// Juanma (08/05/2014) Fix: Now group and tag is checked at the same time, before only tag was checked due to a bad condition
if (!array_key_exists(0, $acltags)) {
// Juanma (08/05/2014) Fix: get all groups recursively (Acl proc func!)
$group_condition = sprintf('%sid_agente IN (SELECT id_agente FROM tagente WHERE id_grupo IN (%s))', $modules_table, implode(',', array_values(groups_get_id_recursive($group_id))));
}
else {
//Avoid the user profiles with all group access.
$group_condition = " 1 = 1 ";
}
//When the acl is only group without tags
if (empty($group_tags)) {
$condition .= "($group_condition)\n";
}
else {
if (is_array($group_tags)) {
$group_tags_query = implode(',',$group_tags);
} else {
$group_tags_query = $group_tags;
}
// Tags condition (The module has at least one of the restricted tags)
$tags_condition = sprintf('%sid_agente_modulo IN (SELECT id_agente_modulo FROM ttag_module WHERE id_tag IN (%s))', $modules_table, $group_tags_query);
$condition .=
" ( \n" .
" $group_condition \n" .
" AND \n" .
" $tags_condition \n" .
" )\n";
}
$i++;
}
// Fix: Wrap SQL expression with "()" to avoid bad SQL sintax that makes Pandora retrieve all modules without taking care of id_agent => id_agent = X AND (sql_tag_expression)
if (!empty($acltags))
$condition .= ' ) ';
//Avoid the user profiles with all group access.
//if (!empty($condition)) {
if (!empty($condition) &&
!array_key_exists(0, array_keys($acltags))) {
$condition = sprintf("\n((%s) OR %sid_agente NOT IN (SELECT id_agente FROM tagente WHERE id_grupo IN (%s)))", $condition, $modules_table, implode(',',array_keys($acltags)));
$in_group = implode(",",$without_tags);
$condition .= sprintf('(tagente.id_grupo IN (%s) OR tasg.id_group IN (%s))',$in_group,$in_group);
}
$condition = !empty($condition) ? "($condition)" : '';
return $condition;
}
@ -859,102 +774,54 @@ function tags_get_acl_tags_event_condition($acltags, $meta = false, $force_group
// Get all tags of the system
$all_tags = tags_get_all_tags(false);
// Juanma (08/05/2014) Fix : Will have all groups retrieved (also propagated ones)
$_groups_not_in = '';
$without_tags = array();
foreach ($acltags as $group_id => $group_tags) {
// Group condition (The module belongs to an agent of the group X)
$group_condition = sprintf('id_grupo IN (%s)', implode(',', array_values(groups_get_id_recursive($group_id, true))));
//$_groups_not_in .= implode(',', array_values(groups_get_id_recursive($group_id))) . ',';
// Tags condition (The module has at least one of the restricted tags)
$tags_condition = '';
// NO check if there is not tag associated with groups
if (empty($group_tags)) {
// FIXME: Not properly way to increse performance
if(enterprise_hook('agents_is_using_secondary_groups')){
$tags_condition = "id_grupo = ".$group_id . " OR id_group = " . $group_id;
}
else{
$tags_condition = "id_grupo = ".$group_id;
}
}
else {
if (!is_array($group_tags)) {
$group_tags = explode(',', $group_tags);
}
foreach ($group_tags as $tag) {
// If the tag ID doesnt exist, ignore
if (!isset($all_tags[$tag])) {
continue;
}
if ($tags_condition != '') {
$tags_condition .= " OR \n";
}
//~ // Add as condition all the posibilities of the serialized tags
//~ $tags_condition .= sprintf('tags LIKE "%s,%%"',io_safe_input($all_tags[$tag]));
//~ $tags_condition .= sprintf(' OR tags LIKE "%%,%s,%%"',io_safe_input($all_tags[$tag]));
//~ $tags_condition .= sprintf(' OR tags LIKE "%%,%s"',io_safe_input($all_tags[$tag]));
//~ $tags_condition .= sprintf(' OR tags LIKE "%s %%"',io_safe_input($all_tags[$tag]));
//~ $tags_condition .= sprintf(' OR tags LIKE "%%,%s %%"',io_safe_input($all_tags[$tag]));
if ($force_group_and_tag) {
if (!empty($all_tags[$tag])) {
if ($force_equal) {
$tags_condition .= sprintf('(tags = "%s"',io_safe_input($all_tags[$tag]));
} else {
$tags_condition .= "(tags LIKE '%".io_safe_input($all_tags[$tag])."%'";
}
$childrens = groups_get_childrens($group_id, null, true);
if (empty($childrens)) {
$tags_condition .= sprintf(' AND id_grupo = %d )', $group_id);
} else {
$childrens_ids[] = $group_id;
foreach ($childrens as $child) {
$childrens_ids[] = (int)$child['id_grupo'];
}
$ids_str = implode(',', $childrens_ids);
$tags_condition .= sprintf(' AND id_grupo IN (%s) )', $ids_str);
}
} else {
$tags_condition .= "id_grupo = ".$group_id;
}
} else {
if ($force_equal) {
$tags_condition .= sprintf('tags = "%s"',io_safe_input($all_tags[$tag]));
} else {
$tags_condition .= "tags LIKE '%".io_safe_input($all_tags[$tag])."%'";
}
}
}
}
// If there is not tag condition ignore
if (empty($tags_condition)) {
$without_tags []= $group_id;
continue;
}
if ($condition != '') {
$condition .= ' OR ';
// Group condition (The module belongs to an agent of the group X)
//$group_condition = sprintf('id_grupo IN (%s)', implode(',', array_values(groups_get_id_recursive($group_id, true))));
$group_condition = "(id_grupo = $group_id OR id_group = $group_id)";
// Tags condition (The module has at least one of the restricted tags)
$tags_condition = '';
$tags_condition_array = array();
foreach ($group_tags as $tag) {
// If the tag ID doesnt exist, ignore
if (!isset($all_tags[$tag])) continue;
$tags_condition_array[] = $force_equal
? sprintf('tags = "%s"',io_safe_input($all_tags[$tag]))
: "tags LIKE '%".io_safe_input($all_tags[$tag])."%'";
}
$condition .= "($tags_condition)\n";
// If there is not tag currently in Pandora, block the group info
if (empty($tags_condition_array)) {
$tags_condition_array[] = "1=0";
}
$tags_condition = $group_condition . " AND (" . implode(" OR ", $tags_condition_array) . ")";
$condition[] = "($tags_condition)\n";
}
//Commented because ACLs propagation don't work
/*
if (!empty($condition)) {
// Juanma (08/05/2014) Fix : Also add events of other groups (taking care of propagate ACLs func!)
if (!empty($_groups_not_in))
$condition = sprintf("\n((%s) OR id_grupo NOT IN (%s))", $condition, rtrim($_groups_not_in, ','));
$condition = implode(' OR ', $condition);
}
*/
if (!empty($without_tags)) {
if (!empty($condition)) {
$condition .= ' OR ';
}
$in_group = implode(",",$without_tags);
$condition .= sprintf('(id_grupo IN (%s) OR id_group IN (%s))',$in_group,$in_group);
}
$condition = !empty($condition) ? "($condition)" : '';
return $condition;
}
@ -975,15 +842,14 @@ function tags_has_user_acl_tags($id_user = false) {
if(is_user_admin($id_user)) {
return false;
}
$query = sprintf("SELECT count(*)
FROM tusuario_perfil, tperfil
WHERE tperfil.id_perfil = tusuario_perfil.id_perfil AND
tusuario_perfil.id_usuario = '%s' AND tags != ''",
$id_user);
$query = "SELECT count(*)
FROM tusuario_perfil
WHERE tusuario_perfil.id_usuario = '$id_user'
AND tags != '' AND tags !='0'";
$user_tags = db_get_value_sql($query);
return (bool)$user_tags;
}
@ -1150,7 +1016,7 @@ function tags_get_tags_for_module_search($id_user = false, $access = 'AR') {
//--------------------------------------------------------------
return false;
}
// Get the tags of the required access flag for each group
// Get the tags of the required access flag for each group
$tags = tags_get_acl_tags($id_user, 0, $access, 'data');
// If there are wrong parameters or fail ACL check, return false
if ($tags_user === ERR_WRONG_PARAMETERS || $tags_user === ERR_ACL) {
@ -1186,252 +1052,27 @@ function tags_check_acl_by_module($id_module = 0, $id_user = false,
$access = 'AW') {
global $config;
$return = false;
if (!empty($id_module)) {
$tags = tags_get_module_tags($id_module);
$groups = modules_get_agent_groups($id_module);
if ($id_user === false) {
$id_user = $config["id_user"];
}
foreach ($groups as $group) {
if (tags_check_acl($id_user, $group, $access, $tags, true)) {
return true;
}
}
}
return $return;
}
/**
* Check the ACLs with tags
*
* @param string ID of the user (with false the user will be taked from config)
* @param string id of the group (0 means for at least one)
* @param string access flag (AR,AW...)
* @param mixed tags to be checked (array() means for at least one)
*
* @return bool true if the acl check has success, false otherwise
*/
function tags_check_acl($id_user, $id_group, $access, $tags = array(), $flag_id_tag = false) {
global $config;
if (empty($id_module)) return false;
if ($id_user === false) {
$id_user = $config['id_user'];
$id_user = $config["id_user"];
}
// Get parents to check in propagate ACL cases
if (!is_array($id_group) && $id_group != 0) {
$id_group = array($id_group);
$group = db_get_row_filter('tgrupo',
array('id_grupo' => $id_group));
$parents = groups_get_parents($group['parent'], true);
foreach ($parents as $parent) {
$id_group[] = $parent['id_grupo'];
}
}
$acls = tags_get_acl_tags($id_user, $id_group, $access, 'data');
// If there are wrong parameters or fail ACL check, return false
if ($acls === ERR_WRONG_PARAMETERS || $acls === ERR_ACL) {
return false;
}
// If there are not tags restrictions or tags passed, check the group access
if (empty($acls) || empty($tags)) {
if (!is_array($id_group))
$group_id_array = array($id_group);
foreach ($id_group as $group) {
if (check_acl($id_user, $group, $access))
return true;
}
}
# Fix: If user profile has more than one group, due to ACL propagation then id_group can be an array
if (is_array($id_group)) {
foreach ($id_group as $group) {
if ($group > 0) {
if (array_key_exists(0, $acls)) {
//There is a All group
foreach ($tags as $tag) {
if (in_array($tag, $acls[0])) {
return true;
}
else {
return false;
}
}
}
else if (isset($acls[$group])) {
foreach ($tags as $tag) {
if (!$flag_id_tag)
$tag = tags_get_id($tag);
if (in_array($tag, $acls[$group])) {
return true;
} else if (empty($acls[$group])) {
return true;
}
}
}
else {
return false;
}
}
else {
foreach ($acls as $acl_tags) {
foreach ($tags as $tag) {
if (!$flag_id_tag)
$tag = tags_get_id($tag);
if (in_array($tag, $acl_tags)) {
return true;
}
}
}
}
}
}
else {
if ($id_group > 0) {
if (isset($acls[$id_group])) {
foreach ($tags as $tag) {
if (!$flag_id_tag)
$tag = tags_get_id($tag);
if (in_array($tag, $acls[$id_group])) {
return true;
}
}
}
else {
return false;
}
}
else {
foreach ($acls as $acl_tags) {
foreach ($tags as $tag) {
if (!$flag_id_tag)
$tag = tags_get_id($tag);
if (in_array($tag, $acl_tags)) {
return true;
}
}
}
}
}
return false;
}
function tags_check_acl_event($id_user, $id_group, $access, $tags = array(),$p = false) {
global $config;
if($id_user === false) {
$id_user = $config['id_user'];
}
$acls = tags_get_acl_tags($id_user, $id_group, $access, 'data');
// If there are wrong parameters or fail ACL check, return false
if($acls === ERR_WRONG_PARAMETERS || $acls === ERR_ACL) {
return false;
}
// If there are not tags restrictions or tags passed, check the group access
if (empty($acls) || empty($tags)) {
if (!is_array($id_group))
$group_id_array = array($id_group);
foreach ($id_group as $group) {
if (check_acl($id_user, $group, $access))
return true;
}
}
# Fix: If user profile has more than one group, due to ACL propagation then id_group can be an array
if (is_array($id_group)) {
foreach ($id_group as $group) {
if ($group > 0) {
if (isset($acls[$group])) {
foreach ($tags as $tag) {
$tag = tags_get_id($tag);
if (in_array($tag, $acls[$group])) {
return true;
}
}
}
else {
//return false;
$return = false;
}
}
else {
foreach ($acls as $acl_tags) {
foreach ($tags as $tag) {
$tag = tags_get_id($tag);
if (in_array($tag, $acl_tags)) {
return true;
}
}
}
}
}
}
else {
if ($id_group > 0) {
if (isset($acls[$id_group])) {
foreach ($tags as $tag) {
$tag = tags_get_id($tag);
if (in_array($tag, $acls[$id_group])) {
return true;
}
}
}
else {
//return false;
$return = false;
}
}
else {
foreach ($acls as $acl_tags) {
foreach ($tags as $tag) {
$tag = tags_get_id($tag);
if (in_array($tag, $acl_tags)) {
return true;
}
}
}
}
}
//return false;
$return = false;
if ($return == false) {
$parent = db_get_value('parent','tgrupo','id_grupo',$id_group);
if ($parent !== 0) {
$propagate = db_get_value('propagate','tgrupo','id_grupo',$parent);
if ($propagate == 1) {
$acl_parent = tags_check_acl_event($id_user, $parent, $access, $tags,$p);
return $acl_parent;
}
}
$tags = tags_get_module_tags($id_module);
$groups = modules_get_agent_groups($id_module);
$user_groups = users_get_groups($id_user, $acces, false, true);
$acl_column = get_acl_column($access);
foreach ($groups as $group) {
// If user has not permission for this group,go to next group
if (!isset($user_groups[$group])) continue;
// No tags means user can see all tags for this group
if (empty($user_groups[$group]["tags"][$acl_column])) return true;
// Check acl
$intersection = array_intersect($tags, $user_groups[$group]["tags"][$acl_column]);
if(!empty($intersection)) return true;
}
return false;
}
/* This function checks event ACLs */
@ -2446,7 +2087,9 @@ function tags_get_user_groups_and_tags ($id_user = false, $access = 'AR', $stric
$return = array();
foreach ($acls as $acl) {
$return[$acl["id_grupo"]] = $acl["tags"];
$return[$acl["id_grupo"]] = isset($acl["tags"][get_acl_column($access)])
? implode(",",$acl["tags"][get_acl_column($access)])
: "";
}
return $return;
@ -2701,4 +2344,41 @@ function tags_get_module_policy_tags($id_tag, $id_module) {
return $id_module_policy;
}
/**
* Get all tags configured to user associated to the agent.
*
* @param int $id_agent Agent to extract tags
* @param string $access Access to check
*
* @return mixed
* false if user has not permission on agent groups
* true if there is not any tag restriction
* array with all tags if there are tags configured
*/
function tags_get_user_applied_agent_tags ($id_agent, $access = "AR") {
global $config;
$agent_groups = agents_get_all_groups_agent($id_agent);
$user_groups = users_get_groups(false, 'AR', false, true);
// Check global agent permissions
if (!check_acl_one_of_groups($config['id_user'], $agent_groups, $access)) {
return false;
}
$acl_column = get_acl_column($access);
$tags = array();
foreach ($agent_groups as $group) {
// If user has not permission to a single group, continue
if (!isset($user_groups[$group])) continue;
$group_tags = $user_groups[$group]["tags"][$acl_column];
if (!empty($group_tags)) {
$tags = array_merge($tags, $group_tags);
} else {
// If an agent
return true;
}
}
return empty($tags) ? true : $tags;
}
?>

View File

@ -745,16 +745,7 @@ function treeview_printTable($id_agente, $server_data = array(), $no_head = fals
foreach ($network_interfaces as $interface_name => $interface) {
if (!empty($interface['traffic'])) {
$permission = false;
if ($strict_user) {
if (tags_check_acl_by_module($interface['traffic']['in'], $config['id_user'], 'RR') === true
&& tags_check_acl_by_module($interface['traffic']['out'], $config['id_user'], 'RR') === true)
$permission = true;
}
else {
$permission = check_acl($config['id_user'], $agent["id_grupo"], "RR");
}
$permission = check_acl($config['id_user'], $agent["id_grupo"], "RR");
if ($permission) {
$params = array(

View File

@ -823,10 +823,26 @@ function ui_format_alert_row ($alert, $agent = true, $url = '', $agent_style = f
else
return array ("", "", "", "", "", "", "");
}
// Get agent id
$id_agent = modules_get_agentmodule_agent ($alert['id_agent_module']);
$agente = db_get_row ('tagente', 'id_agente', $id_agent);
if (defined('METACONSOLE')) {
$server = db_get_row ('tmetaconsole_setup', 'id', $alert['server_data']['id']);
if (metaconsole_connect($server) == NOERR) {
// Get agent data from node
$agente = db_get_row ('tagente', 'id_agente', $alert['id_agent']);
metaconsole_restore_db ();
}
} else {
// Get agent id
$id_agent = modules_get_agentmodule_agent ($alert['id_agent_module']);
$agente = db_get_row ('tagente', 'id_agente', $id_agent);
}
$template = alerts_get_alert_template ($alert['id_alert_template']);
$description = io_safe_output($template['name']);
@ -934,7 +950,7 @@ function ui_format_alert_row ($alert, $agent = true, $url = '', $agent_style = f
ui_print_truncate_text (io_safe_output($description), 'description', false, true, true, '[&hellip;]', '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 = '<div><ul class="action_list">';
@ -4052,7 +4068,7 @@ function ui_get_logo_to_center_networkmap () {
global $config;
if ((!enterprise_installed()) || empty($config['custom_network_center_logo'])) {
return DEFAULT_NETWORKMAP_CENTER_LOGO;
return 'images/networkmap/bola_pandora_network_maps.png';
}
return 'enterprise/images/custom_general_logos/' . $config['custom_support_logo'];

View File

@ -208,23 +208,13 @@ function groups_combine_acl($acl_group_a, $acl_group_b){
"tags" => 1,
);
foreach ($acl_group_a['tags'] as $key => $value) {
$acl_group_b['tags'][$key] = array_merge($value, $acl_group_b['tags'][$key]);
}
foreach ($acl_list as $acl => $aux) {
if($acl == "tags") {
// Mix tags
if (isset($acl_group_a[$acl]) && ($acl_group_a[$acl] != "")) {
if (isset($acl_group_b[$acl]) && ($acl_group_b[$acl] != "")) {
if ($acl_group_b[$acl] != ($acl_group_a[$acl])) {
$acl_group_b[$acl] = $acl_group_a[$acl] . "," . $acl_group_b[$acl];
}
}
else {
$acl_group_b[$acl] = $acl_group_a[$acl];
}
}
continue;
}
if($acl == "tags") continue;
// propagate ACL
$acl_group_b[$acl] = $acl_group_a[$acl] || $acl_group_b[$acl];
}
@ -286,6 +276,8 @@ function users_get_groups ($id_user = false, $privilege = "AR", $returnAllGroup
foreach ($raw_forest as $g) {
// XXX, following code must be remade (TAG)
users_get_explode_tags($g);
if (!isset($forest_acl[$g["id_grupo"]] )) {
$forest_acl[$g["id_grupo"]] = $g;
}
@ -314,6 +306,7 @@ function users_get_groups ($id_user = false, $privilege = "AR", $returnAllGroup
}
else {
// add group to user ACL forest
users_get_explode_tags($group);
$tmp = groups_combine_acl($forest_acl[$parent], $group);
}
if ($tmp !== null) {
@ -418,10 +411,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 +428,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);
}
@ -1066,4 +1062,27 @@ function users_get_strict_mode_groups($id_user, $return_group_all) {
return $return_user_groups;
}
function users_get_explode_tags(&$group) {
if (empty($group['tags'])) {
$group['tags'] = array();
$group['tags']['agent_view'] = array();
$group['tags']['agent_edit'] = array();
$group['tags']['agent_disable'] = array();
$group['tags']['event_view'] = array();
$group['tags']['event_edit'] = array();
$group['tags']['event_management'] = array();
} else {
$aux = explode(',', $group['tags']);
$group['tags'] = array();
$group['tags']['agent_view'] = ($group['agent_view']) ? $aux : array();
$group['tags']['agent_edit'] = ($group['agent_edit']) ? $aux : array();
$group['tags']['agent_disable'] = ($group['agent_disable']) ? $aux : array();
$group['tags']['event_view'] = ($group['event_view']) ? $aux : array();
$group['tags']['event_edit'] = ($group['event_edit']) ? $aux : array();
$group['tags']['event_management'] = ($group['event_management']) ? $aux : array();
}
}
?>

View File

@ -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&amp;id_agente=" . $layoutData['id_agent']);
"estado", "operation/agentes/ver_agente&amp;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&amp;id_agente=" . $layoutData['id_agent']);
"estado", "operation/agentes/ver_agente&amp;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&amp;id_agente=" . $layoutData['id_agent']);
"estado", "operation/agentes/ver_agente&amp;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&amp;id_agente='.$layoutData['id_agent']);
"estado", 'operation/agentes/ver_agente&amp;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&amp;id_agente='.$layoutData["id_agent"].'&amp;tab=data');
"estado", 'operation/agentes/ver_agente&amp;id_agente='.$layoutData["id_agent"].'&amp;tab=data', null, null, null, $isExternalLink);
}
}
}
@ -1437,88 +1437,37 @@ function visual_map_print_item($mode = "read", $layoutData,
}
}
else{
if ($layoutData['id_metaconsole'] != 0) {
if($layoutData['clock_animation'] == 'analogic_1'){
$img = '<img src="../../images/console/signes/clock.png" style="width:'.$width.'px;height:'. ($width+40).'px;">';
}
else{
if($layoutData['time_format'] == 'time'){
$img = '<img src="../../images/console/signes/digital-clock.png" style="width:'.$width.'px;height:'. (($width/3.9)+20).'px;">';
}
else{
$img = '<img src="../../images/console/signes/digital-clock.png" style="width:'.$width.'px;height:'. (($width/3.9)+40).'px;">';
}
}
$image_prefix = ($layoutData['id_metaconsole'] != 0) ? "../../" : "";
if($layoutData['clock_animation'] == 'analogic_1'){
$img = '<img src="' . $image_prefix . 'images/console/signes/clock.png" style="width:'.$width.'px;height:'. ($width+40).'px;">';
}
else{
if($layoutData['clock_animation'] == 'analogic_1'){
$img = '<img src="images/console/signes/clock.png" style="width:'.$width.'px;height:'. ($width+40).'px;">';
}
else{
if($layoutData['time_format'] == 'time'){
$img = '<img src="images/console/signes/digital-clock.png" style="width:'.$width.'px;height:'. (($width/3.9)+20).'px;">';
}
else{
$img = '<img src="images/console/signes/digital-clock.png" style="width:'.$width.'px;height:'. (($width/3.9)+40).'px;">';
}
}
$height_offset = ($layoutData['time_format'] == 'time') ? 20 : 40;
$img = '<img src="' . $image_prefix . 'images/console/signes/digital-clock.png" style="width:'.$width.'px;height:'. (($width/3.9)+$height_offset).'px;">';
}
}
}
else{
if($layoutData['clock_animation'] == 'analogic_1'){
if ($width == 0) {
if ($layoutData['label_position']=='left') {
$img = '<div id="clock_'.$layoutData['id'].'" style="z-index:'.$show_on_top_index.';float:right;height:'.$himg.'px;">' .print_clock_analogic_1 ($layoutData['time_format'], $layoutData['timezone'],$layoutData['clock_animation'],$layoutData['width'],$layoutData['height'],$layoutData['id'],$layoutData['fill_color']).'</div>';
}
elseif ($layoutData['label_position']=='right') {
$img = '<div id="clock_'.$layoutData['id'].'" style="z-index:'.$show_on_top_index.';float:left;height:'.$himg.'px;">' . print_clock_analogic_1 ($layoutData['time_format'], $layoutData['timezone'],$layoutData['clock_animation'],$layoutData['width'],$layoutData['height'],$layoutData['id'],$layoutData['fill_color']).'</div>';
}
else {
$img = '<div id="clock_'.$layoutData['id'].'" style="z-index:'.$show_on_top_index.';height:'.$himg.'px;">' . print_clock_analogic_1 ($layoutData['time_format'], $layoutData['timezone'],$layoutData['clock_animation'],$layoutData['width'],$layoutData['height'],$layoutData['id'],$layoutData['fill_color']).'</div>';
}
if ($layoutData['label_position']=='left') {
$img = '<div id="clock_'.$layoutData['id'].'" style="z-index:'.$show_on_top_index.';float:right;height:'.$himg.'px;margin-bottom:15px;">' . print_clock_analogic_1 ($layoutData['time_format'], $layoutData['timezone'],$layoutData['clock_animation'],$layoutData['width'],$layoutData['height'],$layoutData['id'],$layoutData['fill_color']).'</div>';
}
else{
if ($layoutData['label_position']=='left') {
$img = '<div id="clock_'.$layoutData['id'].'" style="z-index:'.$show_on_top_index.';float:right;height:'.$himg.'px;">' . print_clock_analogic_1 ($layoutData['time_format'], $layoutData['timezone'],$layoutData['clock_animation'],$layoutData['width'],$layoutData['height'],$layoutData['id'],$layoutData['fill_color']).'</div>';
}
elseif ($layoutData['label_position']=='right') {
$img = '<div id="clock_'.$layoutData['id'].'" style="z-index:'.$show_on_top_index.';float:left;height:'.$himg.'px;">' .print_clock_analogic_1 ($layoutData['time_format'], $layoutData['timezone'],$layoutData['clock_animation'],$layoutData['width'],$layoutData['height'],$layoutData['id'],$layoutData['fill_color']).'</div>';
}
else {
$img ='<div id="clock_'.$layoutData['id'].'" style="z-index:'.$show_on_top_index.';height:'.$himg.'px;">' . print_clock_analogic_1 ($layoutData['time_format'], $layoutData['timezone'],$layoutData['clock_animation'],$layoutData['width'],$layoutData['height'],$layoutData['id'],$layoutData['fill_color']).'</div>';
}
elseif ($layoutData['label_position']=='right') {
$img = '<div id="clock_'.$layoutData['id'].'" style="z-index:'.$show_on_top_index.';float:left;height:'.$himg.'px;margin-bottom:15px;">' . print_clock_analogic_1 ($layoutData['time_format'], $layoutData['timezone'],$layoutData['clock_animation'],$layoutData['width'],$layoutData['height'],$layoutData['id'],$layoutData['fill_color']).'</div>';
}
else {
$img = '<div id="clock_'.$layoutData['id'].'" style="z-index:'.$show_on_top_index.';height:'.$himg.'px;margin-bottom:15px;">' . print_clock_analogic_1 ($layoutData['time_format'], $layoutData['timezone'],$layoutData['clock_animation'],$layoutData['width'],$layoutData['height'],$layoutData['id'],$layoutData['fill_color']).'</div>';
}
}
elseif($layoutData['clock_animation'] == 'digital_1'){
if ($width == 0) {
if ($layoutData['label_position']=='left') {
$img = '<div id="clock_'.$layoutData['id'].'" style="z-index:'.$show_on_top_index.';float:right;height:'.$himg.'px;">' .print_clock_digital_1 ($layoutData['time_format'], $layoutData['timezone'],$layoutData['clock_animation'],$layoutData['width'],$layoutData['height'],$layoutData['id'],$layoutData['fill_color']).'</div>';
}
elseif ($layoutData['label_position']=='right') {
$img = '<div id="clock_'.$layoutData['id'].'" style="z-index:'.$show_on_top_index.';float:left;height:'.$himg.'px;">' . print_clock_digital_1 ($layoutData['time_format'], $layoutData['timezone'],$layoutData['clock_animation'],$layoutData['width'],$layoutData['height'],$layoutData['id'],$layoutData['fill_color']).'</div>';
}
else {
$img = '<div id="clock_'.$layoutData['id'].'" style="z-index:'.$show_on_top_index.';height:'.$himg.'px;">' . print_clock_digital_1 ($layoutData['time_format'], $layoutData['timezone'],$layoutData['clock_animation'],$layoutData['width'],$layoutData['height'],$layoutData['id'],$layoutData['fill_color']).'</div>';
}
if ($layoutData['label_position']=='left') {
$img = '<div id="clock_'.$layoutData['id'].'" style="z-index:'.$show_on_top_index.';float:right;height:'.$himg.'px;">' . print_clock_digital_1 ($layoutData['time_format'], $layoutData['timezone'],$layoutData['clock_animation'],$layoutData['width'],$layoutData['height'],$layoutData['id'],$layoutData['fill_color']).'</div>';
}
else{
if ($layoutData['label_position']=='left') {
$img = '<div id="clock_'.$layoutData['id'].'" style="z-index:'.$show_on_top_index.';float:right;height:'.$himg.'px;">' . print_clock_digital_1 ($layoutData['time_format'], $layoutData['timezone'],$layoutData['clock_animation'],$layoutData['width'],$layoutData['height'],$layoutData['id'],$layoutData['fill_color']).'</div>';
}
elseif ($layoutData['label_position']=='right') {
$img = '<div id="clock_'.$layoutData['id'].'" style="z-index:'.$show_on_top_index.';float:left;height:'.$himg.'px;">' .print_clock_digital_1 ($layoutData['time_format'], $layoutData['timezone'],$layoutData['clock_animation'],$layoutData['width'],$layoutData['height'],$layoutData['id'],$layoutData['fill_color']).'</div>';
}
else {
$img ='<div id="clock_'.$layoutData['id'].'" style="z-index:'.$show_on_top_index.';height:'.$himg.'px;">' . print_clock_digital_1 ($layoutData['time_format'], $layoutData['timezone'],$layoutData['clock_animation'],$layoutData['width'],$layoutData['height'],$layoutData['id'],$layoutData['fill_color']).'</div>';
}
elseif ($layoutData['label_position']=='right') {
$img = '<div id="clock_'.$layoutData['id'].'" style="z-index:'.$show_on_top_index.';float:left;height:'.$himg.'px;">' .print_clock_digital_1 ($layoutData['time_format'], $layoutData['timezone'],$layoutData['clock_animation'],$layoutData['width'],$layoutData['height'],$layoutData['id'],$layoutData['fill_color']).'</div>';
}
else {
$img ='<div id="clock_'.$layoutData['id'].'" style="z-index:'.$show_on_top_index.';height:'.$himg.'px;">' . print_clock_digital_1 ($layoutData['time_format'], $layoutData['timezone'],$layoutData['clock_animation'],$layoutData['width'],$layoutData['height'],$layoutData['id'],$layoutData['fill_color']).'</div>';
}
}
}
@ -1775,16 +1724,25 @@ function visual_map_print_item($mode = "read", $layoutData,
$value = format_for_graph($value, 2);
}
if (!empty($unit_text))
$value .= " " . $unit_text;
// Hide value on boolean modules
if (!modules_is_boolean($layoutData['id_agente_modulo'])) {
$img_style_title .=
" <br>" . __("Last value: ")
. remove_right_zeros(number_format($value, $config['graph_precision'])).$unit_text;
if ($layoutData['show_last_value'] != 2) {
if ((!modules_is_boolean($layoutData['id_agente_modulo'])) ||
(modules_is_boolean($layoutData['id_agente_modulo']) && $layoutData['show_last_value'] != 0)){
if (is_numeric($value)) {
$img_style_title .=
" <br>" . __("Last value: ")
. remove_right_zeros(number_format($value, $config['graph_precision']));
} else {
$img_style_title .=
" <br>" . __("Last value: ")
. $value;
}
}
}
if (!empty($unit_text))
$img_style_title .= " " . $unit_text;
if ($layoutData['id_metaconsole'] != 0) {
//Restore db connection
metaconsole_restore_db();
@ -1792,7 +1750,7 @@ function visual_map_print_item($mode = "read", $layoutData,
}
if(get_parameter('action') == 'edit'){
$img_style_title = '';
$img_style_title = '';
}
}

View File

@ -590,6 +590,15 @@ function visual_map_editor_print_item_palette($visualConsole_id, $background) {
<td align="left" style="">' .
html_print_checkbox('show_on_top', 1, '', true) . '</td>';
$show_last_value = array('0' => __('Hide last value on boolean modules'), '1' => __('Enabled'), '2' => __('Disabled'));
$form_items['show_last_value_row'] = array();
$form_items['show_last_value_row']['items'] = array('static_graph');
$form_items['show_last_value_row']['html'] =
'<td align="left" style="">' . __('Show last value') . '</td>
<td align="left">' .
html_print_select($show_last_value, 'last_value', 0, '', '', '', true) .
'</td>';
$form_items['module_graph_size_row'] = array();
$form_items['module_graph_size_row']['items'] = array('module_graph', 'datos');
$form_items['module_graph_size_row']['html'] = '<td align="left">' . __('Size') . '</td>

View File

@ -2240,7 +2240,6 @@ function pandoraFlotArea( graph_id, values, legend,
}
function yFormatter(v, axis) {
axis.datamin = 0;
if (short_data) {
var formatted = number_format(v, force_integer, "", short_data);
}

View File

@ -0,0 +1,56 @@
<?php
/**
* @package Include/help/en
*/
?>
<h1>Modelos de captura de datos</h1>
<p>
Se pueden realizar graficas extrayendo información
de los logs, clasificando la información en base a modelos de captura de datos.
</p>
<p>
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.
</p>
<p>
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.
</p>
<p>
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:
</p>
<p><h4>Título</h4>
Un nombre para el modelo de captura
</p>
<p><h4>Expresión regular</h4>
Cada campo a extraer se identifica con la subexpresión entre los paréntesis (expresión a capturar).
</p>
<p><h4>Los campos</h4>
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:
</p>
<p>clave, _valor_</p>
<p><em>Observación:</em> Si no especificamos un campo valor, será automáticamente el conteo de apariciones
que coinciden con la expresión regular.</p>
<p><em>Observación 2:</em> Si especificamos una columna valor podremos elegir entre representar el valor acumulado
(comportamiento por defecto) o marcar el checkbox para representar el promedio.</p>
<h3>Ejemplo</h3>
<p>Si quisiéramos extraer entradas de un log con el siguiente formato:</p>
<p><b>Sep 19 12:05:01 nova systemd: Starting Session 6132 of user root.</b></p>
<p>Para contar el número de veces que se ha iniciado sesión, agrupando por usuario, usaremos la expresion regular:<p>
<p><b>Starting Session \d+ of user (.*?)\.</b></p>
<p>y de campo:</p>
<p><b>username</b></p>
<p>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.</p>

View File

@ -0,0 +1,56 @@
<?php
/**
* @package Include/help/en
*/
?>
<h1>Visualización y búsqueda avanzadas</h1>
<p>
Se pueden realizar graficas extrayendo información
de los logs, clasificando la información en base a modelos de captura de datos.
</p>
<p>
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.
</p>
<p>
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.
</p>
<p>
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:
</p>
<p><h4>Título</h4>
Un nombre para el modelo de captura
</p>
<p><h4>Expresión regular</h4>
Cada campo a extraer se identifica con la subexpresión entre los paréntesis (expresión a capturar).
</p>
<p><h4>Los campos</h4>
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:
</p>
<p>clave, _valor_</p>
<p><em>Observación:</em> Si no especificamos un campo valor, será automáticamente el conteo de apariciones
que coinciden con la expresión regular.</p>
<p><em>Observación 2:</em> Si especificamos una columna valor podremos elegir entre representar el valor acumulado
(comportamiento por defecto) o marcar el checkbox para representar el promedio.</p>
<h3>Ejemplo</h3>
<p>Si quisiéramos extraer entradas de un log con el siguiente formato:</p>
<p><b>Sep 19 12:05:01 nova systemd: Starting Session 6132 of user root.</b></p>
<p>Para contar el número de veces que se ha iniciado sesión, agrupando por usuario, usaremos la expresion regular:<p>
<p><b>Starting Session \d+ of user (.*?)\.</b></p>
<p>y de campo:</p>
<p><b>username</b></p>
<p>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.</p>

View File

@ -0,0 +1,55 @@
<?php
/**
* @package Include/help/en
*/
?>
<h1>Visualización y búsqueda avanzadas</h1>
<p>
Se pueden realizar graficas extrayendo información
de los logs, clasificando la información en base a modelos de captura de datos.
</p>
<p>
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.
</p>
<p>
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.
</p>
<p>
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:
</p>
<p><h4>Título</h4>
Un nombre para el modelo de captura
</p>
<p><h4>Expresión regular</h4>
Cada campo a extraer se identifica con la subexpresión entre los paréntesis (expresión a capturar).
</p>
<p><h4>Los campos</h4>
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:
</p>
<p>clave, _valor_</p>
<p><em>Observación:</em> Si no especificamos un campo valor, será automáticamente el conteo de apariciones
que coinciden con la expresión regular.</p>
<p><em>Observación 2:</em> Si especificamos una columna valor podremos elegir entre representar el valor acumulado
(comportamiento por defecto) o marcar el checkbox para representar el promedio.</p>
<h3>Ejemplo</h3>
<p>Si quisiéramos extraer entradas de un log con el siguiente formato:</p>
<p><b>Sep 19 12:05:01 nova systemd: Starting Session 6132 of user root.</b></p>
<p>Para contar el número de veces que se ha iniciado sesión, agrupando por usuario, usaremos la expresion regular:<p>
<p><b>Starting Session \d+ of user (.*?)\.</b></p>
<p>y de campo:</p>
<p><b>username</b></p>
<p>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.</p>

View File

@ -3958,26 +3958,6 @@ function get_status_module() {
});
}
function check_changes_num_modules() {
var params = [];
params.push("check_changes_num_modules=1");
params.push("id=" + id_agent);
params.push("page=operation/agentes/pandora_networkmap.view");
jQuery.ajax({
data: params.join("&"),
dataType: 'json',
type: 'POST',
url: action = "../../../ajax.php",
success: function (data) {
if (data['correct']) {
if (module_count != data['count']) {
//location.reload(true);
}
}
}
});
}
function show_networkmap_node(id_agent_param, refresh_state) {
id_agent = id_agent_param;

View File

@ -65,58 +65,6 @@ Array.prototype.in_array = function () {
return false;
};
/**
* Fill up select box with id "module" with modules after agent has been selected
*
* @param event that has been triggered
* @param id_agent Agent ID that has been selected
* @param selected Which module(s) have to be selected
*/
function agent_changed (event, id_agent, selected) {
if (id_agent == undefined)
id_agent = this.value;
$('#module').attr ('disabled', 1);
$('#module').empty ();
$('#module').append ($('<option></option>').html ("Loading...").attr ("value", 0));
jQuery.post ('ajax.php',
{"page": "operation/agentes/ver_agente",
"get_agent_modules_json": 1,
"id_agent": id_agent
},
function (data) {
$('#module').empty ();
if (typeof($(document).data('text_for_module')) != 'undefined') {
$('#module').append ($('<option></option>').html ($(document).data('text_for_module')).attr("value", 0).prop('selected', true));
}
else {
if (typeof(data['any_text']) != 'undefined') {
$('#module').append ($('<option></option>').html (data['any_text']).attr ("value", 0).prop('selected', true));
}
else {
var anyText = $("#any_text").html(); //Trick for catch the translate text.
if (anyText == null) {
anyText = 'Any';
}
$('#module').append ($('<option></option>').html (anyText).attr ("value", 0).prop('selected', true));
}
}
jQuery.each (data, function (i, val) {
s = js_html_entity_decode (val['nombre']);
$('#module').append ($('<option></option>').html (s).attr ("value", val['id_agente_modulo']));
$('#module').fadeIn ('normal');
});
if (selected != undefined)
$('#module').attr ('value', selected);
$('#module').removeAttr('disabled');
},
"json"
);
}
/**
* Util for check is empty object
*
@ -529,7 +477,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 ($('<option></option>').html (s).attr ("value", val));
.append ($('<option></option>').html (s).attr ("value", i));
$('#agents').fadeIn ('normal');
});

View File

@ -540,7 +540,6 @@ function show_events_group_agent (id_insert, id_agent, server_id) {
data: parameter,
dataType: 'html',
success: function (data) {
console.log(data);
$("#"+id_insert).html(data);
$("#"+id_insert).toggle();
}

View File

@ -4726,3 +4726,41 @@ a.up_arrow {
tr:last-child > td > a.down_arrow, tr:first-child > td > a.up_arrow {
visibility: hidden;
}
.group_modules_status_box>tbody>tr>td{
border-bottom: 1px solid #E2E2E2;
border-collapse: collapse;
border-spacing:0;
width: 10%;
height: 20px;
}
.group_modules_status_div{
color: #FFF;
width: 100%;
height: 100%;
text-align: left;
display: block;
vertical-align: middle;
line-height: 20px;
}
.tooltip_counters h3{
font-size: 12pt;
padding-bottom: 10px !important;
text-align: center;
}
.tooltip_counters li{
font-size: 8pt;
margin: 2px;
margin-left: 5px;
}
.tooltip_counters li div{
width: 12px;
height: 12px;
border-radius: 3px;
float: left;
margin-right: 5px;
}

View File

@ -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 ("</html>");
}
@ -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 ("</html>");
}
@ -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 ("</html>");
}
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 ("</html>");
}

View File

@ -71,7 +71,7 @@
<div style='height: 10px'>
<?php
$version = '7.0NG.727';
$build = '180918';
$build = '181016';
$banner = "v$version Build $build";
error_reporting(0);

View File

@ -281,8 +281,7 @@ class Modules {
$modules = array();
$modules_db = array();
$sql_conditions_base = " WHERE tagente.id_agente = tagente_modulo.id_agente
AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo";
$sql_conditions_base = " WHERE 1=1";
// Part SQL for the id_agent
@ -400,7 +399,14 @@ class Modules {
$sql_total = "SELECT count(*)";
$sql = " FROM tagente, tagente_modulo, tagente_estado" .
$sql = " FROM tagente INNER JOIN tagente_modulo
ON tagente_modulo.id_agente = tagente.id_agente
INNER JOIN tagente_estado
ON tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo
LEFT JOIN tagent_secondary_group tasg
ON tagente.id_agente = tasg.id_agent
LEFT JOIN ttag_module
ON ttag_module.id_agente_modulo = tagente_modulo.id_agente_modulo" .
$sql_conditions_all;
$sql_limit = "ORDER BY tagente.nombre ASC ";

View File

@ -273,7 +273,6 @@ $table_data->head_colspan[0] = 3;
$data = array();
$data[0] = '<b>' . __('Group') . '</b>';
$data[1] = '<a href="index.php?sec=estado&amp;sec2=operation/agentes/estado_agente&amp;refr=60&amp;group_id='.$agent["id_grupo"].'">'.groups_get_name ($agent["id_grupo"]).'</a>';
// ACCESS RATE GRAPH
$access_agent = db_get_value_sql("SELECT COUNT(id_agent)
FROM tagent_access
@ -550,6 +549,7 @@ if (!empty($network_interfaces)) {
else {
$group_array = $user_groups_ids;
}
$acl_tags = tags_get_acl_tags($config['id_user'], $group_array, 'ER',
'event_condition', 'AND', '', true, array(), true);

View File

@ -138,17 +138,14 @@ echo "</h4>";
ob_start();
print_form_filter_monitors($id_agente, $status_filter_monitor, $status_text_monitor, $status_hierachy_mode);
echo "<div id='module_list_loading'>" .
html_print_image('images/spinner.gif', true) .
'</div>';
echo "<div id='module_list'>" .
"</div>";
$html_toggle = ob_get_clean();
ui_toggle($html_toggle,
__('List of modules'),

View File

@ -37,21 +37,8 @@ ui_print_page_header (__("Export data"), "images/server_export_mc.png");
$group = get_parameter_post ('group', 0);
$agentName = get_parameter_post ('agent', 0);
switch ($config["dbtype"]) {
case "mysql":
$agents = agents_get_agents(
array('nombre LIKE "' . $agentName . '"'), array ('id_agente'));
break;
case "postgresql":
$agents = agents_get_agents(
array('nombre LIKE \'' . $agentName . '\''), array ('id_agente'));
break;
case "oracle":
$agents = agents_get_agents(
array('nombre LIKE \'%' . $agentName . '%\''), array ('id_agente'));
break;
}
$agents = agents_get_agents(
array('nombre LIKE "' . $agentName . '"'), array ('id_agente'));
$agent = $agents[0]['id_agente'];
$module = (array) get_parameter_post ('module_arr', array ());

View File

@ -47,7 +47,6 @@ $option_type = get_parameter('option_type', 0);
// - others
//----------------------------------------------------------------------
$list_modules = array();
$modules_networkmap_no_proc = agents_get_modules(
$id_agente, false, array(
'id_modulo' => 2, // networkmap type
@ -62,7 +61,6 @@ $modules_networkmap_no_proc = agents_get_modules(
));
if (empty($modules_networkmap_no_proc))
$modules_networkmap_no_proc = array();
$modules_others = agents_get_modules(
$id_agente, false, array(
'id_tipo_modulo' => array(
@ -77,7 +75,6 @@ $modules_others = agents_get_modules(
if (empty($modules_others))
$modules_others = array();
$modules_boolean = agents_get_modules(
$id_agente, false, array(
'id_tipo_modulo' => array(

View File

@ -563,8 +563,6 @@ if (is_ajax ()) {
$get_status_node = (bool)get_parameter('get_status_node', false);
$get_status_module = (bool)get_parameter('get_status_module',
false);
$check_changes_num_modules = (bool)get_parameter(
'check_changes_num_modules', false);
if ($get_status_node) {
$id = (int)get_parameter('id', 0);
@ -593,20 +591,6 @@ if (is_ajax ()) {
return;
}
if ($check_changes_num_modules) {
$id = (int)get_parameter('id', 0);
$modules = agents_get_modules($id);
$return = array();
$return['correct'] = true;
$return['count'] = count($modules);
echo json_encode($return);
return;
}
if ($update_node_alert) {
$map_id = (int)get_parameter('map_id', 0);

View File

@ -87,16 +87,25 @@ if ($id_module) {
enterprise_hook('open_meta_frame');
// Get Groups and profiles from user
$user_groups = implode (',', array_keys (users_get_groups ()));
$user_groups = implode (',', array_keys (users_get_groups (false,'AR',false)));
////////////////////////////////////
// Begin Build SQL sentences
$sql_from = ' FROM ttipo_modulo,tagente LEFT JOIN tagent_secondary_group tasg ON tagente.id_agente = tasg.id_agent, tagente_modulo, tagente_estado,tmodule ';
$sql_from = " FROM tagente_modulo
INNER JOIN tagente
ON tagente_modulo.id_agente = tagente.id_agente
LEFT JOIN tagent_secondary_group tasg
ON tagente.id_agente = tasg.id_agent
INNER JOIN tagente_estado
ON tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo
INNER JOIN tmodule
ON tmodule.id_module = tagente_modulo.id_modulo
INNER JOIN ttipo_modulo
ON tagente_modulo.id_tipo_modulo = ttipo_modulo.id_tipo
LEFT JOIN ttag_module
ON tagente_modulo.id_agente_modulo = ttag_module.id_agente_modulo";
$sql_conditions_base = ' WHERE tagente.id_agente = tagente_modulo.id_agente
AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo AND tagente_modulo.id_tipo_modulo = ttipo_modulo.id_tipo AND tmodule.id_module = tagente_modulo.id_modulo';
$sql_conditions = ' AND tagente.disabled = 0';
$sql_conditions = ' WHERE tagente.disabled = 0';
if (is_numeric($ag_group)) {
$id_ag_group = 0;
@ -149,8 +158,7 @@ else if ($modulegroup > -1) {
// Module name selector
if ($ag_modulename != '') {
$sql_conditions .= sprintf (' AND tagente_modulo.nombre = \'%s\'',
$ag_modulename);
$sql_conditions .= " AND tagente_modulo.nombre LIKE '%" .$ag_modulename. "%'";
}
if ($module_option !== 0) {
@ -261,8 +269,7 @@ if (!users_is_admin()) {
}
// Two modes of filter. All the filters and only ACLs filter
$sql_conditions_all = $sql_conditions_base . $sql_conditions . $sql_conditions_group . $sql_conditions_tags . $sql_conditions_custom_fields;
$sql_conditions_acl = $sql_conditions_base . $sql_conditions_group . $sql_conditions_tags . $sql_conditions_custom_fields;
$sql_conditions_all = $sql_conditions . $sql_conditions_group . $sql_conditions_tags . $sql_conditions_custom_fields;
// Get count to paginate
if (!defined('METACONSOLE'))
@ -336,22 +343,16 @@ $table->data[0][5] = html_print_select($rows_select, 'modulegroup', $modulegroup
$table->rowspan[0][6] = 2;
$table->data[0][6] = html_print_submit_button (__('Show'), 'uptbutton',
false, 'class="sub search" style="margin-top:0px;"',true);
$modules = array();
$modules = modules_get_modules_name ($sql_from , $sql_conditions_acl, is_metaconsole());
$table->data[1][0] = __('Module name');
$table->data[1][1] = html_print_select (index_array ($modules, 'nombre', 'nombre'), 'ag_modulename',
$ag_modulename, '', __('All'), '', true, false, true, '', false, 'width: 150px;');
$table->data[1][1] = html_print_autocomplete_modules('ag_modulename',
$ag_modulename, false, true, '', array(), true);
$table->data[1][2] = __('Search');
$table->data[1][3] = html_print_input_text ('ag_freestring', $ag_freestring, '', 20, 30, true);
if (!is_metaconsole())
$table->data[1][4] = __('Tags') .
ui_print_help_tip(__('Only it is show tags in use.'), true);
else
$table->data[1][4] = __('Tags') .
ui_print_help_tip(__('Only it is show tags in use.'), true);
$table->data[1][4] = __('Tags') .
ui_print_help_tip(__('Only it is show tags in use.'), true);
$tags = array();
$tags = tags_get_user_tags();

View File

@ -177,15 +177,14 @@ echo '<td style="vertical-align: top; width: 75%; padding-top: 0px;" id="rightco
// Last events information
// ---------------------------------------------------------------------
$acltags = tags_get_user_groups_and_tags ($config['id_user'], 'ER', $user_strict);
if (!empty($acltags)) {
$tags_condition = tags_get_acl_tags_event_condition($acltags, false, $user_strict);
if (check_acl($config['id_user'],0,'ER')) {
$tags_condition = tags_get_acl_tags(false,0,'ER','event_condition');
$event_filter = "estado<>1";
if (!empty($tags_condition)) {
$events = events_print_event_table ("estado<>1 AND ($tags_condition)", 10, "100%",true,false,true);
ui_toggle($events, __('Latest events'),false,false);
$event_filter .= " AND ($tags_condition)";
}
$events = events_print_event_table ($event_filter, 10, "100%",true,false,true);
ui_toggle($events, __('Latest events'),false,false);
}
// ---------------------------------------------------------------------

View File

@ -29,13 +29,13 @@ ui_require_javascript_file('openlayers.pandora');
enterprise_include_once ('operation/agentes/ver_agente.php');
check_login ();
if (is_ajax ()) {
$get_agent_json = (bool) get_parameter ('get_agent_json');
$get_agent_modules_json = (bool) get_parameter ('get_agent_modules_json');
$get_agent_status_tooltip = (bool) get_parameter ("get_agent_status_tooltip");
$get_agents_group_json = (bool) get_parameter ("get_agents_group_json");
$get_modules_group_json = (bool) get_parameter ("get_modules_group_json");
$get_modules_group_value_name_json = (bool) get_parameter ("get_modules_group_value_name_json");
$get_agent_modules_json_for_multiple_agents = (bool) get_parameter("get_agent_modules_json_for_multiple_agents");
$get_agent_modules_alerts_json_for_multiple_agents = (bool) get_parameter("get_agent_modules_alerts_json_for_multiple_agents");
$get_agent_modules_multiple_alerts_json_for_multiple_agents = (bool) get_parameter("get_agent_modules_multiple_alerts_json_for_multiple_agents");
@ -85,22 +85,39 @@ if (is_ajax ()) {
switch ($status_agents) {
case AGENT_STATUS_NORMAL:
$filter[] = "(normal_count = total_count)";
$filter[] = "(
critical_count = 0
AND warning_count = 0
AND unknown_count = 0
AND normal_count > 0)";
break;
case AGENT_STATUS_WARNING:
$filter[] = "(critical_count = 0 AND warning_count > 0)";
$filter[] = "(
critical_count = 0
AND warning_count > 0
AND total_count > 0)";
break;
case AGENT_STATUS_CRITICAL:
$filter[] = "(critical_count > 0)";
break;
case AGENT_STATUS_UNKNOWN:
$filter[] = "(critical_count = 0 AND warning_count = 0 AND unknown_count > 0)";
$filter[] = "(
critical_count = 0
AND warning_count = 0
AND unknown_count > 0)";
break;
case AGENT_STATUS_NOT_NORMAL:
$filter[] = "(normal_count <> total_count)";
$filter[] = "(
critical_count > 0
OR warning_count > 0
OR unknown_count > 0
OR total_count = 0
OR total_count = notinit_count)";
break;
case AGENT_STATUS_NOT_INIT:
$filter[] = "(notinit_count = total_count)";
$filter[] = "(
total_count = 0
OR total_count = notinit_count)";
break;
}
$filter['order'] = "alias ASC";
@ -166,12 +183,23 @@ if (is_ajax ()) {
}
if ($get_modules_group_json) {
$id_group = (int) get_parameter('id_module_group');
$id_group = (int) get_parameter('id_module_group', 0);
$id_agents = get_parameter('id_agents');
$selection = get_parameter('selection');
select_modules_for_agent_group($id_group, $id_agents, $selection);
}
if ($get_modules_group_value_name_json) {
$id_agents = get_parameter('id_agents');
$selection = get_parameter('selection');
// No filter by module group
$modules = select_modules_for_agent_group(0, $id_agents, $selection, false, true);
echo json_encode($modules);
return;
}
if ($get_agent_json) {
$id_agent = (int) get_parameter ('id_agent');
@ -201,63 +229,18 @@ if (is_ajax ()) {
if ($get_agents_json_for_multiple_modules) {
$nameModules = get_parameter('module_name');
$selection_mode = get_parameter('selection_mode','common');
$selection_mode = get_parameter('selection_mode','common') == "all";
$status_modulo = (int) get_parameter ('status_module', -1);
$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
FROM tagente t1, tagente_modulo t2
WHERE t1.id_agente = t2.id_agente
AND t1.id_grupo IN (' . $group_id_list .')
AND t2.nombre IN (\'' . implode('\',\'', $nameModules) . '\')';
// Status selector
if ($status_modulo == AGENT_MODULE_STATUS_NORMAL) { //Normal
$sql_conditions .= ' estado = 0 AND utimestamp > 0)
OR (t2.id_tipo_modulo IN(21,22,23,100)) ';
}
elseif ($status_modulo == AGENT_MODULE_STATUS_CRITICAL_BAD) { //Critical
$sql_conditions .= ' estado = 1 AND utimestamp > 0 )';
}
elseif ($status_modulo == AGENT_MODULE_STATUS_WARNING) { //Warning
$sql_conditions .= ' estado = 2 AND utimestamp > 0 )';
}
elseif ($status_modulo == AGENT_MODULE_STATUS_NOT_NORMAL) { //Not normal
$sql_conditions .= ' estado <> 0';
}
elseif ($status_modulo == AGENT_MODULE_STATUS_UNKNOWN) { //Unknown
$sql_conditions .= ' estado = 3 AND utimestamp <> 0 )';
}
elseif ($status_modulo == AGENT_MODULE_STATUS_NOT_INIT) { //Not init
$sql_conditions .= ' utimestamp = 0 )
AND t2.id_tipo_modulo NOT IN (21,22,23,100)';
}
if ($status_modulo != -1) {
$sql .= ' AND t2.id_agente_modulo IN (SELECT id_agente_modulo FROM tagente_estado where ' . $sql_conditions;
}
if ($selection_mode == 'common') {
$sql .= 'AND (
SELECT count(t3.nombre)
FROM tagente t3, tagente_modulo t4
WHERE t3.id_agente = t4.id_agente AND t1.nombre = t3.nombre
AND t4.nombre IN (\'' . implode('\',\'', $nameModules) . '\')) = '.count($nameModules);
}
$sql .= ' ORDER BY t1.alias';
$nameAgents = db_get_all_rows_sql($sql);
if ($nameAgents == false)
$nameAgents = array();
foreach ($nameAgents as $nameAgent) {
$names[] = io_safe_output($nameAgent['name']);
}
$names = select_agents_for_module_group(
$nameModules,
$selection_mode,
array (
'status' => $status_modulo
),
"AW"
);
echo json_encode($names);
return;
}
@ -374,17 +357,7 @@ if (is_ajax ()) {
$filter .= ' AND t1.id_tipo_modulo NOT IN (' . implode($module_types_excluded) . ')';
if (!empty($module_name)) {
switch ($config['dbtype']) {
case "mysql":
$filter .= " AND t1.nombre COLLATE utf8_general_ci LIKE '%$module_name%'";
break;
case "postgresql":
$filter .= " AND t1.nombre LIKE '%$module_name%'";
break;
case "oracle":
$filter .= " AND UPPER(t1.nombre) LIKE UPPER('%$module_name%')";
break;
}
$filter .= " AND t1.nombre COLLATE utf8_general_ci LIKE '%$module_name%'";
}
// Status selector
@ -674,7 +647,7 @@ if (is_ajax ()) {
}
if ($status_modulo != -1) {
$filter['id_agente_modulo IN'] = ' (SELECT id_agente_modulo FROM tagente_estado where ' . $sql_conditions;
$filter['tagente_modulo.id_agente_modulo IN'] = ' (SELECT id_agente_modulo FROM tagente_estado where ' . $sql_conditions;
}
@ -686,7 +659,7 @@ if (is_ajax ()) {
if ($get_id_and_name)
$fields = array('id_agente_modulo', 'nombre');
if ($get_distinct_name)
$fields = array('DISTINCT(nombre)');
$fields = array('DISTINCT(tagente_modulo.nombre)');
$indexed = (bool) get_parameter ('indexed', true);
$agentName = (string) get_parameter ('agent_name', null);
@ -718,7 +691,6 @@ if (is_ajax ()) {
$id_agent = array_keys(
agents_get_group_agents(
array_keys (users_get_groups ()), $search, "none"));
$agent_modules = agents_get_modules ($id_agent, $fields, $filter, $indexed, true, false, $tags);
}
// Restore db connection
@ -731,7 +703,6 @@ if (is_ajax ()) {
$id_agent = array_keys(
agents_get_group_agents(
array_keys(users_get_groups ()), $search, "none"));
$agent_modules = agents_get_modules ($id_agent, $fields, $filter, $indexed, true, false, $tags);
}

View File

@ -158,7 +158,7 @@ if ($user_comment != '') {
}
if ($source != '') {
$sql_post .= " AND source LIKE '$source'";
$sql_post .= " AND source LIKE '%$source%'";
}
// In metaconsole mode the agent search is performed by name
@ -310,6 +310,7 @@ if ($id_group > 0 && in_array ($id_group, array_keys ($groups))) {
else {
$group_array = array_keys($groups);
}
if (check_acl ($id_user, 0, "ER"))
$tags_acls_condition = tags_get_acl_tags($id_user, $group_array, 'ER',
'event_condition', 'AND', '', $meta, array(), true); //FORCE CHECK SQL "(TAG = tag1 AND id_grupo = 1)"

View File

@ -40,11 +40,13 @@ $params = array (
// Events query params
"search" => io_safe_input($search),
"event_type" => $event_type,
"severity" => $severity,
"status" => $status,
"id_group" => $id_group,
"recursion" => $recursion,
"refr" => (int)get_parameter("refr", 0),
"id_agent" => $id_agent,
"id_agent_module" => $id_agent_module,
"pagination" => $pagination,
"group_rep" => $group_rep,
@ -156,12 +158,13 @@ else {
$table->align[$i] = 'left';
$i++;
if (in_array('server_name', $show_fields)) {
foreach ($show_fields as $k_s => $fields) {
if ($fields == 'server_name') {
$table->head[$i] = __('Server');
$table->align[$i] = 'left';
$i++;
}
if (in_array('estado', $show_fields)) {
if ($fields == 'estado') {
$table->head[$i] = __('Status') . html_print_sort_arrows(
array_merge($params, array('sort_field' => 'status')),
'sort'
@ -169,7 +172,7 @@ else {
$table->align[$i] = 'left';
$i++;
}
if (in_array('id_evento', $show_fields)) {
if ($fields == 'id_evento') {
$table->head[$i] = __('Event ID') . html_print_sort_arrows(
array_merge($params, array('sort_field' => 'event_id')),
'sort'
@ -178,7 +181,7 @@ else {
$i++;
}
if (in_array('evento', $show_fields)) {
if ($fields == 'evento') {
$table->head[$i] = __('Event Name') . html_print_sort_arrows(
array_merge($params, array('sort_field' => 'event_name')),
'sort'
@ -187,7 +190,7 @@ else {
$table->style[$i] = 'min-width: 200px; max-width: 350px; word-break: break-all;';
$i++;
}
if (in_array('id_agente', $show_fields)) {
if ($fields == 'id_agente') {
$table->head[$i] = __('Agent name') . html_print_sort_arrows(
array_merge($params, array('sort_field' => 'agent_id')),
'sort'
@ -196,7 +199,7 @@ else {
$table->style[$i] = 'max-width: 350px; word-break: break-all;';
$i++;
}
if (in_array('timestamp', $show_fields)) {
if ($fields == 'timestamp') {
$table->head[$i] = __('Timestamp') . html_print_sort_arrows(
array_merge($params, array('sort_field' => 'timestamp')),
'sort'
@ -205,7 +208,7 @@ else {
$i++;
}
if (in_array('id_usuario', $show_fields)) {
if ($fields == 'id_usuario') {
$table->head[$i] = __('User') . html_print_sort_arrows(
array_merge($params, array('sort_field' => 'user_id')),
'sort'
@ -214,7 +217,7 @@ else {
$i++;
}
if (in_array('owner_user', $show_fields)) {
if ($fields == 'owner_user') {
$table->head[$i] = __('Owner') . html_print_sort_arrows(
array_merge($params, array('sort_field' => 'owner')),
'sort'
@ -223,7 +226,7 @@ else {
$i++;
}
if (in_array('id_grupo', $show_fields)) {
if ($fields == 'id_grupo') {
$table->head[$i] = __('Group') . html_print_sort_arrows(
array_merge($params, array('sort_field' => 'group_id')),
'sort'
@ -232,7 +235,7 @@ else {
$i++;
}
if (in_array('event_type', $show_fields)) {
if ($fields == 'event_type') {
$table->head[$i] = __('Event Type') . html_print_sort_arrows(
array_merge($params, array('sort_field' => 'event_type')),
'sort'
@ -242,7 +245,7 @@ else {
$table->style[$i] = 'min-width: 85px;';
$i++;
}
if (in_array('id_agentmodule', $show_fields)) {
if ($fields == 'id_agentmodule') {
$table->head[$i] = __('Module Name') . html_print_sort_arrows(
array_merge($params, array('sort_field' => 'module_name')),
'sort'
@ -251,7 +254,7 @@ else {
$i++;
}
if (in_array('id_alert_am', $show_fields)) {
if ($fields == 'id_alert_am') {
$table->head[$i] = __('Alert') . html_print_sort_arrows(
array_merge($params, array('sort_field' => 'alert_id')),
'sort'
@ -261,7 +264,7 @@ else {
$i++;
}
if (in_array('criticity', $show_fields)) {
if ($fields == 'criticity') {
$table->head[$i] = __('Severity') . html_print_sort_arrows(
array_merge($params, array('sort_field' => 'criticity')),
'sort'
@ -270,7 +273,7 @@ else {
$i++;
}
if (in_array('user_comment', $show_fields)) {
if ($fields == 'user_comment') {
$table->head[$i] = __('Comment') . html_print_sort_arrows(
array_merge($params, array('sort_field' => 'comment')),
'sort'
@ -279,7 +282,7 @@ else {
$i++;
}
if (in_array('tags', $show_fields)) {
if ($fields == 'tags') {
$table->head[$i] = __('Tags') . html_print_sort_arrows(
array_merge($params, array('sort_field' => 'tags')),
'sort'
@ -288,7 +291,7 @@ else {
$i++;
}
if (in_array('source', $show_fields)) {
if ($fields == 'source') {
$table->head[$i] = __('Source') . html_print_sort_arrows(
array_merge($params, array('sort_field' => 'source')),
'sort'
@ -296,7 +299,7 @@ else {
$i++;
}
if (in_array('id_extra', $show_fields)) {
if ($fields == 'id_extra') {
$table->head[$i] = __('Extra ID') . html_print_sort_arrows(
array_merge($params, array('sort_field' => 'extra_id')),
'sort'
@ -305,7 +308,7 @@ else {
$i++;
}
if (in_array('ack_utimestamp', $show_fields)) {
if ($fields == 'ack_utimestamp') {
$table->head[$i] = __('ACK Timestamp') . html_print_sort_arrows(
array_merge($params, array('sort_field' => 'ack_utimestamp')),
'sort'
@ -314,13 +317,13 @@ else {
$i++;
}
if (in_array('instructions', $show_fields)) {
if ($fields == 'instructions') {
$table->head[$i] = __('Instructions');
$table->align[$i] = 'left';
$i++;
}
if (in_array('data', $show_fields)) {
if ($fields == 'data') {
$table->head[$i] = __('Data') . html_print_sort_arrows(
array_merge($params, array('sort_field' => 'data')),
'sort'
@ -329,7 +332,7 @@ else {
$i++;
}
if (in_array('module_status', $show_fields)) {
if ($fields == 'module_status') {
$table->head[$i] = __('Module Status') . html_print_sort_arrows(
array_merge($params, array('sort_field' => 'module_status')),
'sort'
@ -337,6 +340,7 @@ else {
$i++;
}
}
if ($i != 0 && $allow_action) {
$table->head[$i] = __('Action');
$table->align[$i] = 'left';
@ -447,35 +451,6 @@ else {
$i++;
if (in_array('server_name',$show_fields)) {
if ($meta) {
if (can_user_access_node ()) {
$data[$i] = "<a href='" . $event["server_url"] . "/index.php?sec=estado&sec2=operation/agentes/group_view" . $event['server_url_hash'] . "'>" . $event["server_name"] . "</a>";
}
else {
$data[$i] = $event["server_name"];
}
}
else {
$data[$i] = db_get_value('name','tserver');
}
$table->cellclass[count($table->data)][$i] = $myclass;
$i++;
}
if (in_array('estado',$show_fields)) {
$data[$i] = html_print_image ($img_st, true,
array ("class" => "image_status",
"title" => $title_st,
"id" => 'status_img_'.$event["id_evento"]));
$table->cellstyle[count($table->data)][$i] = 'background: #F3F3F3;';
$i++;
}
if (in_array('id_evento',$show_fields)) {
$data[$i] = $event["id_evento"];
$table->cellclass[count($table->data)][$i] = $myclass;
$i++;
}
switch ($event["criticity"]) {
default:
case 0:
@ -500,8 +475,37 @@ else {
$img_sev = "images/status_sets/default/severity_major.png";
break;
}
foreach ($show_fields as $k_s => $fields) {
if ($fields == 'server_name') {
if ($meta) {
if (can_user_access_node ()) {
$data[$i] = "<a href='" . $event["server_url"] . "/index.php?sec=estado&sec2=operation/agentes/group_view" . $event['server_url_hash'] . "'>" . $event["server_name"] . "</a>";
}
else {
$data[$i] = $event["server_name"];
}
}
else {
$data[$i] = db_get_value('name','tserver');
}
$table->cellclass[count($table->data)][$i] = $myclass;
$i++;
}
if ($fields == 'estado') {
$data[$i] = html_print_image ($img_st, true,
array ("class" => "image_status",
"title" => $title_st,
"id" => 'status_img_'.$event["id_evento"]));
$table->cellstyle[count($table->data)][$i] = 'background: #F3F3F3;';
$i++;
}
if ($fields == 'id_evento') {
$data[$i] = $event["id_evento"];
$table->cellclass[count($table->data)][$i] = $myclass;
$i++;
}
if (in_array('evento', $show_fields)) {
if ($fields == 'evento') {
// Event description
$data[$i] = '<span title="' . strip_tags(io_safe_output($event["evento"])) . '" class="f9">';
if($allow_action) {
@ -516,7 +520,7 @@ else {
$i++;
}
if (in_array('id_agente', $show_fields)) {
if ($fields == 'id_agente') {
$data[$i] = '<span class="'.$myclass.'">';
if ($event["id_agente"] > 0) {
@ -549,7 +553,7 @@ else {
$i++;
}
if (in_array('timestamp', $show_fields)) {
if ($fields == 'timestamp') {
//Time
$data[$i] = '<span class="'.$myclass.'">';
if ($group_rep == 1) {
@ -563,7 +567,7 @@ else {
$i++;
}
if (in_array('id_usuario',$show_fields)) {
if ($fields == 'id_usuario') {
$user_name = db_get_value('fullname', 'tusuario', 'id_user', $event['id_usuario']);
if(empty($user_name)) {
$user_name = $event['id_usuario'];
@ -573,7 +577,7 @@ else {
$i++;
}
if (in_array('owner_user',$show_fields)) {
if ($fields == 'owner_user') {
$owner_name = db_get_value('fullname', 'tusuario', 'id_user', $event['owner_user']);
if(empty($owner_name)) {
$owner_name = $event['owner_user'];
@ -583,7 +587,7 @@ else {
$i++;
}
if (in_array('id_grupo',$show_fields)) {
if ($fields == 'id_grupo') {
if ($meta) {
$data[$i] = $event['group_name'];
}
@ -599,13 +603,13 @@ else {
$i++;
}
if (in_array('event_type',$show_fields)) {
if ($fields == 'event_type') {
$data[$i] = events_print_type_description($event["event_type"], true);
$table->cellclass[count($table->data)][$i] = $myclass;
$i++;
}
if (in_array('id_agentmodule',$show_fields)) {
if ($fields == 'id_agentmodule') {
if ($meta) {
$module_link = '<a href="'.$event["server_url"].'/index.php?sec=estado&amp;sec2=operation/agentes/ver_agente&amp;id_agente=' . $event["id_agente"] . $event["server_url_hash"] . '">';
if (can_user_access_node ()) {
@ -624,7 +628,7 @@ else {
$i++;
}
if (in_array('id_alert_am',$show_fields)) {
if ($fields == 'id_alert_am') {
if($meta) {
$data[$i] = $event["alert_template_name"];
}
@ -647,13 +651,13 @@ else {
$i++;
}
if (in_array('criticity',$show_fields)) {
if ($fields == 'criticity') {
$data[$i] = get_priority_name ($event["criticity"]);
$table->cellclass[count($table->data)][$i] = $myclass;
$i++;
}
if (in_array('user_comment',$show_fields)) {
if ($fields == 'user_comment') {
$safe_event_user_comment = strip_tags(io_safe_output($event["user_comment"]));
$line_breaks = array("\r\n", "\n", "\r");
$safe_event_user_comment = str_replace($line_breaks, '<br>', $safe_event_user_comment);
@ -684,25 +688,25 @@ else {
$i++;
}
if (in_array('tags',$show_fields)) {
if ($fields == 'tags') {
$data[$i] = tags_get_tags_formatted($event['tags']);
$table->cellclass[count($table->data)][$i] = $myclass;
$i++;
}
if (in_array('source',$show_fields)) {
if ($fields == 'source') {
$data[$i] = $event["source"];
$table->cellclass[count($table->data)][$i] = $myclass;
$i++;
}
if (in_array('id_extra',$show_fields)) {
if ($fields == 'id_extra') {
$data[$i] = $event["id_extra"];
$table->cellclass[count($table->data)][$i] = $myclass;
$i++;
}
if (in_array('ack_utimestamp',$show_fields)) {
if ($fields == 'ack_utimestamp') {
if ($event["ack_utimestamp"] == 0) {
$data[$i] = '';
}
@ -713,7 +717,7 @@ else {
$i++;
}
if (in_array('instructions',$show_fields)) {
if ($fields == 'instructions') {
switch($event['event_type']) {
case 'going_unknown':
if(!empty($event["unknown_instructions"])) {
@ -751,7 +755,7 @@ else {
$table->cellclass[count($table->data)][$i] = $myclass;
$i++;
}
if (in_array('data',$show_fields)) {
if ($fields == 'data') {
$data[$i] = $event["data"];
if($data[$i] %1 == 0)
$data[$i]= number_format($data[$i], 0);
@ -760,11 +764,12 @@ else {
$table->cellclass[count($table->data)][$i] = $myclass;
$i++;
}
if (in_array('module_status',$show_fields)) {
if ($fields == 'module_status') {
$data[$i] = modules_get_modules_status ($event["module_status"]);
$table->cellclass[count($table->data)][$i] = $myclass;
$i++;
}
}
if ($i != 0 && $allow_action) {
//Actions

Some files were not shown because too many files have changed in this diff Show More