Merge branch 'develop' into '1979-5352-plugin-de-monitorizacion-log-apache-dev'
# Conflicts: # pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql
This commit is contained in:
commit
080cfb20ca
|
@ -1,5 +1,5 @@
|
|||
# Base config file for Pandora FMS agents
|
||||
# Version 7.0NG.726, AIX version
|
||||
# Version 7.0NG.727, AIX version
|
||||
# Licensed under GPL license v2,
|
||||
# Copyright (c) 2003-2010 Artica Soluciones Tecnologicas
|
||||
# http://www.pandorafms.com
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# Base config file for Pandora FMS agents
|
||||
# Version 7.0NG.726, FreeBSD Version
|
||||
# Version 7.0NG.727, FreeBSD Version
|
||||
# Licensed under GPL license v2,
|
||||
# Copyright (c) 2003-2010 Artica Soluciones Tecnologicas
|
||||
# http://www.pandorafms.com
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# Base config file for Pandora FMS agents
|
||||
# Version 7.0NG.726, HP-UX Version
|
||||
# Version 7.0NG.727, HP-UX Version
|
||||
# Licensed under GPL license v2,
|
||||
# Copyright (c) 2003-2009 Artica Soluciones Tecnologicas
|
||||
# http://www.pandorafms.com
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# Base config file for Pandora FMS agents
|
||||
# Version 7.0NG.726, GNU/Linux
|
||||
# Version 7.0NG.727, GNU/Linux
|
||||
# Licensed under GPL license v2,
|
||||
# Copyright (c) 2003-2009 Artica Soluciones Tecnologicas
|
||||
# http://www.pandorafms.com
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# Base config file for Pandora FMS agents
|
||||
# Version 7.0NG.726, GNU/Linux
|
||||
# Version 7.0NG.727, GNU/Linux
|
||||
# Licensed under GPL license v2,
|
||||
# Copyright (c) 2003-2009 Artica Soluciones Tecnologicas
|
||||
# http://www.pandorafms.com
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# Base config file for Pandora FMS agents
|
||||
# Version 7.0NG.726, Solaris Version
|
||||
# Version 7.0NG.727, Solaris Version
|
||||
# Licensed under GPL license v2,
|
||||
# Copyright (c) 2003-2009 Artica Soluciones Tecnologicas
|
||||
# http://www.pandorafms.com
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# Base config file for Pandora FMS Windows Agent
|
||||
# (c) 2006-2010 Artica Soluciones Tecnologicas
|
||||
# Version 7.0NG.726
|
||||
# Version 7.0NG.727
|
||||
|
||||
# This program is Free Software, you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public Licence as published by the Free Software
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# Fichero de configuracion base de agentes de Pandora
|
||||
# Base config file for Pandora agents
|
||||
# Version 7.0NG.726, AIX version
|
||||
# Version 7.0NG.727, AIX version
|
||||
|
||||
# General Parameters
|
||||
# ==================
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# Fichero de configuracion base de agentes de Pandora
|
||||
# Base config file for Pandora agents
|
||||
# Version 7.0NG.726
|
||||
# Version 7.0NG.727
|
||||
# FreeBSD/IPSO version
|
||||
# Licenced under GPL licence, 2003-2007 Sancho Lerena
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# Fichero de configuracion base de agentes de Pandora
|
||||
# Base config file for Pandora agents
|
||||
# Version 7.0NG.726, HPUX Version
|
||||
# Version 7.0NG.727, HPUX Version
|
||||
|
||||
# General Parameters
|
||||
# ==================
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# Base config file for Pandora FMS agents
|
||||
# Version 7.0NG.726
|
||||
# Version 7.0NG.727
|
||||
# Licensed under GPL license v2,
|
||||
# (c) 2003-2010 Artica Soluciones Tecnologicas
|
||||
# please visit http://pandora.sourceforge.net
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# Base config file for Pandora FMS agents
|
||||
# Version 7.0NG.726
|
||||
# Version 7.0NG.727
|
||||
# Licensed under GPL license v2,
|
||||
# (c) 2003-2009 Artica Soluciones Tecnologicas
|
||||
# please visit http://pandora.sourceforge.net
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# Base config file for Pandora FMS agents
|
||||
# Version 7.0NG.726
|
||||
# Version 7.0NG.727
|
||||
# Licensed under GPL license v2,
|
||||
# please visit http://pandora.sourceforge.net
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# Fichero de configuracion base de agentes de Pandora
|
||||
# Base config file for Pandora agents
|
||||
# Version 7.0NG.726, Solaris version
|
||||
# Version 7.0NG.727, Solaris version
|
||||
|
||||
# General Parameters
|
||||
# ==================
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# Base config file for Pandora FMS agents
|
||||
# Version 7.0NG.726, AIX version
|
||||
# Version 7.0NG.727, AIX version
|
||||
# Licensed under GPL license v2,
|
||||
# Copyright (c) 2003-2010 Artica Soluciones Tecnologicas
|
||||
# http://www.pandorafms.com
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
package: pandorafms-agent-unix
|
||||
Version: 7.0NG.726-180906
|
||||
Version: 7.0NG.727-180917
|
||||
Architecture: all
|
||||
Priority: optional
|
||||
Section: admin
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
pandora_version="7.0NG.726-180906"
|
||||
pandora_version="7.0NG.727-180917"
|
||||
|
||||
echo "Test if you has the tools for to make the packages."
|
||||
whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# Base config file for Pandora FMS agents
|
||||
# Version 7.0NG.726, GNU/Linux
|
||||
# Version 7.0NG.727, GNU/Linux
|
||||
# Licensed under GPL license v2,
|
||||
# Copyright (c) 2003-2012 Artica Soluciones Tecnologicas
|
||||
# http://www.pandorafms.com
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# Base config file for Pandora FMS agents
|
||||
# Version 7.0NG.726, FreeBSD Version
|
||||
# Version 7.0NG.727, FreeBSD Version
|
||||
# Licensed under GPL license v2,
|
||||
# Copyright (c) 2003-2016 Artica Soluciones Tecnologicas
|
||||
# http://www.pandorafms.com
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# Base config file for Pandora FMS agents
|
||||
# Version 7.0NG.726, HP-UX Version
|
||||
# Version 7.0NG.727, HP-UX Version
|
||||
# Licensed under GPL license v2,
|
||||
# Copyright (c) 2003-2009 Artica Soluciones Tecnologicas
|
||||
# http://www.pandorafms.com
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# Base config file for Pandora FMS agents
|
||||
# Version 7.0NG.726, GNU/Linux
|
||||
# Version 7.0NG.727, GNU/Linux
|
||||
# Licensed under GPL license v2,
|
||||
# Copyright (c) 2003-2014 Artica Soluciones Tecnologicas
|
||||
# http://www.pandorafms.com
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# Base config file for Pandora FMS agents
|
||||
# Version 7.0NG.726, GNU/Linux
|
||||
# Version 7.0NG.727, GNU/Linux
|
||||
# Licensed under GPL license v2,
|
||||
# Copyright (c) 2003-2009 Artica Soluciones Tecnologicas
|
||||
# http://www.pandorafms.com
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# Base config file for Pandora FMS agents
|
||||
# Version 7.0NG.726, NetBSD Version
|
||||
# Version 7.0NG.727, NetBSD Version
|
||||
# Licensed under GPL license v2,
|
||||
# Copyright (c) 2003-2010 Artica Soluciones Tecnologicas
|
||||
# http://www.pandorafms.com
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# Base config file for Pandora FMS agents
|
||||
# Version 7.0NG.726, Solaris Version
|
||||
# Version 7.0NG.727, Solaris Version
|
||||
# Licensed under GPL license v2,
|
||||
# Copyright (c) 2003-2009 Artica Soluciones Tecnologicas
|
||||
# http://www.pandorafms.com
|
||||
|
|
|
@ -41,8 +41,8 @@ my $Sem = undef;
|
|||
# Semaphore used to control the number of threads
|
||||
my $ThreadSem = undef;
|
||||
|
||||
use constant AGENT_VERSION => '7.0NG.726';
|
||||
use constant AGENT_BUILD => '180906';
|
||||
use constant AGENT_VERSION => '7.0NG.727';
|
||||
use constant AGENT_BUILD => '180917';
|
||||
|
||||
# Agent log default file size maximum and instances
|
||||
use constant DEFAULT_MAX_LOG_SIZE => 600000;
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
#Pandora FMS Linux Agent
|
||||
#
|
||||
%define name pandorafms_agent_unix
|
||||
%define version 7.0NG.726
|
||||
%define release 180906
|
||||
%define version 7.0NG.727
|
||||
%define release 180917
|
||||
|
||||
Summary: Pandora FMS Linux agent, PERL version
|
||||
Name: %{name}
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
#Pandora FMS Linux Agent
|
||||
#
|
||||
%define name pandorafms_agent_unix
|
||||
%define version 7.0NG.726
|
||||
%define release 180906
|
||||
%define version 7.0NG.727
|
||||
%define release 180917
|
||||
|
||||
Summary: Pandora FMS Linux agent, PERL version
|
||||
Name: %{name}
|
||||
|
|
|
@ -9,8 +9,8 @@
|
|||
# Please see http://www.pandorafms.org. This code is licensed under GPL 2.0 license.
|
||||
# **********************************************************************
|
||||
|
||||
PI_VERSION="7.0NG.726"
|
||||
PI_BUILD="180906"
|
||||
PI_VERSION="7.0NG.727"
|
||||
PI_BUILD="180917"
|
||||
OS_NAME=`uname -s`
|
||||
|
||||
FORCE=0
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# Base config file for Pandora FMS Windows Agent
|
||||
# (c) 2006-2017 Artica Soluciones Tecnologicas
|
||||
# Version 7.0NG.726
|
||||
# Version 7.0NG.727
|
||||
|
||||
# This program is Free Software, you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public Licence as published by the Free Software
|
||||
|
|
|
@ -3,7 +3,7 @@ AllowLanguageSelection
|
|||
{Yes}
|
||||
|
||||
AppName
|
||||
{Pandora FMS Windows Agent v7.0NG.726}
|
||||
{Pandora FMS Windows Agent v7.0NG.727}
|
||||
|
||||
ApplicationID
|
||||
{17E3D2CF-CA02-406B-8A80-9D31C17BD08F}
|
||||
|
@ -186,7 +186,7 @@ UpgradeApplicationID
|
|||
{}
|
||||
|
||||
Version
|
||||
{180906}
|
||||
{180917}
|
||||
|
||||
ViewReadme
|
||||
{Yes}
|
||||
|
|
|
@ -30,7 +30,7 @@ using namespace Pandora;
|
|||
using namespace Pandora_Strutils;
|
||||
|
||||
#define PATH_SIZE _MAX_PATH+1
|
||||
#define PANDORA_VERSION ("7.0NG.726(Build 180906)")
|
||||
#define PANDORA_VERSION ("7.0NG.727(Build 180917)")
|
||||
|
||||
string pandora_path;
|
||||
string pandora_dir;
|
||||
|
|
|
@ -11,7 +11,7 @@ BEGIN
|
|||
VALUE "LegalCopyright", "Artica ST"
|
||||
VALUE "OriginalFilename", "PandoraAgent.exe"
|
||||
VALUE "ProductName", "Pandora FMS Windows Agent"
|
||||
VALUE "ProductVersion", "(7.0NG.726(Build 180906))"
|
||||
VALUE "ProductVersion", "(7.0NG.727(Build 180917))"
|
||||
VALUE "FileVersion", "1.0.0.0"
|
||||
END
|
||||
END
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
package: pandorafms-console
|
||||
Version: 7.0NG.726-180906
|
||||
Version: 7.0NG.727-180917
|
||||
Architecture: all
|
||||
Priority: optional
|
||||
Section: admin
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
pandora_version="7.0NG.726-180906"
|
||||
pandora_version="7.0NG.727-180917"
|
||||
|
||||
package_pear=0
|
||||
package_pandora=1
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
Order deny,allow
|
||||
Deny from All
|
|
@ -12,9 +12,19 @@ ALTER TABLE tagente_modulo ALTER COLUMN `parent_module_id` SET default 0;
|
|||
ALTER TABLE `tlayout_data` ADD COLUMN `linked_layout_status_type` ENUM ('default', 'weight', 'service') DEFAULT 'default';
|
||||
ALTER TABLE `tlayout_data` ADD COLUMN `linked_layout_status_as_service_warning` FLOAT(20, 3) NOT NULL default 0;
|
||||
ALTER TABLE `tlayout_data` ADD COLUMN `linked_layout_status_as_service_critical` FLOAT(20, 3) NOT NULL default 0;
|
||||
ALTER TABLE `tlayout_data` ADD COLUMN `linked_layout_node_id` INT(10) NOT NULL default 0;
|
||||
ALTER TABLE `tlayout_template_data` ADD COLUMN `linked_layout_status_type` ENUM ('default', 'weight', 'service') DEFAULT 'default';
|
||||
ALTER TABLE `tlayout_template_data` ADD COLUMN `linked_layout_status_as_service_warning` FLOAT(20, 3) NOT NULL default 0;
|
||||
ALTER TABLE `tlayout_template_data` ADD COLUMN `linked_layout_status_as_service_critical` FLOAT(20, 3) NOT NULL default 0;
|
||||
ALTER TABLE `tlayout_template_data` ADD COLUMN `linked_layout_node_id` INT(10) NOT NULL default 0;
|
||||
|
||||
-- -----------------------------------------------------
|
||||
-- Add column in table `treport`
|
||||
-- -----------------------------------------------------
|
||||
|
||||
ALTER TABLE `treport` ADD COLUMN `hidden` tinyint(1) NOT NULL DEFAULT 0;
|
||||
|
||||
ALTER TABLE `tpolicy_modules_inventory` ADD COLUMN `custom_fields` MEDIUMBLOB NOT NULL;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `tlog_graph_models` (
|
||||
`id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
|
|
|
@ -1784,3 +1784,10 @@ CREATE TABLE IF NOT EXISTS `tlog_graph_models` (
|
|||
INSERT INTO tlog_graph_models VALUES (1, 'Apache log model',
|
||||
'^.*?\s+.*".*?\s(\/.*?)\?.*1.1"\s+(.*?)\s+(.*?)\s+',
|
||||
'pagina, html_err_code, _tiempo_', 1);
|
||||
|
||||
-- -----------------------------------------------------
|
||||
-- Add column in table `treport`
|
||||
-- -----------------------------------------------------
|
||||
|
||||
ALTER TABLE `treport` ADD COLUMN `hidden` tinyint(1) NOT NULL DEFAULT 0;
|
||||
|
||||
|
|
|
@ -32,39 +32,38 @@ if (is_ajax ()) {
|
|||
require ("general/noaccess.php");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
$get_group_json = (bool) get_parameter ('get_group_json');
|
||||
$get_group_agents = (bool) get_parameter ('get_group_agents');
|
||||
$get_is_disabled = (bool) get_parameter ('get_is_disabled');
|
||||
|
||||
|
||||
if ($get_group_json) {
|
||||
$id_group = (int) get_parameter ('id_group');
|
||||
|
||||
|
||||
if ($id_group == 0) {
|
||||
$group = array('id_grupo' => 0,
|
||||
'nombre' => 'All',
|
||||
'nombre' => 'All',
|
||||
'icon' => 'world',
|
||||
'parent' => 0,
|
||||
'disabled' => 0,
|
||||
'custom_id' => null);
|
||||
|
||||
echo json_encode ($group);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (! check_acl ($config['id_user'], $id_group, "AR")) {
|
||||
db_pandora_audit("ACL Violation",
|
||||
"Trying to access Alert Management");
|
||||
echo json_encode (false);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
$group = db_get_row ('tgrupo', 'id_grupo', $id_group);
|
||||
|
||||
|
||||
echo json_encode ($group);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if ($get_group_agents) {
|
||||
ob_clean();
|
||||
$id_group = (int) get_parameter ('id_group');
|
||||
|
@ -86,33 +85,33 @@ if (is_ajax ()) {
|
|||
$serialized = (bool)get_parameter('serialized', false);
|
||||
$serialized_separator = (string)get_parameter('serialized_separator', "|");
|
||||
$force_serialized = (bool)get_parameter('force_serialized', false);
|
||||
|
||||
|
||||
if (! check_acl ($config['id_user'], $id_group, "AR")) {
|
||||
db_pandora_audit("ACL Violation",
|
||||
"Trying to access Alert Management");
|
||||
echo json_encode (false);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if ( https_is_running() ) {
|
||||
header('Content-type: application/json');
|
||||
}
|
||||
|
||||
|
||||
if ($filter_agents_json != '') {
|
||||
$filter['id_agente'] = json_decode(io_safe_output($filter_agents_json), true);
|
||||
}
|
||||
|
||||
|
||||
if ($all_agents) {
|
||||
$filter['all_agents'] = true;
|
||||
}
|
||||
else {
|
||||
$filter['disabled'] = $disabled;
|
||||
}
|
||||
|
||||
|
||||
if ($search != '') {
|
||||
$filter['string'] = $search;
|
||||
}
|
||||
|
||||
|
||||
if ($status_agents != AGENT_STATUS_ALL) {
|
||||
$filter['status'] = $status_agents;
|
||||
}
|
||||
|
@ -120,10 +119,8 @@ if (is_ajax ()) {
|
|||
# Juanma (22/05/2014) Fix: If remove void agents setted
|
||||
$_sql_post = ' 1=1 ';
|
||||
if ($show_void_agents == 0) {
|
||||
|
||||
$_sql_post .= ' AND id_agente IN (SELECT a.id_agente FROM tagente a, tagente_modulo b WHERE a.id_agente=b.id_agente AND b.delete_pending=0) AND \'1\'';
|
||||
$filter[$_sql_post] = '1';
|
||||
|
||||
}
|
||||
|
||||
$id_groups_get_agents = $id_group;
|
||||
|
@ -192,7 +189,7 @@ if (is_ajax ()) {
|
|||
|
||||
$agents = $all_agents_array;
|
||||
}
|
||||
|
||||
|
||||
echo json_encode ($agents);
|
||||
return;
|
||||
}
|
||||
|
@ -208,11 +205,10 @@ if (is_ajax ()) {
|
|||
echo json_encode($return);
|
||||
return;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (! check_acl($config['id_user'], 0, "AW")) {
|
||||
if (! check_acl($config['id_user'], 0, "PM")) {
|
||||
db_pandora_audit("ACL Violation",
|
||||
"Trying to access Group Management");
|
||||
require ("general/noaccess.php");
|
||||
|
@ -221,24 +217,20 @@ if (! check_acl($config['id_user'], 0, "AW")) {
|
|||
|
||||
// Header
|
||||
if (defined('METACONSOLE')) {
|
||||
|
||||
agents_meta_print_header();
|
||||
$sec = 'advanced';
|
||||
|
||||
echo '<div class="notify">';
|
||||
echo __("Edit or delete groups can cause problems with synchronization");
|
||||
echo '</div>';
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
ui_print_page_header (__("Groups defined in %s", get_product_name()),
|
||||
"images/group.png", false, "", true, "");
|
||||
ui_print_page_header (
|
||||
__("Groups defined in %s", get_product_name()),
|
||||
"images/group.png", false, "", true, ""
|
||||
);
|
||||
$sec = 'gagente';
|
||||
|
||||
}
|
||||
|
||||
|
||||
$create_group = (bool) get_parameter ('create_group');
|
||||
$update_group = (bool) get_parameter ('update_group');
|
||||
$delete_group = (bool) get_parameter ('delete_group');
|
||||
|
@ -258,7 +250,7 @@ if (($create_group) && (check_acl($config['id_user'], 0, "PM"))) {
|
|||
$other = (string) get_parameter ('other');
|
||||
$check = db_get_value('nombre', 'tgrupo', 'nombre', $name);
|
||||
$propagate = (bool) get_parameter('propagate');
|
||||
|
||||
|
||||
/*Check if name field is empty*/
|
||||
if ($name != "") {
|
||||
if (!$check) {
|
||||
|
@ -275,7 +267,7 @@ if (($create_group) && (check_acl($config['id_user'], 0, "PM"))) {
|
|||
'other' => $other,
|
||||
'password' => io_safe_input($group_pass)
|
||||
);
|
||||
|
||||
|
||||
$result = db_process_sql_insert('tgrupo', $values);
|
||||
if ($result) {
|
||||
ui_print_success_message(__('Group successfully created'));
|
||||
|
@ -309,7 +301,7 @@ if ($update_group) {
|
|||
$description = (string) get_parameter ('description');
|
||||
$contact = (string) get_parameter ('contact');
|
||||
$other = (string) get_parameter ('other');
|
||||
|
||||
|
||||
/*Check if name field is empty*/
|
||||
if ( $name != "") {
|
||||
switch ($config["dbtype"]) {
|
||||
|
@ -332,7 +324,7 @@ if ($update_group) {
|
|||
else {
|
||||
$result = false;
|
||||
}
|
||||
|
||||
|
||||
if ($result !== false) {
|
||||
ui_print_success_message(__('Group successfully updated'));
|
||||
}
|
||||
|
@ -344,19 +336,19 @@ if ($update_group) {
|
|||
/* Delete group */
|
||||
if (($delete_group) && (check_acl($config['id_user'], 0, "PM"))) {
|
||||
$id_group = (int) get_parameter ('id_group');
|
||||
|
||||
|
||||
$usedGroup = groups_check_used($id_group);
|
||||
|
||||
|
||||
if (!$usedGroup['return']) {
|
||||
$group = db_get_row_filter('tgrupo',
|
||||
array('id_grupo' => $id_group));
|
||||
|
||||
|
||||
db_process_sql_update('tgrupo',
|
||||
array('parent' => $group['parent']), array('parent' => $id_group));
|
||||
|
||||
|
||||
$result = db_process_sql_delete('tgroup_stat',
|
||||
array('id_group' => $id_group));
|
||||
|
||||
|
||||
$result = db_process_sql_delete('tgrupo',
|
||||
array('id_grupo' => $id_group));
|
||||
}
|
||||
|
@ -364,136 +356,166 @@ if (($delete_group) && (check_acl($config['id_user'], 0, "PM"))) {
|
|||
ui_print_error_message(
|
||||
sprintf(__('The group is not empty. It is use in %s.'), implode(', ', $usedGroup['tables'])));
|
||||
}
|
||||
|
||||
|
||||
if ($result && (!$usedGroup['return'])) {
|
||||
ui_print_success_message(__('Group successfully deleted'));
|
||||
}
|
||||
}
|
||||
else {
|
||||
ui_print_error_message(__('There was a problem deleting group'));
|
||||
}
|
||||
}
|
||||
db_clean_cache();
|
||||
|
||||
if ($create_group || $delete_group || $update_group) {
|
||||
$groups = users_get_groups ($config['id_user'], "AR", true, true, null, 'id_grupo', false);
|
||||
$groups = groups_get_groups_tree_recursive($groups);
|
||||
} else {
|
||||
$groups = users_get_groups_tree ($config['id_user'], "AR", true);
|
||||
$acl='';
|
||||
$search_name = '';
|
||||
$offset = (int)get_parameter('offset', 0);
|
||||
$search = (string)get_parameter('search', '');
|
||||
$block_size = $config['block_size'];
|
||||
|
||||
if(!empty($search)){
|
||||
$search_name = "AND t.nombre LIKE '%$search%'";
|
||||
}
|
||||
|
||||
$table = new StdClass();
|
||||
$table->width = '100%';
|
||||
if (!users_can_manage_group_all("AR")){
|
||||
$user_groups_acl = users_get_groups(false, "AR");
|
||||
$groups_acl = implode(",", $user_groups_ACL);
|
||||
if(empty($groups_acl)) return ui_print_info_message ( array('no_close'=>true, 'message'=> __('There are no defined groups') ) );
|
||||
|
||||
$all_parents = array();
|
||||
$groups_count = 0;
|
||||
$sons = array();
|
||||
|
||||
$groups_count = count($groups);
|
||||
|
||||
foreach ($groups as $k => $g) {
|
||||
if ($g['parent'] != 0) {
|
||||
$all_parents[$g['parent']] = $g['parent'];
|
||||
}
|
||||
}
|
||||
krsort($all_parents);
|
||||
foreach ($all_parents as $parent) {
|
||||
foreach ($groups as $k => $g) {
|
||||
if ($g['parent'] == $parent) {
|
||||
$sons[$g['parent']][] = $g;
|
||||
unset($groups[$k]);
|
||||
}
|
||||
}
|
||||
$acl = "AND t.id_grupo IN ($groups_acl)";
|
||||
}
|
||||
|
||||
$form = "<form method='post' action=''>";
|
||||
$form .= "<table class='databox filters' width='100%' style='font-weight: bold;'>";
|
||||
$form .= "<tr><td>" . __('Search') . ' ';
|
||||
$form .= html_print_input_text ("search", $search, '', 100, 100, true);
|
||||
$form .= "</td><td>";
|
||||
$form .= "<input name='find' type='submit' class='sub search' value='".__('Search')."'>";
|
||||
$form .= "<td></tr>";
|
||||
$form .= "</table>";
|
||||
$form .= "</form>";
|
||||
|
||||
echo $form;
|
||||
|
||||
$groups_sql =
|
||||
"SELECT t.*,
|
||||
p.nombre AS parent_name,
|
||||
IF(t.parent=p.id_grupo, 1, 0) AS has_child
|
||||
FROM tgrupo t
|
||||
LEFT JOIN tgrupo p
|
||||
ON t.parent=p.id_grupo
|
||||
WHERE 1=1
|
||||
$acl
|
||||
$search_name
|
||||
ORDER BY nombre
|
||||
LIMIT $offset, $block_size
|
||||
";
|
||||
|
||||
$groups = db_get_all_rows_sql($groups_sql);
|
||||
|
||||
if (!empty($groups)) {
|
||||
//Count all groups for pagination only saw user and filters
|
||||
$groups_sql_count = "SELECT count(*)
|
||||
FROM tgrupo t
|
||||
WHERE 1=1
|
||||
$acl
|
||||
$search_name
|
||||
";
|
||||
$groups_count = db_get_value_sql($groups_sql_count);
|
||||
|
||||
$table = new StdClass();
|
||||
$table->width = '100%';
|
||||
$table->class = "databox data";
|
||||
$table->head = array ();
|
||||
$table->head[0] = __('Name');
|
||||
$table->head[1] = __('ID');
|
||||
$table->head[0] = __('ID');
|
||||
$table->head[1] = __('Name');
|
||||
$table->head[2] = __('Icon');
|
||||
$table->head[3] = __('Alerts');
|
||||
$table->head[4] = __('Description');
|
||||
$table->head[5] = __('Actions');
|
||||
$table->head[4] = __('Parent');
|
||||
$table->head[5] = __('Description');
|
||||
$table->head[6] = __('Actions');
|
||||
$table->align = array ();
|
||||
$table->align[0] = 'right';
|
||||
$table->align[2] = 'left';
|
||||
$table->align[5] = 'left';
|
||||
$table->size[4] = '30%';
|
||||
$table->size[5] = '10%';
|
||||
$table->align[6] = 'left';
|
||||
$table->size[5] = '30%';
|
||||
$table->size[6] = '10%';
|
||||
$table->data = array ();
|
||||
|
||||
$offset = (int)get_parameter('offset', 0);
|
||||
$limit = $offset + $config['block_size'];
|
||||
|
||||
|
||||
|
||||
$pagination = ui_pagination($groups_count,
|
||||
false, 0, $config['block_size'], true, 'offset', false);
|
||||
|
||||
$n = -1;
|
||||
$iterator = 0;
|
||||
$branch_classes = array();
|
||||
foreach ($groups as $group) {
|
||||
$n++;
|
||||
|
||||
// Only print the page range
|
||||
if ($n < $offset || $n >= $limit) {
|
||||
continue;
|
||||
|
||||
foreach ($groups as $key => $group) {
|
||||
$url = "index.php?sec=gagente&sec2=godmode/groups/configure_group&id_group=".$group['id_grupo'];
|
||||
$url_delete = "index.php?sec=gagente&sec2=godmode/groups/group_list&delete_group=1&id_group=" . $group['id_grupo'];
|
||||
$table->data[$key][0] = $group['id_grupo'];
|
||||
$table->data[$key][1] = "<a href='$url'>" . $group['nombre'] . "</a>";
|
||||
$table->data[$key][2] = html_print_image(
|
||||
"images/groups_small/" . $group['icon'] . ".png",
|
||||
true,
|
||||
array(
|
||||
"style" => '',
|
||||
"class" => "bot",
|
||||
"alt" => $group['nombre'],
|
||||
"title" => $group['nombre'],
|
||||
false, false, false, true
|
||||
)
|
||||
);
|
||||
|
||||
//reporting_get_group_stats
|
||||
$table->data[$key][3] = $group['disabled'] ? __('Disabled') : __('Enabled');
|
||||
$table->data[$key][4] = $group['parent_name'];
|
||||
$table->data[$key][5] = $group['description'];
|
||||
$table->data[$key][6] = "<a href='$url'>" .
|
||||
html_print_image(
|
||||
"images/config.png",
|
||||
true,
|
||||
array(
|
||||
"alt" => __('Edit'),
|
||||
"title" => __('Edit'),
|
||||
"border" => '0'
|
||||
)
|
||||
) .
|
||||
"</a>";
|
||||
|
||||
$confirm_message = __('Are you sure?');
|
||||
if ($group['has_child']) {
|
||||
$confirm_message = __('The child groups will be updated to use the parent id of the deleted group') . ". " . $confirm_message;
|
||||
}
|
||||
|
||||
$symbolBranchs = ' symbol_branch_' . $group['parent'];
|
||||
|
||||
$has_children = isset($sons[$group['id_grupo']]);
|
||||
$data = groups_get_group_to_list($group, $groups_count, $symbolBranchs, $has_children);
|
||||
array_push ($table->data, $data);
|
||||
$table->rowstyle[$iterator] = '';
|
||||
if ($group['id_grupo'] != 0) {
|
||||
$branch_classes[$group['id_grupo']] = ' branch_0';
|
||||
$table->rowclass[$iterator] = 'parent_' . $group['parent'] . ' branch_0';
|
||||
}
|
||||
$iterator++;
|
||||
|
||||
groups_print_group_sons($group, $sons, $branch_classes,
|
||||
$groups_count, $table, $iterator, $symbolBranchs);
|
||||
|
||||
$table->data[$key][6] .= ' ' .
|
||||
'<a href="'. $url_delete. '" onClick="if (!confirm(\' '.$confirm_message.'\')) return false;">' .
|
||||
html_print_image(
|
||||
"images/cross.png",
|
||||
true,
|
||||
array(
|
||||
"alt" => __('Delete'),
|
||||
"title" => __('Delete'),
|
||||
"border" => '0'
|
||||
)
|
||||
) .
|
||||
"</a>";
|
||||
|
||||
}
|
||||
|
||||
echo $pagination;
|
||||
|
||||
|
||||
echo ui_pagination(
|
||||
$groups_count, false,
|
||||
$offset, $block_size,
|
||||
true, 'offset', false
|
||||
);
|
||||
html_print_table ($table);
|
||||
|
||||
echo $pagination;
|
||||
echo ui_pagination(
|
||||
$groups_count, false,
|
||||
$offset, $block_size,
|
||||
true, 'offset', true
|
||||
);
|
||||
}
|
||||
else {
|
||||
ui_print_info_message ( array('no_close'=>true, 'message'=> __('There are no defined groups') ) );
|
||||
}
|
||||
|
||||
if (check_acl($config['id_user'], 0, "PM")) {
|
||||
echo '<form method="post" action="index.php?sec='.$sec.'&sec2=godmode/groups/configure_group&pure='.$pure.'">';
|
||||
echo '<div class="action-buttons" style="width: '.$table->width.'">';
|
||||
html_print_submit_button (__('Create group'), 'crt', false, 'class="sub next"');
|
||||
echo '</div>';
|
||||
echo '<form method="post" action="index.php?sec='.$sec.'&sec2=godmode/groups/configure_group">';
|
||||
echo '<div class="action-buttons" style="width:100%;">';
|
||||
html_print_submit_button (__('Create group'), 'crt', false, 'class="sub next"');
|
||||
echo '</div>';
|
||||
echo '</form>';
|
||||
}
|
||||
|
||||
enterprise_hook('close_meta_frame');
|
||||
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
function showBranch(parent) {
|
||||
display = $('.parent_' + parent).css('display');
|
||||
|
||||
if (display != 'none') {
|
||||
$('.symbol_' + parent).html('+');
|
||||
$('.parent_' + parent).css('display', 'none');
|
||||
|
||||
//Close the child branch too
|
||||
$('.branch_' + parent).css('display', 'none');
|
||||
$('.symbol_branch_' + parent).html('+');
|
||||
}
|
||||
else {
|
||||
$('.symbol_' + parent).html('-');
|
||||
$('.parent_' + parent).css('display', '');
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -829,6 +829,7 @@ function readFields() {
|
|||
values['bars_graph_type'] = $("select[name=bars_graph_type]").val();
|
||||
values['parent'] = $("select[name=parent]").val();
|
||||
values['map_linked'] = $("select[name=map_linked]").val();
|
||||
values['linked_map_node_id'] = $("input[name=linked_map_node_id]").val();
|
||||
values['linked_map_status_calculation_type'] = $("select[name=linked_map_status_calculation_type]").val();
|
||||
values['map_linked_weight'] = $("input[name=map_linked_weight]").val();
|
||||
values['linked_map_status_service_critical'] = $("input[name=linked_map_status_service_critical]").val();
|
||||
|
@ -1542,8 +1543,15 @@ function loadFieldsFromDB(item) {
|
|||
$("select[name=parent]").val(val);
|
||||
if (key == 'linked_layout_status_type')
|
||||
$("select[name=linked_map_status_calculation_type]").val(val).change();
|
||||
if (key == 'id_layout_linked')
|
||||
$("select[name=map_linked]").val(val).change();
|
||||
if (key == 'id_layout_linked') {
|
||||
if (data['linked_layout_node_id'] == null)
|
||||
$("select[name=map_linked]").val(val).change();
|
||||
else
|
||||
$("select[name=map_linked] > option[data-node-id=" + data['linked_layout_node_id'] + "][value=" + val + "]")
|
||||
.prop("selected", true).change();
|
||||
}
|
||||
if (key == 'linked_layout_node_id')
|
||||
$("input[name=linked_map_node_id]").val(val);
|
||||
if (key == 'id_layout_linked_weight')
|
||||
$("input[name=map_linked_weight]").val(val);
|
||||
if (key == 'linked_layout_status_as_service_critical')
|
||||
|
@ -1958,6 +1966,7 @@ function cleanFields(item) {
|
|||
$("select[name=parent]").val('');
|
||||
$("select[name=linked_map_status_calculation_type]").val('default').change();
|
||||
$("select[name=map_linked]").val('').change();
|
||||
$("input[name=linked_map_node_id]").val(0);
|
||||
$("input[name=map_linked_weight]").val('');
|
||||
$("input[name=linked_map_status_service_critical]").val('');
|
||||
$("input[name=linked_map_status_service_warning]").val('');
|
||||
|
|
|
@ -833,7 +833,7 @@ ui_require_javascript_file('pandora_modules');
|
|||
i++;
|
||||
}
|
||||
|
||||
$('#command_preview').html(command+' '+parameters);
|
||||
$('#command_preview').html(_.escape(command) + ' ' + _.escape(parameters));
|
||||
}
|
||||
|
||||
function show_locked_dialog(id_plugin, plugin_name) {
|
||||
|
|
|
@ -709,6 +709,10 @@ $table_chars->data[$row][1] = html_print_select($options_zoom_graphs, 'zoom_grap
|
|||
$row++;
|
||||
|
||||
$table_chars->data[$row][0] = __('Graph image height');
|
||||
$table_chars->data[$row][0] .= ui_print_help_tip(
|
||||
__('This is the height in pixels of the module graph or custom graph in the reports (both: HTML and PDF)'),
|
||||
true
|
||||
);
|
||||
$table_chars->data[$row][1] = html_print_input_text ('graph_image_height', $config['graph_image_height'], '', 20, 20, true);
|
||||
$row++;
|
||||
|
||||
|
|
|
@ -152,7 +152,8 @@ if ($create_user) {
|
|||
ui_print_error_message (__('The current authentication scheme doesn\'t support creating users on %s', get_product_name()));
|
||||
return;
|
||||
}
|
||||
|
||||
if (html_print_csrf_error()) return;
|
||||
|
||||
$values = array ();
|
||||
$values['id_user'] = (string) get_parameter ('id_user');
|
||||
$values['fullname'] = (string) get_parameter ('fullname');
|
||||
|
@ -279,6 +280,8 @@ if ($create_user) {
|
|||
}
|
||||
|
||||
if ($update_user) {
|
||||
if (html_print_csrf_error()) return;
|
||||
|
||||
$values = array ();
|
||||
$values['id_user'] = (string) get_parameter ('id_user');
|
||||
$values['fullname'] = (string) get_parameter ('fullname');
|
||||
|
@ -705,14 +708,12 @@ echo '<form method="post" autocomplete="off">';
|
|||
html_print_table ($table);
|
||||
|
||||
echo '<div style="width: '.$table->width.'" class="action-buttons">';
|
||||
if ($new_user) {
|
||||
if ($config['admin_can_add_user']) {
|
||||
if ($config['admin_can_add_user']) {
|
||||
html_print_csrf_hidden();
|
||||
if ($new_user) {
|
||||
html_print_input_hidden ('create_user', 1);
|
||||
html_print_submit_button (__('Create'), 'crtbutton', false, 'class="sub wand"');
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ($config['user_can_update_info']) {
|
||||
} else {
|
||||
html_print_input_hidden ('update_user', 1);
|
||||
html_print_submit_button (__('Update'), 'uptbutton', false, 'class="sub upd"');
|
||||
}
|
||||
|
|
|
@ -100,6 +100,7 @@ $width = get_parameter('width', null);
|
|||
$height = get_parameter('height', null);
|
||||
$parent = get_parameter('parent', null);
|
||||
$map_linked = get_parameter('map_linked', null);
|
||||
$linked_map_node_id = get_parameter('linked_map_node_id', null);
|
||||
$linked_map_status_calculation_type = get_parameter('linked_map_status_calculation_type', 'default');
|
||||
|
||||
$map_linked_weight = get_parameter('map_linked_weight', null);
|
||||
|
@ -613,6 +614,10 @@ switch ($action) {
|
|||
if ($id_agent !== null) {
|
||||
$values['id_agent'] = $id_agent;
|
||||
}
|
||||
|
||||
if ($linked_map_node_id !== null) {
|
||||
$values['linked_layout_node_id'] = (int) $linked_map_node_id;
|
||||
}
|
||||
}
|
||||
else if ($id_agent == 0) {
|
||||
$values['id_agent'] = 0;
|
||||
|
@ -1135,6 +1140,11 @@ switch ($action) {
|
|||
}
|
||||
$values['id_agente_modulo'] = $id_module;
|
||||
$values['id_layout_linked'] = $map_linked;
|
||||
|
||||
if (defined('METACONSOLE') && $metaconsole) {
|
||||
$values['linked_layout_node_id'] = (int) $linked_map_node_id;
|
||||
}
|
||||
|
||||
$values['linked_layout_status_type'] = $linked_map_status_calculation_type;
|
||||
|
||||
if ($map_linked_weight !== null) {
|
||||
|
@ -1419,7 +1429,6 @@ if ($get_element_status) {
|
|||
array('id' => $id_element));
|
||||
|
||||
$res = visual_map_get_status_element($layoutData);
|
||||
html_debug($res, true);
|
||||
echo $res;
|
||||
|
||||
return;
|
||||
|
|
|
@ -19,6 +19,7 @@ class Tree {
|
|||
protected $id = -1;
|
||||
protected $rootID = -1;
|
||||
protected $serverID = false;
|
||||
protected $serverName = '';
|
||||
protected $tree = array();
|
||||
protected $filter = array();
|
||||
protected $childrenMethod = "on_demand";
|
||||
|
@ -50,6 +51,9 @@ class Tree {
|
|||
$this->id = $id;
|
||||
$this->rootID = !empty($rootID) ? $rootID : $id;
|
||||
$this->serverID = $serverID;
|
||||
if (is_metaconsole()) {
|
||||
$this->serverName = metaconsole_get_server_by_id($serverID);
|
||||
}
|
||||
$this->childrenMethod = $childrenMethod;
|
||||
$this->access = $access;
|
||||
|
||||
|
@ -151,23 +155,23 @@ class Tree {
|
|||
return array(
|
||||
'warning' => array(
|
||||
'header' => "0 AS x_critical, SUM(total) AS x_warning, 0 AS x_normal, 0 AS x_unknown, 0 AS x_not_init, 0 AS x_alerts, 0 AS x_total, g",
|
||||
'condition' => "AND ta.warning_count > 0 AND ta.critical_count = 0"
|
||||
'condition' => "AND " . agents_get_status_clause(AGENT_STATUS_WARNING, $this->filter['show_not_init_agents'])
|
||||
),
|
||||
'critical' => array(
|
||||
'header' => "SUM(total) AS x_critical, 0 AS x_warning, 0 AS x_normal, 0 AS x_unknown, 0 AS x_not_init, 0 AS x_alerts, 0 AS x_total, g",
|
||||
'condition' => "AND ta.critical_count > 0"
|
||||
'condition' => "AND " . agents_get_status_clause(AGENT_STATUS_CRITICAL, $this->filter['show_not_init_agents'])
|
||||
),
|
||||
'normal' => array(
|
||||
'header' => "0 AS x_critical, 0 AS x_warning, SUM(total) AS x_normal, 0 AS x_unknown, 0 AS x_not_init, 0 AS x_alerts, 0 AS x_total, g",
|
||||
'condition' => "AND ta.critical_count = 0 AND ta.warning_count = 0 AND ta.unknown_count = 0 AND ta.normal_count > 0"
|
||||
'condition' => "AND " . agents_get_status_clause(AGENT_STATUS_NORMAL, $this->filter['show_not_init_agents'])
|
||||
),
|
||||
'unknown' => array(
|
||||
'header' => "0 AS x_critical, 0 AS x_warning, 0 AS x_normal, SUM(total) AS x_unknown, 0 AS x_not_init, 0 AS x_alerts, 0 AS x_total, g",
|
||||
'condition' => "AND ta.critical_count = 0 AND ta.warning_count = 0 AND ta.unknown_count > 0"
|
||||
'condition' => "AND " . agents_get_status_clause(AGENT_STATUS_UNKNOWN, $this->filter['show_not_init_agents'])
|
||||
),
|
||||
'not_init' => array(
|
||||
'header' => "0 AS x_critical, 0 AS x_warning, 0 AS x_normal, 0 AS x_unknown, SUM(total) AS x_not_init, 0 AS x_alerts, 0 AS x_total, g",
|
||||
'condition' => $this->filter['show_not_init_agents'] ? "AND ta.total_count = ta.notinit_count" : " AND 1=0"
|
||||
'condition' => "AND " . agents_get_status_clause(AGENT_STATUS_NOT_INIT, $this->filter['show_not_init_agents'])
|
||||
),
|
||||
'alerts' => array(
|
||||
'header' => "0 AS x_critical, 0 AS x_warning, 0 AS x_normal, 0 AS x_unknown, 0 AS x_not_init, SUM(total) AS x_alerts, 0 AS x_total, g",
|
||||
|
@ -175,7 +179,7 @@ class Tree {
|
|||
),
|
||||
'total' => array(
|
||||
'header' => "0 AS x_critical, 0 AS x_warning, 0 AS x_normal, 0 AS x_unknown, 0 AS x_not_init, 0 AS x_alerts, SUM(total) AS x_total, g",
|
||||
'condition' => $this->filter['show_not_init_agents'] ? "" : "AND ta.total_count <> ta.notinit_count"
|
||||
'condition' => "AND " . agents_get_status_clause(AGENT_STATUS_ALL, $this->filter['show_not_init_agents'])
|
||||
)
|
||||
);
|
||||
}
|
||||
|
@ -228,43 +232,9 @@ class Tree {
|
|||
? $state
|
||||
: $this->filter['statusModule'];
|
||||
|
||||
$filter = array();
|
||||
switch ($selected_status) {
|
||||
case AGENT_MODULE_STATUS_CRITICAL_ALERT:
|
||||
case AGENT_MODULE_STATUS_CRITICAL_BAD:
|
||||
$filter[] = "(
|
||||
tae.estado = ".AGENT_MODULE_STATUS_CRITICAL_ALERT."
|
||||
OR tae.estado = ".AGENT_MODULE_STATUS_CRITICAL_BAD."
|
||||
)";
|
||||
break;
|
||||
case AGENT_MODULE_STATUS_WARNING_ALERT:
|
||||
case AGENT_MODULE_STATUS_WARNING:
|
||||
$filter[] = "(
|
||||
tae.estado = ".AGENT_MODULE_STATUS_WARNING_ALERT."
|
||||
OR tae.estado = ".AGENT_MODULE_STATUS_WARNING."
|
||||
)";
|
||||
break;
|
||||
case AGENT_MODULE_STATUS_UNKNOWN:
|
||||
$filter[] = "tae.estado = ".AGENT_MODULE_STATUS_UNKNOWN." ";
|
||||
break;
|
||||
case AGENT_MODULE_STATUS_NO_DATA:
|
||||
case AGENT_MODULE_STATUS_NOT_INIT:
|
||||
$filter[] = "(
|
||||
tae.estado = ".AGENT_MODULE_STATUS_NO_DATA."
|
||||
OR tae.estado = ".AGENT_MODULE_STATUS_NOT_INIT."
|
||||
)";
|
||||
break;
|
||||
case AGENT_MODULE_STATUS_NORMAL_ALERT:
|
||||
case AGENT_MODULE_STATUS_NORMAL:
|
||||
$filter[] = "(
|
||||
tae.estado = ".AGENT_MODULE_STATUS_NORMAL_ALERT."
|
||||
OR tae.estado = ".AGENT_MODULE_STATUS_NORMAL."
|
||||
)";
|
||||
break;
|
||||
default:
|
||||
$filter[] = "1=1";
|
||||
break;
|
||||
}
|
||||
$filter = array(
|
||||
modules_get_state_condition($selected_status)
|
||||
);
|
||||
if (!$this->filter['show_not_init_modules'] && $state === false) {
|
||||
if (!empty($filter))
|
||||
$filter[] = "(
|
||||
|
@ -278,7 +248,7 @@ class Tree {
|
|||
: " AND $filter ";
|
||||
}
|
||||
|
||||
protected function getGroupAclCondition() {
|
||||
public function getGroupAclCondition() {
|
||||
if (users_can_manage_group_all("AR")) return "";
|
||||
|
||||
$groups_str= implode(",", $this->userGroupsArray);
|
||||
|
@ -301,105 +271,6 @@ class Tree {
|
|||
return " AND tg.nombre LIKE '%" . $this->filter['searchGroup'] . "%'";
|
||||
}
|
||||
|
||||
protected function getAgentCounterColumnsSql ($agent_table) {
|
||||
// Add the agent counters to the columns
|
||||
|
||||
if ($this->filter['statusAgent'] == -1) {
|
||||
// Critical
|
||||
$agent_critical_filter = $this->getAgentStatusFilter(AGENT_STATUS_CRITICAL);
|
||||
$agents_critical_count = "($agent_table
|
||||
$agent_critical_filter) AS total_critical_count";
|
||||
// Warning
|
||||
$agent_warning_filter = $this->getAgentStatusFilter(AGENT_STATUS_WARNING);
|
||||
$agents_warning_count = "($agent_table
|
||||
$agent_warning_filter) AS total_warning_count";
|
||||
// Unknown
|
||||
$agent_unknown_filter = $this->getAgentStatusFilter(AGENT_STATUS_UNKNOWN);
|
||||
$agents_unknown_count = "($agent_table
|
||||
$agent_unknown_filter) AS total_unknown_count";
|
||||
// Normal
|
||||
$agent_normal_filter = $this->getAgentStatusFilter(AGENT_STATUS_NORMAL);
|
||||
$agents_normal_count = "($agent_table
|
||||
$agent_normal_filter) AS total_normal_count";
|
||||
// Not init
|
||||
if($this->filter['show_not_init_agents']){
|
||||
$agent_not_init_filter = $this->getAgentStatusFilter(AGENT_STATUS_NOT_INIT);
|
||||
$agents_not_init_count = "($agent_table
|
||||
$agent_not_init_filter) AS total_not_init_count";
|
||||
}
|
||||
else{
|
||||
$agent_not_init_filter = 0;
|
||||
$agents_not_init_count = 0;
|
||||
}
|
||||
|
||||
// Alerts fired
|
||||
$agents_fired_count = "($agent_table
|
||||
AND ta.fired_count > 0) AS total_fired_count";
|
||||
// Total
|
||||
$agents_total_count = "($agent_table) AS total_count";
|
||||
|
||||
$columns = "$agents_critical_count, $agents_warning_count, "
|
||||
. "$agents_unknown_count, $agents_normal_count, $agents_not_init_count, "
|
||||
. "$agents_fired_count, $agents_total_count";
|
||||
}
|
||||
else {
|
||||
// Alerts fired
|
||||
$agents_fired_count = "($agent_table
|
||||
AND ta.fired_count > 0) AS total_fired_count";
|
||||
// Total
|
||||
$agents_total_count = "($agent_table) AS total_count";
|
||||
|
||||
switch ($this->filter['statusAgent']) {
|
||||
case AGENT_STATUS_NOT_INIT:
|
||||
// Not init
|
||||
$agent_not_init_filter = $this->getAgentStatusFilter(AGENT_STATUS_NOT_INIT);
|
||||
$agents_not_init_count = "($agent_table
|
||||
$agent_not_init_filter) AS total_not_init_count";
|
||||
$columns = "$agents_not_init_count, $agents_fired_count, $agents_total_count";
|
||||
break;
|
||||
case AGENT_STATUS_CRITICAL:
|
||||
// Critical
|
||||
$agent_critical_filter = $this->getAgentStatusFilter(AGENT_STATUS_CRITICAL);
|
||||
$agents_critical_count = "($agent_table
|
||||
$agent_critical_filter) AS total_critical_count";
|
||||
$columns = "$agents_critical_count, $agents_fired_count, $agents_total_count";
|
||||
break;
|
||||
case AGENT_STATUS_WARNING:
|
||||
// Warning
|
||||
$agent_warning_filter = $this->getAgentStatusFilter(AGENT_STATUS_WARNING);
|
||||
$agents_warning_count = "($agent_table
|
||||
$agent_warning_filter) AS total_warning_count";
|
||||
$columns = "$agents_warning_count, $agents_fired_count, $agents_total_count";
|
||||
break;
|
||||
case AGENT_STATUS_UNKNOWN:
|
||||
// Unknown
|
||||
$agent_unknown_filter = $this->getAgentStatusFilter(AGENT_STATUS_UNKNOWN);
|
||||
$agents_unknown_count = "($agent_table
|
||||
$agent_unknown_filter) AS total_unknown_count";
|
||||
$columns = "$agents_unknown_count, $agents_fired_count, $agents_total_count";
|
||||
break;
|
||||
case AGENT_STATUS_NORMAL:
|
||||
// Normal
|
||||
$agent_normal_filter = $this->getAgentStatusFilter(AGENT_STATUS_NORMAL);
|
||||
$agents_normal_count = "($agent_table
|
||||
$agent_normal_filter) AS total_normal_count";
|
||||
$columns = "$agents_normal_count, $agents_fired_count, $agents_total_count";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $columns;
|
||||
}
|
||||
|
||||
protected function getAgentCountersSql ($agent_table) {
|
||||
global $config;
|
||||
|
||||
$columns = $this->getAgentCounterColumnsSql($agent_table);
|
||||
$columns = "SELECT $columns FROM dual LIMIT 1";
|
||||
|
||||
return $columns;
|
||||
}
|
||||
|
||||
static function cmpSortNames($a, $b) {
|
||||
return strcmp($a["name"], $b["name"]);
|
||||
}
|
||||
|
@ -580,9 +451,9 @@ class Tree {
|
|||
$module['status'] = $module['estado'];
|
||||
$module['value'] = $module['datos'];
|
||||
|
||||
if (is_metaconsole() && !empty($server)) {
|
||||
$module['serverID'] = $server['id'];
|
||||
$module['serverName'] = $server['server_name'];
|
||||
if (is_metaconsole()) {
|
||||
$module['serverID'] = $this->serverID;
|
||||
$module['serverName'] = $this->serverName;
|
||||
}
|
||||
else {
|
||||
$module['serverName'] = false;
|
||||
|
@ -675,7 +546,7 @@ class Tree {
|
|||
"refresh" => SECONDS_10MINUTES
|
||||
);
|
||||
|
||||
if (is_metaconsole() && !empty($server)) {
|
||||
if (is_metaconsole()) {
|
||||
// Set the server id
|
||||
$graph_params["server"] = $module['serverID'];
|
||||
}
|
||||
|
|
|
@ -19,6 +19,8 @@ require_once($config['homedir']."/include/class/Tree.class.php");
|
|||
|
||||
class TreeGroup extends Tree {
|
||||
|
||||
protected $propagateCounters = true;
|
||||
|
||||
public function __construct($type, $rootType = '', $id = -1, $rootID = -1, $serverID = false, $childrenMethod = "on_demand", $access = 'AR') {
|
||||
|
||||
global $config;
|
||||
|
@ -38,6 +40,10 @@ class TreeGroup extends Tree {
|
|||
)";
|
||||
}
|
||||
|
||||
public function setPropagateCounters($value) {
|
||||
$this->propagateCounters = (bool)$value;
|
||||
}
|
||||
|
||||
protected function getData() {
|
||||
if ($this->id == -1) {
|
||||
$this->getFirstLevel();
|
||||
|
@ -126,9 +132,13 @@ class TreeGroup extends Tree {
|
|||
return !$group['have_parent'];
|
||||
});
|
||||
// Propagate child counters to her parents
|
||||
TreeGroup::processCounters($groups);
|
||||
// Filter groups and eliminates the reference to empty groups
|
||||
$groups = TreeGroup::deleteEmptyGroups($groups);
|
||||
if ($this->propagateCounters) {
|
||||
TreeGroup::processCounters($groups);
|
||||
// Filter groups and eliminates the reference to empty groups
|
||||
$groups = TreeGroup::deleteEmptyGroups($groups);
|
||||
} else {
|
||||
$groups = TreeGroup::deleteEmptyGroupsNotPropagate($groups);
|
||||
}
|
||||
|
||||
usort($groups, array("Tree", "cmpSortNames"));
|
||||
return $groups;
|
||||
|
@ -353,6 +363,32 @@ class TreeGroup extends Tree {
|
|||
return $new_groups;
|
||||
}
|
||||
|
||||
protected static function deleteEmptyGroupsNotPropagate ($groups) {
|
||||
$new_groups = array();
|
||||
foreach ($groups as $group) {
|
||||
// Tray to remove the children groups
|
||||
if (!empty($group['children'])) {
|
||||
$children = TreeGroup::deleteEmptyGroupsNotPropagate ($group['children']);
|
||||
if (empty($children)) {
|
||||
unset($group['children']);
|
||||
// If a group is empty, do not add to new_groups.
|
||||
if (isset($group['counters']['total']) && $group['counters']['total'] != 0) {
|
||||
$new_groups[] = $group;
|
||||
}
|
||||
} else {
|
||||
$group['children'] = $children;
|
||||
$new_groups[] = $group;
|
||||
}
|
||||
} else {
|
||||
// If a group is empty, do not add to new_groups.
|
||||
if (isset($group['counters']['total']) && $group['counters']['total'] != 0) {
|
||||
$new_groups[] = $group;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $new_groups;
|
||||
}
|
||||
|
||||
private static function extractGroupsWithIDs ($groups, $ids_hash) {
|
||||
$result_groups = array();
|
||||
foreach ($groups as $group) {
|
||||
|
|
|
@ -22,8 +22,8 @@
|
|||
/**
|
||||
* Pandora build version and version
|
||||
*/
|
||||
$build_version = 'PC180906';
|
||||
$pandora_version = 'v7.0NG.726';
|
||||
$build_version = 'PC180917';
|
||||
$pandora_version = 'v7.0NG.727';
|
||||
|
||||
// Do not overwrite default timezone set if defined.
|
||||
$script_tz = @date_default_timezone_get();
|
||||
|
|
|
@ -3274,7 +3274,7 @@ function generator_chart_to_pdf($type_graph_pdf, $params, $params_combined = fal
|
|||
$img_url = $config["homeurl"] . "attachment/" . $img_file;
|
||||
|
||||
$width_img = 500;
|
||||
$height_img = (isset($config['graph_image_height'])) ? $config['graph_image_height'] : 350;
|
||||
$height_img = (isset($config['graph_image_height'])) ? $config['graph_image_height'] : 280;
|
||||
|
||||
$params['height'] = $height_img;
|
||||
|
||||
|
@ -3344,4 +3344,27 @@ function get_copyright_notice () {
|
|||
return $stored_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a random code to prevent cross site request fogery attacks
|
||||
*
|
||||
* @return string Generated code
|
||||
*/
|
||||
function generate_csrf_code() {
|
||||
// Start session to make this var permanent
|
||||
session_start();
|
||||
$_SESSION['csrf_code'] = md5(uniqid(mt_rand(), true));
|
||||
session_write_close();
|
||||
return $_SESSION['csrf_code'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate the CSRF code
|
||||
*
|
||||
* @return bool True if code is valid
|
||||
*/
|
||||
function validate_csrf_code() {
|
||||
$code = get_parameter('csrf_code');
|
||||
return isset($code) && isset($_SESSION['csrf_code'])
|
||||
&& $_SESSION['csrf_code'] == $code;
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -966,12 +966,12 @@ function agents_get_group_agents (
|
|||
$filter['order'] = 'alias';
|
||||
|
||||
if (is_metaconsole()) {
|
||||
$table_name = 'tmetaconsole_agent LEFT JOIN tmetaconsole_agent_secondary_group ON ta.id_agente = tasg.id_agent';
|
||||
$table_name = 'tmetaconsole_agent ta LEFT JOIN tmetaconsole_agent_secondary_group tasg ON ta.id_agente = tasg.id_agent';
|
||||
|
||||
$fields = array(
|
||||
'id_tagente AS id_agente',
|
||||
'ta.id_tagente AS id_agente',
|
||||
'alias',
|
||||
'id_tmetaconsole_setup AS id_server'
|
||||
'ta.id_tmetaconsole_setup AS id_server'
|
||||
);
|
||||
}
|
||||
else {
|
||||
|
@ -2742,4 +2742,33 @@ function agents_check_access_agent ($id_agent, $access = "AR") {
|
|||
// Return null otherwise
|
||||
return null;
|
||||
}
|
||||
|
||||
function agents_get_status_clause($state, $show_not_init = true) {
|
||||
switch ($state) {
|
||||
case AGENT_STATUS_CRITICAL:
|
||||
return "(ta.critical_count > 0)";
|
||||
case AGENT_STATUS_WARNING:
|
||||
return "(ta.warning_count > 0 AND ta.critical_count = 0)";
|
||||
case AGENT_STATUS_UNKNOWN:
|
||||
return "(
|
||||
ta.critical_count = 0 AND ta.warning_count = 0 AND ta.unknown_count > 0
|
||||
)";
|
||||
case AGENT_STATUS_NOT_INIT:
|
||||
return $show_not_init
|
||||
? "(ta.total_count = ta.notinit_count)"
|
||||
: "1=0";
|
||||
case AGENT_STATUS_NORMAL:
|
||||
return "(
|
||||
ta.critical_count = 0 AND ta.warning_count = 0
|
||||
AND ta.unknown_count = 0 AND ta.normal_count > 0
|
||||
)";
|
||||
case AGENT_STATUS_ALL:
|
||||
default:
|
||||
return $show_not_init
|
||||
? "1=1"
|
||||
: "(ta.total_count <> ta.notinit_count)";
|
||||
}
|
||||
// If the state is not an expected state, return no condition
|
||||
return "1=1";
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -50,7 +50,10 @@ function alerts_get_alerts($id_group = 0, $free_search = "", $status = "all", $s
|
|||
|
||||
$id_groups = array_keys($groups);
|
||||
|
||||
$group_query = " AND t3.id_grupo IN (" . implode(',', $id_groups) . ") ";
|
||||
$group_query = " AND (
|
||||
t3.id_grupo IN (" . implode(',', $id_groups) . ")
|
||||
OR tasg.id_group IN (" . implode(',', $id_groups) . ")
|
||||
)";
|
||||
}
|
||||
else {
|
||||
$group_query = "";
|
||||
|
@ -103,6 +106,8 @@ function alerts_get_alerts($id_group = 0, $free_search = "", $status = "all", $s
|
|||
ON t0.id_agent_module = t2.id_agente_modulo
|
||||
INNER JOIN tagente t3
|
||||
ON t2.id_agente = t3.id_agente
|
||||
LEFT JOIN tagent_secondary_group tasg
|
||||
ON tasg.id_agent = t3.id_agente
|
||||
WHERE 1=1
|
||||
' . $status_query . ' ' . $standby_query . ' ' . $group_query . '
|
||||
AND (t1.name LIKE "%' . $free_search . '%"
|
||||
|
@ -1792,9 +1797,12 @@ function get_group_alerts($id_group, $filter = '', $options = false,
|
|||
FROM tagente_modulo
|
||||
WHERE delete_pending = 0
|
||||
AND id_agente IN (SELECT id_agente
|
||||
FROM tagente
|
||||
FROM tagente ta
|
||||
LEFT JOIN tagent_secondary_group tasg
|
||||
ON ta.id_agente = tasg.id_agent
|
||||
WHERE
|
||||
id_grupo IN (' . implode(',', $id_group) . '))';
|
||||
id_grupo IN (' . implode(',', $id_group) . ')
|
||||
OR id_group IN (' . implode(',', $id_group) . '))';
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1861,6 +1869,8 @@ function get_group_alerts($id_group, $filter = '', $options = false,
|
|||
ON talert_template_modules.id_agent_module = t2.id_agente_modulo
|
||||
INNER JOIN tagente t3
|
||||
ON t2.id_agente = t3.id_agente
|
||||
LEFT JOIN tagent_secondary_group tasg
|
||||
ON tasg.id_agent = t2.id_agente
|
||||
INNER JOIN talert_templates t4
|
||||
ON talert_template_modules.id_alert_template = t4.id
|
||||
WHERE id_agent_module in (%s) %s %s %s",
|
||||
|
|
|
@ -30,6 +30,7 @@ include_once($config['homedir'] . "/include/functions_network_components.php");
|
|||
include_once($config['homedir'] . "/include/functions_netflow.php");
|
||||
include_once($config['homedir'] . "/include/functions_servers.php");
|
||||
include_once($config['homedir'] . "/include/functions_planned_downtimes.php");
|
||||
include_once($config['homedir'] . "/include/functions_db.php");
|
||||
enterprise_include_once ('include/functions_local_components.php');
|
||||
enterprise_include_once ('include/functions_events.php');
|
||||
enterprise_include_once ('include/functions_agents.php');
|
||||
|
@ -11397,8 +11398,282 @@ function util_api_check_agent_and_print_error($id_agent, $returnType, $access =
|
|||
return false;
|
||||
}
|
||||
|
||||
function api_get_user_info($thrash1, $thrash2, $other, $returnType) {
|
||||
if (defined ('METACONSOLE')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$separator = ';';
|
||||
|
||||
$other = json_decode(base64_decode($other['data']),true);
|
||||
|
||||
$sql = 'select * from tusuario where id_user = "'.$other[0]['id_user'].'" and password = "'.$other[0]['password'].'"';
|
||||
|
||||
$user_info = db_get_all_rows_sql($sql);
|
||||
|
||||
if (count($user_info) > 0 and $user_info !== false) {
|
||||
$data = array('type' => 'array', 'data' => $user_info);
|
||||
returnData($returnType, $data, $separator);
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
|
||||
This function receives different parameters to process one of these actions the logging process in our application from the records in the audit of pandora fms, to avoid concurrent access of administrator users, and optionally to prohibit access to non-administrator users:
|
||||
|
||||
Parameter 0
|
||||
|
||||
The User ID that attempts the action is used to check the status of the application for access.
|
||||
|
||||
Parameter 1
|
||||
|
||||
Login, logout, exclude, browse.
|
||||
|
||||
These requests receive a response that we can treat as we consider, this function only sends answers, does not perform any action in your application, you must customize them.
|
||||
|
||||
Login action: free (register our access), taken, denied (if you are not an administrator user and parameter four is set to 1, register the expulsion).
|
||||
|
||||
Browse action: It has the same answers as login, but does not register anything in the audit.
|
||||
|
||||
Logout action: It records the deslogeo but does not send a response.
|
||||
|
||||
All other actions do not return a response,
|
||||
|
||||
Parameter 2
|
||||
|
||||
IP address of the application is also used to check the status of the application for access.
|
||||
|
||||
Parameter 3
|
||||
|
||||
Name of the application, it is also used to check the status of the application for access.
|
||||
|
||||
Parameter 4
|
||||
|
||||
If you mark 1 you will avoid the access to the non-administrators users, returning the response `denied' and registering that expulsion in the audit of pandora fms.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
function api_set_access_process($thrash1, $thrash2, $other, $returnType) {
|
||||
if (defined ('METACONSOLE')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$other['data'] = explode('|',$other['data']);
|
||||
|
||||
$sql = 'select id_usuario,utimestamp from tsesion where descripcion like "%'.$other['data'][2].'%" and accion like "%'.$other['data'][3].' Logon%" and id_usuario IN (select id_user from tusuario where is_admin = 1) and id_usuario != "'.$other['data'][0].'" order by utimestamp DESC limit 1';
|
||||
$audit_concurrence = db_get_all_rows_sql($sql);
|
||||
$sql_user = 'select id_usuario,utimestamp from tsesion where descripcion like "%'.$other['data'][2].'%" and accion like "%'.$other['data'][3].' Logon%" and id_usuario IN (select id_user from tusuario where is_admin = 1) and id_usuario = "'.$other['data'][0].'" order by utimestamp DESC limit 1';
|
||||
$audit_concurrence_user = db_get_all_rows_sql($sql_user);
|
||||
$sql2 = 'select id_usuario,utimestamp,accion from tsesion where descripcion like "%'.$other['data'][2].'%" and accion like "%'.$other['data'][3].' Logoff%" and id_usuario = "'.$audit_concurrence[0]['id_usuario'].'" order by utimestamp DESC limit 1';
|
||||
$audit_concurrence_2 = db_get_all_rows_sql($sql2);
|
||||
|
||||
//The user trying to log in is an administrator
|
||||
if(users_is_admin($other['data'][0])){
|
||||
//The admin user is trying to login
|
||||
if($other['data'][1] == 'login'){
|
||||
// Check if there is an administrator user logged in prior to our last login
|
||||
if($audit_concurrence[0]['utimestamp'] > $audit_concurrence_user[0]['utimestamp']){
|
||||
// Check if the administrator user logged in later to us has unlogged and left the node free
|
||||
if($audit_concurrence[0]['utimestamp'] > $audit_concurrence_2[0]['utimestamp']){
|
||||
// The administrator user logged in later has not yet unlogged
|
||||
returnData('string', array('type' => 'string', 'data' => 'taken'));
|
||||
}
|
||||
else{
|
||||
// The administrator user logged in later has already unlogged
|
||||
returnData('string', array('type' => 'string', 'data' => 'free'));
|
||||
}
|
||||
}
|
||||
else{
|
||||
// There is no administrator user who has logged in since then to log us in.
|
||||
db_pandora_audit($other['data'][3].' Logon', 'Logged in '.$other['data'][3].' node '.$other['data'][2] , $other['data'][0]);
|
||||
returnData('string', array('type' => 'string', 'data' => 'free'));
|
||||
}
|
||||
|
||||
}
|
||||
elseif ($other['data'][1] == 'logout') {
|
||||
// The administrator user wants to log out
|
||||
db_pandora_audit($other['data'][3].' Logoff', 'Logout from '.$other['data'][3].' node '.$other['data'][2], $other['data'][0]);
|
||||
}
|
||||
elseif ($other['data'][1] == 'exclude') {
|
||||
// The administrator user has ejected another administrator user who was logged in
|
||||
db_pandora_audit($other['data'][3].' Logon', 'Logged in '.$other['data'][3].' node '.$other['data'][2] , $other['data'][0]);
|
||||
db_pandora_audit($other['data'][3].' Logoff', 'Logout from '.$other['data'][3].' node '.$other['data'][2] , $audit_concurrence[0]['id_usuario']);
|
||||
|
||||
}
|
||||
//The admin user is trying to browse
|
||||
elseif ($other['data'][1] == 'browse') {
|
||||
// Check if there is an administrator user logged in prior to our last login
|
||||
if($audit_concurrence[0]['utimestamp'] > $audit_concurrence_user[0]['utimestamp']){
|
||||
// Check if the administrator user logged in later to us has unlogged and left the node free
|
||||
if($audit_concurrence[0]['utimestamp'] > $audit_concurrence_2[0]['utimestamp']){
|
||||
// The administrator user logged in later has not yet unlogged
|
||||
returnData('string', array('type' => 'string', 'data' => $audit_concurrence[0]['id_usuario']));
|
||||
}
|
||||
else{
|
||||
// The administrator user logged in later has already unlogged
|
||||
returnData('string', array('type' => 'string', 'data' => 'free'));
|
||||
}
|
||||
}
|
||||
else{
|
||||
// There is no administrator user who has logged in since then to log us in.
|
||||
returnData('string', array('type' => 'string', 'data' => 'free'));
|
||||
}
|
||||
|
||||
}
|
||||
elseif ($other['data'][1] == 'cancelled'){
|
||||
//The administrator user tries to log in having another administrator logged in, but instead of expelling him he cancels his log in.
|
||||
db_pandora_audit($other['data'][3].' cancelled access', 'Cancelled access in '.$other['data'][3].' node '.$other['data'][2] , $other['data'][0]);
|
||||
returnData('string', array('type' => 'string', 'data' => 'cancelled'));
|
||||
}
|
||||
|
||||
}
|
||||
else{
|
||||
|
||||
if($other['data'][4] == 1){
|
||||
//The user trying to log in is not an administrator and is not allowed no admin access
|
||||
db_pandora_audit($other['data'][3].' denied access', 'Denied access to non-admin user '.$other['data'][3].' node '.$other['data'][2] , $other['data'][0]);
|
||||
returnData('string', array('type' => 'string', 'data' => 'denied'));
|
||||
}
|
||||
else{
|
||||
//The user trying to log in is not an administrator and is allowed no admin access
|
||||
if($other['data'][1] == 'login'){
|
||||
//The user trying to login is not admin, can enter without concurrent use filter
|
||||
db_pandora_audit($other['data'][3].' Logon', 'Logged in '.$other['data'][3].' node '.$other['data'][2] , $other['data'][0]);
|
||||
returnData('string', array('type' => 'string', 'data' => 'free'));
|
||||
|
||||
}
|
||||
elseif ($other['data'][1] == 'logout') {
|
||||
//The user trying to logoff is not admin
|
||||
db_pandora_audit($other['data'][3].' Logoff', 'Logout from '.$other['data'][3].' node '.$other['data'][2], $other['data'][0]);
|
||||
}
|
||||
elseif ($other['data'][1] == 'browse'){
|
||||
//The user trying to browse in an app page is not admin, can enter without concurrent use filter
|
||||
returnData('string', array('type' => 'string', 'data' => 'free'));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function api_get_traps($thrash1, $thrash2, $other, $returnType) {
|
||||
|
||||
if (defined ('METACONSOLE')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$other['data'] = explode('|',$other['data']);
|
||||
|
||||
$other['data'][1] = date("Y-m-d H:i:s",$other['data'][1]);
|
||||
|
||||
$sql = 'SELECT * from ttrap where timestamp >= "'.$other['data'][1].'"';
|
||||
|
||||
// $sql = 'SELECT * from ttrap where source = "'.$other['data'][0].'" and timestamp >= "'.$other['data'][1].'"';
|
||||
|
||||
if($other['data'][4]){
|
||||
$other['data'][4] = date("Y-m-d H:i:s",$other['data'][4]);
|
||||
$sql .= ' and timestamp <= "'.$other['data'][4].'"';
|
||||
}
|
||||
|
||||
if($other['data'][2]){
|
||||
$sql .= ' limit '.$other['data'][2];
|
||||
}
|
||||
|
||||
if($other['data'][3]){
|
||||
$sql .= ' offset '.$other['data'][3];
|
||||
}
|
||||
|
||||
if($other['data'][5]){
|
||||
$sql .= ' and status = 0';
|
||||
}
|
||||
|
||||
if(sizeof($other['data']) == 0){
|
||||
$sql = 'SELECT * from ttrap';
|
||||
}
|
||||
|
||||
|
||||
$traps = db_get_all_rows_sql($sql);
|
||||
|
||||
if($other['data'][6]){
|
||||
|
||||
foreach ($traps as $key => $value) {
|
||||
|
||||
if(!strpos($value['oid_custom'],$other['data'][6]) && $other['data'][7] == 'false'){
|
||||
unset($traps[$key]);
|
||||
}
|
||||
|
||||
if(strpos($value['oid_custom'],$other['data'][6]) && $other['data'][7] == 'true'){
|
||||
unset($traps[$key]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$traps_json = json_encode($traps);
|
||||
|
||||
if (count($traps) > 0 and $traps !== false) {
|
||||
returnData('string', array('type' => 'string', 'data' => $traps_json));
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function api_set_validate_traps ($id, $thrash2, $other, $thrash3) {
|
||||
|
||||
if (defined ('METACONSOLE')) {
|
||||
return;
|
||||
}
|
||||
|
||||
if($id == 'all'){
|
||||
$result = db_process_sql_update('ttrap',array('status' => 1));
|
||||
}
|
||||
else{
|
||||
$result = db_process_sql_update('ttrap',
|
||||
array('status' => 1), array('id_trap' => $id));
|
||||
}
|
||||
|
||||
if (is_error($result)) {
|
||||
// TODO: Improve the error returning more info
|
||||
returnError('error_update_trap', __('Error in trap update.'));
|
||||
}
|
||||
else {
|
||||
returnData('string',
|
||||
array('type' => 'string',
|
||||
'data' => __('Validated traps.')));
|
||||
}
|
||||
}
|
||||
|
||||
function api_set_delete_traps ($id, $thrash2, $other, $thrash3) {
|
||||
|
||||
if (defined ('METACONSOLE')) {
|
||||
return;
|
||||
}
|
||||
|
||||
if($id == 'all'){
|
||||
$result = db_process_sql ('delete from ttrap');
|
||||
}
|
||||
else{
|
||||
$result = db_process_sql_delete('ttrap',array('id_trap' => $id));
|
||||
}
|
||||
|
||||
if (is_error($result)) {
|
||||
// TODO: Improve the error returning more info
|
||||
returnError('error_delete_trap', __('Error in trap delete.'));
|
||||
}
|
||||
else {
|
||||
returnData('string',
|
||||
array('type' => 'string',
|
||||
'data' => __('Deleted traps.')));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
|
|
@ -631,10 +631,10 @@ function config_update_config () {
|
|||
if (!config_update_value ('type_mode_graph', (int) get_parameter('type_mode_graph', 0)))
|
||||
$error_update[] = __('Default soft graphs');
|
||||
|
||||
if (!config_update_value ('zoom_graph', (int) get_parameter('zoom_graph', 0)))
|
||||
if (!config_update_value ('zoom_graph', (int) get_parameter('zoom_graph', 1)))
|
||||
$error_update[] = __('Default zoom graphs');
|
||||
|
||||
if (!config_update_value ('graph_image_height', (int) get_parameter('graph_image_height', 0)))
|
||||
if (!config_update_value ('graph_image_height', (int) get_parameter('graph_image_height', 280)))
|
||||
$error_update[] = __('Default height of the chart image');
|
||||
|
||||
if (!config_update_value ('classic_menu', (bool) get_parameter('classic_menu', false)))
|
||||
|
@ -667,10 +667,7 @@ function config_update_config () {
|
|||
}
|
||||
}
|
||||
//--------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------
|
||||
// CUSTOM INTERVAL VALUES
|
||||
//--------------------------------------------------
|
||||
|
@ -1859,11 +1856,15 @@ function config_process_config () {
|
|||
if (!isset($config['render_proc'])) {
|
||||
config_update_value ('render_proc', 0);
|
||||
}
|
||||
|
||||
|
||||
if (!isset($config['graph_image_height'])) {
|
||||
config_update_value ('graph_image_height', 320);
|
||||
config_update_value ('graph_image_height', 280);
|
||||
}
|
||||
|
||||
|
||||
if (!isset($config['zoom_graph'])) {
|
||||
config_update_value ('zoom_graph', 1);
|
||||
}
|
||||
|
||||
if (!isset($config["render_proc_ok"])) {
|
||||
config_update_value ('render_proc_ok', __('Ok') );
|
||||
}
|
||||
|
|
|
@ -20,31 +20,29 @@
|
|||
*/
|
||||
|
||||
/**
|
||||
* Create a prediction based on module data with least square method (linear regression)
|
||||
* Create a prediction based on module data with least square method (linear regression)
|
||||
*
|
||||
* @param int Module id.
|
||||
* @param int Period of the module data.
|
||||
* @param int Period of the prediction or false to use it in prediction_date function (see below).
|
||||
* @param int Period of the prediction or false to use it in prediction_date function (see below).
|
||||
* @param int Maximun value using this function for prediction_date.
|
||||
* @param int Minimun value using this function for prediction_date.
|
||||
* @param bool Result data for CSV file exportation.
|
||||
*
|
||||
*
|
||||
* @return array Void array or prediction of the module data.
|
||||
*/
|
||||
function forecast_projection_graph($module_id,
|
||||
$period = SECONDS_2MONTHS, $prediction_period, $max_value = false,
|
||||
$min_value = false, $csv = false) {
|
||||
|
||||
|
||||
global $config;
|
||||
|
||||
$max_exec_time = ini_get('max_execution_time');
|
||||
|
||||
|
||||
$max_exec_time = ini_get('max_execution_time');
|
||||
|
||||
if ($max_exec_time !== false) {
|
||||
|
||||
$max_exec_time = (int)$max_exec_time;
|
||||
|
||||
$max_exec_time = (int)$max_exec_time;
|
||||
}
|
||||
|
||||
|
||||
$begin_time = time();
|
||||
|
||||
$params =array(
|
||||
|
@ -54,16 +52,16 @@ function forecast_projection_graph($module_id,
|
|||
'projection' => true
|
||||
);
|
||||
|
||||
$module_data = grafico_modulo_sparse ($params);
|
||||
|
||||
$module_data = grafico_modulo_sparse($params);
|
||||
|
||||
if (empty($module_data)) {
|
||||
return array();
|
||||
return array();
|
||||
}
|
||||
// Prevents bad behaviour over image error
|
||||
// Prevents bad behaviour over image error
|
||||
else if (!is_array($module_data) and preg_match('/^<img(.)*$/', $module_data)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Data initialization
|
||||
$sum_obs = 0;
|
||||
$sum_xi = 0;
|
||||
|
@ -113,35 +111,16 @@ function forecast_projection_graph($module_id,
|
|||
$cont++;
|
||||
}
|
||||
}
|
||||
|
||||
$cont--;
|
||||
|
||||
// Calculation over data above:
|
||||
// 1. Calculation of linear correlation coefficient...
|
||||
|
||||
// 1.1 Average for X: Sum(Xi)/Obs
|
||||
// 1.1 Average for X: Sum(Xi)/Obs
|
||||
// 1.2 Average for Y: Sum(Yi)/Obs
|
||||
// 2. Covariance between vars
|
||||
// 3.1 Standard deviation for X: sqrt((Sum(Xi²)/Obs) - (avg X)²)
|
||||
// 3.2 Standard deviation for Y: sqrt((Sum(Yi²)/Obs) - (avg Y)²)
|
||||
// 3.1 Standard deviation for X: sqrt((Sum(Xi²)/Obs) - (avg X)²)
|
||||
// 3.2 Standard deviation for Y: sqrt((Sum(Yi²)/Obs) - (avg Y)²)
|
||||
// Linear correlation coefficient:
|
||||
|
||||
|
||||
/*
|
||||
if ($cont != 0) {
|
||||
$covariance = $sum_xi_yi/$cont;
|
||||
$dev_x = sqrt(($sum_xi2/$cont) - ($avg_x*$avg_x));
|
||||
$dev_y = sqrt(($sum_yi2/$cont) - ($avg_y*$avg_y));
|
||||
} else {
|
||||
$covariance = 0;
|
||||
$dev_x = 0;
|
||||
$dev_y = 0;
|
||||
}
|
||||
// Prevents division by zero
|
||||
if ($dev_x != 0 and $dev_y != 0) {
|
||||
$linear_coef = $covariance / ($dev_x * $dev_y);
|
||||
}
|
||||
*/
|
||||
// Agent interval could be zero, 300 is the predefined
|
||||
if ($sum_obs == 0) {
|
||||
$agent_interval = SECONDS_5MINUTES;
|
||||
|
@ -149,37 +128,35 @@ function forecast_projection_graph($module_id,
|
|||
else {
|
||||
$agent_interval = $sum_diff_dates / $sum_obs;
|
||||
}
|
||||
|
||||
|
||||
// Could be a inverse correlation coefficient
|
||||
// if $linear_coef < 0.0
|
||||
// if $linear_coef >= -1.0 and $linear_coef <= -0.8999
|
||||
// Function variables have an inverse linear relathionship!
|
||||
// else
|
||||
// Function variables don't have an inverse linear relathionship!
|
||||
|
||||
// else
|
||||
// Function variables don't have an inverse linear relathionship!
|
||||
// Could be a direct correlation coefficient
|
||||
// else
|
||||
// else
|
||||
// if ($linear_coef >= 0.8999 and $linear_coef <= 1.0) {
|
||||
// Function variables have a direct linear relathionship!
|
||||
// else
|
||||
// else
|
||||
// Function variables don't have a direct linear relathionship!
|
||||
|
||||
// 2. Calculation of linear regresion...
|
||||
|
||||
|
||||
$b_num = (($cont * $sum_xi_yi) - ($sum_xi * $sum_yi));
|
||||
$b_den = (($cont * $sum_xi2) - ($sum_xi * $sum_xi));
|
||||
if ($b_den == 0)
|
||||
return;
|
||||
$b = $b_num / $b_den;
|
||||
|
||||
|
||||
$a_num = ($sum_yi) - ($b * $sum_xi);
|
||||
|
||||
|
||||
if ($cont != 0) {
|
||||
$a = $a_num / $cont;
|
||||
} else {
|
||||
$a = 0;
|
||||
}
|
||||
|
||||
|
||||
// Data inicialization
|
||||
$output_data = array();
|
||||
if ($prediction_period != false) {
|
||||
|
@ -188,11 +165,11 @@ function forecast_projection_graph($module_id,
|
|||
$current_ts = $last_timestamp;
|
||||
$in_range = true;
|
||||
$time_format_2 = '';
|
||||
|
||||
|
||||
$temp_range = $period;
|
||||
if ($period < $prediction_period)
|
||||
$temp_range = $prediction_period;
|
||||
|
||||
|
||||
if ($temp_range <= SECONDS_6HOURS) {
|
||||
$time_format = 'H:i:s';
|
||||
}
|
||||
|
@ -206,15 +183,15 @@ function forecast_projection_graph($module_id,
|
|||
elseif ($temp_range <= SECONDS_1MONTH) {
|
||||
$time_format = 'M d';
|
||||
$time_format_2 = 'H\h';
|
||||
}
|
||||
}
|
||||
else {
|
||||
$time_format = 'M d';
|
||||
}
|
||||
|
||||
// Aplying linear regression to module data in order to do the prediction
|
||||
$output_data = array();
|
||||
|
||||
// Aplying linear regression to module data in order to do the prediction
|
||||
$idx = 0;
|
||||
// Create data in graph format like
|
||||
|
||||
while ($in_range) {
|
||||
$now = time();
|
||||
|
||||
|
@ -242,9 +219,10 @@ function forecast_projection_graph($module_id,
|
|||
if ($current_ts - $last_timestamp >= 94608000) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Found it
|
||||
if ($max_value >= $output_data[$idx][0] and $min_value <= $output_data[$idx][0]) {
|
||||
if (($max_value >= $output_data[$idx][0]) &&
|
||||
($min_value <= $output_data[$idx][0]) ) {
|
||||
return $current_ts;
|
||||
}
|
||||
}
|
||||
|
@ -254,7 +232,6 @@ function forecast_projection_graph($module_id,
|
|||
$current_ts = $current_ts + $agent_interval;
|
||||
$idx++;
|
||||
}
|
||||
|
||||
return $output_data;
|
||||
}
|
||||
|
||||
|
@ -264,8 +241,8 @@ function forecast_projection_graph($module_id,
|
|||
* @param int Module id.
|
||||
* @param int Given data period to make the prediction
|
||||
* @param int Max value in the interval.
|
||||
* @param int Min value in the interval.
|
||||
*
|
||||
* @param int Min value in the interval.
|
||||
*
|
||||
* @return mixed timestamp with the prediction date or false
|
||||
*/
|
||||
function forecast_prediction_date ($module_id,
|
||||
|
@ -274,6 +251,5 @@ function forecast_prediction_date ($module_id,
|
|||
if ($min_value > $max_value) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return forecast_projection_graph($module_id, $period, false, $max_value, $min_value);
|
||||
}
|
||||
|
|
|
@ -264,9 +264,7 @@ function grafico_modulo_sparse_data_chart (
|
|||
$data_module_graph['id_module_type'] == 18 ||
|
||||
$data_module_graph['id_module_type'] == 9 ||
|
||||
$data_module_graph['id_module_type'] == 31 ||
|
||||
$data_module_graph['id_module_type'] == 100 ||
|
||||
$params['baseline'] || $params['projection']
|
||||
){
|
||||
$data_module_graph['id_module_type'] == 100 ){
|
||||
|
||||
$data = db_get_all_rows_filter (
|
||||
'tagente_datos',
|
||||
|
@ -421,8 +419,7 @@ function grafico_modulo_sparse_data(
|
|||
$data_module_graph['id_module_type'] == 18 ||
|
||||
$data_module_graph['id_module_type'] == 9 ||
|
||||
$data_module_graph['id_module_type'] == 31 ||
|
||||
$data_module_graph['id_module_type'] == 100 ||
|
||||
$params['projection'] ){
|
||||
$data_module_graph['id_module_type'] == 100 ){
|
||||
$array_data = grafico_modulo_sparse_data_chart (
|
||||
$agent_module_id,
|
||||
$date_array,
|
||||
|
@ -892,7 +889,9 @@ function grafico_modulo_sparse ($params) {
|
|||
}
|
||||
|
||||
if(!isset($params['zoom'])){
|
||||
$params['zoom'] = $config['zoom_graph'];
|
||||
$params['zoom'] = $config['zoom_graph']
|
||||
? $config['zoom_graph']
|
||||
: 1;
|
||||
}
|
||||
|
||||
if(!isset($params['type_mode_graph'])){
|
||||
|
@ -922,7 +921,6 @@ function grafico_modulo_sparse ($params) {
|
|||
$legend = array();
|
||||
$array_events_alerts = array();
|
||||
|
||||
|
||||
$date_array = array();
|
||||
$date_array["period"] = $params['period'];
|
||||
$date_array["final_date"] = $params['date'];
|
||||
|
@ -964,53 +962,58 @@ function grafico_modulo_sparse ($params) {
|
|||
}
|
||||
|
||||
if(!$params['array_data_create']){
|
||||
if ($params['compare'] !== false) {
|
||||
$series_suffix = 2;
|
||||
if($params['baseline']){
|
||||
$array_data = get_baseline_data($agent_module_id, $date_array, $data_module_graph, $params);
|
||||
}
|
||||
else{
|
||||
if ($params['compare'] !== false) {
|
||||
$series_suffix = 2;
|
||||
|
||||
$date_array_prev['final_date'] = $date_array['start_date'];
|
||||
$date_array_prev['start_date'] = $date_array['start_date'] - $date_array['period'];
|
||||
$date_array_prev['period'] = $date_array['period'];
|
||||
$date_array_prev['final_date'] = $date_array['start_date'];
|
||||
$date_array_prev['start_date'] = $date_array['start_date'] - $date_array['period'];
|
||||
$date_array_prev['period'] = $date_array['period'];
|
||||
|
||||
if ($params['compare'] === 'overlapped') {
|
||||
$params['flag_overlapped'] = 1;
|
||||
}
|
||||
else{
|
||||
$params['flag_overlapped'] = 0;
|
||||
if ($params['compare'] === 'overlapped') {
|
||||
$params['flag_overlapped'] = 1;
|
||||
}
|
||||
else{
|
||||
$params['flag_overlapped'] = 0;
|
||||
}
|
||||
|
||||
$array_data = grafico_modulo_sparse_data(
|
||||
$agent_module_id,
|
||||
$date_array_prev,
|
||||
$data_module_graph,
|
||||
$params,
|
||||
$series_suffix
|
||||
);
|
||||
|
||||
switch ($params['compare']) {
|
||||
case 'separated':
|
||||
case 'overlapped':
|
||||
// Store the chart calculated
|
||||
$array_data_prev = $array_data;
|
||||
$legend_prev = $legend;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$series_suffix = 1;
|
||||
$params['flag_overlapped'] = 0;
|
||||
|
||||
$array_data = grafico_modulo_sparse_data(
|
||||
$agent_module_id,
|
||||
$date_array_prev,
|
||||
$date_array,
|
||||
$data_module_graph,
|
||||
$params,
|
||||
$series_suffix
|
||||
);
|
||||
|
||||
switch ($params['compare']) {
|
||||
case 'separated':
|
||||
case 'overlapped':
|
||||
// Store the chart calculated
|
||||
$array_data_prev = $array_data;
|
||||
$legend_prev = $legend;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$series_suffix = 1;
|
||||
$params['flag_overlapped'] = 0;
|
||||
|
||||
$array_data = grafico_modulo_sparse_data(
|
||||
$agent_module_id,
|
||||
$date_array,
|
||||
$data_module_graph,
|
||||
$params,
|
||||
$series_suffix
|
||||
);
|
||||
|
||||
if($params['compare']){
|
||||
if ($params['compare'] === 'overlapped') {
|
||||
$array_data = array_merge($array_data, $array_data_prev);
|
||||
$legend = array_merge($legend, $legend_prev);
|
||||
if($params['compare']){
|
||||
if ($params['compare'] === 'overlapped') {
|
||||
$array_data = array_merge($array_data, $array_data_prev);
|
||||
$legend = array_merge($legend, $legend_prev);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1219,7 +1222,7 @@ function graphic_combined_module (
|
|||
}
|
||||
else{
|
||||
$params['stacked'] = 'area';
|
||||
$params['projection'] = $params_combined['projection'];
|
||||
$params['projection'] = true;
|
||||
}
|
||||
|
||||
if(!isset($params_combined['labels'])){
|
||||
|
@ -1512,6 +1515,14 @@ function graphic_combined_module (
|
|||
$date_array["final_date"] = $params['date'];
|
||||
$date_array["start_date"] = $params['date'] - $params['period'];
|
||||
|
||||
if($params_combined['projection']){
|
||||
$output_projection = forecast_projection_graph(
|
||||
$module_list[0],
|
||||
$params['period'],
|
||||
$params_combined['projection']
|
||||
);
|
||||
}
|
||||
|
||||
$i=0;
|
||||
$array_data = array();
|
||||
foreach ($module_list as $key => $agent_module_id) {
|
||||
|
@ -1578,10 +1589,13 @@ function graphic_combined_module (
|
|||
$i++;
|
||||
}
|
||||
|
||||
if($params_combined['projection'] && is_array($params_combined['projection'])){
|
||||
$date_array_projection = max($params_combined['projection']);
|
||||
$date_array['final_date'] = $date_array_projection[0] / 1000;
|
||||
$array_data['projection']['data']= $params_combined['projection'];
|
||||
if($params_combined['projection']){
|
||||
// If projection doesn't have data then don't draw graph
|
||||
if ($output_projection != NULL) {
|
||||
$date_array_projection = max($output_projection);
|
||||
$date_array['final_date'] = $date_array_projection[0] / 1000;
|
||||
$array_data['projection']['data']= $output_projection;
|
||||
}
|
||||
}
|
||||
|
||||
//summatory and average series
|
||||
|
@ -4115,7 +4129,7 @@ function fullscale_data (
|
|||
if($min_value != PHP_INT_MAX) {
|
||||
$data["min" . $series_suffix]['data'][] = array($real_date , $min_value);
|
||||
}
|
||||
|
||||
|
||||
if($max_value != -PHP_INT_MAX) {
|
||||
$data["max" . $series_suffix]['data'][] = array($real_date , $max_value);
|
||||
}
|
||||
|
@ -4141,7 +4155,7 @@ function fullscale_data (
|
|||
$min_value_total = $min_value;
|
||||
}
|
||||
//avg sum_total
|
||||
$sum_data_total += $sum_data;
|
||||
$sum_data_total += $sum_data/$count_data;
|
||||
|
||||
//avg count_total
|
||||
$count_data_total++;
|
||||
|
@ -4189,6 +4203,7 @@ function fullscale_data (
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
$data["sum" . $series_suffix]['min'] = $min_value_total;
|
||||
$data["sum" . $series_suffix]['max'] = $max_value_total;
|
||||
$data["sum" . $series_suffix]['avg'] = $sum_data_total/$count_data_total;
|
||||
|
@ -4253,12 +4268,12 @@ function fullscale_data (
|
|||
|
||||
if(isset($v["datos"]) && $v["datos"]){
|
||||
//max
|
||||
if($v['datos'] >= $max_value){
|
||||
$max_value = $v['datos'];
|
||||
if((float)$v['datos'] >= $max_value_max){
|
||||
$max_value_max = $v['datos'];
|
||||
}
|
||||
//min
|
||||
if($v['datos'] <= $min_value){
|
||||
$min_value = $v['datos'];
|
||||
if((float)$v['datos'] <= $min_value_min){
|
||||
$min_value_min = $v['datos'];
|
||||
}
|
||||
//avg sum
|
||||
$sum_data += $v["datos"];
|
||||
|
@ -4274,8 +4289,8 @@ function fullscale_data (
|
|||
}
|
||||
}
|
||||
|
||||
$data["sum" . $series_suffix]['min'] = $min_value;
|
||||
$data["sum" . $series_suffix]['max'] = $max_value;
|
||||
$data["sum" . $series_suffix]['min'] = $min_value_min;
|
||||
$data["sum" . $series_suffix]['max'] = $max_value_max;
|
||||
$data["sum" . $series_suffix]['avg'] = $sum_data/$count_data;
|
||||
}
|
||||
|
||||
|
@ -5096,4 +5111,53 @@ function graph_monitor_wheel ($width = 550, $height = 600, $filter = false) {
|
|||
return d3_sunburst_graph ($graph_data, $width, $height, true);
|
||||
}
|
||||
|
||||
function get_baseline_data($agent_module_id, $date_array, $data_module_graph, $params){
|
||||
$period = $date_array["period"];
|
||||
$date = $date_array["final_date"];
|
||||
$array_data = array();
|
||||
for ($i = 0; $i < 4; $i++) {
|
||||
$date_array = array();
|
||||
$date_array["period"] = $period;
|
||||
$date_array["final_date"] = $date - $period * $i;
|
||||
$date_array["start_date"] = $date - $period * ($i + 1);
|
||||
|
||||
$data = grafico_modulo_sparse_data(
|
||||
$agent_module_id,
|
||||
$date_array,
|
||||
$data_module_graph,
|
||||
$params,
|
||||
$i
|
||||
);
|
||||
|
||||
$array_data[] = $data;
|
||||
|
||||
}
|
||||
$result = array();
|
||||
$array_data[1] = array_reverse($array_data[1]['sum1']['slice_data']);
|
||||
$array_data[2] = array_reverse($array_data[2]['sum2']['slice_data']);
|
||||
$array_data[3] = array_reverse($array_data[3]['sum3']['slice_data']);
|
||||
foreach ($array_data[0]['sum0']['slice_data'] as $key => $value) {
|
||||
$data1 = array_pop($array_data[1]);
|
||||
$data2 = array_pop($array_data[2]);
|
||||
$data3 = array_pop($array_data[3]);
|
||||
|
||||
$result['slice_data'][$key]['min'] = ($data1['min'] + $data2['min'] + $data3['min'] + $value['min']) / 4;
|
||||
$result['slice_data'][$key]['avg'] = ($data1['avg'] + $data2['avg'] + $data3['avg'] + $value['avg']) / 4;
|
||||
$result['slice_data'][$key]['max'] = ($data1['max'] + $data2['max'] + $data3['max'] + $value['max']) / 4;
|
||||
|
||||
$result['data'][] = array($key, $result['slice_data'][$key]['avg']);
|
||||
}
|
||||
|
||||
$result['avg'] = ($array_data[0]['sum0']['avg'] + $array_data[1]['sum1']['avg'] + $array_data[2]['sum2']['avg'] +$array_data[3]['sum3']['avg'])/4;
|
||||
$result['max'] = max($array_data[0]['sum0']['max'], $array_data[1]['sum1']['max'], $array_data[2]['sum2']['max'], $array_data[3]['sum3']['max']);
|
||||
$result['min'] = min($array_data[0]['sum0']['min'], $array_data[1]['sum1']['min'], $array_data[2]['sum2']['min'], $array_data[3]['sum3']['min']);
|
||||
|
||||
$result['agent_module_id'] = $array_data[0]['sum0']['agent_module_id'];
|
||||
$result['id_module_type'] = $array_data[0]['sum0']['id_module_type'];
|
||||
$result['agent_name'] = $array_data[0]['sum0']['agent_name'];
|
||||
$result['module_name'] = $array_data[0]['sum0']['module_name'];
|
||||
$result['agent_alias'] = $array_data[0]['sum0']['agent_alias'];
|
||||
return array('sum0' => $result);
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -16,801 +16,179 @@
|
|||
|
||||
include_once ($config['homedir'] . "/include/functions_groups.php");
|
||||
include_once ($config['homedir'] . "/include/functions_tags.php");
|
||||
include_once ($config['homedir'] . "/include/class/Tree.class.php");
|
||||
include_once ($config['homedir'] . "/include/class/TreeGroup.class.php");
|
||||
|
||||
function groupview_get_all_data ($id_user = false, $user_strict = false, $acltags, $returnAllGroup = false, $agent_filter = array(), $module_filter = array(), $access = 'AR') {
|
||||
global $config;
|
||||
if ($id_user == false) {
|
||||
$id_user = $config['id_user'];
|
||||
}
|
||||
|
||||
$user_groups = array();
|
||||
$user_tags = array();
|
||||
|
||||
foreach ($acltags as $item) {
|
||||
$user_groups[$item["id_grupo"]] = $item["nombre"];
|
||||
|
||||
if ($item["tags"] != '') {
|
||||
$tags_group = explode(',', $item["tags"]);
|
||||
|
||||
foreach ($tags_group as $tag) {
|
||||
$user_tags[$tag] = tags_get_name($tag);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$user_groups_ids = implode(',', array_keys($acltags));
|
||||
|
||||
if (!empty($user_groups_ids)) {
|
||||
if (is_metaconsole()) {
|
||||
switch ($config["dbtype"]) {
|
||||
case "mysql":
|
||||
$list_groups = db_get_all_rows_sql("
|
||||
SELECT *
|
||||
FROM tgrupo
|
||||
WHERE id_grupo IN (" . $user_groups_ids . ")
|
||||
AND id_grupo IN (SELECT id_grupo FROM tmetaconsole_agent WHERE disabled = 0)
|
||||
ORDER BY nombre COLLATE utf8_general_ci ASC");
|
||||
break;
|
||||
case "postgresql":
|
||||
$list_groups = db_get_all_rows_sql("
|
||||
SELECT *
|
||||
FROM tgrupo
|
||||
WHERE id_grupo IN (" . $user_groups_ids . ")
|
||||
AND id_grupo IN (SELECT id_grupo FROM tmetaconsole_agent WHERE disabled = 0)
|
||||
ORDER BY nombre ASC");
|
||||
break;
|
||||
case "oracle":
|
||||
$list_groups = db_get_all_rows_sql("
|
||||
SELECT *
|
||||
FROM tgrupo
|
||||
WHERE id_grupo IN (" . $user_groups_ids . ")
|
||||
AND id_grupo IN (SELECT id_grupo FROM tmetaconsole_agent WHERE disabled = 0)
|
||||
ORDER BY nombre ASC");
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
switch ($config["dbtype"]) {
|
||||
case "mysql":
|
||||
$list_groups = db_get_all_rows_sql("
|
||||
SELECT *
|
||||
FROM tgrupo
|
||||
WHERE id_grupo IN (" . $user_groups_ids . ")
|
||||
AND id_grupo IN (SELECT id_grupo FROM tagente WHERE disabled = 0)
|
||||
ORDER BY nombre COLLATE utf8_general_ci ASC");
|
||||
break;
|
||||
case "postgresql":
|
||||
$list_groups = db_get_all_rows_sql("
|
||||
SELECT *
|
||||
FROM tgrupo
|
||||
WHERE id_grupo IN (" . $user_groups_ids . ")
|
||||
AND id_grupo IN (SELECT id_grupo FROM tagente WHERE disabled = 0)
|
||||
ORDER BY nombre ASC");
|
||||
break;
|
||||
case "oracle":
|
||||
$list_groups = db_get_all_rows_sql("
|
||||
SELECT *
|
||||
FROM tgrupo
|
||||
WHERE id_grupo IN (" . $user_groups_ids . ")
|
||||
AND id_grupo IN (SELECT id_grupo FROM tagente WHERE disabled = 0)
|
||||
ORDER BY nombre ASC");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($list_groups as $group) {
|
||||
$list[$group['id_grupo']]['_name_'] = $group['nombre'];
|
||||
$list[$group['id_grupo']]['_id_'] = $group['id_grupo'];
|
||||
$list[$group['id_grupo']]['_monitors_critical_'] = 0;
|
||||
$list[$group['id_grupo']]['_monitors_warning_'] = 0;
|
||||
$list[$group['id_grupo']]['_monitors_unknown_'] = 0;
|
||||
$list[$group['id_grupo']]['_monitors_not_init_'] = 0;
|
||||
$list[$group['id_grupo']]['_monitors_ok_'] = 0;
|
||||
$list[$group['id_grupo']]['_agents_not_init_'] = 0;
|
||||
$list[$group['id_grupo']]['_agents_unknown_'] = 0;
|
||||
$list[$group['id_grupo']]['_agents_critical_'] = 0;
|
||||
$list[$group['id_grupo']]['_total_agents_'] = 0;
|
||||
$list[$group['id_grupo']]["_monitor_checks_"] = 0;
|
||||
$list[$group['id_grupo']]["_monitor_not_normal_"] = 0;
|
||||
$list[$group['id_grupo']]['_monitors_alerts_fired_'] = 0;
|
||||
}
|
||||
if ($list_groups == false) {
|
||||
$list_groups = array();
|
||||
}
|
||||
|
||||
/*
|
||||
* Agent cache for metaconsole.
|
||||
* Retrieve the statistic data from the cache table.
|
||||
*/
|
||||
if (is_metaconsole()) {
|
||||
foreach ($list_groups as $group) {
|
||||
$group_agents = db_get_row_sql("SELECT SUM(warning_count) AS _monitors_warning_,
|
||||
SUM(critical_count) AS _monitors_critical_,
|
||||
SUM(normal_count) AS _monitors_ok_,
|
||||
SUM(unknown_count) AS _monitors_unknown_,
|
||||
SUM(notinit_count) AS _monitors_not_init_,
|
||||
SUM(fired_count) AS _monitors_alerts_fired_,
|
||||
COUNT(*) AS _total_agents_, id_grupo, intervalo,
|
||||
ultimo_contacto, disabled
|
||||
FROM tmetaconsole_agent ta
|
||||
LEFT JOIN tmetaconsole_agent_secondary_group tasg
|
||||
ON ta.id_agente = tasg.id_agent
|
||||
WHERE (
|
||||
ta.id_grupo = " . $group['id_grupo'] . "
|
||||
OR tasg.id_group = " . $group['id_grupo'] . "
|
||||
) AND disabled = 0 GROUP BY id_grupo");
|
||||
$list[$group['id_grupo']]['_monitors_critical_'] = (int)$group_agents['_monitors_critical_'];
|
||||
$list[$group['id_grupo']]['_monitors_warning_'] = (int)$group_agents['_monitors_warning_'];
|
||||
$list[$group['id_grupo']]['_monitors_unknown_'] = (int)$group_agents['_monitors_unknown_'];
|
||||
$list[$group['id_grupo']]['_monitors_not_init_'] = (int)$group_agents['_monitors_not_init_'];
|
||||
$list[$group['id_grupo']]['_monitors_ok_'] = (int)$group_agents['_monitors_ok_'];
|
||||
|
||||
$list[$group['id_grupo']]['_monitors_alerts_fired_'] = (int)$group_agents['_monitors_alerts_fired_'];
|
||||
|
||||
$list[$group['id_grupo']]['_total_agents_'] = (int)$group_agents['_total_agents_'];
|
||||
|
||||
$list[$group['id_grupo']]["_monitor_checks_"] = $list[$group['id_grupo']]["_monitors_not_init_"] + $list[$group['id_grupo']]["_monitors_unknown_"] + $list[$group['id_grupo']]["_monitors_warning_"] + $list[$group['id_grupo']]["_monitors_critical_"] + $list[$group['id_grupo']]["_monitors_ok_"];
|
||||
|
||||
// Calculate not_normal monitors
|
||||
$list[$group['id_grupo']]["_monitor_not_normal_"] = $list[$group['id_grupo']]["_monitor_checks_"] - $list[$group['id_grupo']]["_monitors_ok_"];
|
||||
|
||||
$total_agents = $list[$group['id_grupo']]['_total_agents_'];
|
||||
|
||||
if (($group['id_grupo'] != 0) && ($total_agents > 0)) {
|
||||
$agents = db_get_all_rows_sql("SELECT warning_count,
|
||||
critical_count,
|
||||
normal_count,
|
||||
unknown_count,
|
||||
notinit_count,
|
||||
fired_count,
|
||||
disabled
|
||||
FROM tmetaconsole_agent
|
||||
WHERE id_grupo = " . $group['id_grupo'] );
|
||||
foreach ($agents as $agent) {
|
||||
if ($agent['critical_count'] > 0) {
|
||||
$list[$group['id_grupo']]['_agents_critical_'] += 1;
|
||||
}
|
||||
else {
|
||||
if (($agent['critical_count'] == 0) && ($agent['warning_count'] == 0) && ($group_agents['disabled'] == 0) && ($agent['normal_count'] == 0)) {
|
||||
if ($agent['unknown_count'] > 0) {
|
||||
$list[$group['id_grupo']]['_agents_unknown_'] += 1;
|
||||
}
|
||||
}
|
||||
if (($agent['critical_count'] == 0) && ($agent['warning_count'] == 0) && ($group_agents['disabled'] == 0) && ($agent['normal_count'] == 0) && ($agent['unknown_count'] == 0)) {
|
||||
if ($agent['notinit_count'] > 0) {
|
||||
$list[$group['id_grupo']]['_agents_not_init_'] += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (false) { //FIXME: The cached group view is wasted. Avoid to reach this code.
|
||||
|
||||
$group_stat = db_get_all_rows_sql ("SELECT
|
||||
SUM(ta.normal_count) as normal, SUM(ta.critical_count) as critical,
|
||||
SUM(ta.warning_count) as warning,SUM(ta.unknown_count) as unknown,
|
||||
SUM(ta.notinit_count) as not_init, SUM(fired_count) as alerts_fired
|
||||
FROM tagente ta
|
||||
WHERE id_grupo IN ($user_groups_ids)");
|
||||
|
||||
$list['_agents_unknown_'] = $group_stat[0]["unknown"];
|
||||
$list['_monitors_alerts_fired_'] = $group_stat[0]["alerts_fired"];
|
||||
|
||||
$list['_monitors_ok_'] = $group_stat[0]["normal"];
|
||||
$list['_monitors_warning_'] = $group_stat[0]["warning"];
|
||||
$list['_monitors_critical_'] = $group_stat[0]["critical"];
|
||||
$list['_monitors_unknown_'] = $group_stat[0]["unknown"];
|
||||
$list['_monitors_not_init_'] = $group_stat[0]["not_init"];
|
||||
$total_agentes = agents_get_agents (false, array('count(*) as total_agents'), $access,false, false);
|
||||
$list['_total_agents_'] = $total_agentes[0]['total_agents'];
|
||||
$list["_monitor_alerts_fire_count_"] = $group_stat[0]["alerts_fired"];
|
||||
|
||||
$list['_monitors_alerts_'] = groupview_monitor_alerts (explode(',',$user_groups_ids), $user_strict,explode(',',$user_groups_ids));
|
||||
// Get total count of monitors for this group, except disabled.
|
||||
$list["_monitor_checks_"] = $list["_monitors_not_init_"] + $list["_monitors_unknown_"] + $list["_monitors_warning_"] + $list["_monitors_critical_"] + $list["_monitors_ok_"];
|
||||
|
||||
// Calculate not_normal monitors
|
||||
$list["_monitor_not_normal_"] = $list["_monitor_checks_"] - $list["_monitors_ok_"];
|
||||
|
||||
if ($list["_monitor_not_normal_"] > 0 && $list["_monitor_checks_"] > 0) {
|
||||
$list["_monitor_health_"] = format_numeric (100 - ($list["_monitor_not_normal_"] / ($list["_monitor_checks_"] / 100)), 1);
|
||||
}
|
||||
else {
|
||||
$list["_monitor_health_"] = 100;
|
||||
}
|
||||
|
||||
if ($list["_monitors_not_init_"] > 0 && $list["_monitor_checks_"] > 0) {
|
||||
$list["_module_sanity_"] = format_numeric (100 - ($list["_monitors_not_init_"] / ($list["_monitor_checks_"] / 100)), 1);
|
||||
}
|
||||
else {
|
||||
$list["_module_sanity_"] = 100;
|
||||
}
|
||||
|
||||
if (isset($list["_alerts_"])) {
|
||||
if ($list["_monitors_alerts_fired_"] > 0 && $list["_alerts_"] > 0) {
|
||||
$list["_alert_level_"] = format_numeric (100 - ($list["_monitors_alerts_fired_"] / ($list["_alerts_"] / 100)), 1);
|
||||
}
|
||||
else {
|
||||
$list["_alert_level_"] = 100;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$list["_alert_level_"] = 100;
|
||||
$list["_alerts_"] = 0;
|
||||
}
|
||||
|
||||
$list["_monitor_bad_"] = $list["_monitors_critical_"] + $list["_monitors_warning_"];
|
||||
|
||||
if ($list["_monitor_bad_"] > 0 && $list["_monitor_checks_"] > 0) {
|
||||
$list["_global_health_"] = format_numeric (100 - ($list["_monitor_bad_"] / ($list["_monitor_checks_"] / 100)), 1);
|
||||
}
|
||||
else {
|
||||
$list["_global_health_"] = 100;
|
||||
}
|
||||
|
||||
$list["_server_sanity_"] = format_numeric (100 - $list["_module_sanity_"], 1);
|
||||
}
|
||||
else {
|
||||
foreach ($list_groups as $group) {
|
||||
$agent_not_init = agents_get_agents(array (
|
||||
'disabled' => 0,
|
||||
'id_grupo' => $group['id_grupo'],
|
||||
'status' => AGENT_STATUS_NOT_INIT),
|
||||
array ('COUNT(DISTINCT id_agente) as total'), $access, false);
|
||||
$list[$group['id_grupo']]['_agents_not_init_'] = isset ($agent_not_init[0]['total']) ? $agent_not_init[0]['total'] : 0;
|
||||
$agent_unknown = agents_get_agents(array (
|
||||
'disabled' => 0,
|
||||
'id_grupo' => $group['id_grupo'],
|
||||
'status' => AGENT_STATUS_UNKNOWN),
|
||||
array ('COUNT(DISTINCT id_agente) as total'), $access, false);
|
||||
$list[$group['id_grupo']]['_agents_unknown_'] = isset ($agent_unknown[0]['total']) ? $agent_unknown[0]['total'] : 0;
|
||||
$agent_critical = agents_get_agents(array (
|
||||
'disabled' => 0,
|
||||
'id_grupo' => $group['id_grupo'],
|
||||
'status' => AGENT_STATUS_CRITICAL),
|
||||
array ('COUNT(DISTINCT id_agente) as total'), $access, false);
|
||||
$list[$group['id_grupo']]['_agents_critical_'] = isset ($agent_critical[0]['total']) ? $agent_critical[0]['total'] : 0;
|
||||
$agent_total = agents_get_agents(array (
|
||||
'disabled' => 0,
|
||||
'id_grupo' => $group['id_grupo']),
|
||||
array ('COUNT(DISTINCT id_agente) as total'), $access, false);
|
||||
$list[$group['id_grupo']]['_total_agents_'] = isset ($agent_total[0]['total']) ? $agent_total[0]['total'] : 0;
|
||||
$list[$group['id_grupo']]["_monitor_not_normal_"] = $list[$group['id_grupo']]["_monitor_checks_"] - $list[$group['id_grupo']]["_monitors_ok_"];
|
||||
$list[$group['id_grupo']]['_monitors_alerts_fired_'] = groupview_monitor_fired_alerts ($group['id_grupo'], $user_strict,array($group['id_grupo']));
|
||||
$result_list = db_get_all_rows_sql("SELECT COUNT(*) as contado, estado
|
||||
FROM tagente_estado tae INNER JOIN tagente ta
|
||||
ON tae.id_agente = ta.id_agente
|
||||
AND ta.disabled = 0
|
||||
AND ta.id_grupo = " . $group['id_grupo'] . "
|
||||
INNER JOIN tagente_modulo tam
|
||||
ON tae.id_agente_modulo = tam.id_agente_modulo
|
||||
AND tam.disabled = 0
|
||||
WHERE tae.utimestamp > 0
|
||||
GROUP BY estado");
|
||||
if ($result_list) {
|
||||
foreach ($result_list as $result) {
|
||||
switch ($result['estado']) {
|
||||
case AGENT_MODULE_STATUS_CRITICAL_BAD:
|
||||
$list[$group['id_grupo']]['_monitors_critical_'] = (int)$result['contado'];
|
||||
break;
|
||||
case AGENT_MODULE_STATUS_WARNING_ALERT:
|
||||
break;
|
||||
case AGENT_MODULE_STATUS_WARNING:
|
||||
$list[$group['id_grupo']]['_monitors_warning_'] = (int)$result['contado'];
|
||||
break;
|
||||
case AGENT_MODULE_STATUS_UNKNOWN:
|
||||
$list[$group['id_grupo']]['_monitors_unknown_'] = (int)$result['contado'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
$result_normal = db_get_row_sql("SELECT COUNT(*) as contado
|
||||
FROM tagente_estado tae INNER JOIN tagente ta
|
||||
ON tae.id_agente = ta.id_agente
|
||||
AND ta.disabled = 0
|
||||
AND ta.id_grupo = " . $group['id_grupo'] . "
|
||||
INNER JOIN tagente_modulo tam
|
||||
ON tae.id_agente_modulo = tam.id_agente_modulo
|
||||
AND tam.disabled = 0
|
||||
WHERE tae.estado = 0
|
||||
AND (tae.utimestamp > 0 OR tam.id_tipo_modulo IN(21,22,23,100))
|
||||
GROUP BY estado");
|
||||
$list[$group['id_grupo']]['_monitors_ok_'] = isset ($result_normal['contado']) ? $result_normal['contado'] : 0;
|
||||
|
||||
$result_not_init = db_get_row_sql("SELECT COUNT(*) as contado
|
||||
FROM tagente_estado tae INNER JOIN tagente ta
|
||||
ON tae.id_agente = ta.id_agente
|
||||
AND ta.disabled = 0
|
||||
AND ta.id_grupo = " . $group['id_grupo'] . "
|
||||
INNER JOIN tagente_modulo tam
|
||||
ON tae.id_agente_modulo = tam.id_agente_modulo
|
||||
AND tam.disabled = 0
|
||||
WHERE tae.utimestamp = 0
|
||||
AND tae.estado IN (".AGENT_MODULE_STATUS_NO_DATA.",".AGENT_MODULE_STATUS_NOT_INIT." )
|
||||
AND tam.id_tipo_modulo NOT IN (21,22,23,100)
|
||||
GROUP BY estado");
|
||||
$list[$group['id_grupo']]['_monitors_not_init_'] = isset ($result_not_init['contado']) ? $result_not_init['contado'] : 0;
|
||||
}
|
||||
}
|
||||
return $list;
|
||||
}
|
||||
|
||||
function groupview_status_modules_agents($id_user = false, $user_strict = false, $access = 'AR', $force_group_and_tag = true, $returnAllGroup = false) {
|
||||
global $config;
|
||||
|
||||
if ($id_user == false) {
|
||||
$id_user = $config['id_user'];
|
||||
}
|
||||
|
||||
//$acltags = tags_get_user_groups_and_tags ($id_user, $access, $user_strict);
|
||||
$acltags = users_get_groups ($id_user, $access, true, true);
|
||||
|
||||
$result_list = groupview_get_all_data ($id_user, $user_strict,
|
||||
$acltags, false, array(), array(), $access);
|
||||
return $result_list;
|
||||
}
|
||||
|
||||
function groupview_monitor_alerts ($group_array, $strict_user = false, $id_group_strict = false) {
|
||||
|
||||
// If there are not groups to query, we jump to nextone
|
||||
|
||||
if (empty ($group_array)) {
|
||||
return 0;
|
||||
|
||||
}
|
||||
else if (!is_array ($group_array)) {
|
||||
$group_array = array($group_array);
|
||||
}
|
||||
|
||||
$group_clause = implode (",", $group_array);
|
||||
$group_clause = "(" . $group_clause . ")";
|
||||
|
||||
if ($strict_user) {
|
||||
$group_clause_strict = implode (",", $id_group_strict);
|
||||
$group_clause_strict = "(" . $group_clause_strict . ")";
|
||||
if ($group_clause_strict !== '()') {
|
||||
$sql = "SELECT COUNT(talert_template_modules.id)
|
||||
FROM talert_template_modules, tagente_modulo, tagente_estado, tagente
|
||||
WHERE tagente.id_grupo IN $group_clause_strict AND tagente_modulo.id_agente = tagente.id_agente
|
||||
AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo
|
||||
AND talert_template_modules.id_agent_module = tagente_modulo.id_agente_modulo";
|
||||
}
|
||||
$count = db_get_sql ($sql);
|
||||
return $count;
|
||||
} else {
|
||||
//TODO REVIEW ORACLE AND POSTGRES
|
||||
return db_get_sql ("SELECT COUNT(talert_template_modules.id)
|
||||
FROM talert_template_modules, tagente_modulo, tagente_estado, tagente
|
||||
WHERE tagente.id_grupo IN $group_clause AND tagente_modulo.id_agente = tagente.id_agente
|
||||
AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo
|
||||
AND talert_template_modules.id_agent_module = tagente_modulo.id_agente_modulo");
|
||||
}
|
||||
}
|
||||
|
||||
function groupview_monitor_fired_alerts ($group_array, $strict_user = false, $id_group_strict = false) {
|
||||
|
||||
// If there are not groups to query, we jump to nextone
|
||||
if (empty ($group_array)) {
|
||||
return 0;
|
||||
}
|
||||
else if (!is_array ($group_array)) {
|
||||
$group_array = array($group_array);
|
||||
}
|
||||
|
||||
$group_clause = implode (",", $group_array);
|
||||
$group_clause = "(" . $group_clause . ")";
|
||||
|
||||
return db_get_sql ("SELECT COUNT(talert_template_modules.id)
|
||||
FROM talert_template_modules, tagente_modulo, tagente_estado, tagente
|
||||
WHERE tagente.id_grupo IN $group_clause AND tagente_modulo.id_agente = tagente.id_agente
|
||||
AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo
|
||||
AND talert_template_modules.id_agent_module = tagente_modulo.id_agente_modulo
|
||||
AND times_fired > 0");
|
||||
}
|
||||
|
||||
function groupview_get_groups_list($id_user = false, $access = 'AR') {
|
||||
global $config;
|
||||
if ($id_user == false) {
|
||||
$id_user = $config['id_user'];
|
||||
}
|
||||
|
||||
$user_groups = users_get_groups($id_user, $access, true, false);
|
||||
|
||||
$groups_with_privileges = implode(',', array_keys($user_groups));
|
||||
|
||||
//change ALL for 0
|
||||
$user_groups[0] = 0;
|
||||
|
||||
$user_groups_ids = implode(',', array_keys($user_groups));
|
||||
|
||||
if (!empty($user_groups_ids)) {
|
||||
$table = is_metaconsole() ? 'tmetaconsole_agent' : 'tagente';
|
||||
$table_secondary = is_metaconsole()
|
||||
? 'tmetaconsole_agent_secondary_group'
|
||||
: 'tagent_secondary_group';
|
||||
|
||||
$list_groups = db_get_all_rows_sql("
|
||||
SELECT *
|
||||
FROM tgrupo
|
||||
WHERE id_grupo IN ($user_groups_ids)
|
||||
AND (
|
||||
id_grupo IN (SELECT id_grupo FROM $table WHERE disabled = 0)
|
||||
OR id_grupo IN (SELECT id_group FROM $table_secondary WHERE id_group IN ($user_groups_ids))
|
||||
)
|
||||
ORDER BY nombre COLLATE utf8_general_ci ASC"
|
||||
);
|
||||
}
|
||||
|
||||
//Add the group "All" at first
|
||||
$group_all = array('id_grupo'=>0, 'nombre'=>'All', 'icon'=>'', 'parent'=>'', 'propagate'=>0, 'disabled'=>0,
|
||||
'custom_id'=>'', 'id_skin'=>0, 'description'=>'', 'contact'=>'', 'other'=>'', 'password'=>'');
|
||||
if ($list_groups !== false) {
|
||||
array_unshift($list_groups, $group_all);
|
||||
} else {
|
||||
$list_groups = array($group_all);
|
||||
}
|
||||
|
||||
//Takes the parents even without agents, first ids
|
||||
$fathers_id = '';
|
||||
$list_father_groups = array();
|
||||
foreach ($list_groups as $group) {
|
||||
if ($group['parent'] != '') {
|
||||
$grup = $group['parent'];
|
||||
while ($grup != 0) {
|
||||
$recursive_fathers = db_get_row_sql ("SELECT parent FROM tgrupo
|
||||
WHERE id_grupo = " . $grup);
|
||||
$grup = $recursive_fathers['parent'];
|
||||
if (!strpos($fathers_id, $grup)) {
|
||||
$fathers_id .= ',' . $grup;
|
||||
}
|
||||
}
|
||||
if (!strpos($fathers_id, $group['parent'])) {
|
||||
$fathers_id .= ',' . $group['parent'];
|
||||
}
|
||||
}
|
||||
}
|
||||
//Eliminate the first comma
|
||||
$fathers_id = substr($fathers_id, 1);
|
||||
while ($fathers_id{0} == ',') {
|
||||
$fathers_id = substr($fathers_id, 1);
|
||||
}
|
||||
//Takes the parents even without agents, complete groups
|
||||
if ($fathers_id) {
|
||||
$list_father_groups = db_get_all_rows_sql("
|
||||
SELECT *
|
||||
FROM tgrupo
|
||||
WHERE id_grupo IN (" . $fathers_id . ")
|
||||
AND id_grupo IN (" . $groups_with_privileges . ")
|
||||
ORDER BY nombre COLLATE utf8_general_ci ASC");
|
||||
if (!empty($list_father_groups)) {
|
||||
//Merges the arrays and eliminates the duplicates groups
|
||||
$list_groups = array_merge($list_groups, $list_father_groups);
|
||||
}
|
||||
}
|
||||
$list_groups = groupview_array_unique_multidim($list_groups, 'id_grupo');
|
||||
//Order groups (Father-children)
|
||||
$ordered_groups = groupview_order_groups_for_parents($list_groups);
|
||||
$ordered_ids = array();
|
||||
$ordered_ids = groupview_order_group_ids($ordered_groups, $ordered_ids);
|
||||
$final_list = array();
|
||||
array_push($final_list, $group_all);
|
||||
|
||||
foreach ($ordered_ids as $key) {
|
||||
if ($key == 'All') {
|
||||
continue;
|
||||
}
|
||||
$complete_group = db_get_row_sql("
|
||||
SELECT *
|
||||
FROM tgrupo
|
||||
WHERE nombre = '" . $key . "'");
|
||||
array_push($final_list, $complete_group);
|
||||
}
|
||||
|
||||
$list_groups = $final_list;
|
||||
|
||||
$list = array();
|
||||
foreach ($list_groups as $group) {
|
||||
$list[$group['id_grupo']]['_name_'] = $group['nombre'];
|
||||
$list[$group['id_grupo']]['_id_'] = $group['id_grupo'];
|
||||
$list[$group['id_grupo']]['icon'] = $group['icon'];
|
||||
$list[$group['id_grupo']]['_monitors_critical_'] = 0;
|
||||
$list[$group['id_grupo']]['_monitors_warning_'] = 0;
|
||||
$list[$group['id_grupo']]['_monitors_unknown_'] = 0;
|
||||
$list[$group['id_grupo']]['_monitors_not_init_'] = 0;
|
||||
$list[$group['id_grupo']]['_monitors_ok_'] = 0;
|
||||
$list[$group['id_grupo']]['_agents_not_init_'] = 0;
|
||||
$list[$group['id_grupo']]['_agents_unknown_'] = 0;
|
||||
$list[$group['id_grupo']]['_agents_critical_'] = 0;
|
||||
$list[$group['id_grupo']]['_total_agents_'] = 0;
|
||||
$list[$group['id_grupo']]["_monitor_checks_"] = 0;
|
||||
$list[$group['id_grupo']]["_monitor_not_normal_"] = 0;
|
||||
$list[$group['id_grupo']]['_monitors_alerts_fired_'] = 0;
|
||||
}
|
||||
|
||||
if ($list_groups == false) {
|
||||
$list_groups = array();
|
||||
}
|
||||
|
||||
if (is_metaconsole() || ($config["realtimestats"] == 0)) { // Agent cache
|
||||
$list = group_view_get_cache_stats ($list, $list_groups, $user_groups_ids);
|
||||
} else {
|
||||
foreach ($list_groups as $group) {
|
||||
// If id group is 0 get all accesses groups
|
||||
$group_id = $group['id_grupo'] == 0
|
||||
? $user_groups_ids
|
||||
: $group['id_grupo'];
|
||||
$agent_not_init = agents_get_agents(array (
|
||||
'disabled' => 0,
|
||||
'id_grupo' => $group['id_grupo'],
|
||||
'status' => AGENT_STATUS_NOT_INIT),
|
||||
array ('COUNT(DISTINCT id_agente) as total'), $access, false);
|
||||
$list[$group['id_grupo']]['_agents_not_init_'] = isset ($agent_not_init[0]['total']) ? $agent_not_init[0]['total'] : 0;
|
||||
$agent_unknown = agents_get_agents(array (
|
||||
'disabled' => 0,
|
||||
'id_grupo' => $group['id_grupo'],
|
||||
'status' => AGENT_STATUS_UNKNOWN),
|
||||
array ('COUNT(DISTINCT id_agente) as total'), $access, false);
|
||||
$list[$group['id_grupo']]['_agents_unknown_'] = isset ($agent_unknown[0]['total']) ? $agent_unknown[0]['total'] : 0;
|
||||
$agent_critical = agents_get_agents(array (
|
||||
'disabled' => 0,
|
||||
'id_grupo' => $group['id_grupo'],
|
||||
'status' => AGENT_STATUS_CRITICAL),
|
||||
array ('COUNT(DISTINCT id_agente) as total'), $access, false);
|
||||
$list[$group['id_grupo']]['_agents_critical_'] = isset ($agent_critical[0]['total']) ? $agent_critical[0]['total'] : 0;
|
||||
$agent_total = agents_get_agents(array (
|
||||
'disabled' => 0,
|
||||
'id_grupo' => $group['id_grupo']),
|
||||
array ('COUNT(DISTINCT id_agente) as total'), $access, false);
|
||||
$list[$group['id_grupo']]['_total_agents_'] = isset ($agent_total[0]['total']) ? $agent_total[0]['total'] : 0;
|
||||
$list[$group['id_grupo']]["_monitor_not_normal_"] = $list[$group['id_grupo']]["_monitor_checks_"] - $list[$group['id_grupo']]["_monitors_ok_"];
|
||||
$list[$group['id_grupo']]["_monitor_not_normal_"] = $list[$group['id_grupo']]["_monitor_checks_"] - $list[$group['id_grupo']]["_monitors_ok_"];
|
||||
$list[$group['id_grupo']]['_monitors_alerts_fired_'] = groupview_monitor_fired_alerts ($group['id_grupo'], $user_strict,$group['id_grupo']);
|
||||
$result_list = db_get_all_rows_sql("SELECT COUNT(*) as contado, estado
|
||||
FROM tagente_estado tae INNER JOIN tagente ta
|
||||
ON tae.id_agente = ta.id_agente
|
||||
AND ta.disabled = 0
|
||||
LEFT JOIN tagent_secondary_group tasg
|
||||
ON tasg.id_agent = ta.id_agente
|
||||
INNER JOIN tagente_modulo tam
|
||||
ON tae.id_agente_modulo = tam.id_agente_modulo
|
||||
AND tam.disabled = 0
|
||||
WHERE tae.utimestamp > 0
|
||||
AND (
|
||||
ta.id_grupo IN (" . $group_id . ")
|
||||
OR tasg.id_group IN (" . $group_id . ")
|
||||
)
|
||||
GROUP BY estado");
|
||||
if ($result_list) {
|
||||
foreach ($result_list as $result) {
|
||||
switch ($result['estado']) {
|
||||
case AGENT_MODULE_STATUS_CRITICAL_BAD:
|
||||
$list[$group['id_grupo']]['_monitors_critical_'] = (int)$result['contado'];
|
||||
break;
|
||||
case AGENT_MODULE_STATUS_WARNING_ALERT:
|
||||
break;
|
||||
case AGENT_MODULE_STATUS_WARNING:
|
||||
$list[$group['id_grupo']]['_monitors_warning_'] = (int)$result['contado'];
|
||||
break;
|
||||
case AGENT_MODULE_STATUS_UNKNOWN:
|
||||
$list[$group['id_grupo']]['_monitors_unknown_'] = (int)$result['contado'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$result_normal = db_get_row_sql("SELECT COUNT(*) as contado
|
||||
FROM tagente_estado tae INNER JOIN tagente ta
|
||||
ON tae.id_agente = ta.id_agente
|
||||
AND ta.disabled = 0
|
||||
LEFT JOIN tagent_secondary_group tasg
|
||||
ON tasg.id_agent = ta.id_agente
|
||||
INNER JOIN tagente_modulo tam
|
||||
ON tae.id_agente_modulo = tam.id_agente_modulo
|
||||
AND tam.disabled = 0
|
||||
WHERE tae.estado = 0
|
||||
AND (tae.utimestamp > 0 OR tam.id_tipo_modulo IN(21,22,23,100))
|
||||
AND (
|
||||
ta.id_grupo IN (" . $group_id . ")
|
||||
OR tasg.id_group IN (" . $group_id . ")
|
||||
)
|
||||
GROUP BY estado");
|
||||
$list[$group['id_grupo']]['_monitors_ok_'] = isset ($result_normal['contado']) ? $result_normal['contado'] : 0;
|
||||
|
||||
$result_not_init = db_get_row_sql("SELECT COUNT(*) as contado
|
||||
FROM tagente_estado tae INNER JOIN tagente ta
|
||||
ON tae.id_agente = ta.id_agente
|
||||
AND ta.disabled = 0
|
||||
LEFT JOIN tagent_secondary_group tasg
|
||||
ON tasg.id_agent = ta.id_agente
|
||||
INNER JOIN tagente_modulo tam
|
||||
ON tae.id_agente_modulo = tam.id_agente_modulo
|
||||
AND tam.disabled = 0
|
||||
WHERE tae.utimestamp = 0 AND
|
||||
tae.estado IN (".AGENT_MODULE_STATUS_NO_DATA.",".AGENT_MODULE_STATUS_NOT_INIT." )
|
||||
AND tam.id_tipo_modulo NOT IN (21,22,23,100)
|
||||
AND (
|
||||
ta.id_grupo IN (" . $group_id . ")
|
||||
OR tasg.id_group IN (" . $group_id . ")
|
||||
)
|
||||
GROUP BY estado");
|
||||
$list[$group['id_grupo']]['_monitors_not_init_'] = isset ($result_not_init['contado']) ? $result_not_init['contado'] : 0;
|
||||
}
|
||||
}
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
//Order the groups by parents
|
||||
function groupview_order_groups_for_parents ($view_groups) {
|
||||
$final_groups = array();
|
||||
// Index the groups
|
||||
$groups = array();
|
||||
foreach ($view_groups as $item) {
|
||||
$groups[$item['id_grupo']] = $item;
|
||||
}
|
||||
// Build the group hierarchy
|
||||
foreach ($groups as $id => $group) {
|
||||
$groups[$id]['have_parent'] = false;
|
||||
if (!isset($groups[$id]['parent']))
|
||||
continue;
|
||||
$parent = $groups[$id]['parent'];
|
||||
// Parent exists
|
||||
if (isset($groups[$parent])) {
|
||||
if (!isset($groups[$parent]['children']))
|
||||
$groups[$parent]['children'] = array();
|
||||
// Store a reference to the group into the parent
|
||||
$groups[$parent]['children'][] = &$groups[$id];
|
||||
|
||||
// This group was introduced into a parent
|
||||
$groups[$id]['have_parent'] = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Sort the children groups
|
||||
for ($i = 0; $i < count($groups); $i++) {
|
||||
if (isset($groups[$i]['children']))
|
||||
usort($groups[$i]['children'], function ($a, $b) {
|
||||
return strcmp($a["nombre"], $b["nombre"]);
|
||||
});
|
||||
}
|
||||
// Extract the root groups
|
||||
foreach ($groups as $group) {
|
||||
if (!$group['have_parent'])
|
||||
$final_groups[] = $group;
|
||||
}
|
||||
// Sort the root groups
|
||||
usort($final_groups, function ($a, $b) {
|
||||
return strcmp($a["name"], $b["name"]);
|
||||
});
|
||||
|
||||
return $final_groups;
|
||||
}
|
||||
|
||||
function groupview_order_group_ids($groups, $ordered_ids){
|
||||
function groupview_plain_groups($groups) {
|
||||
$group_result = array();
|
||||
foreach ($groups as $group) {
|
||||
$plain_child = array();
|
||||
if (!empty($group['children'])) {
|
||||
$ordered_ids[$group['id_grupo']] = $group['nombre'];
|
||||
$ordered_ids = groupview_order_group_ids($group['children'], $ordered_ids);
|
||||
}
|
||||
else {
|
||||
$ordered_ids[$group['id_grupo']] = $group['nombre'];
|
||||
$plain_child = groupview_plain_groups($group['children']);
|
||||
unset($group['children']);
|
||||
}
|
||||
$group_result[] = $group;
|
||||
$group_result = array_merge($group_result, $plain_child);
|
||||
}
|
||||
return $ordered_ids;
|
||||
return $group_result;
|
||||
}
|
||||
|
||||
//Function to eliminate duplicates groups in multidimensional array
|
||||
function groupview_array_unique_multidim($groups, $key){
|
||||
$temp_group = array();
|
||||
$i = 0;
|
||||
$key_group = array();
|
||||
foreach($groups as $group){
|
||||
if(!in_array($group[$key],$key_group)){
|
||||
$key_group[$i] = $group[$key];
|
||||
$temp_group[$i] = $group;
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
return $temp_group;
|
||||
function groupview_get_modules_counters($groups_ids = false) {
|
||||
if(empty($groups_ids)){
|
||||
return array();
|
||||
}
|
||||
|
||||
$groups_ids = implode(',', $groups_ids);
|
||||
$table = is_metaconsole() ? 'tmetaconsole_agent' : 'tagente';
|
||||
$table_sec = is_metaconsole()
|
||||
? 'tmetaconsole_agent_secondary_group'
|
||||
: 'tagent_secondary_group';
|
||||
|
||||
$fields = array (
|
||||
"g" ,
|
||||
"SUM(module_normal) AS total_module_normal",
|
||||
"SUM(module_critical) AS total_module_critical",
|
||||
"SUM(module_warning) AS total_module_warning",
|
||||
"SUM(module_unknown) AS total_module_unknown",
|
||||
"SUM(module_not_init) AS total_module_not_init",
|
||||
"SUM(module_alerts) AS total_module_alerts",
|
||||
"SUM(module_total) AS total_module"
|
||||
);
|
||||
|
||||
$fields_impl = implode(',', $fields);
|
||||
$sql = "SELECT $fields_impl FROM
|
||||
(
|
||||
SELECT SUM(ta.normal_count) AS module_normal,
|
||||
SUM(ta.critical_count) AS module_critical,
|
||||
SUM(ta.warning_count) AS module_warning,
|
||||
SUM(ta.unknown_count) AS module_unknown,
|
||||
SUM(ta.notinit_count) AS module_not_init,
|
||||
SUM(ta.fired_count) AS module_alerts,
|
||||
SUM(ta.total_count) AS module_total,
|
||||
ta.id_grupo AS g
|
||||
FROM $table ta
|
||||
WHERE ta.id_grupo IN ($groups_ids)
|
||||
GROUP BY ta.id_grupo
|
||||
UNION ALL
|
||||
SELECT SUM(ta.normal_count) AS module_normal,
|
||||
SUM(ta.critical_count) AS module_critical,
|
||||
SUM(ta.warning_count) AS module_warning,
|
||||
SUM(ta.unknown_count) AS module_unknown,
|
||||
SUM(ta.notinit_count) AS module_not_init,
|
||||
SUM(ta.fired_count) AS module_alerts,
|
||||
SUM(ta.total_count) AS module_total,
|
||||
tasg.id_group AS g
|
||||
FROM $table ta
|
||||
INNER JOIN $table_sec tasg
|
||||
ON ta.id_agente = tasg.id_agent
|
||||
WHERE tasg.id_group IN ($groups_ids)
|
||||
GROUP BY tasg.id_group
|
||||
) x GROUP BY g";
|
||||
return db_get_all_rows_sql($sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the stats to group view using the cache
|
||||
*
|
||||
* @param array Skeleton to fill with the group information
|
||||
* @param array Groups information
|
||||
* @param string Groups that user has access separated by commas
|
||||
*/
|
||||
function group_view_get_cache_stats ($list, $list_groups, $user_groups_ids) {
|
||||
function groupview_get_all_counters($tree_group) {
|
||||
$all_name = __("All");
|
||||
$group_acl = $tree_group->getGroupAclCondition();
|
||||
$table = is_metaconsole() ? 'tmetaconsole_agent' : 'tagente';
|
||||
$table_sec = is_metaconsole()
|
||||
? 'tmetaconsole_agent_secondary_group'
|
||||
: 'tagent_secondary_group';
|
||||
$sql =
|
||||
"SELECT SUM(ta.normal_count) AS _monitors_ok_,
|
||||
SUM(ta.critical_count) AS _monitors_critical_,
|
||||
SUM(ta.warning_count) AS _monitors_warning_,
|
||||
SUM(ta.unknown_count) AS _monitors_unknown_,
|
||||
SUM(ta.notinit_count) AS _monitors_not_init_,
|
||||
SUM(ta.fired_count) AS _monitors_alerts_fired_,
|
||||
SUM(ta.total_count) AS _monitor_checks_,
|
||||
SUM(IF(ta.critical_count > 0, 1, 0)) AS _agents_critical_,
|
||||
SUM(IF(ta.critical_count = 0 AND ta.warning_count = 0 AND ta.unknown_count > 0, 1, 0)) AS _agents_unknown_,
|
||||
SUM(IF(ta.total_count = ta.notinit_count, 1, 0)) AS _agents_not_init_,
|
||||
COUNT(ta.id_agente) AS _total_agents_,
|
||||
'$all_name' AS _name_,
|
||||
0 AS _id_,
|
||||
'' AS _icon_
|
||||
FROM $table ta
|
||||
WHERE ta.disabled = 0
|
||||
AND ta.id_agente IN (
|
||||
SELECT ta.id_agente FROM $table ta
|
||||
LEFT JOIN $table_sec tasg
|
||||
ON ta.id_agente = tasg.id_agent
|
||||
WHERE ta.disabled = 0
|
||||
$group_acl
|
||||
GROUP BY ta.id_agente
|
||||
)
|
||||
";
|
||||
$data = db_get_row_sql($sql);
|
||||
$data["_monitor_not_normal_"] = $data["_monitor_checks_"] - $data["_monitors_ok_"];
|
||||
return $data;
|
||||
}
|
||||
|
||||
$table_agent = 'tagente';
|
||||
$table_secondary = 'tagent_secondary_group';
|
||||
// Change the metaconsole tables
|
||||
if (is_metaconsole()) {
|
||||
$table_agent = 'tmetaconsole_agent';
|
||||
$table_secondary = 'tmetaconsole_agent_secondary_group';
|
||||
function groupview_get_groups_list($id_user = false, $access = 'AR', $is_not_paginated = false) {
|
||||
global $config;
|
||||
if ($id_user == false) {
|
||||
$id_user = $config['id_user'];
|
||||
}
|
||||
|
||||
// Walk for each group
|
||||
foreach ($list_groups as $group) {
|
||||
// If id group is 0 get all accesses groups
|
||||
$group_id = $group['id_grupo'] == 0
|
||||
? $user_groups_ids
|
||||
: $group['id_grupo'];
|
||||
$group_agents = db_get_row_sql("SELECT SUM(warning_count) AS _monitors_warning_,
|
||||
SUM(critical_count) AS _monitors_critical_,
|
||||
SUM(normal_count) AS _monitors_ok_,
|
||||
SUM(unknown_count) AS _monitors_unknown_,
|
||||
SUM(notinit_count) AS _monitors_not_init_,
|
||||
SUM(fired_count) AS _monitors_alerts_fired_,
|
||||
COUNT(*) AS _total_agents_, id_grupo, intervalo,
|
||||
ultimo_contacto, disabled
|
||||
FROM $table_agent ta
|
||||
LEFT JOIN $table_secondary tasg
|
||||
ON tasg.id_agent = ta.id_agente
|
||||
WHERE (
|
||||
ta.id_grupo IN (" . $group_id . ")
|
||||
OR tasg.id_group IN (" . $group_id . ")
|
||||
)
|
||||
AND disabled = 0");
|
||||
$tree_group = new TreeGroup("group", "group");
|
||||
$tree_group->setPropagateCounters(false);
|
||||
$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);
|
||||
|
||||
$list[$group['id_grupo']]['_monitors_critical_'] = (int)$group_agents['_monitors_critical_'];
|
||||
$list[$group['id_grupo']]['_monitors_warning_'] = (int)$group_agents['_monitors_warning_'];
|
||||
$list[$group['id_grupo']]['_monitors_unknown_'] = (int)$group_agents['_monitors_unknown_'];
|
||||
$list[$group['id_grupo']]['_monitors_not_init_'] = (int)$group_agents['_monitors_not_init_'];
|
||||
$list[$group['id_grupo']]['_monitors_ok_'] = (int)$group_agents['_monitors_ok_'];
|
||||
$list[$group['id_grupo']]['_monitors_alerts_fired_'] = (int)$group_agents['_monitors_alerts_fired_'];
|
||||
$list[$group['id_grupo']]['_total_agents_'] = (int)$group_agents['_total_agents_'];
|
||||
$list[$group['id_grupo']]["_monitor_checks_"] = $list[$group['id_grupo']]["_monitors_not_init_"]
|
||||
+ $list[$group['id_grupo']]["_monitors_unknown_"]
|
||||
+ $list[$group['id_grupo']]["_monitors_warning_"]
|
||||
+ $list[$group['id_grupo']]["_monitors_critical_"]
|
||||
+ $list[$group['id_grupo']]["_monitors_ok_"];
|
||||
$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());
|
||||
|
||||
if ($group['icon'])
|
||||
$list[$group['id_grupo']]["_iconImg_"] = html_print_image ("images/".$group['icon'].".png", true, array ("style" => 'vertical-align: middle;'));
|
||||
$modules_counters = groupview_get_modules_counters(array_keys($agents_counters));
|
||||
$modules_counters = array_reduce($modules_counters, function($carry, $item){
|
||||
$carry[$item['g']] = $item;
|
||||
return $carry;
|
||||
}, array());
|
||||
|
||||
// Calculate not_normal monitors
|
||||
$list[$group['id_grupo']]["_monitor_not_normal_"] = $list["_monitor_checks_"] - $list["_monitors_ok_"];
|
||||
$total_counters = array();
|
||||
|
||||
$total_agents = $list[$group['id_grupo']]['_total_agents_'];
|
||||
foreach ($agents_counters as $id_group => $agent_counter) {
|
||||
$list[$id_group]['_name_'] = $agent_counter['name'];
|
||||
$list[$id_group]['_id_'] = $agent_counter['id'];
|
||||
$list[$id_group]['_iconImg_'] = $agent_counter['icon'];
|
||||
|
||||
if ($total_agents > 0) {
|
||||
$agents = db_get_all_rows_sql(sprintf ("SELECT warning_count,
|
||||
critical_count,
|
||||
normal_count,
|
||||
unknown_count,
|
||||
notinit_count,
|
||||
fired_count,
|
||||
disabled
|
||||
FROM $table_agent ta
|
||||
LEFT JOIN $table_secondary tasg
|
||||
ON ta.id_agente = tasg.id_agent
|
||||
WHERE ta.id_grupo IN (%s) OR tasg.id_group IN (%s)",
|
||||
$group_id, $group_id));
|
||||
foreach ($agents as $agent) {
|
||||
if ($agent['critical_count'] > 0) {
|
||||
$list[$group['id_grupo']]['_agents_critical_'] += 1;
|
||||
}
|
||||
else {
|
||||
if (($agent['critical_count'] == 0) && ($agent['warning_count'] == 0) && ($group_agents['disabled'] == 0) && ($agent['normal_count'] == 0)) {
|
||||
if ($agent['unknown_count'] > 0) {
|
||||
$list[$group['id_grupo']]['_agents_unknown_'] += 1;
|
||||
}
|
||||
}
|
||||
if (($agent['critical_count'] == 0) && ($agent['warning_count'] == 0) && ($group_agents['disabled'] == 0) && ($agent['normal_count'] == 0) && ($agent['unknown_count'] == 0)) {
|
||||
if ($agent['notinit_count'] > 0) {
|
||||
$list[$group['id_grupo']]['_agents_not_init_'] += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$list[$id_group]['_agents_not_init_'] = $agent_counter['counters']['not_init'];
|
||||
$list[$id_group]['_agents_unknown_'] = $agent_counter['counters']['unknown'];
|
||||
$list[$id_group]['_agents_critical_'] = $agent_counter['counters']['critical'];
|
||||
$list[$id_group]['_total_agents_'] = $agent_counter['counters']['total'];
|
||||
|
||||
$list[$id_group]['_monitors_critical_'] = (int)$modules_counters[$id_group]['total_module_critical'];
|
||||
$list[$id_group]['_monitors_warning_'] = (int)$modules_counters[$id_group]['total_module_warning'];
|
||||
$list[$id_group]['_monitors_unknown_'] = (int)$modules_counters[$id_group]['total_module_unknown'];
|
||||
$list[$id_group]['_monitors_not_init_'] = (int)$modules_counters[$id_group]['total_module_not_init'];
|
||||
$list[$id_group]['_monitors_ok_'] = (int)$modules_counters[$id_group]['total_module_normal'];
|
||||
$list[$id_group]["_monitor_checks_"] = (int)$modules_counters[$id_group]['total_module'];
|
||||
$list[$id_group]["_monitor_not_normal_"] = $list[$group['id_grupo']]["_monitor_checks_"] - $list[$group['id_grupo']]['_monitors_ok_'];
|
||||
$list[$id_group]['_monitors_alerts_fired_'] = (int)$modules_counters[$id_group]['total_module_alerts'];
|
||||
}
|
||||
return $list;
|
||||
|
||||
array_unshift($list, groupview_get_all_counters($tree_group));
|
||||
return array(
|
||||
'groups' => $list,
|
||||
'counter' => $counter
|
||||
);
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
@ -2504,4 +2504,24 @@ function html_print_sort_arrows ($params, $order_tag, $up = 'up', $down = 'down'
|
|||
'</a>'
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* Print an input hidden with a new csrf token generated
|
||||
*/
|
||||
function html_print_csrf_hidden () {
|
||||
html_print_input_hidden('csrf_code', generate_csrf_code());
|
||||
}
|
||||
|
||||
/**
|
||||
* Print an error if csrf is incorrect
|
||||
*/
|
||||
function html_print_csrf_error () {
|
||||
if (validate_csrf_code()) return false;
|
||||
|
||||
ui_print_error_message (
|
||||
__('%s cannot verify the origin of the request. Try again, please.',
|
||||
get_product_name())
|
||||
);
|
||||
return true;
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -2775,4 +2775,37 @@ function modules_get_counter_by_states($state) {
|
|||
// to not show any data
|
||||
return false;
|
||||
}
|
||||
?>
|
||||
|
||||
function modules_get_state_condition($state) {
|
||||
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."
|
||||
)";
|
||||
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."
|
||||
)";
|
||||
case AGENT_MODULE_STATUS_UNKNOWN:
|
||||
return "tae.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."
|
||||
)";
|
||||
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."
|
||||
)";
|
||||
}
|
||||
// If the state is not an expected state, return no condition
|
||||
return "1=1";
|
||||
}
|
||||
?>
|
|
@ -395,7 +395,8 @@ function reporting_make_reporting_data($report = null, $id_report,
|
|||
$content,
|
||||
$type,
|
||||
$force_width_chart,
|
||||
$force_height_chart);
|
||||
$force_height_chart
|
||||
);
|
||||
break;
|
||||
case 'netflow_area':
|
||||
$report['contents'][] = reporting_netflow(
|
||||
|
@ -628,7 +629,6 @@ function reporting_make_reporting_data($report = null, $id_report,
|
|||
}
|
||||
$index_content++;
|
||||
}
|
||||
|
||||
return reporting_check_structure_report($report);
|
||||
}
|
||||
|
||||
|
@ -2807,18 +2807,17 @@ function agents_get_network_interfaces_array(
|
|||
$row_interface['chart'] = null;
|
||||
|
||||
$width = null;
|
||||
$height = null;
|
||||
|
||||
$params =array(
|
||||
'period' => $content['period'],
|
||||
'width' => $width,
|
||||
'height' => $height,
|
||||
'unit_name' => array_fill(0, count($interface['traffic']), __("bytes/s")),
|
||||
'date' => $report["datetime"],
|
||||
'only_image'=> $pdf,
|
||||
'homeurl' => $config['homeurl'],
|
||||
'fullscale' => $fullscale,
|
||||
'server_id' => $id_meta
|
||||
'server_id' => $id_meta,
|
||||
'height' => $config['graph_image_height']
|
||||
);
|
||||
|
||||
$params_combined = array(
|
||||
|
@ -3483,79 +3482,6 @@ function reporting_netflow($report, $content, $type,
|
|||
return reporting_check_structure_content($return);
|
||||
}
|
||||
|
||||
function reporting_simple_baseline_graph($report, $content,
|
||||
$type = 'dinamic', $force_width_chart = null,
|
||||
$force_height_chart = null) {
|
||||
|
||||
global $config;
|
||||
|
||||
if ($config['metaconsole']) {
|
||||
$id_meta = metaconsole_get_id_server($content["server_name"]);
|
||||
$server = metaconsole_get_connection_by_id ($id_meta);
|
||||
metaconsole_connect($server);
|
||||
}
|
||||
|
||||
$return['type'] = 'simple_baseline_graph';
|
||||
|
||||
if (empty($content['name'])) {
|
||||
$content['name'] = __('Simple baseline graph');
|
||||
}
|
||||
|
||||
$module_name = io_safe_output(
|
||||
modules_get_agentmodule_name($content['id_agent_module']));
|
||||
$agent_name = io_safe_output(
|
||||
modules_get_agentmodule_agent_alias ($content['id_agent_module']));
|
||||
|
||||
$return['title'] = $content['name'];
|
||||
$return['subtitle'] = $agent_name . " - " . $module_name;
|
||||
$return["description"] = $content["description"];
|
||||
$return["date"] = reporting_get_date_text($report, $content);
|
||||
$return['label'] = (isset($content['style']['label'])) ? $content['style']['label'] : '';
|
||||
|
||||
// Get chart
|
||||
reporting_set_conf_charts($width, $height, $only_image, $type,
|
||||
$content, $ttl);
|
||||
|
||||
$baseline_data = enterprise_hook(
|
||||
'reporting_enterprise_get_baseline',
|
||||
array (
|
||||
$content['id_agent_module'],
|
||||
$content['period'],
|
||||
$report["datetime"]
|
||||
)
|
||||
);
|
||||
|
||||
if ($baseline_data === ENTERPRISE_NOT_HOOK) {
|
||||
$baseline_data = array ();
|
||||
}
|
||||
|
||||
switch ($type) {
|
||||
case 'dinamic':
|
||||
case 'static':
|
||||
$params =array(
|
||||
'agent_module_id' => $content['id_agent_module'],
|
||||
'period' => $content['period'],
|
||||
'date' => $report["datetime"],
|
||||
'only_image' => $only_image,
|
||||
'homeurl' => ui_get_full_url(false, false, false, false),
|
||||
'ttl' => $ttl,
|
||||
'array_data_create' => $baseline_data,
|
||||
'server_id' => $id_meta
|
||||
);
|
||||
|
||||
$return['chart'] = grafico_modulo_sparse ($params);
|
||||
break;
|
||||
case 'data':
|
||||
break;
|
||||
}
|
||||
|
||||
if ($config['metaconsole']) {
|
||||
metaconsole_restore_db();
|
||||
}
|
||||
|
||||
return reporting_check_structure_content($return);
|
||||
}
|
||||
|
||||
function reporting_prediction_date($report, $content) {
|
||||
|
||||
global $config;
|
||||
|
@ -3631,31 +3557,20 @@ function reporting_projection_graph($report, $content,
|
|||
switch ($type) {
|
||||
case 'dinamic':
|
||||
case 'static':
|
||||
$output_projection = forecast_projection_graph(
|
||||
$content['id_agent_module'],
|
||||
$content['period'],
|
||||
$content['top_n_value']
|
||||
);
|
||||
|
||||
// If projection doesn't have data then don't draw graph
|
||||
if ($output_projection == NULL) {
|
||||
$output_projection = false;
|
||||
}
|
||||
|
||||
$params =array(
|
||||
'period' => $content['period'],
|
||||
'width' => $width,
|
||||
'height' => $height,
|
||||
'date' => $report["datetime"],
|
||||
'unit' => '',
|
||||
'only_image' => $pdf,
|
||||
'homeurl' => ui_get_full_url(false, false, false, false) . '/',
|
||||
'ttl' => $ttl,
|
||||
'server_id' => $id_meta
|
||||
'server_id' => $id_meta,
|
||||
'height' => $config['graph_image_height']
|
||||
);
|
||||
|
||||
$params_combined = array(
|
||||
'projection' => $output_projection
|
||||
'projection' => $content['top_n_value'],
|
||||
);
|
||||
|
||||
$return['chart'] = graphic_combined_module(
|
||||
|
@ -3884,27 +3799,27 @@ function reporting_value($report, $content, $type,$pdf) {
|
|||
|
||||
$return['agent_name'] = $agent_name;
|
||||
$return['module_name'] = $module_name;
|
||||
|
||||
|
||||
if($pdf){
|
||||
$only_image = 1;
|
||||
}
|
||||
|
||||
$params =array(
|
||||
'agent_module_id' => $content['id_agent_module'],
|
||||
'period' => $content['period'],
|
||||
'width' => '600px',
|
||||
'pure' => false,///true
|
||||
'date' => $report["datetime"],
|
||||
'only_image' => $only_image,
|
||||
'homeurl' => ui_get_full_url(false, false, false, false),
|
||||
'ttl' => 1,///2
|
||||
'type_graph' => $config['type_module_charts'],
|
||||
'time_interval' => $content['lapse'],
|
||||
'server_id' => $id_meta
|
||||
'agent_module_id' => $content['id_agent_module'],
|
||||
'period' => $content['period'],
|
||||
'width' => '600px',
|
||||
'pure' => false,///true
|
||||
'date' => $report["datetime"],
|
||||
'only_image' => $only_image,
|
||||
'homeurl' => ui_get_full_url(false, false, false, false),
|
||||
'ttl' => 1,///2
|
||||
'type_graph' => $config['type_module_charts'],
|
||||
'time_interval' => $content['lapse'],
|
||||
'server_id' => $id_meta,
|
||||
'height' => $config['graph_image_height']
|
||||
);
|
||||
|
||||
switch ($type) {
|
||||
|
||||
switch ($type) {
|
||||
case 'max':
|
||||
if($content['lapse_calc'] == 0){
|
||||
$value = reporting_get_agentmodule_data_max(
|
||||
|
@ -6344,24 +6259,23 @@ function reporting_custom_graph($report, $content, $type = 'dinamic',
|
|||
$return['chart'] = '';
|
||||
|
||||
$width =null;
|
||||
$height =null;
|
||||
|
||||
switch ($type) {
|
||||
case 'dinamic':
|
||||
case 'static':
|
||||
|
||||
$params =array(
|
||||
'period' => $content['period'],
|
||||
'width' => $width,
|
||||
'height' => $height,
|
||||
'date' => $report["datetime"],
|
||||
'only_image' => $pdf,
|
||||
'homeurl' => ui_get_full_url(false, false, false, false),
|
||||
'ttl' => $ttl,
|
||||
'percentil' => $graphs[0]["percentil"],
|
||||
'fullscale' => $graphs[0]["fullscale"],
|
||||
'server_id' => $id_meta
|
||||
'server_id' => $id_meta,
|
||||
'height' => $config['graph_image_height']
|
||||
);
|
||||
|
||||
$params_combined = array(
|
||||
'stacked' => $graphs[0]["stacked"],
|
||||
'summatory' => $graphs[0]["summatory_series"],
|
||||
|
@ -6464,7 +6378,8 @@ function reporting_simple_graph($report, $content, $type = 'dinamic',
|
|||
'show_unknown' => true,
|
||||
'percentil' => ($content['style']['percentil'] == 1) ? $config['percentil'] : null,
|
||||
'fullscale' => $fullscale,
|
||||
'server_id' => $id_meta
|
||||
'server_id' => $id_meta,
|
||||
'height' => $config['graph_image_height']
|
||||
);
|
||||
|
||||
$return['chart'] = grafico_modulo_sparse($params);
|
||||
|
@ -6491,15 +6406,14 @@ function reporting_simple_graph($report, $content, $type = 'dinamic',
|
|||
|
||||
function reporting_get_date_text($report = null, $content = null) {
|
||||
global $config;
|
||||
|
||||
|
||||
$return = array();
|
||||
$return['date'] = null;
|
||||
$return['period'] = null;
|
||||
$return['from'] = null;
|
||||
$return['to'] = null;
|
||||
|
||||
|
||||
if (!empty($report) && !empty($content)) {
|
||||
|
||||
if ($content['period'] == 0) {
|
||||
$es = json_decode($content['external_source'], true);
|
||||
if ($es['date'] == 0) {
|
||||
|
@ -6515,7 +6429,7 @@ function reporting_get_date_text($report = null, $content = null) {
|
|||
$return['to'] = $report["datetime"];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
|
@ -6531,7 +6445,7 @@ function reporting_check_structure_report($return) {
|
|||
$return['datetime'] = "";
|
||||
if (!isset($return['period']))
|
||||
$return['period'] = "";
|
||||
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
|
@ -6551,7 +6465,7 @@ function reporting_check_structure_content($report) {
|
|||
$report["date"]['from'] = "";
|
||||
$report["date"]['to'] = "";
|
||||
}
|
||||
|
||||
|
||||
return $report;
|
||||
}
|
||||
|
||||
|
@ -7000,54 +6914,41 @@ function reporting_get_group_stats ($id_group = 0, $access = 'AR') {
|
|||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!empty($group_array)) {
|
||||
$monitors_info = groups_monitor_total_counters($group_array, true);
|
||||
// Get monitor NOT INIT, except disabled AND async modules
|
||||
$data["monitor_not_init"] += (int) groups_get_not_init_monitors ($group_array, array(), array(), false, false, true);
|
||||
|
||||
// Get monitor OK, except disabled and non-init
|
||||
$data["monitor_ok"] += (int) groups_get_normal_monitors ($group_array, array(), array(), false, false, true);
|
||||
|
||||
// Get monitor CRITICAL, except disabled and non-init
|
||||
$data["monitor_critical"] += (int) groups_get_critical_monitors ($group_array, array(), array(), false, false, true);
|
||||
|
||||
// Get monitor WARNING, except disabled and non-init
|
||||
$data["monitor_warning"] += (int) groups_get_warning_monitors ($group_array, array(), array(), false, false, true);
|
||||
|
||||
// Get monitor UNKNOWN, except disabled and non-init
|
||||
$data["monitor_unknown"] += (int) groups_get_unknown_monitors ($group_array, array(), array(), false, false, true);
|
||||
|
||||
// Get alerts configured, except disabled
|
||||
$data["monitor_alerts"] += groups_monitor_alerts ($group_array) ;
|
||||
|
||||
// Get alert configured currently FIRED, except disabled
|
||||
$data["monitor_alerts_fired"] += groups_monitor_fired_alerts ($group_array);
|
||||
|
||||
// Calculate totals using partial counts from above
|
||||
|
||||
// Get TOTAL non-init modules, except disabled ones and async modules
|
||||
$data["monitor_not_init"] += $monitors_info['not_init'];
|
||||
$data["total_not_init"] += $data["monitor_not_init"];
|
||||
|
||||
// Get monitor OK, except disabled and non-init
|
||||
$data["monitor_ok"] += $monitors_info['ok'];
|
||||
// Get monitor CRITICAL, except disabled and non-init
|
||||
$data["monitor_critical"] += $monitors_info['critical'];
|
||||
// Get monitor WARNING, except disabled and non-init
|
||||
$data["monitor_warning"] += $monitors_info['warning'];
|
||||
// Get monitor UNKNOWN, except disabled and non-init
|
||||
$data["monitor_unknown"] += $monitors_info['unknown'];
|
||||
$data["monitor_checks"] += $monitors_info['total'];
|
||||
|
||||
// Get alerts configured, except disabled
|
||||
$alerts_info = groups_monitor_alerts_total_counters ($group_array);
|
||||
$data["monitor_alerts"] += $alerts_info['total'];
|
||||
// Get alert configured currently FIRED, except disabled
|
||||
$data["monitor_alerts_fired"] += $alerts_info['fired'];
|
||||
|
||||
$agents_info = groups_agents_total_counters($group_array);
|
||||
// Get TOTAL agents in a group
|
||||
$data["total_agents"] += (int) groups_get_total_agents ($group_array, array(), array(), false, false, true);
|
||||
|
||||
$data["total_agents"] += $agents_info['total'];
|
||||
// Get Agents OK
|
||||
$data["agent_ok"] += (int) groups_get_normal_agents ($group_array, array(), array(), false, false, true);
|
||||
|
||||
// Get Agents Warning
|
||||
$data["agent_warning"] += (int) groups_get_warning_agents ($group_array, array(), array(), false, false, true);
|
||||
|
||||
$data["agent_ok"] += $agents_info['ok'];
|
||||
// Get Agents Warning
|
||||
$data["agent_warning"] += $agents_info['warning'];
|
||||
// Get Agents Critical
|
||||
$data["agent_critical"] += (int) groups_get_critical_agents ($group_array, array(), array(), false, false, true);
|
||||
|
||||
$data["agent_critical"] += $agents_info['critical'];
|
||||
// Get Agents Unknown
|
||||
$data["agent_unknown"] += (int) groups_get_unknown_agents ($group_array, array(), array(), false, false, true);
|
||||
|
||||
$data["agent_unknown"] += $agents_info['unknown'];
|
||||
// Get Agents Not init
|
||||
$data["agent_not_init"] += (int) groups_get_not_init_agents ($group_array, array(), array(), false, false, true);
|
||||
|
||||
// Get total count of monitors for this group, except disabled.
|
||||
$data["monitor_checks"] += $data["monitor_not_init"] + $data["monitor_unknown"] + $data["monitor_warning"] + $data["monitor_critical"] + $data["monitor_ok"];
|
||||
$data["agent_not_init"] += $agents_info['not_init'];
|
||||
}
|
||||
}
|
||||
// Calculate not_normal monitors
|
||||
|
|
|
@ -95,10 +95,12 @@ function reports_get_reports ($filter = false, $fields = false,
|
|||
$filter[] = sprintf ('private = 0 OR (private = 1 AND id_user = "%s")',
|
||||
$config['id_user']);
|
||||
*/
|
||||
$filter['hidden'] = 0;
|
||||
if (is_array ($fields)) {
|
||||
$fields[] = 'id_group';
|
||||
$fields[] = 'id_user';
|
||||
$fields[] = 'id_group_edit';
|
||||
$fields[] = 'hidden';
|
||||
}
|
||||
|
||||
$reports = array ();
|
||||
|
|
|
@ -803,6 +803,18 @@ function visual_map_print_item($mode = "read", $layoutData,
|
|||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// Override url
|
||||
if (
|
||||
is_metaconsole() &&
|
||||
!empty($layoutData["id_layout_linked"]) &&
|
||||
!empty($layoutData["linked_layout_node_id"])
|
||||
) {
|
||||
$url = ui_meta_get_url_console_child(
|
||||
$layoutData['linked_layout_node_id'],
|
||||
"network", "operation/visual_console/render_view&id=" . (int) $layoutData["id_layout_linked"]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// + 1 for to avoid the box and lines items are on the top of
|
||||
|
@ -3137,38 +3149,22 @@ function visual_map_get_status_element($layoutData) {
|
|||
WHERE id_agente_modulo = ' . $layoutData['id_agente_modulo']);
|
||||
|
||||
//Linked to other layout ?? - Only if not module defined
|
||||
if ($layoutData['id_layout_linked'] != 0) {
|
||||
if ($layoutData['id_layout_linked_weight'] != 0) {
|
||||
$calculate_weight = true;
|
||||
}
|
||||
else {
|
||||
$calculate_weight = false;
|
||||
if (!empty($layoutData['id_layout_linked'])) {
|
||||
if (!empty($layoutData['linked_layout_node_id'])) {
|
||||
//Metaconsole db connection
|
||||
$connection = db_get_row_filter ('tmetaconsole_setup',
|
||||
array('id' => $layoutData['linked_layout_node_id']));
|
||||
if (metaconsole_load_external_db($connection) != NOERR) return VISUAL_MAP_STATUS_UNKNOWN;
|
||||
}
|
||||
|
||||
$status = visual_map_get_layout_status($layoutData['id_layout_linked'], $layoutData);
|
||||
|
||||
if ($layoutData['id_layout_linked_weight'] > 0) {
|
||||
$elements_to_compare = db_get_all_rows_sql("SELECT id, element_group FROM tlayout_data WHERE type = 0 AND id_layout = " . $layoutData['id_layout_linked']);
|
||||
|
||||
$childs_group_acl = array();
|
||||
foreach ($elements_to_compare as $c) {
|
||||
if (check_acl ($config['id_user'], $c['element_group'], "VR")) {
|
||||
$childs_group_acl[] = $c['id'];
|
||||
}
|
||||
}
|
||||
$elements_to_compare = $childs_group_acl;
|
||||
|
||||
$aux_weight = ($status['elements_in_critical'] / count($elements_to_compare)) * 100;
|
||||
|
||||
if ($aux_weight >= $layoutData['id_layout_linked_weight']) {
|
||||
$status = $status['temp_total'];
|
||||
}
|
||||
else {
|
||||
$status = VISUAL_MAP_STATUS_NORMAL;
|
||||
if (count($elements_to_compare) == 0) {
|
||||
$status = VISUAL_MAP_STATUS_UNKNOWN;
|
||||
}
|
||||
}
|
||||
if (!empty($layoutData['linked_layout_node_id'])) {
|
||||
//Restore db connection
|
||||
metaconsole_restore_db();
|
||||
}
|
||||
|
||||
return $status;
|
||||
}
|
||||
else {
|
||||
switch ($layoutData["type"]) {
|
||||
|
@ -3676,7 +3672,7 @@ function visual_map_translate_agent_status ($agent_status) {
|
|||
}
|
||||
|
||||
function visual_map_translate_module_status ($module_status) {
|
||||
switch ($agent_status) {
|
||||
switch ($module_status) {
|
||||
case AGENT_MODULE_STATUS_NORMAL:
|
||||
case AGENT_MODULE_STATUS_NORMAL_ALERT:
|
||||
default:
|
||||
|
@ -3717,6 +3713,7 @@ function visual_map_get_layout_status ($layout_id, $status_data = array(), $dept
|
|||
if ($depth > 10) return VISUAL_MAP_STATUS_UNKNOWN;
|
||||
|
||||
$layout_items = db_get_all_rows_filter("tlayout_data", array("id_layout" => $layout_id));
|
||||
|
||||
if ($layout_items === false) return VISUAL_MAP_STATUS_UNKNOWN;
|
||||
|
||||
// Check for valid items to retrieve the status for
|
||||
|
@ -3738,17 +3735,6 @@ function visual_map_get_layout_status ($layout_id, $status_data = array(), $dept
|
|||
!empty($layout_item_data["id_layout_linked"]) ||
|
||||
!empty($layout_item_data["id_agente_modulo"]) ||
|
||||
!empty($layout_item_data["id_agent"])
|
||||
) && (
|
||||
// Weight and service types for status calculation require STATIC_GRAPH items
|
||||
(
|
||||
$status_data["linked_layout_status_type"] !== "weight" &&
|
||||
$status_data["linked_layout_status_type"] !== "service"
|
||||
) || (
|
||||
$layout_item_data['type'] == STATIC_GRAPH && (
|
||||
$status_data["linked_layout_status_type"] === "weight" ||
|
||||
$status_data["linked_layout_status_type"] === "service"
|
||||
)
|
||||
)
|
||||
) &&
|
||||
// ACL check
|
||||
check_acl($config["id_user"], $layout_item_data["element_group"], "VR")
|
||||
|
@ -3769,21 +3755,30 @@ function visual_map_get_layout_status ($layout_id, $status_data = array(), $dept
|
|||
$meta_connected_to = null;
|
||||
|
||||
foreach ($valid_layout_items as $layout_item_data) {
|
||||
$node_id = null;
|
||||
|
||||
if (is_metaconsole()) {
|
||||
if (empty($layout_item_data["id_metaconsole"]) && $meta_connected_to) {
|
||||
$node_id = (
|
||||
!empty($layout_item_data["id_layout_linked"]) &&
|
||||
!empty($layout_item_data["linked_layout_node_id"])
|
||||
)
|
||||
? $layout_item_data["linked_layout_node_id"]
|
||||
: $layout_item_data["id_metaconsole"];
|
||||
|
||||
if (empty($node_id) && $meta_connected_to) {
|
||||
metaconsole_restore_db(); // Restore db connection
|
||||
$meta_connected_to = null;
|
||||
}
|
||||
else if (
|
||||
!empty($layout_item_data["id_metaconsole"]) && (
|
||||
!empty($node_id) && (
|
||||
empty($meta_connected_to) ||
|
||||
$meta_connected_to != $layout_item_data["id_metaconsole"]
|
||||
$meta_connected_to != $node_id
|
||||
)
|
||||
) {
|
||||
if (!empty($meta_connected_to)) metaconsole_restore_db(); // Restore db connection
|
||||
$connection = metaconsole_get_connection_by_id($layout_item_data["id_metaconsole"]);
|
||||
$connection = metaconsole_get_connection_by_id($node_id);
|
||||
if (metaconsole_load_external_db($connection) != NOERR) continue;
|
||||
$meta_connected_to = $layout_item_data["id_metaconsole"];
|
||||
$meta_connected_to = $node_id;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -697,13 +697,88 @@ function visual_map_editor_print_item_palette($visualConsole_id, $background) {
|
|||
'group_item', 'static_graph', 'percentile_bar',
|
||||
'percentile_item', 'module_graph', 'simple_value',
|
||||
'icon', 'label', 'datos', 'donut_graph');
|
||||
$form_items_advance['map_linked_row']['html'] = '<td align="left">'.
|
||||
__('Linked map') . '</td>' .
|
||||
'<td align="left">' . html_print_select_from_sql (
|
||||
'SELECT id, name
|
||||
FROM tlayout
|
||||
WHERE id != ' . (int) $visualConsole_id, 'map_linked', 0, 'onLinkedMapChange(event)', __('None'), 0, true) .
|
||||
'</td>';
|
||||
$visual_maps = db_get_all_rows_filter("tlayout", "id != " . (int) $visualConsole_id, array("id", "name"));
|
||||
|
||||
$form_items_advance['map_linked_row']['html'] = '<td align="left">'
|
||||
. __('Linked visual console')
|
||||
. '</td>'
|
||||
. '<td align="left">';
|
||||
|
||||
if (is_metaconsole()) {
|
||||
$meta_servers = metaconsole_get_servers();
|
||||
foreach ($meta_servers as $server) {
|
||||
if (metaconsole_load_external_db($server) !== NOERR) {
|
||||
metaconsole_restore_db();
|
||||
continue;
|
||||
}
|
||||
|
||||
$node_visual_maps = db_get_all_rows_filter("tlayout", array(), array("id", "name"));
|
||||
|
||||
foreach ($node_visual_maps as $node_visual_map) {
|
||||
$node_visual_map["node_id"] = (int) $server["id"];
|
||||
$visual_maps[] = $node_visual_map;
|
||||
}
|
||||
|
||||
metaconsole_restore_db();
|
||||
}
|
||||
|
||||
$meta_servers_by_id = array_reduce($meta_servers, function ($arr, $item) {
|
||||
$arr[$item["id"]] = $item;
|
||||
return $arr;
|
||||
}, array());
|
||||
|
||||
$form_items_advance['map_linked_row']['html'] .= html_print_select_from_sql(
|
||||
array(), 'map_linked', 0, 'onLinkedMapChange(event)', __('None'), 0, true
|
||||
);
|
||||
$form_items_advance['map_linked_row']['html'] .= html_print_input_hidden(
|
||||
"linked_map_node_id", 0, true
|
||||
);
|
||||
|
||||
ob_start();
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
(function () {
|
||||
var $mapLinkedSelect = $("select#map_linked");
|
||||
var $linkedMapNodeIDInput = $("input#hidden-linked_map_node_id");
|
||||
var visualMaps = <?php echo json_encode($visual_maps); ?>;
|
||||
var nodesById = <?php echo json_encode($meta_servers_by_id); ?>;
|
||||
|
||||
visualMaps.forEach(function (vMap) {
|
||||
$mapLinkedSelect.append(
|
||||
'<option data-node-id="' + (vMap["node_id"] || 0) + '" value="' + vMap["id"] + '">'
|
||||
+ vMap["name"]
|
||||
+ (
|
||||
nodesById[vMap["node_id"]]
|
||||
? ' (' + nodesById[vMap["node_id"]]["server_name"] + ')'
|
||||
: ''
|
||||
)
|
||||
+ '</option>'
|
||||
);
|
||||
});
|
||||
|
||||
$mapLinkedSelect.change(function (event) {
|
||||
var mapLinkedID = Number.parseInt(event.target.value);
|
||||
var itemSelected = $(event.target).children("option:selected");
|
||||
|
||||
if (itemSelected.length === 0) {
|
||||
$linkedMapNodeIDInput.val(0);
|
||||
} else {
|
||||
var nodeId = itemSelected.data("node-id");
|
||||
$linkedMapNodeIDInput.val(nodeId != null ? nodeId : 0);
|
||||
}
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
<?php
|
||||
$form_items_advance['map_linked_row']['html'] .= ob_get_clean();
|
||||
}
|
||||
else {
|
||||
$form_items_advance['map_linked_row']['html'] .= html_print_select_from_sql(
|
||||
$visual_maps, 'map_linked', 0, 'onLinkedMapChange(event)', __('None'), 0, true
|
||||
);
|
||||
}
|
||||
|
||||
$form_items_advance['map_linked_row']['html'] .= '</td>';
|
||||
|
||||
$status_type_select_items = array(
|
||||
"weight" => __("By status weight"),
|
||||
|
@ -715,7 +790,7 @@ function visual_map_editor_print_item_palette($visualConsole_id, $background) {
|
|||
'percentile_item', 'module_graph', 'simple_value',
|
||||
'icon', 'label', 'datos', 'donut_graph');
|
||||
$form_items_advance['linked_map_status_calculation_row']['html'] = '<td align="left">'.
|
||||
__('Type of the status calculation of the linked map') . '</td>'
|
||||
__('Type of the status calculation of the linked visual console') . '</td>'
|
||||
. '<td align="left">'
|
||||
. html_print_select(
|
||||
$status_type_select_items,
|
||||
|
@ -728,6 +803,7 @@ function visual_map_editor_print_item_palette($visualConsole_id, $background) {
|
|||
false,
|
||||
false
|
||||
)
|
||||
. ui_print_help_icon("linked_map_status_calc", true)
|
||||
. '</td>';
|
||||
|
||||
$form_items_advance['map_linked_weight'] = array();
|
||||
|
@ -736,13 +812,12 @@ function visual_map_editor_print_item_palette($visualConsole_id, $background) {
|
|||
'percentile_item', 'module_graph', 'simple_value',
|
||||
'icon', 'label', 'datos', 'donut_graph');
|
||||
$form_items_advance['map_linked_weight']['html'] = '<td align="left">'
|
||||
. __('Linked map weight') . '</td>'
|
||||
. __('Linked visual console weight') . '</td>'
|
||||
. '<td align="left">'
|
||||
. html_print_input_text(
|
||||
'map_linked_weight', 80, '', 5, 5, true, false, false, "", "type_number percentage"
|
||||
)
|
||||
. '<span>%</span>'
|
||||
. ui_print_help_icon("linked_map_weight", true)
|
||||
. '</td>';
|
||||
|
||||
$form_items_advance['linked_map_status_service_critical_row'] = array();
|
||||
|
|
|
@ -284,7 +284,7 @@ function pandoraFlotPieCustom(graph_id, values, labels, width,
|
|||
set_watermark(graph_id, plot,
|
||||
$('#watermark_image_' + graph_id).attr('src'));
|
||||
}
|
||||
|
||||
/*
|
||||
window.onresize = function(event) {
|
||||
$.plot($('#' + graph_id), data, conf_pie);
|
||||
if (no_data == data.length) {
|
||||
|
@ -319,7 +319,7 @@ function pandoraFlotPieCustom(graph_id, values, labels, width,
|
|||
$(this).css('transform', "rotate(-35deg)").css('color', 'black');
|
||||
});
|
||||
}
|
||||
|
||||
*/
|
||||
}
|
||||
|
||||
function pandoraFlotHBars(graph_id, values, labels, water_mark,
|
||||
|
@ -1673,7 +1673,9 @@ function pandoraFlotArea( graph_id, values, legend,
|
|||
|
||||
// Re-calculate the graph height with the legend height
|
||||
if (dashboard || vconsole) {
|
||||
var hDiff = $('#'+graph_id).height() - $('#legend_'+graph_id).height();
|
||||
$acum = 0;
|
||||
if(dashboard) $acum = 35;
|
||||
var hDiff = $('#'+graph_id).height() - $('#legend_'+graph_id).height() - $acum;
|
||||
if(/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ){
|
||||
}
|
||||
else {
|
||||
|
@ -2169,10 +2171,11 @@ function pandoraFlotArea( graph_id, values, legend,
|
|||
}
|
||||
});
|
||||
|
||||
$('#'+graph_id).bind('mouseout',resetInteractivity(vconsole));
|
||||
|
||||
if(!vconsole){
|
||||
$('#overview_'+graph_id).bind('mouseout',resetInteractivity);
|
||||
$('#'+graph_id)
|
||||
.bind('mouseout', resetInteractivity);
|
||||
$('#overview_'+graph_id)
|
||||
.bind('mouseout', resetInteractivity);
|
||||
}
|
||||
|
||||
if(image_treshold){
|
||||
|
@ -2216,7 +2219,7 @@ function pandoraFlotArea( graph_id, values, legend,
|
|||
}
|
||||
|
||||
// Reset interactivity styles
|
||||
function resetInteractivity(vconsole) {
|
||||
function resetInteractivity() {
|
||||
$('#timestamp_'+graph_id).hide();
|
||||
dataset = plot.getData();
|
||||
for (i = 0; i < dataset.length; ++i) {
|
||||
|
@ -2225,14 +2228,15 @@ function pandoraFlotArea( graph_id, values, legend,
|
|||
$('#legend_' + graph_id + ' .legendLabel')
|
||||
.eq(i).html(label_aux);
|
||||
}
|
||||
$('#legend_' + graph_id + ' .legendLabel').css('color', legend_color);
|
||||
$('#legend_' + graph_id + ' .legendLabel').css('font-size', font_size + 2 +'px');
|
||||
$('#legend_' + graph_id + ' .legendLabel').css('font-family', font + 'Font');
|
||||
$('#legend_' + graph_id + ' .legendLabel')
|
||||
.css('color', legend_color);
|
||||
$('#legend_' + graph_id + ' .legendLabel')
|
||||
.css('font-size', font_size + 2 +'px');
|
||||
$('#legend_' + graph_id + ' .legendLabel')
|
||||
.css('font-family', font + 'Font');
|
||||
|
||||
plot.clearCrosshair();
|
||||
if(!vconsole){
|
||||
overview.clearCrosshair();
|
||||
}
|
||||
overview.clearCrosshair();
|
||||
}
|
||||
|
||||
function yFormatter(v, axis) {
|
||||
|
|
|
@ -132,9 +132,10 @@ function flot_area_graph (
|
|||
$params['grid_color'] = '#C1C1C1';
|
||||
break;
|
||||
}
|
||||
$padding_vconsole = $params['dashboard'] ? 'padding: 1px 0px 10px 10px;' : '';
|
||||
|
||||
// Parent layer
|
||||
$return = "<div class='parent_graph' style='width: " . ($params['width']) . ";" . $background_style . "'>";
|
||||
$return = "<div class='parent_graph' style='width: " . ($params['width']) . ";" . $background_style . $padding_vconsole . "'>";
|
||||
// Set some containers to legend, graph, timestamp tooltip, etc.
|
||||
if($params['show_legend']){
|
||||
$return .= "<p id='legend_$graph_id' style='text-align:left;'></p>";
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
/**
|
||||
* @package Include/help/es
|
||||
*/
|
||||
?>
|
||||
<h1>Ways to calculate the status of the linked visual console</h1>
|
||||
|
||||
<h3>By Default</h3>
|
||||
<p>
|
||||
It calculates the status based on the status of all elements, as an agent would do.
|
||||
</p>
|
||||
|
||||
<h3>By weight</h3>
|
||||
<p>
|
||||
It calculates the status of the elements that have a visual console, a module or an agent assigned in relation to a percentage of elements configured by the user. This percentage is the one that has to exceed the number of elements of a non-normal status with respect to the number of elements taken into account in the calculation for that status to change.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
For example, given an element with a percentage of 50% and a visual console linked with 5 elements:
|
||||
</p>
|
||||
<ul>
|
||||
<li>1 <i>critical</i>, 1 <i>warning</i> y 3 <i>normal</i> -> Status <i>normal</i>.</li>
|
||||
<li>2 <i>critical</i>, 2 <i>warning</i> y 1 <i>normal</i> -> Status <i>normal</i>.</li>
|
||||
<li>1 <i>critical</i>, 3 <i>warning</i> y 1 <i>normal</i> -> Status <i>warning</i>.</li>
|
||||
<li>3 <i>critical</i>, 1 <i>warning</i> y 1 <i>normal</i> -> Status <i>critical.</i></li>
|
||||
<li>1 <i>critical</i>, 1 <i>warning</i> y 3 <i>unknown</i> -> Status <i>unknown</i>.</li>
|
||||
</ul>
|
||||
|
||||
<p>
|
||||
If several statuses exceed the weight, the priority is the same as in the rest of the status calculation (<i>critical</i> > <i>warning</i> > <i>unknown</i>). If there are no elements to perform the calculation, the status becomes <i>unknown</i>.
|
||||
</p>
|
||||
|
||||
<h3>By critical elements</h3>
|
||||
<p>
|
||||
It calculates the status using the elements in <i>critical</i> status and the percentages of the thresholds defined by the user. If the number of elements in <i>critical</i> status with respect to the number of elements taken into account in the calculation exceeds the percentage assigned as <i>warning</i>, the status becomes <i>warning</i>. The same applies to the percentage assigned as <i>critical</i>, which also has preference.
|
||||
</p>
|
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
/**
|
||||
* @package Include/help/es
|
||||
*/
|
||||
?>
|
||||
<h1>Formas de calcular el estado de la consola visual enlazada</h1>
|
||||
|
||||
<h3>Por defecto</h3>
|
||||
<p>
|
||||
Calcula el estado a partir del estado de todos los elementos, como lo haría un agente.
|
||||
</p>
|
||||
|
||||
<h3>Por peso</h3>
|
||||
<p>
|
||||
Calcula el estado de los elementos que tienen asignados una consola visual, un módulo o un agente en relación a un porcentaje de elementos configurado por el usuario. Este porcentaje es el que tiene que superar el número de elementos de un estado no normal respecto al número de elementos tenidos en cuenta en el cálculo para que el ese estado cambie.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Por ejemplo, dado un elemento con un porcentaje del 50% y una consola visual enlazada con 5 elementos:
|
||||
</p>
|
||||
<ul>
|
||||
<li>1 <i>critical</i>, 1 <i>warning</i> y 3 <i>normal</i> -> Estado <i>normal</i>.</li>
|
||||
<li>2 <i>critical</i>, 2 <i>warning</i> y 1 <i>normal</i> -> Estado <i>normal</i>.</li>
|
||||
<li>1 <i>critical</i>, 3 <i>warning</i> y 1 <i>normal</i> -> Estado <i>warning</i>.</li>
|
||||
<li>3 <i>critical</i>, 1 <i>warning</i> y 1 <i>normal</i> -> Estado <i>critical.</i></li>
|
||||
<li>1 <i>critical</i>, 1 <i>warning</i> y 3 <i>unknown</i> -> Estado <i>unknown</i>.</li>
|
||||
</ul>
|
||||
|
||||
<p>
|
||||
Si varios estados superan el peso, la prioridad es igual que en el resto de cálculo de estados (<i>critical</i> > <i>warning</i> > <i>unknown</i>). Si no hay elementos para realizar el cálculo, el estado pasa a ser <i>unknown</i>.
|
||||
</p>
|
||||
|
||||
<h3>Por elementos críticos</h3>
|
||||
<p>
|
||||
Calcula el estado usando los elementos en estado <i>critical</i> y los porcentajes de los umbrales definidos por el usuario. Si el número de los elementos en estado <i>critical</i> respecto al número de elementos tenidos en cuenta en el cálculo supera el porcentaje asignado como <i>warning</i>, el estado pasa a ser <i>warning</i>. Lo mismo para el porcentaje asignado como <i>critical</i>, que además tiene preferencia.
|
||||
</p>
|
|
@ -70,8 +70,8 @@
|
|||
<body>
|
||||
<div style='height: 10px'>
|
||||
<?php
|
||||
$version = '7.0NG.726';
|
||||
$build = '180906';
|
||||
$version = '7.0NG.727';
|
||||
$build = '180917';
|
||||
$banner = "v$version Build $build";
|
||||
|
||||
error_reporting(0);
|
||||
|
|
|
@ -34,8 +34,6 @@ require_once('operation/agents.php');
|
|||
require_once('operation/modules.php');
|
||||
require_once('operation/module_graph.php');
|
||||
require_once('operation/agent.php');
|
||||
require_once('operation/networkmaps.php');
|
||||
require_once('operation/networkmap.php');
|
||||
require_once('operation/visualmaps.php');
|
||||
require_once('operation/visualmap.php');
|
||||
$enterpriseHook = enterprise_include('mobile/include/enterprise.class.php');
|
||||
|
@ -333,14 +331,6 @@ switch ($action) {
|
|||
$agent = new Agent();
|
||||
$agent->show();
|
||||
break;
|
||||
case 'networkmaps':
|
||||
$networkmaps = new Networkmaps();
|
||||
$networkmaps->show();
|
||||
break;
|
||||
case 'networkmap':
|
||||
$networkmap = new Networkmap();
|
||||
$networkmap->show();
|
||||
break;
|
||||
case 'visualmaps':
|
||||
$visualmaps = new Visualmaps();
|
||||
$visualmaps->show();
|
||||
|
|
|
@ -179,29 +179,14 @@ class Groups {
|
|||
$ui->endContent();
|
||||
$ui->showPage();
|
||||
}
|
||||
|
||||
|
||||
private function getListGroups() {
|
||||
$return = array();
|
||||
|
||||
|
||||
$system = System::getInstance();
|
||||
$user = User::getInstance();
|
||||
|
||||
$all_data = groupview_status_modules_agents ($system->getConfig('id_user'), false, 'AR', false);
|
||||
$result_groups = groupview_get_groups_list($system->getConfig('id_user'),'AR');
|
||||
|
||||
foreach ($all_data as $group_all_data) {
|
||||
$result_groups[0]['_total_agents_'] += $group_all_data["_total_agents_"];
|
||||
$result_groups[0]['_monitors_ok_'] += $group_all_data["_monitors_ok_"];
|
||||
$result_groups[0]['_monitors_warning_'] += $group_all_data["_monitors_warning_"];
|
||||
$result_groups[0]['_monitors_critical_'] += $group_all_data["_monitors_critical_"];
|
||||
$result_groups[0]['_monitors_unknown_'] += $group_all_data["_monitors_unknown_"];
|
||||
$result_groups[0]['_monitors_not_init_'] += $group_all_data["_monitors_not_init_"];
|
||||
$result_groups[0]['_agents_unknown_'] += $group_all_data["_agents_unknown_"];
|
||||
$result_groups[0]['_agents_not_init_'] += $group_all_data["_agents_not_init_"];
|
||||
$result_groups[0]['_agents_critical_'] += $group_all_data["_agents_critical_"];
|
||||
$result_groups[0]['_monitors_alerts_fired_'] += $group_all_data["_monitors_alerts_fired_"];
|
||||
}
|
||||
|
||||
return $result_groups;
|
||||
$result_groups = groupview_get_groups_list($system->getConfig('id_user'),'AR', true);
|
||||
|
||||
return $result_groups['groups'];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -73,13 +73,6 @@ class Home {
|
|||
'menu_item' => true,
|
||||
'icon' => 'modules'
|
||||
);
|
||||
|
||||
$items['networkmaps'] = array(
|
||||
'name' => __('Networkmaps'),
|
||||
'filename' => 'networkmaps.php',
|
||||
'menu_item' => true,
|
||||
'icon' => 'network_maps'
|
||||
);
|
||||
$items['visualmaps'] = array(
|
||||
'name' => __('Visual consoles'),
|
||||
'filename' => 'visualmaps.php',
|
||||
|
@ -100,12 +93,6 @@ class Home {
|
|||
'menu_item' => false,
|
||||
'icon' => ''
|
||||
);
|
||||
$items['networkmap'] = array(
|
||||
'name' => __('Networkmap'),
|
||||
'filename' => 'networkmap.php',
|
||||
'menu_item' => false,
|
||||
'icon' => ''
|
||||
);
|
||||
$items['visualmap'] = array(
|
||||
'name' => __('Visualmap'),
|
||||
'filename' => 'visualmap.php',
|
||||
|
|
|
@ -1,246 +0,0 @@
|
|||
<?php
|
||||
// Pandora FMS - http://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2010 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.
|
||||
|
||||
require_once ('../include/functions_networkmap.php');
|
||||
|
||||
class Networkmap {
|
||||
private $correct_acl = false;
|
||||
private $acl = "AR";
|
||||
|
||||
private $id = 0;
|
||||
private $network_map = null;
|
||||
|
||||
function __construct($id = false) {
|
||||
$system = System::getInstance();
|
||||
|
||||
if ($id === false)
|
||||
$this->getFilters();
|
||||
else
|
||||
$this->id = $id;
|
||||
|
||||
$store_group = db_get_value('store_group',
|
||||
'tnetwork_map', 'id_networkmap', $this->id);
|
||||
|
||||
if ($store_group !== false
|
||||
&& $system->checkACL($this->acl, $store_group))
|
||||
$this->correct_acl = true;
|
||||
}
|
||||
|
||||
public function ajax($parameter2 = false) {
|
||||
$system = System::getInstance();
|
||||
|
||||
if (!$this->correct_acl) {
|
||||
return;
|
||||
}
|
||||
else {
|
||||
switch ($parameter2) {
|
||||
case 'xxx':
|
||||
//$this->getFilters();
|
||||
//$page = $system->getRequest('page', 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function getFilters() {
|
||||
$system = System::getInstance();
|
||||
|
||||
$this->id = (int)$system->getRequest('id', 0);
|
||||
}
|
||||
|
||||
public function show() {
|
||||
if (!$this->correct_acl) {
|
||||
$this->show_fail_acl();
|
||||
}
|
||||
else {
|
||||
$this->getFilters();
|
||||
|
||||
$this->networkmap = db_get_row('tnetwork_map',
|
||||
'id_networkmap', $this->id);
|
||||
|
||||
$this->show_networkmap();
|
||||
}
|
||||
}
|
||||
|
||||
private function show_fail_acl() {
|
||||
$error['type'] = 'onStart';
|
||||
$error['title_text'] = __('You don\'t have access to this page');
|
||||
$error['content_text'] = System::getDefaultACLFailText();
|
||||
if (class_exists("HomeEnterprise"))
|
||||
$home = new HomeEnterprise();
|
||||
else
|
||||
$home = new Home();
|
||||
$home->show($error);
|
||||
}
|
||||
|
||||
private function show_networkmap() {
|
||||
$ui = Ui::getInstance();
|
||||
$system = System::getInstance();
|
||||
|
||||
$ui->createPage();
|
||||
$ui->createDefaultHeader(
|
||||
sprintf("%s",
|
||||
$this->networkmap['name']),
|
||||
$ui->createHeaderButton(
|
||||
array('icon' => 'back',
|
||||
'pos' => 'left',
|
||||
'text' => __('Back'),
|
||||
'href' => 'index.php?page=networkmaps')));
|
||||
$ui->showFooter(false);
|
||||
$ui->beginContent();
|
||||
|
||||
//Hack for mobile
|
||||
global $hack_networkmap_mobile;
|
||||
$hack_networkmap_mobile = true;
|
||||
|
||||
switch ($this->networkmap['type']) {
|
||||
case 'groups':
|
||||
$graph = networkmap_generate_dot_groups (
|
||||
__('Pandora FMS'),
|
||||
$this->networkmap['id_group'],
|
||||
$this->networkmap['simple'],
|
||||
$this->networkmap['font_size'],
|
||||
$this->networkmap['layout'],
|
||||
(bool)$this->networkmap['nooverlap'],
|
||||
$this->networkmap['zoom'],
|
||||
$this->networkmap['distance_nodes'],
|
||||
$this->networkmap['center'], 1, 0,
|
||||
$this->networkmap['only_modules_with_alerts'],
|
||||
$this->networkmap['id_module_group'],
|
||||
$this->networkmap['hide_policy_modules'],
|
||||
$this->networkmap['depth'],
|
||||
$this->networkmap['id_networkmap']);
|
||||
break;
|
||||
case 'policies':
|
||||
$enterprise = enterprise_include('/include/functions_policies.php');
|
||||
|
||||
if ($enterprise != ENTERPRISE_NOT_HOOK) {
|
||||
$graph = policies_generate_dot_graph (__('Pandora FMS'),
|
||||
$this->networkmap['id_group'],
|
||||
$this->networkmap['simple'],
|
||||
$this->networkmap['font_size'],
|
||||
$this->networkmap['layout'],
|
||||
(bool)$this->networkmap['nooverlap'],
|
||||
$this->networkmap['zoom'],
|
||||
$this->networkmap['distance_nodes'],
|
||||
$this->networkmap['center'], 1, 0,
|
||||
$this->networkmap['only_modules_with_alerts'],
|
||||
$this->networkmap['id_module_group'],
|
||||
$this->networkmap['depth'],
|
||||
$this->networkmap['id_networkmap']);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
case 'topology':
|
||||
$graph = networkmap_generate_dot (__('Pandora FMS'),
|
||||
$this->networkmap['id_group'],
|
||||
$this->networkmap['simple'],
|
||||
$this->networkmap['font_size'],
|
||||
$this->networkmap['layout'],
|
||||
(bool)$this->networkmap['nooverlap'],
|
||||
$this->networkmap['zoom'],
|
||||
$this->networkmap['distance_nodes'],
|
||||
$this->networkmap['center'], 1, 0,
|
||||
$this->networkmap['id_networkmap'],
|
||||
$this->networkmap['show_snmp_modules'], true,
|
||||
true);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ($graph === false) {
|
||||
$ui->contentAddHtml('<p style="color: #ff0000;">' . __('No networkmaps') . '</p>');
|
||||
|
||||
$ui->endContent();
|
||||
$ui->showPage();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
$filter = networkmap_get_filter($this->networkmap['layout']);
|
||||
|
||||
// Generate image and map
|
||||
// If image was generated just a few minutes ago, then don't regenerate (it takes long) unless regen checkbox is set
|
||||
$filename_map = safe_url_extraclean (
|
||||
$system->getConfig('attachment_store')) . "/networkmap_" . $filter;
|
||||
$filename_img = safe_url_extraclean (
|
||||
$system->getConfig('attachment_store')) . "/networkmap_" .
|
||||
$filter . "_" . $this->networkmap['font_size'];
|
||||
$url_img = "../attachment/networkmap_" .
|
||||
$filter . "_" . $this->networkmap['font_size'];
|
||||
$filename_dot = safe_url_extraclean(
|
||||
$system->getConfig("attachment_store")) . "/networkmap_" . $filter;
|
||||
if ($this->networkmap['simple']) {
|
||||
$filename_map .= "_simple";
|
||||
$filename_img .= "_simple";
|
||||
$url_img .= "_simple";
|
||||
$filename_dot .= "_simple";
|
||||
}
|
||||
if ($this->networkmap['nooverlap']) {
|
||||
$filename_map .= "_nooverlap";
|
||||
$filename_img .= "_nooverlap";
|
||||
$url_img .= "_nooverlap";
|
||||
$filename_dot .= "_nooverlap";
|
||||
}
|
||||
$filename_map .= "_" . $this->networkmap['id_networkmap'] . ".map";
|
||||
$filename_img .= "_" . $this->networkmap['id_networkmap'] . ".png";
|
||||
$url_img .= "_" . $this->networkmap['id_networkmap'] . ".png";
|
||||
$filename_dot .= "_" . $this->networkmap['id_networkmap'] . ".dot";
|
||||
|
||||
if ($this->networkmap['regenerate'] != 1 && file_exists($filename_img) && filemtime($filename_img) > get_system_time () - 300) {
|
||||
$result = true;
|
||||
}
|
||||
else {
|
||||
$fh = @fopen ($filename_dot, 'w');
|
||||
if ($fh === false) {
|
||||
$result = false;
|
||||
}
|
||||
else {
|
||||
fwrite ($fh, $graph);
|
||||
$cmd = $filter . " -Tcmapx -o" . $filename_map." -Tpng -o".$filename_img." ".$filename_dot;
|
||||
$result = system ($cmd);
|
||||
fclose ($fh);
|
||||
//unlink ($filename_dot);
|
||||
}
|
||||
}
|
||||
|
||||
if ($result !== false) {
|
||||
if (! file_exists ($filename_map)) {
|
||||
$ui->contentAddHtml('<p style="color: #ff0000;">' . __('Map could not be generated') . '</p>');
|
||||
|
||||
$ui->endContent();
|
||||
$ui->showPage();
|
||||
|
||||
return;
|
||||
}
|
||||
$ui->contentAddHtml('<div style="width: auto; overflow-x: auto; text-align: center;">');
|
||||
$ui->contentAddHtml('<img style="width: 90%;" src="' . $url_img . '" />');
|
||||
$ui->contentAddHtml('</div>');
|
||||
}
|
||||
else {
|
||||
$ui->contentAddHtml('<p style="color: #ff0000;">' . __('Map could not be generated') . '</p>');
|
||||
|
||||
$ui->endContent();
|
||||
$ui->showPage();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$ui->endContent();
|
||||
$ui->showPage();
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -1,250 +0,0 @@
|
|||
<?php
|
||||
// Pandora FMS - http://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2010 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.
|
||||
|
||||
ob_start();
|
||||
require_once ('../include/functions_networkmap.php');
|
||||
ob_get_clean(); //Fixed unused javascript code.
|
||||
|
||||
class Networkmaps {
|
||||
private $correct_acl = false;
|
||||
private $acl = "AR";
|
||||
|
||||
private $default = true;
|
||||
private $default_filters = array();
|
||||
|
||||
private $group = 0;
|
||||
private $type = 0;
|
||||
|
||||
private $list_types = null;
|
||||
|
||||
function __construct() {
|
||||
$system = System::getInstance();
|
||||
|
||||
if ($system->checkACL($this->acl)) {
|
||||
$this->correct_acl = true;
|
||||
}
|
||||
else {
|
||||
$this->correct_acl = false;
|
||||
}
|
||||
}
|
||||
|
||||
public function ajax($parameter2 = false) {
|
||||
$system = System::getInstance();
|
||||
|
||||
if (!$this->correct_acl) {
|
||||
return;
|
||||
}
|
||||
else {
|
||||
switch ($parameter2) {
|
||||
case 'xxx':
|
||||
//$this->getFilters();
|
||||
//$page = $system->getRequest('page', 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function getFilters() {
|
||||
$system = System::getInstance();
|
||||
$user = User::getInstance();
|
||||
|
||||
$this->default_filters['group'] = true;
|
||||
$this->default_filters['type'] = true;
|
||||
|
||||
$this->group = (int)$system->getRequest('group', __("Group"));
|
||||
if (!$user->isInGroup($this->acl, $this->group)) {
|
||||
$this->group = 0;
|
||||
}
|
||||
if (($this->group === __("Group")) || ($this->group == 0)) {
|
||||
$this->group = 0;
|
||||
}
|
||||
else {
|
||||
$this->default = false;
|
||||
$this->default_filters['group'] = false;
|
||||
}
|
||||
|
||||
$this->type = $system->getRequest('type', __("Type"));
|
||||
if (($this->type === __("Type")) || ($this->type === '0')) {
|
||||
$this->type = '0';
|
||||
}
|
||||
else {
|
||||
$this->default = false;
|
||||
$this->default_filters['type'] = false;
|
||||
}
|
||||
}
|
||||
|
||||
public function show() {
|
||||
if (!$this->correct_acl) {
|
||||
$this->show_fail_acl();
|
||||
}
|
||||
else {
|
||||
$this->getFilters();
|
||||
$this->show_networkmaps();
|
||||
}
|
||||
}
|
||||
|
||||
private function show_fail_acl() {
|
||||
$error['type'] = 'onStart';
|
||||
$error['title_text'] = __('You don\'t have access to this page');
|
||||
$error['content_text'] = System::getDefaultACLFailText();
|
||||
if (class_exists("HomeEnterprise"))
|
||||
$home = new HomeEnterprise();
|
||||
else
|
||||
$home = new Home();
|
||||
$home->show($error);
|
||||
}
|
||||
|
||||
private function show_networkmaps() {
|
||||
$ui = Ui::getInstance();
|
||||
|
||||
$ui->createPage();
|
||||
$ui->createDefaultHeader(__("Networkmaps"),
|
||||
$ui->createHeaderButton(
|
||||
array('icon' => 'back',
|
||||
'pos' => 'left',
|
||||
'text' => __('Back'),
|
||||
'href' => 'index.php?page=home')));
|
||||
$ui->showFooter(false);
|
||||
$ui->beginContent();
|
||||
$filter_title = sprintf(__('Filter Networkmaps by %s'),
|
||||
$this->filterNetworkmapsGetString());
|
||||
$ui->contentBeginCollapsible($filter_title);
|
||||
$ui->beginForm("index.php?page=networkmaps");
|
||||
$system = System::getInstance();
|
||||
$groups = users_get_groups_for_select(
|
||||
$system->getConfig('id_user'), "AR", true, true, false, 'id_grupo');
|
||||
$options = array(
|
||||
'name' => 'group',
|
||||
'title' => __('Group'),
|
||||
'label' => __('Group'),
|
||||
'items' => $groups,
|
||||
'selected' => $this->group
|
||||
);
|
||||
$ui->formAddSelectBox($options);
|
||||
|
||||
$networkmap_types = networkmap_get_filter_types();
|
||||
$networkmap_types[0] = __('All');
|
||||
$options = array(
|
||||
'name' => 'type',
|
||||
'title' => __('Type'),
|
||||
'label' => __('Type'),
|
||||
'items' => $networkmap_types,
|
||||
'selected' => $this->type
|
||||
);
|
||||
$ui->formAddSelectBox($options);
|
||||
|
||||
$options = array(
|
||||
'icon' => 'refresh',
|
||||
'icon_pos' => 'right',
|
||||
'text' => __('Apply Filter')
|
||||
);
|
||||
$ui->formAddSubmitButton($options);
|
||||
$html = $ui->getEndForm();
|
||||
$ui->contentCollapsibleAddItem($html);
|
||||
$ui->contentEndCollapsible();
|
||||
$this->listNetworkmapsHtml();
|
||||
$ui->endContent();
|
||||
$ui->showPage();
|
||||
}
|
||||
|
||||
private function listNetworkmapsHtml() {
|
||||
$system = System::getInstance();
|
||||
$ui = Ui::getInstance();
|
||||
|
||||
// Create filter
|
||||
$where = array();
|
||||
// Order by type field
|
||||
$where['order'] = 'type';
|
||||
|
||||
if ($this->group != '0') {
|
||||
$where['store_group'] = $this->group;
|
||||
}
|
||||
else {
|
||||
$where['store_group'] = array_keys(users_get_groups());
|
||||
}
|
||||
|
||||
if ($this->type != '0')
|
||||
$where['type'] = $this->type;
|
||||
|
||||
$network_maps = db_get_all_rows_filter('tnetwork_map',
|
||||
$where);
|
||||
if (empty($network_maps)) {
|
||||
$network_maps = array();
|
||||
}
|
||||
$list = array();
|
||||
foreach ($network_maps as $networkmap) {
|
||||
// ACL
|
||||
if (! $system->checkACL("AR", $networkmap['store_group']))
|
||||
continue;
|
||||
|
||||
// If enterprise not loaded then skip this code
|
||||
if ($networkmap['type'] == 'policies' and (!defined('PANDORA_ENTERPRISE')))
|
||||
continue;
|
||||
$row = array();
|
||||
$row[__('Name')] = '<a class="ui-link" data-ajax="false" href="index.php?page=networkmap&id=' . $networkmap['id_networkmap'] . '">' . io_safe_output($networkmap['name']) . '</a>';
|
||||
$row[__('Type')] = $networkmap['type'];
|
||||
$row[__('Group')] = ui_print_group_icon($networkmap["store_group"], true, "groups_small", "" , false);
|
||||
$list[] = $row;
|
||||
}
|
||||
|
||||
if (count($network_maps) == 0) {
|
||||
$ui->contentAddHtml('<p style="color: #ff0000;">' . __('No networkmaps') . '</p>');
|
||||
}
|
||||
else {
|
||||
$table = new Table();
|
||||
$table->id = 'list_networkmaps';
|
||||
$table->importFromHash($list);
|
||||
$ui->contentAddHtml($table->getHTML());
|
||||
}
|
||||
|
||||
$ui->contentAddLinkListener('list_networkmaps');
|
||||
}
|
||||
|
||||
private function filterNetworkmapsGetString() {
|
||||
if ($this->default) {
|
||||
return __("(Default)");
|
||||
}
|
||||
else {
|
||||
$filters_to_serialize = array();
|
||||
|
||||
if (!$this->default_filters['group']) {
|
||||
$filters_to_serialize[] = sprintf(__("Group: %s"),
|
||||
groups_get_name($this->group, true));
|
||||
}
|
||||
if (!$this->default_filters['type']) {
|
||||
$networkmap_types = networkmap_get_filter_types();
|
||||
$networkmap_types[0] = __('All');
|
||||
|
||||
$filters_to_serialize[] = sprintf(__("Type: %s"),
|
||||
$networkmap_types[$this->type]);
|
||||
}
|
||||
|
||||
$string = '(' . implode(' - ', $filters_to_serialize) . ')';
|
||||
|
||||
|
||||
//~ $networkmap_types = networkmap_get_filter_types();
|
||||
//~ $networkmap_types[0] = __('All');
|
||||
//~ $type = $networkmap_types[$this->type];
|
||||
//~ $group = groups_get_name($this->group, true);
|
||||
//~
|
||||
//~
|
||||
//~ $string = sprintf(
|
||||
//~ __("(Type: %s - Group: %s)"),
|
||||
//~ $type, $group);
|
||||
|
||||
return $string;
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -187,77 +187,37 @@ if ($alert_validate) {
|
|||
enterprise_hook('open_meta_frame');
|
||||
|
||||
if ($free_search != '') {
|
||||
switch ($config["dbtype"]) {
|
||||
case "mysql":
|
||||
$whereAlertSimple = 'AND (' .
|
||||
'id_alert_template IN (
|
||||
SELECT id
|
||||
FROM talert_templates
|
||||
WHERE name LIKE "%' . $free_search . '%") OR ' .
|
||||
'id_alert_template IN (
|
||||
SELECT id
|
||||
FROM talert_templates
|
||||
WHERE id_alert_action IN (
|
||||
SELECT id
|
||||
FROM talert_actions
|
||||
WHERE name LIKE "%' . $free_search . '%")) OR ' .
|
||||
'talert_template_modules.id IN (
|
||||
SELECT id_alert_template_module
|
||||
FROM talert_template_module_actions
|
||||
WHERE id_alert_action IN (
|
||||
SELECT id
|
||||
FROM talert_actions
|
||||
WHERE name LIKE "%' . $free_search . '%")) OR ' .
|
||||
'id_agent_module IN (
|
||||
SELECT id_agente_modulo
|
||||
FROM tagente_modulo
|
||||
WHERE nombre LIKE "%' . $free_search . '%") OR ' .
|
||||
'id_agent_module IN (
|
||||
SELECT id_agente_modulo
|
||||
FROM tagente_modulo
|
||||
WHERE id_agente IN (
|
||||
SELECT id_agente
|
||||
FROM tagente
|
||||
WHERE nombre LIKE "%' . $free_search . '%") OR alias LIKE "%' . $free_search . '%")' .
|
||||
')';
|
||||
|
||||
break;
|
||||
case "postgresql":
|
||||
case "oracle":
|
||||
$whereAlertSimple = 'AND (' .
|
||||
'id_alert_template IN (
|
||||
SELECT id
|
||||
FROM talert_templates
|
||||
WHERE name LIKE \'%' . $free_search . '%\') OR ' .
|
||||
'id_alert_template IN (
|
||||
SELECT id
|
||||
FROM talert_templates
|
||||
WHERE id_alert_action IN (
|
||||
SELECT id
|
||||
FROM talert_actions
|
||||
WHERE name LIKE \'%' . $free_search . '%\')) OR ' .
|
||||
'talert_template_modules.id IN (
|
||||
SELECT id_alert_template_module
|
||||
FROM talert_template_module_actions
|
||||
WHERE id_alert_action IN (
|
||||
SELECT id
|
||||
FROM talert_actions
|
||||
WHERE name LIKE \'%' . $free_search . '%\')) OR ' .
|
||||
'id_agent_module IN (
|
||||
SELECT id_agente_modulo
|
||||
FROM tagente_modulo
|
||||
WHERE nombre LIKE \'%' . $free_search . '%\') OR ' .
|
||||
'id_agent_module IN (
|
||||
SELECT id_agente_modulo
|
||||
FROM tagente_modulo
|
||||
WHERE id_agente IN (
|
||||
SELECT id_agente
|
||||
FROM tagente
|
||||
WHERE nombre LIKE \'%' . $free_search . '%\' OR alias LIKE \'%' . $free_search . '%\'))' .
|
||||
')';
|
||||
|
||||
break;
|
||||
}
|
||||
$whereAlertSimple = 'AND (' .
|
||||
'id_alert_template IN (
|
||||
SELECT id
|
||||
FROM talert_templates
|
||||
WHERE name LIKE "%' . $free_search . '%") OR ' .
|
||||
'id_alert_template IN (
|
||||
SELECT id
|
||||
FROM talert_templates
|
||||
WHERE id_alert_action IN (
|
||||
SELECT id
|
||||
FROM talert_actions
|
||||
WHERE name LIKE "%' . $free_search . '%")) OR ' .
|
||||
'talert_template_modules.id IN (
|
||||
SELECT id_alert_template_module
|
||||
FROM talert_template_module_actions
|
||||
WHERE id_alert_action IN (
|
||||
SELECT id
|
||||
FROM talert_actions
|
||||
WHERE name LIKE "%' . $free_search . '%")) OR ' .
|
||||
'id_agent_module IN (
|
||||
SELECT id_agente_modulo
|
||||
FROM tagente_modulo
|
||||
WHERE nombre LIKE "%' . $free_search . '%") OR ' .
|
||||
'id_agent_module IN (
|
||||
SELECT id_agente_modulo
|
||||
FROM tagente_modulo
|
||||
WHERE id_agente IN (
|
||||
SELECT id_agente
|
||||
FROM tagente
|
||||
WHERE nombre LIKE "%' . $free_search . '%") OR alias LIKE "%' . $free_search . '%")' .
|
||||
')';
|
||||
}
|
||||
else {
|
||||
$whereAlertSimple = '';
|
||||
|
|
|
@ -36,7 +36,6 @@ $agentId = (int)get_parameter('id_agente');
|
|||
$id_agente = $agentId;
|
||||
$agent_name = agents_get_name($id_agente);
|
||||
$agent_alias = agents_get_alias($id_agente);
|
||||
$agentData = gis_get_data_last_position_agent($id_agente);
|
||||
|
||||
//Avoid the agents with characters that fails the div.
|
||||
$agent_name_original = $agent_name;
|
||||
|
@ -83,35 +82,22 @@ switch ($config["dbtype"]) {
|
|||
gis_activate_ajax_refresh(null, $timestampLastOperation);
|
||||
gis_activate_select_control();
|
||||
|
||||
if ($agentData === false) {
|
||||
ui_print_info_message (
|
||||
__("There is no GIS data for this agent, so it's positioned in default position of map.") );
|
||||
}
|
||||
|
||||
$dataLastPosition = gis_get_data_last_position_agent($agentId);
|
||||
if ($dataLastPosition !== false) {
|
||||
echo "<b>" . __("Last position in ") .
|
||||
$dataLastPosition['start_timestamp'] . ":</b> " .
|
||||
$dataLastPosition['stored_longitude'] . ", " . $dataLastPosition['stored_latitude'] . ", " . $dataLastPosition['stored_altitude'];
|
||||
}
|
||||
|
||||
echo "<br />";
|
||||
echo "<form class='' action='index.php?" . $url . "' method='POST'>";
|
||||
echo "<table width=100% class='databox filters'>";
|
||||
echo "<tr><td>" . __("Period to show data as path") . ": ";
|
||||
echo "<tr><td>" . __("Period to show data as path");
|
||||
echo "<td>";
|
||||
html_print_extended_select_for_time ('period', $period, '', '', '0', 10);
|
||||
echo "<td>";
|
||||
html_print_submit_button(__('Refresh path'), 'refresh', false, 'class = "sub upd" style="margin-top:0px"');
|
||||
echo "</table></form>";
|
||||
|
||||
echo "<h4>" . __("Positional data from the last") . " " . human_time_description_raw ($period) ."</h4>";
|
||||
/* Get the total number of Elements for the pagination */
|
||||
$sqlCount = sprintf ("SELECT COUNT(*)
|
||||
FROM tgis_data_history
|
||||
WHERE tagente_id_agente = %d AND end_timestamp > FROM_UNIXTIME(%d)
|
||||
ORDER BY end_timestamp DESC", $agentId, get_system_time () - $period);
|
||||
$countData = db_get_value_sql($sqlCount);
|
||||
|
||||
$countData = (int) db_get_value_sql($sqlCount);
|
||||
|
||||
/* Get the elements to present in this page */
|
||||
switch ($config["dbtype"]) {
|
||||
|
@ -141,9 +127,7 @@ switch ($config["dbtype"]) {
|
|||
|
||||
$result = db_get_all_rows_sql ($sql, true);
|
||||
|
||||
|
||||
if ($result === false) {
|
||||
|
||||
$sql2 = sprintf ("
|
||||
SELECT current_longitude AS longitude, current_latitude AS latitude, current_altitude AS altitude,
|
||||
start_timestamp, description, number_of_packages, manual_placement
|
||||
|
@ -163,10 +147,11 @@ if ($result === false) {
|
|||
}
|
||||
|
||||
if ($result !== false) {
|
||||
if(!$countData){
|
||||
$countData = 1;
|
||||
}
|
||||
ui_pagination ($countData, false) ;
|
||||
echo "<h4>" . __("Positional data from the last") . " " . human_time_description_raw($period) ."</h4>";
|
||||
|
||||
if ($countData > 0) ui_pagination($countData, false);
|
||||
|
||||
$table = new StdClass();
|
||||
$table->data = array();
|
||||
foreach ($result as $key => $row) {
|
||||
$distance = 0;
|
||||
|
@ -187,9 +172,13 @@ if ($result !== false) {
|
|||
$rowdata = array(
|
||||
$row['longitude'],
|
||||
$row['latitude'],
|
||||
$row['altitude'],
|
||||
$row['start_timestamp'],
|
||||
$row['end_timestamp'],
|
||||
(int) $row['altitude'] . " m",
|
||||
is_numeric($row['start_timestamp'])
|
||||
? date($config["date_format"], $row['start_timestamp'])
|
||||
: date_w_fixed_tz($row['start_timestamp']),
|
||||
is_numeric($row['end_timestamp'])
|
||||
? date($config["date_format"], $row['end_timestamp'])
|
||||
: date_w_fixed_tz($row['end_timestamp']),
|
||||
$row['description'],
|
||||
sprintf(__('%s Km'), $distance),
|
||||
$row['number_of_packages'],
|
||||
|
@ -206,13 +195,12 @@ if ($result !== false) {
|
|||
__('Distance'),
|
||||
__("# of Packages"),
|
||||
__("Manual placement"));
|
||||
$table->class = 'position_data_table';
|
||||
$table->class = 'databox data';
|
||||
$table->id = $agent_name.'_position_data_table';
|
||||
$table->title = $agent_alias . " " . __("positional data");
|
||||
$table->titlestyle = "background-color:#799E48;";
|
||||
html_print_table($table); unset($table);
|
||||
$table->width = '100%';
|
||||
html_print_table($table);
|
||||
unset($table);
|
||||
|
||||
ui_pagination ($countData, false) ;
|
||||
echo "<h3>" . __('Total') . ' ' . $countData . ' ' . __('Data') . "</h3>";
|
||||
if ($countData > 0) ui_pagination($countData, false);
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -30,7 +30,6 @@ if (!$agent_a && !$agent_w) {
|
|||
require ("general/noaccess.php");
|
||||
exit;
|
||||
}
|
||||
$offset = get_parameter('offset', 0);
|
||||
// Update network modules for this group
|
||||
// Check for Network FLAG change request
|
||||
// Made it a subquery, much faster on both the database and server side
|
||||
|
@ -81,12 +80,12 @@ $agents_notinit = 0;
|
|||
$all_alerts_fired = 0;
|
||||
|
||||
//Groups and tags
|
||||
$result_groups = groupview_get_groups_list(
|
||||
$result_groups_info = groupview_get_groups_list(
|
||||
$config['id_user'],
|
||||
($agent_a == true) ? 'AR' : (($agent_w == true) ? 'AW' : 'AR')
|
||||
);
|
||||
|
||||
$count = count($result_groups);
|
||||
$result_groups = $result_groups_info['groups'];
|
||||
$count = $result_groups_info['counter'];
|
||||
|
||||
if ($result_groups[0]["_id_"] == 0) {
|
||||
$total_agentes = $result_groups[0]["_total_agents_"];
|
||||
|
@ -187,10 +186,7 @@ if (!empty($result_groups)) {
|
|||
echo "<th width='10%' style='min-width: 60px;text-align:center;'>" . __("Alert fired") . "</th>";
|
||||
echo "</tr>";
|
||||
|
||||
$result_groups = array_slice($result_groups, $offset, $config['block_size']);
|
||||
|
||||
foreach ($result_groups as $data) {
|
||||
|
||||
$groups_id = $data["_id_"];
|
||||
|
||||
// Calculate entire row color
|
||||
|
@ -454,4 +450,4 @@ if (!empty($result_groups)) {
|
|||
} else {
|
||||
ui_print_info_message ( __('There are no defined agents'));
|
||||
}
|
||||
?>
|
||||
?>
|
||||
|
|
|
@ -56,7 +56,6 @@ ui_print_page_header (__("Tactical view"), "", false, "", false, $updated_time);
|
|||
|
||||
//Currently this function makes loading this page is impossible. Change
|
||||
//and create new function.
|
||||
//$all_data = group_get_groups_list($config['id_user'], $user_strict, 'AR', true, false, 'tactical');
|
||||
|
||||
$all_data = tactical_status_modules_agents($config['id_user'], $user_strict, 'AR', $user_strict);
|
||||
|
||||
|
|
|
@ -108,6 +108,9 @@ $layers = gis_get_layers($idMap);
|
|||
|
||||
// Render map
|
||||
|
||||
$has_management_acl = check_acl($config["id_user"], $map['group_id'], "MW")
|
||||
|| check_acl ($config["id_user"], $map['group_id'], "MM");
|
||||
|
||||
$buttons = array();
|
||||
|
||||
if ($config["pure"] == 0) {
|
||||
|
@ -119,22 +122,14 @@ else {
|
|||
html_print_image ("images/normalscreen.png", true, array ("title" => __('Back to normal mode'))) . "</a>";
|
||||
}
|
||||
|
||||
if (check_acl ($config["id_user"], $map['group_id'], "MW") || check_acl ($config["id_user"], $map['group_id'], "MM")) {
|
||||
$buttons['setup']['text'] = '<a href="index.php?sec=godgismaps&sec2=godmode/gis_maps/configure_gis_map&action=edit_map&map_id='. $idMap.'">'.html_print_image ("images/setup.png", true, array ("title" => __('Setup'))).'</a>';
|
||||
$buttons['setup']['godmode'] = 1;
|
||||
|
||||
|
||||
if ($has_management_acl) {
|
||||
$hash = md5($config["dbpass"] . $idMap . $config["id_user"]);
|
||||
|
||||
$buttons['public_link']['text'] = '<a href="' .
|
||||
ui_get_full_url('operation/gis_maps/public_console.php?hash=' .$hash .
|
||||
'&map_id=' . $idMap . '&id_user=' . $config["id_user"]) . '" target="_blank">'.
|
||||
html_print_image ("images/camera_mc.png", true, array ("title" => __('Show link to public Visual Console'))).'</a>';
|
||||
}
|
||||
|
||||
$buttonsString = '<a href="index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=3">' .
|
||||
html_print_image("images/bricks.png", true, array("class" => "top", "border" => '0')) . ' Agent - test_gis1</a></li></ul></div><div id="menu_tab"><ul class="mn"><li class="nomn"><a href="index.php?sec=estado&sec2=godmode/agentes/configurar_agente&id_agente=3">' . html_print_image("images/setup.png", true, array("class" => "top", "title" => "Manage", "border" => "0", "width" => "16", "title" => "Manage")) . ' </a></li><li class="nomn_high"><a href="index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=3">' . html_print_image("images/monitor.png", true, array("class" => "top", "title" => "Main", "border" => "0")) . ' </a></li><li class="nomn"><a href="index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=3&tab=data">' . html_print_image("images/lightbulb.png", true, array("class" => "top", "title" => "Data", "border" => "0")) . ' </a></li><li class="nomn"><a href="index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=3&tab=alert">' . html_print_image("images/bell.png", true, array("class" => "top", "title" => "Alerts", "border" => "0")) . ' </a></li><li class="nomn"><a href="index.php?sec=estado&sec2=operation/agentes/ver_agente&tab=sla&id_agente=3">' . html_print_image("images/images.png", true, array("class" => "top", "title" => "S.L.A.", "border" => "0")) . ' </a></li><li class="nomn"><a href="index.php?sec=estado&sec2=operation/agentes/estado_agente&group_id=2">' . html_print_image("images/agents_group.png", true, array("class" => "top", "title" => "Group", "border" => "0")) . ' </a></li><li class="nomn"><a href="index.php?sec=estado&sec2=operation/agentes/ver_agente&tab=inventory&id_agente=3">' . html_print_image("images/page_white_text.png", true, array("class" => "top", "title" => "Inventory", "border" => "0", "width" => "16")) . ' </a></li><li class="nomn"><a href="index.php?sec=estado&sec2=operation/agentes/ver_agente&tab=gis&id_agente=3">' . html_print_image("images/world.png", array("class" => "top", "title" => "GIS data", "border" => "0")) . ' </a>';
|
||||
|
||||
$times = array(
|
||||
5 => __('5 seconds'),
|
||||
10 => __('10 seconds'),
|
||||
|
@ -144,19 +139,31 @@ $times = array(
|
|||
SECONDS_5MINUTES => __('5 minutes'),
|
||||
SECONDS_10MINUTES => __('10 minutes'),
|
||||
SECONDS_1HOUR => __('1 hour'),
|
||||
SECONDS_2HOUR => __('2 hours'));
|
||||
SECONDS_2HOUR => __('2 hours')
|
||||
);
|
||||
|
||||
$buttons[]['text'] = ' ' . __('Refresh: ') . html_print_select($times, 'refresh_time', 60, 'changeRefreshTime(this.value);', '', 0, true, false, false) . " ";
|
||||
$buttons[]['text'] = "<div style='margin-top: 6px;'>"
|
||||
.__('Refresh') . ": "
|
||||
. html_print_select($times, 'refresh_time', 60, 'changeRefreshTime(this.value);', '', 0, true, false, false)
|
||||
. "</div>";
|
||||
|
||||
$status = array(
|
||||
'all' => __('All'),
|
||||
'all' => __('None'),
|
||||
'bad' => __('Critical'),
|
||||
'warning' => __('Warning'),
|
||||
'ok' => __('Ok'),
|
||||
'default' => __('Other'));
|
||||
'default' => __('Other')
|
||||
);
|
||||
|
||||
$buttons[]['text'] = ' ' . __('Show agents by state: ') .
|
||||
html_print_select($status, 'show_status', 'all', 'changeShowStatus(this.value);', '', 0, true, false, false) . " ";
|
||||
$buttons[]['text'] = "<div style='margin-top: 6px;'>"
|
||||
. __('Filter by status') . ": "
|
||||
. html_print_select($status, 'show_status', 'all', 'changeShowStatus(this.value);', '', 0, true, false, false)
|
||||
. "</div>";
|
||||
|
||||
if ($has_management_acl) {
|
||||
$buttons['setup']['text'] = '<a href="index.php?sec=godgismaps&sec2=godmode/gis_maps/configure_gis_map&action=edit_map&map_id='. $idMap.'">'.html_print_image ("images/setup.png", true, array ("title" => __('Setup'))).'</a>';
|
||||
$buttons['setup']['godmode'] = 1;
|
||||
}
|
||||
|
||||
ui_print_page_header(__('Map') . " » " . __('Map') . " " . $map['map_name'],
|
||||
"images/op_gis.png", false, "", false, $buttons);
|
||||
|
|
|
@ -66,6 +66,8 @@ else {
|
|||
|
||||
// Update user info
|
||||
if (isset ($_GET["modified"]) && !$view_mode) {
|
||||
if (html_print_csrf_error()) return;
|
||||
|
||||
$upd_info = array ();
|
||||
$upd_info["fullname"] = get_parameter_post ("fullname", $user_info["fullname"]);
|
||||
$upd_info["firstname"] = get_parameter_post ("firstname", $user_info["firstname"]);
|
||||
|
@ -490,6 +492,7 @@ if (!$config["user_can_update_info"]) {
|
|||
echo '<i>'.__('You can not change your user info under the current authentication scheme').'</i>';
|
||||
}
|
||||
else {
|
||||
html_print_csrf_hidden();
|
||||
html_print_submit_button (__('Update'), 'uptbutton', $view_mode, 'class="sub upd"');
|
||||
}
|
||||
echo '</div></form>';
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
# Pandora FMS Console
|
||||
#
|
||||
%define name pandorafms_console
|
||||
%define version 7.0NG.726
|
||||
%define release 180906
|
||||
%define version 7.0NG.727
|
||||
%define release 180917
|
||||
|
||||
# User and Group under which Apache is running
|
||||
%define httpd_name httpd
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
# Pandora FMS Console
|
||||
#
|
||||
%define name pandorafms_console
|
||||
%define version 7.0NG.726
|
||||
%define release 180906
|
||||
%define version 7.0NG.727
|
||||
%define release 180917
|
||||
%define httpd_name httpd
|
||||
# User and Group under which Apache is running
|
||||
%define httpd_name apache2
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
# This code is licensed under GPL 2.0 license.
|
||||
# **********************************************************************
|
||||
|
||||
PI_VERSION="7.0NG.726"
|
||||
PI_VERSION="7.0NG.727"
|
||||
FORCE=0
|
||||
DESTDIR=""
|
||||
LOG_TIMESTAMP=`date +"%Y/%m/%d %H:%M:%S"`
|
||||
|
|
|
@ -1242,6 +1242,7 @@ CREATE TABLE IF NOT EXISTS `treport` (
|
|||
`id_group_edit` mediumint(8) unsigned NULL DEFAULT 0,
|
||||
`metaconsole` tinyint(1) DEFAULT 0,
|
||||
`non_interactive` tinyint(1) UNSIGNED NOT NULL default 0,
|
||||
`hidden` tinyint(1) DEFAULT 0,
|
||||
PRIMARY KEY(`id_report`)
|
||||
) ENGINE = InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
|
@ -1381,6 +1382,7 @@ CREATE TABLE IF NOT EXISTS `tlayout_data` (
|
|||
`border_color` varchar(200) DEFAULT "",
|
||||
`fill_color` varchar(200) DEFAULT "",
|
||||
`show_statistics` tinyint(2) NOT NULL default '0',
|
||||
`linked_layout_node_id` INT(10) NOT NULL default 0,
|
||||
`linked_layout_status_type` ENUM ('default', 'weight', 'service') DEFAULT 'default',
|
||||
`id_layout_linked_weight` int(10) NOT NULL default '0',
|
||||
`linked_layout_status_as_service_warning` FLOAT(20, 3) NOT NULL default 0,
|
||||
|
@ -2363,6 +2365,7 @@ CREATE TABLE IF NOT EXISTS `tpolicy_modules_inventory` (
|
|||
`username` varchar(100) default '',
|
||||
`password` varchar(100) default '',
|
||||
`pending_delete` tinyint(1) default '0',
|
||||
`custom_fields` MEDIUMBLOB NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
FOREIGN KEY (`id_policy`) REFERENCES tpolicies(`id`)
|
||||
ON UPDATE CASCADE ON DELETE CASCADE,
|
||||
|
@ -3315,6 +3318,7 @@ CREATE TABLE IF NOT EXISTS `tlayout_template_data` (
|
|||
`border_color` varchar(200) DEFAULT "",
|
||||
`fill_color` varchar(200) DEFAULT "",
|
||||
`show_statistics` tinyint(2) NOT NULL default '0',
|
||||
`linked_layout_node_id` INT(10) NOT NULL default 0,
|
||||
`linked_layout_status_type` ENUM ('default', 'weight', 'service') DEFAULT 'default',
|
||||
`id_layout_linked_weight` int(10) NOT NULL default '0',
|
||||
`linked_layout_status_as_service_warning` FLOAT(20, 3) NOT NULL default 0,
|
||||
|
|
|
@ -112,7 +112,7 @@ INSERT INTO `tconfig` (`token`, `value`) VALUES
|
|||
('MR', 19),
|
||||
('identification_reminder', 1),
|
||||
('identification_reminder_timestamp', 0),
|
||||
('current_package_enterprise', '726'),
|
||||
('current_package_enterprise', '727'),
|
||||
('post_process_custom_values', '{"0.00000038580247":"Seconds to months","0.00000165343915":"Seconds to weeks","0.00001157407407":"Seconds to days","0.01666666666667":"Seconds to minutes","0.00000000093132":"Bytes to Gigabytes","0.00000095367432":"Bytes to Megabytes","0.0009765625":"Bytes to Kilobytes","0.00000001653439":"Timeticks to weeks","0.00000011574074":"Timeticks to days"}'),
|
||||
('custom_docs_logo', 'default_docs.png'),
|
||||
('custom_support_logo', 'default_support.png'),
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
package: pandorafms-server
|
||||
Version: 7.0NG.726-180906
|
||||
Version: 7.0NG.727-180917
|
||||
Architecture: all
|
||||
Priority: optional
|
||||
Section: admin
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
pandora_version="7.0NG.726-180906"
|
||||
pandora_version="7.0NG.727-180917"
|
||||
|
||||
package_cpan=0
|
||||
package_pandora=1
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#############################################################################
|
||||
# Pandora FMS Server Parameters
|
||||
# Pandora FMS, the Flexible Monitoring System.
|
||||
# Version 7.0NG.726
|
||||
# Version 7.0NG.727
|
||||
# Licensed under GPL license v2,
|
||||
# (c) 2003-2017 Artica Soluciones Tecnologicas
|
||||
# http://www.pandorafms.com
|
||||
|
|
|
@ -44,8 +44,8 @@ our @EXPORT = qw(
|
|||
);
|
||||
|
||||
# version: Defines actual version of Pandora Server for this module only
|
||||
my $pandora_version = "7.0NG.726";
|
||||
my $pandora_build = "180906";
|
||||
my $pandora_version = "7.0NG.727";
|
||||
my $pandora_build = "180917";
|
||||
our $VERSION = $pandora_version." ".$pandora_build;
|
||||
|
||||
# Setup hash
|
||||
|
|
|
@ -4635,97 +4635,93 @@ Process groups statistics for statistics table
|
|||
##########################################################################
|
||||
sub pandora_group_statistics ($$) {
|
||||
my ($pa_config, $dbh) = @_;
|
||||
|
||||
# Variable init
|
||||
my $modules = 0;
|
||||
my $normal = 0;
|
||||
my $critical = 0;
|
||||
my $warning = 0;
|
||||
my $unknown = 0;
|
||||
my $non_init = 0;
|
||||
my $alerts = 0;
|
||||
my $alerts_fired = 0;
|
||||
my $agents = 0;
|
||||
my $agents_unknown = 0;
|
||||
my $utimestamp = 0;
|
||||
my $group = 0;
|
||||
my $is_meta = is_metaconsole($pa_config);
|
||||
|
||||
# Get all groups
|
||||
my @groups = get_db_rows ($dbh, 'SELECT id_grupo FROM tgrupo');
|
||||
my $table = is_metaconsole($pa_config) ? 'tmetaconsole_agent' : 'tagente';
|
||||
my $sec_table = is_metaconsole($pa_config)
|
||||
? 'tmetaconsole_agent_secondary_group'
|
||||
: 'tagent_secondary_group';
|
||||
logger($pa_config, "Updating no realtime group stats.", 10);
|
||||
|
||||
# For each valid group get the stats: Simple uh?
|
||||
foreach my $group_row (@groups) {
|
||||
my $total_alerts_condition = $is_meta
|
||||
? "0"
|
||||
: "COUNT(tatm.id)";
|
||||
my $joins_alerts = $is_meta
|
||||
? ""
|
||||
: "LEFT JOIN tagente_modulo tam
|
||||
ON tam.id_agente = ta.id_agente
|
||||
INNER JOIN talert_template_modules tatm
|
||||
ON tatm.id_agent_module = tam.id_agente_modulo";
|
||||
my $agent_table = $is_meta
|
||||
? "tmetaconsole_agent"
|
||||
: "tagente";
|
||||
my $agent_seconsary_table = $is_meta
|
||||
? "tmetaconsole_agent_secondary_group"
|
||||
: "tagent_secondary_group";
|
||||
|
||||
$group = $group_row->{'id_grupo'};
|
||||
|
||||
# NOTICE - Calculations done here MUST BE the same than used in PHP code to have
|
||||
# the same criteria. PLEASE, double check any changes here and in functions_groups.php
|
||||
$agents_unknown = get_db_value ($dbh, "SELECT COUNT(DISTINCT(id_agente))
|
||||
FROM $table LEFT JOIN $sec_table ON id_agente=id_agent
|
||||
WHERE disabled=0 AND critical_count=0 AND warning_count=0 AND unknown_count>0 AND (id_grupo=? OR id_group=?)", $group, $group);
|
||||
$agents_unknown = 0 unless defined ($agents_unknown);
|
||||
|
||||
$agents = get_db_value ($dbh, "SELECT COUNT(DISTINCT(id_agente))
|
||||
FROM $table LEFT JOIN $sec_table ON id_agente=id_agent
|
||||
WHERE(id_grupo=$group OR id_group=$group) AND disabled=0");
|
||||
$agents = 0 unless defined ($agents);
|
||||
|
||||
$modules = get_db_value ($dbh, "SELECT SUM(total_count) FROM
|
||||
# Update the record.
|
||||
db_do ($dbh, "REPLACE INTO tgroup_stat(
|
||||
`id_group`, `modules`, `normal`, `critical`, `warning`, `unknown`,
|
||||
`non-init`, `alerts`, `alerts_fired`, `agents`,
|
||||
`agents_unknown`, `utimestamp`
|
||||
)
|
||||
SELECT
|
||||
tg.id_grupo AS id_group,
|
||||
IF (SUM(modules_total) IS NULL,0,SUM(modules_total)) AS modules,
|
||||
IF (SUM(modules_ok) IS NULL,0,SUM(modules_ok)) AS normal,
|
||||
IF (SUM(modules_critical) IS NULL,0,SUM(modules_critical)) AS critical,
|
||||
IF (SUM(modules_warning) IS NULL,0,SUM(modules_warning)) AS warning,
|
||||
IF (SUM(modules_unknown) IS NULL,0,SUM(modules_unknown)) AS unknown,
|
||||
IF (SUM(modules_not_init) IS NULL,0,SUM(modules_not_init)) AS `non-init`,
|
||||
IF (SUM(alerts_total) IS NULL,0,SUM(alerts_total)) AS alerts,
|
||||
IF (SUM(alerts_fired) IS NULL,0,SUM(alerts_fired)) AS alerts_fired,
|
||||
IF (SUM(agents_total) IS NULL,0,SUM(agents_total)) AS agents,
|
||||
IF (SUM(agents_unknown) IS NULL,0,SUM(agents_unknown)) AS agents_unknown,
|
||||
UNIX_TIMESTAMP() AS utimestamp
|
||||
FROM
|
||||
(
|
||||
SELECT DISTINCT(id_agente), total_count
|
||||
FROM $table LEFT JOIN $sec_table ON id_agente=id_agent
|
||||
WHERE disabled=0 AND (id_grupo=? OR id_group=?)
|
||||
) AS t1", $group, $group);
|
||||
$modules = 0 unless defined ($modules);
|
||||
SELECT SUM(ta.normal_count) AS modules_ok,
|
||||
SUM(ta.critical_count) AS modules_critical,
|
||||
SUM(ta.warning_count) AS modules_warning,
|
||||
SUM(ta.unknown_count) AS modules_unknown,
|
||||
SUM(ta.notinit_count) AS modules_not_init,
|
||||
SUM(ta.total_count) AS modules_total,
|
||||
SUM(ta.fired_count) AS alerts_fired,
|
||||
$total_alerts_condition AS alerts_total,
|
||||
SUM(IF(ta.critical_count > 0, 1, 0)) AS agents_critical,
|
||||
SUM(IF(ta.critical_count = 0 AND ta.warning_count = 0 AND ta.unknown_count > 0, 1, 0)) AS agents_unknown,
|
||||
SUM(IF(ta.total_count = ta.notinit_count, 1, 0)) AS agents_not_init,
|
||||
COUNT(ta.id_agente) AS agents_total,
|
||||
ta.id_grupo AS g
|
||||
FROM $agent_table ta
|
||||
$joins_alerts
|
||||
WHERE ta.disabled = 0
|
||||
GROUP BY g
|
||||
|
||||
$normal = get_db_value ($dbh, "SELECT COUNT(DISTINCT(id_agente))
|
||||
FROM $table LEFT JOIN $sec_table ON id_agente=id_agent
|
||||
WHERE disabled=0 AND critical_count=0 AND warning_count=0 AND unknown_count=0 AND normal_count>0 AND (id_grupo=? OR id_group=?)", $group, $group);
|
||||
$normal = 0 unless defined ($normal);
|
||||
UNION ALL
|
||||
|
||||
$critical = get_db_value ($dbh, "SELECT COUNT(DISTINCT(id_agente))
|
||||
FROM $table LEFT JOIN $sec_table ON id_agente=id_agent
|
||||
WHERE disabled=0 AND critical_count>0 AND (id_grupo=? OR id_group=?)", $group, $group);
|
||||
$critical = 0 unless defined ($critical);
|
||||
|
||||
$warning = get_db_value ($dbh, "SELECT COUNT(DISTINCT(id_agente))
|
||||
FROM $table LEFT JOIN $sec_table ON id_agente=id_agent
|
||||
WHERE disabled=0 AND critical_count=0 AND warning_count>0 AND (id_grupo=? OR id_group=?)", $group, $group);
|
||||
$warning = 0 unless defined ($warning);
|
||||
|
||||
$unknown = get_db_value ($dbh, "SELECT COUNT(DISTINCT(id_agente))
|
||||
FROM $table LEFT JOIN $sec_table ON id_agente=id_agent
|
||||
WHERE disabled=0 AND critical_count=0 AND warning_count=0 AND unknown_count>0 AND (id_grupo=? OR id_group=?)", $group, $group);
|
||||
$unknown = 0 unless defined ($unknown);
|
||||
|
||||
$non_init = get_db_value ($dbh, "SELECT COUNT(DISTINCT(id_agente))
|
||||
FROM $table LEFT JOIN $sec_table ON id_agente=id_agent
|
||||
WHERE disabled=0 AND total_count=notinit_count AND (id_grupo=? OR id_group=?)", $group, $group);
|
||||
$non_init = 0 unless defined ($non_init);
|
||||
|
||||
# Total alert count not available on the meta console.
|
||||
if ($table eq 'tagente') {
|
||||
$alerts = get_db_value ($dbh, "SELECT COUNT(talert_template_modules.id)
|
||||
FROM talert_template_modules, tagente_modulo, tagente
|
||||
WHERE tagente.id_grupo = $group AND tagente_modulo.id_agente = tagente.id_agente
|
||||
AND tagente_modulo.disabled = 0 AND tagente.disabled = 0
|
||||
AND talert_template_modules.disabled = 0
|
||||
AND talert_template_modules.id_agent_module = tagente_modulo.id_agente_modulo");
|
||||
}
|
||||
$alerts = 0 unless defined ($alerts);
|
||||
|
||||
$alerts_fired = get_db_value ($dbh, "SELECT SUM(fired_count) FROM $table WHERE disabled=0 AND id_grupo=?", $group);
|
||||
$alerts_fired = 0 unless defined ($alerts_fired);
|
||||
|
||||
# Update the record.
|
||||
db_do ($dbh, "REPLACE INTO tgroup_stat (id_group, modules, normal, critical, warning, unknown, " . $PandoraFMS::DB::RDBMS_QUOTE . 'non-init' . $PandoraFMS::DB::RDBMS_QUOTE . ", alerts, alerts_fired, agents, agents_unknown, utimestamp) VALUES ($group, $modules, $normal, $critical, $warning, $unknown, $non_init, $alerts, $alerts_fired, $agents, $agents_unknown, UNIX_TIMESTAMP())");
|
||||
|
||||
}
|
||||
SELECT SUM(ta.normal_count) AS modules_ok,
|
||||
SUM(ta.critical_count) AS modules_critical,
|
||||
SUM(ta.warning_count) AS modules_warning,
|
||||
SUM(ta.unknown_count) AS modules_unknown,
|
||||
SUM(ta.notinit_count) AS modules_not_init,
|
||||
SUM(ta.total_count) AS modules_total,
|
||||
SUM(ta.fired_count) AS alerts_fired,
|
||||
$total_alerts_condition AS alerts_total,
|
||||
SUM(IF(ta.critical_count > 0, 1, 0)) AS agents_critical,
|
||||
SUM(IF(ta.critical_count = 0 AND ta.warning_count = 0 AND ta.unknown_count > 0, 1, 0)) AS agents_unknown,
|
||||
SUM(IF(ta.total_count = ta.notinit_count, 1, 0)) AS agents_not_init,
|
||||
COUNT(ta.id_agente) AS agents_total,
|
||||
tasg.id_group AS g
|
||||
FROM $agent_table ta
|
||||
LEFT JOIN $agent_seconsary_table tasg
|
||||
ON ta.id_agente = tasg.id_agent
|
||||
$joins_alerts
|
||||
WHERE ta.disabled = 0
|
||||
GROUP BY g
|
||||
) counters
|
||||
RIGHT JOIN tgrupo tg
|
||||
ON counters.g = tg.id_grupo
|
||||
GROUP BY tg.id_grupo"
|
||||
);
|
||||
|
||||
logger($pa_config, "No realtime group stats updated.", 6);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -31,8 +31,8 @@ use base 'Exporter';
|
|||
our @ISA = qw(Exporter);
|
||||
|
||||
# version: Defines actual version of Pandora Server for this module only
|
||||
my $pandora_version = "7.0NG.726";
|
||||
my $pandora_build = "180906";
|
||||
my $pandora_version = "7.0NG.727";
|
||||
my $pandora_build = "180917";
|
||||
our $VERSION = $pandora_version." ".$pandora_build;
|
||||
|
||||
our %EXPORT_TAGS = ( 'all' => [ qw() ] );
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
# Pandora FMS Server
|
||||
#
|
||||
%define name pandorafms_server
|
||||
%define version 7.0NG.726
|
||||
%define release 180906
|
||||
%define version 7.0NG.727
|
||||
%define release 180917
|
||||
|
||||
Summary: Pandora FMS Server
|
||||
Name: %{name}
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
# Pandora FMS Server
|
||||
#
|
||||
%define name pandorafms_server
|
||||
%define version 7.0NG.726
|
||||
%define release 180906
|
||||
%define version 7.0NG.727
|
||||
%define release 180917
|
||||
|
||||
Summary: Pandora FMS Server
|
||||
Name: %{name}
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
# This code is licensed under GPL 2.0 license.
|
||||
# **********************************************************************
|
||||
|
||||
PI_VERSION="7.0NG.726"
|
||||
PI_BUILD="180906"
|
||||
PI_VERSION="7.0NG.727"
|
||||
PI_BUILD="180917"
|
||||
|
||||
MODE=$1
|
||||
if [ $# -gt 1 ]; then
|
||||
|
|
|
@ -34,7 +34,7 @@ use PandoraFMS::Config;
|
|||
use PandoraFMS::DB;
|
||||
|
||||
# version: define current version
|
||||
my $version = "7.0NG.726 PS180906";
|
||||
my $version = "7.0NG.727 PS180917";
|
||||
|
||||
# Pandora server configuration
|
||||
my %conf;
|
||||
|
|
|
@ -36,7 +36,7 @@ use Encode::Locale;
|
|||
Encode::Locale::decode_argv;
|
||||
|
||||
# version: define current version
|
||||
my $version = "7.0NG.726 PS180906";
|
||||
my $version = "7.0NG.727 PS180917";
|
||||
|
||||
# save program name for logging
|
||||
my $progname = basename($0);
|
||||
|
|
|
@ -100,7 +100,8 @@ case "$1" in
|
|||
echo "$PANDORA_RB_PRODUCT_NAME Server is currently running on this machine with PID ($PANDORA_PID)."
|
||||
rc_exit # running start on a service already running
|
||||
fi
|
||||
|
||||
|
||||
export PERL_LWP_SSL_VERIFY_HOSTNAME=0
|
||||
$PANDORA_DAEMON $PANDORA_HOME -D
|
||||
sleep 1
|
||||
|
||||
|
|
Loading…
Reference in New Issue