Merge branch 'develop' into ent-2588-service-like-visual-console-status
This commit is contained in:
commit
2c88d33709
pandora_agents
pc
AIX
FreeBSD
HP-UX
Linux
NT4
SunOS
Win32
shellscript
aix
bsd-ipso
hp-ux
linux
mac_osx
openWRT
solaris
unix
AIX
DEBIAN
Darwin
FreeBSD
HP-UX
Linux
NT4
NetBSD
SunOS
pandora_agentpandora_agent.redhat.specpandora_agent.specpandora_agent_installerwin32
pandora_console
DEBIAN
attachment
extras
godmode
groups
servers
setup
users
include
ajax
class
Tree.class.phpTreeGroup.class.phpTreeGroupEdition.class.phpTreeModule.class.phpTreeModuleGroup.class.phpTreeOS.class.phpTreeTag.class.php
config_process.phpfunctions.phpfunctions_agents.phpfunctions_alerts.phpfunctions_api.phpfunctions_config.phpfunctions_forecast.phpfunctions_graph.phpfunctions_groups.phpfunctions_groupview.phpfunctions_html.phpfunctions_modules.phpfunctions_reporting.phpfunctions_reporting_html.phpfunctions_reports.phpgraphs
javascript
styles
mobile
operation
agentes
gis_maps
users
pandora_server
|
@ -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-180904
|
||||
Version: 7.0NG.727-180918
|
||||
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-180904"
|
||||
pandora_version="7.0NG.727-180918"
|
||||
|
||||
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 => '180904';
|
||||
use constant AGENT_VERSION => '7.0NG.727';
|
||||
use constant AGENT_BUILD => '180918';
|
||||
|
||||
# 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 180904
|
||||
%define version 7.0NG.727
|
||||
%define release 180918
|
||||
|
||||
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 180904
|
||||
%define version 7.0NG.727
|
||||
%define release 180918
|
||||
|
||||
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="180904"
|
||||
PI_VERSION="7.0NG.727"
|
||||
PI_BUILD="180918"
|
||||
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
|
||||
{180904}
|
||||
{180918}
|
||||
|
||||
ViewReadme
|
||||
{Yes}
|
||||
|
|
|
@ -32,7 +32,7 @@ using namespace Pandora;
|
|||
*/
|
||||
Pandora_Data::Pandora_Data (string value) {
|
||||
this->value = value;
|
||||
GetSystemTime (&(this->timestamp));
|
||||
GetLocalTime (&(this->timestamp));
|
||||
this->data_origin = pandora_data_unknown_source;
|
||||
}
|
||||
|
||||
|
@ -68,7 +68,7 @@ Pandora_Data::Pandora_Data (string value, SYSTEMTIME *system_time) {
|
|||
*/
|
||||
Pandora_Data::Pandora_Data (string value, string data_origin) {
|
||||
this->value = value;
|
||||
GetSystemTime (&(this->timestamp));
|
||||
GetLocalTime (&(this->timestamp));
|
||||
this->data_origin = data_origin;
|
||||
}
|
||||
|
||||
|
@ -99,7 +99,7 @@ Pandora_Data::Pandora_Data (string value, SYSTEMTIME *system_time, string data_o
|
|||
*/
|
||||
Pandora_Data::Pandora_Data () {
|
||||
this->value = "";
|
||||
GetSystemTime (&(this->timestamp));
|
||||
GetLocalTime (&(this->timestamp));
|
||||
this->data_origin = "";
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ using namespace Pandora;
|
|||
using namespace Pandora_Strutils;
|
||||
|
||||
#define PATH_SIZE _MAX_PATH+1
|
||||
#define PANDORA_VERSION ("7.0NG.726(Build 180904)")
|
||||
#define PANDORA_VERSION ("7.0NG.727(Build 180918)")
|
||||
|
||||
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 180904))"
|
||||
VALUE "ProductVersion", "(7.0NG.727(Build 180918))"
|
||||
VALUE "FileVersion", "1.0.0.0"
|
||||
END
|
||||
END
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
package: pandorafms-console
|
||||
Version: 7.0NG.726-180904
|
||||
Version: 7.0NG.727-180918
|
||||
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-180904"
|
||||
pandora_version="7.0NG.727-180918"
|
||||
|
||||
package_pear=0
|
||||
package_pandora=1
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
Order deny,allow
|
||||
Deny from All
|
|
@ -18,4 +18,32 @@ ALTER TABLE `tlayout_template_data` ADD COLUMN `linked_layout_status_as_service_
|
|||
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 `trecon_task` ADD COLUMN `snmp_version` varchar(5) NOT NULL default '1';
|
||||
ALTER TABLE `trecon_task` ADD COLUMN `snmp_auth_user` varchar(255) NOT NULL default '';
|
||||
ALTER TABLE `trecon_task` ADD COLUMN `snmp_auth_pass` varchar(255) NOT NULL default '';
|
||||
ALTER TABLE `trecon_task` ADD COLUMN `snmp_auth_method` varchar(25) NOT NULL default '';
|
||||
ALTER TABLE `trecon_task` ADD COLUMN `snmp_privacy_method` varchar(25) NOT NULL default '';
|
||||
ALTER TABLE `trecon_task` ADD COLUMN `snmp_privacy_pass` varchar(255) NOT NULL default '';
|
||||
ALTER TABLE `trecon_task` ADD COLUMN `snmp_security_level` varchar(25) NOT NULL default '';
|
||||
ALTER TABLE `tpolicy_modules_inventory` ADD COLUMN `custom_fields` MEDIUMBLOB NOT NULL;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `tlog_graph_models` (
|
||||
`id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`title` TEXT NOT NULL,
|
||||
`regexp` TEXT NOT NULL,
|
||||
`fields` TEXT NOT NULL,
|
||||
`average` tinyint(1) NOT NULL default '0',
|
||||
PRIMARY KEY(`id`)
|
||||
) ENGINE = InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
INSERT INTO tlog_graph_models VALUES (1, 'Apache log model',
|
||||
'^.*?\s+.*".*?\s(\/.*?)\?.*1.1"\s+(.*?)\s+(.*?)\s+',
|
||||
'pagina, html_err_code, _tiempo_', 1);
|
||||
|
||||
COMMIT;
|
|
@ -1768,3 +1768,33 @@ CREATE TABLE IF NOT EXISTS `tlayout_template_data` (
|
|||
PRIMARY KEY(`id`),
|
||||
FOREIGN KEY (`id_layout_template`) REFERENCES tlayout_template(`id`) ON DELETE CASCADE ON UPDATE CASCADE
|
||||
) ENGINE = InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
-- ---------------------------------------------------------------------
|
||||
-- Table `tlog_graph_models`
|
||||
-- ---------------------------------------------------------------------
|
||||
CREATE TABLE IF NOT EXISTS `tlog_graph_models` (
|
||||
`id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`title` TEXT NOT NULL,
|
||||
`regexp` TEXT NOT NULL,
|
||||
`fields` TEXT NOT NULL,
|
||||
`average` tinyint(1) NOT NULL default '0',
|
||||
PRIMARY KEY(`id`)
|
||||
) ENGINE = InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
INSERT INTO tlog_graph_models VALUES (1, 'Apache log model',
|
||||
'^.*?\s+.*".*?\s(\/.*?)\?.*1.1"\s+(.*?)\s+(.*?)\s+',
|
||||
'pagina, html_err_code, _tiempo_', 1);
|
||||
|
||||
-- -----------------------------------------------------
|
||||
-- Add column in table `treport`
|
||||
-- -----------------------------------------------------
|
||||
|
||||
ALTER TABLE `treport` ADD COLUMN `hidden` tinyint(1) NOT NULL DEFAULT 0;
|
||||
|
||||
ALTER TABLE `trecon_task` ADD COLUMN `snmp_version` varchar(5) NOT NULL default '1';
|
||||
ALTER TABLE `trecon_task` ADD COLUMN `snmp_auth_user` varchar(255) NOT NULL default '';
|
||||
ALTER TABLE `trecon_task` ADD COLUMN `snmp_auth_pass` varchar(255) NOT NULL default '';
|
||||
ALTER TABLE `trecon_task` ADD COLUMN `snmp_auth_method` varchar(25) NOT NULL default '';
|
||||
ALTER TABLE `trecon_task` ADD COLUMN `snmp_privacy_method` varchar(25) NOT NULL default '';
|
||||
ALTER TABLE `trecon_task` ADD COLUMN `snmp_privacy_pass` varchar(255) NOT NULL default '';
|
||||
ALTER TABLE `trecon_task` ADD COLUMN `snmp_security_level` varchar(25) NOT NULL default '';
|
||||
|
|
|
@ -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,36 +205,68 @@ 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");
|
||||
return;
|
||||
}
|
||||
|
||||
$sec = defined('METACONSOLE') ? 'advanced' : 'gagente';
|
||||
$url_tree = "index.php?sec=$sec&sec2=godmode/groups/group_list&tab=tree";
|
||||
$url_groups = "index.php?sec=$sec&sec2=godmode/groups/group_list&tab=groups";
|
||||
$buttons['tree'] = array(
|
||||
'active' => false,
|
||||
'text' => "<a href='$url_tree'>" .
|
||||
html_print_image(
|
||||
"images/gm_massive_operations.png",
|
||||
true,
|
||||
array (
|
||||
"title" => __('Tree Group view')
|
||||
)
|
||||
) . "</a>"
|
||||
);
|
||||
|
||||
$buttons['groups'] = array(
|
||||
'active' => false,
|
||||
'text' => "<a href='$url_groups'>" .
|
||||
html_print_image(
|
||||
"images/group.png",
|
||||
true,
|
||||
array(
|
||||
"title" => __('Group view')
|
||||
)
|
||||
) . "</a>"
|
||||
);
|
||||
|
||||
$tab = (string)get_parameter('tab', 'groups');
|
||||
|
||||
// Marks correct tab
|
||||
switch ($tab) {
|
||||
case 'tree':
|
||||
$buttons['tree']['active'] = true;
|
||||
break;
|
||||
case 'groups':
|
||||
default:
|
||||
$buttons['groups']['active'] = true;
|
||||
break;
|
||||
}
|
||||
|
||||
// Header
|
||||
if (defined('METACONSOLE')) {
|
||||
|
||||
agents_meta_print_header();
|
||||
$sec = 'advanced';
|
||||
|
||||
echo '<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, $buttons
|
||||
);
|
||||
}
|
||||
else {
|
||||
|
||||
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');
|
||||
|
@ -258,7 +287,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 +304,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 +338,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 +361,7 @@ if ($update_group) {
|
|||
else {
|
||||
$result = false;
|
||||
}
|
||||
|
||||
|
||||
if ($result !== false) {
|
||||
ui_print_success_message(__('Group successfully updated'));
|
||||
}
|
||||
|
@ -344,19 +373,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 +393,272 @@ 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);
|
||||
if($tab == 'tree'){
|
||||
echo html_print_image('images/spinner.gif', true,
|
||||
array('class' => "loading_tree",
|
||||
'style' => 'display: none;'));
|
||||
echo "<div id='tree-controller-recipient'></div>";
|
||||
|
||||
}
|
||||
|
||||
$table = new StdClass();
|
||||
$table->width = '100%';
|
||||
|
||||
$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]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!empty($groups)) {
|
||||
$table->class = "databox data";
|
||||
$table->head = array ();
|
||||
$table->head[0] = __('Name');
|
||||
$table->head[1] = __('ID');
|
||||
$table->head[2] = __('Icon');
|
||||
$table->head[3] = __('Alerts');
|
||||
$table->head[4] = __('Description');
|
||||
$table->head[5] = __('Actions');
|
||||
$table->align = array ();
|
||||
$table->align[2] = 'left';
|
||||
$table->align[5] = 'left';
|
||||
$table->size[4] = '30%';
|
||||
$table->size[5] = '10%';
|
||||
$table->data = array ();
|
||||
|
||||
else{
|
||||
$acl='';
|
||||
$search_name = '';
|
||||
$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;
|
||||
}
|
||||
|
||||
$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);
|
||||
$search = (string)get_parameter('search', '');
|
||||
$block_size = $config['block_size'];
|
||||
|
||||
if(!empty($search)){
|
||||
$search_name = "AND t.nombre LIKE '%$search%'";
|
||||
}
|
||||
|
||||
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') ) );
|
||||
|
||||
$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] = __('ID');
|
||||
$table->head[1] = __('Name');
|
||||
$table->head[2] = __('Icon');
|
||||
$table->head[3] = __('Alerts');
|
||||
$table->head[4] = __('Parent');
|
||||
$table->head[5] = __('Description');
|
||||
$table->head[6] = __('Actions');
|
||||
$table->align = array ();
|
||||
$table->align[0] = 'left';
|
||||
$table->align[2] = 'left';
|
||||
$table->align[6] = 'left';
|
||||
$table->size[0] = '3%';
|
||||
$table->size[5] = '30%';
|
||||
$table->size[6] = '5%';
|
||||
$table->data = array ();
|
||||
|
||||
foreach ($groups as $key => $group) {
|
||||
$url = "index.php?sec=gagente&sec2=godmode/groups/configure_group&id_group=".$group['id_grupo'];
|
||||
$url_delete = "index.php?sec=gagente&sec2=godmode/groups/group_list&delete_group=1&id_group=" . $group['id_grupo'];
|
||||
$table->data[$key][0] = $group['id_grupo'];
|
||||
$table->data[$key][1] = "<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;
|
||||
}
|
||||
|
||||
$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 ui_pagination(
|
||||
$groups_count, false,
|
||||
$offset, $block_size,
|
||||
true, 'offset', false
|
||||
);
|
||||
html_print_table ($table);
|
||||
echo ui_pagination(
|
||||
$groups_count, false,
|
||||
$offset, $block_size,
|
||||
true, 'offset', true
|
||||
);
|
||||
}
|
||||
else {
|
||||
ui_print_info_message ( array('no_close'=>true, 'message'=> __('There are no defined groups') ) );
|
||||
}
|
||||
|
||||
echo $pagination;
|
||||
|
||||
html_print_table ($table);
|
||||
|
||||
echo $pagination;
|
||||
}
|
||||
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>';
|
||||
}
|
||||
|
||||
ui_require_javascript_file("TreeController", "include/javascript/tree/");
|
||||
|
||||
enterprise_hook('close_meta_frame');
|
||||
$tab = "group_edition";
|
||||
|
||||
?>
|
||||
|
||||
<?php if (!is_metaconsole()){ ?>
|
||||
<script type="text/javascript" src="include/javascript/fixed-bottom-box.js"></script>
|
||||
<?php }else{ ?>
|
||||
<script type="text/javascript" src="../../include/javascript/fixed-bottom-box.js"></script>
|
||||
<?php } ?>
|
||||
|
||||
<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', '');
|
||||
}
|
||||
}
|
||||
var treeController = TreeController.getController();
|
||||
|
||||
if (typeof treeController.recipient != 'undefined' && treeController.recipient.length > 0)
|
||||
treeController.recipient.empty();
|
||||
|
||||
$(".loading_tree").show();
|
||||
|
||||
var parameters = {};
|
||||
parameters['page'] = "include/ajax/tree.ajax";
|
||||
parameters['getChildren'] = 1;
|
||||
parameters['type'] = "<?php echo $tab; ?>";
|
||||
parameters['filter'] = {};
|
||||
parameters['filter']['searchGroup'] = '';
|
||||
parameters['filter']['searchAgent'] = '';
|
||||
parameters['filter']['statusAgent'] = '';
|
||||
parameters['filter']['searchModule'] = '';
|
||||
parameters['filter']['statusModule'] = '';
|
||||
parameters['filter']['groupID'] = '';
|
||||
parameters['filter']['tagID'] = '';
|
||||
parameters['filter']['searchHirearchy'] = 1;
|
||||
parameters['filter']['show_not_init_agents'] = 1;
|
||||
parameters['filter']['show_not_init_modules'] = 1;
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",
|
||||
data: parameters,
|
||||
success: function(data) {
|
||||
if (data.success) {
|
||||
$(".loading_tree").hide();
|
||||
|
||||
treeController.init({
|
||||
recipient: $("div#tree-controller-recipient"),
|
||||
//detailRecipient: $.fixedBottomBox({ width: 400, height: window.innerHeight * 0.9 }),
|
||||
page: parameters['page'],
|
||||
emptyMessage: "<?php echo __('No data found'); ?>",
|
||||
foundMessage: "<?php echo __('Found groups'); ?>",
|
||||
tree: data.tree,
|
||||
baseURL: "<?php echo ui_get_full_url(false, false, false, is_metaconsole()); ?>",
|
||||
ajaxURL: "<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",
|
||||
filter: parameters['filter'],
|
||||
counterTitles: {
|
||||
total: {
|
||||
agents: "<?php echo __('Total agents'); ?>",
|
||||
modules: "<?php echo __('Total modules'); ?>",
|
||||
none: "<?php echo __('Total'); ?>"
|
||||
},
|
||||
alerts: {
|
||||
agents: "<?php echo __('Fired alerts'); ?>",
|
||||
modules: "<?php echo __('Fired alerts'); ?>",
|
||||
none: "<?php echo __('Fired alerts'); ?>"
|
||||
},
|
||||
critical: {
|
||||
agents: "<?php echo __('Critical agents'); ?>",
|
||||
modules: "<?php echo __('Critical modules'); ?>",
|
||||
none: "<?php echo __('Critical'); ?>"
|
||||
},
|
||||
warning: {
|
||||
agents: "<?php echo __('Warning agents'); ?>",
|
||||
modules: "<?php echo __('Warning modules'); ?>",
|
||||
none: "<?php echo __('Warning'); ?>"
|
||||
},
|
||||
unknown: {
|
||||
agents: "<?php echo __('Unknown agents'); ?>",
|
||||
modules: "<?php echo __('Unknown modules'); ?>",
|
||||
none: "<?php echo __('Unknown'); ?>"
|
||||
},
|
||||
not_init: {
|
||||
agents: "<?php echo __('Not init agents'); ?>",
|
||||
modules: "<?php echo __('Not init modules'); ?>",
|
||||
none: "<?php echo __('Not init'); ?>"
|
||||
},
|
||||
ok: {
|
||||
agents: "<?php echo __('Normal agents'); ?>",
|
||||
modules: "<?php echo __('Normal modules'); ?>",
|
||||
none: "<?php echo __('Normal'); ?>"
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
dataType: "json"
|
||||
});
|
||||
</script>
|
||||
|
|
|
@ -97,7 +97,15 @@ if ((isset ($_GET["update"])) OR ((isset ($_GET["create"])))) {
|
|||
$field2 = get_parameter ("_field2_", "");
|
||||
$field3 = get_parameter ("_field3_", "");
|
||||
$field4 = get_parameter ("_field4_", "");
|
||||
|
||||
$snmp_version = get_parameter_post ("snmp_version");
|
||||
$snmp3_auth_user = get_parameter_post ("snmp_auth_user");
|
||||
$snmp3_auth_pass = get_parameter_post ("snmp_auth_pass");
|
||||
$snmp3_privacy_method = get_parameter_post ("snmp_privacy_method");
|
||||
$snmp3_privacy_pass = get_parameter_post ("snmp_privacy_pass");
|
||||
$snmp3_auth_method = get_parameter_post ("snmp_auth_method");
|
||||
$snmp3_security_level = get_parameter_post ("snmp_security_level");
|
||||
|
||||
|
||||
if ($mode == "network_sweep")
|
||||
$id_recon_script = 0;
|
||||
else
|
||||
|
@ -154,8 +162,30 @@ if (isset($_GET["update"])) {
|
|||
'macros' => $macros,
|
||||
'alias_as_name' => $alias_as_name,
|
||||
'snmp_enabled' => $snmp_enabled,
|
||||
'vlan_enabled' => $vlan_enabled
|
||||
'vlan_enabled' => $vlan_enabled,
|
||||
'snmp_version' => $snmp_version
|
||||
);
|
||||
|
||||
$values_v3 = array(
|
||||
'snmp_auth_user' => $snmp3_auth_user,
|
||||
'snmp_auth_pass' => $snmp3_auth_pass,
|
||||
'snmp_privacy_method' => $snmp3_privacy_method,
|
||||
'snmp_privacy_pass' => $snmp3_privacy_pass,
|
||||
'snmp_auth_method' => $snmp3_auth_method,
|
||||
'snmp_security_level' => $snmp3_security_level
|
||||
);
|
||||
if($values['snmp_version'] == '1' || $values['snmp_version'] == '2' || $values['snmp_version'] == '2c'){
|
||||
$values_v3 = array(
|
||||
'snmp_auth_user' => '',
|
||||
'snmp_auth_pass' => '',
|
||||
'snmp_privacy_method' => '',
|
||||
'snmp_privacy_pass' => '',
|
||||
'snmp_auth_method' => '',
|
||||
'snmp_security_level' => ''
|
||||
);
|
||||
}
|
||||
|
||||
$values = array_merge($values, $values_v3);
|
||||
|
||||
$where = array('id_rt' => $id);
|
||||
|
||||
|
@ -217,13 +247,37 @@ if (isset($_GET["create"])) {
|
|||
'macros' => $macros,
|
||||
'alias_as_name' => $alias_as_name,
|
||||
'snmp_enabled' => $snmp_enabled,
|
||||
'vlan_enabled' => $vlan_enabled
|
||||
'vlan_enabled' => $vlan_enabled,
|
||||
'snmp_version' => $snmp_version
|
||||
);
|
||||
|
||||
$values_v3 = array(
|
||||
'snmp_auth_user' => $snmp3_auth_user,
|
||||
'snmp_auth_pass' => $snmp3_auth_pass,
|
||||
'snmp_privacy_method' => $snmp3_privacy_method,
|
||||
'snmp_privacy_pass' => $snmp3_privacy_pass,
|
||||
'snmp_auth_method' => $snmp3_auth_method,
|
||||
'snmp_security_level' => $snmp3_security_level
|
||||
);
|
||||
if($values['snmp_version'] == '1' || $values['snmp_version'] == '2' || $values['snmp_version'] == '2c'){
|
||||
$values_v3 = array(
|
||||
'snmp_auth_user' => '',
|
||||
'snmp_auth_pass' => '',
|
||||
'snmp_privacy_method' => '',
|
||||
'snmp_privacy_pass' => '',
|
||||
'snmp_auth_method' => '',
|
||||
'snmp_security_level' => ''
|
||||
);
|
||||
}
|
||||
if ($values['snmp_version'] == '3'){
|
||||
$values['vlan_enabled'] = 0;
|
||||
}
|
||||
|
||||
$values = array_merge($values, $values_v3);
|
||||
|
||||
$name = io_safe_output($name);
|
||||
$name = trim($name, ' ');
|
||||
$name = io_safe_input($name);
|
||||
|
||||
$reason = "";
|
||||
|
||||
if ($name != "") {
|
||||
|
@ -293,7 +347,7 @@ else {
|
|||
$color=1;
|
||||
if ($result !== false) {
|
||||
$table = new StdClass();
|
||||
$table->head = array (__('Name'), __('Network'), __('Mode'), __('Group'), __('Incident'), __('OS'), __('Interval'), __('Ports'), __('Action'));
|
||||
$table->head = array (__('Name'), __('Network'), __('Mode'), __('Group'), __('SNMP Version'), __('Incident'), __('OS'), __('Interval'), __('Ports'), __('Action'));
|
||||
$table->align = array ("left","left","left","left","left","left","left","left");
|
||||
$table->width = "100%";
|
||||
$table->cellpadding = 4;
|
||||
|
@ -336,48 +390,64 @@ if ($result !== false) {
|
|||
$data[3] = "-";
|
||||
}
|
||||
|
||||
//SNMP VERSION
|
||||
if ($row["snmp_version"] == '1'){
|
||||
$data[4] = "v. 1";
|
||||
}
|
||||
elseif($row["snmp_version"] == '2'){
|
||||
$data[4] = "v. 2";
|
||||
}
|
||||
elseif($row["snmp_version"] == '2c'){
|
||||
$data[4] = "v. 2c";
|
||||
}
|
||||
elseif($row["snmp_version"] == '3'){
|
||||
$data[4] = "v. 3";
|
||||
}
|
||||
|
||||
|
||||
|
||||
// INCIDENT
|
||||
$data[4] = (($row["create_incident"] == 1) ? __('Yes') : __('No'));
|
||||
$data[5] = (($row["create_incident"] == 1) ? __('Yes') : __('No'));
|
||||
|
||||
// OS
|
||||
if ($row["id_recon_script"] == 0) {
|
||||
$data[5] =(($row["id_os"] > 0) ? ui_print_os_icon ($row["id_os"], false, true) : __('Any'));
|
||||
$data[6] =(($row["id_os"] > 0) ? ui_print_os_icon ($row["id_os"], false, true) : __('Any'));
|
||||
}
|
||||
else {
|
||||
$data[5] = "-";
|
||||
$data[6] = "-";
|
||||
}
|
||||
// INTERVAL
|
||||
if ($row["interval_sweep"]==0)
|
||||
$data[6] = __("Manual");
|
||||
$data[7] = __("Manual");
|
||||
else
|
||||
$data[6] =human_time_description_raw($row["interval_sweep"]);
|
||||
$data[7] =human_time_description_raw($row["interval_sweep"]);
|
||||
|
||||
// PORTS
|
||||
if ($row["id_recon_script"] == 0) {
|
||||
$data[7] = substr($row["recon_ports"],0,15);
|
||||
$data[8] = substr($row["recon_ports"],0,15);
|
||||
}
|
||||
else {
|
||||
$data[7] = "-";
|
||||
$data[8] = "-";
|
||||
}
|
||||
|
||||
// ACTION
|
||||
$task_group = $row["id_group"];
|
||||
|
||||
if (in_array($task_group, $user_groups_w)){
|
||||
$data[8] = '<a href="index.php?sec=estado&sec2=operation/servers/recon_view">' . html_print_image("images/eye.png", true) . '</a>';
|
||||
$data[8] .= '<a href="index.php?sec=gservers&sec2=godmode/servers/manage_recontask&delete='.$row["id_rt"].'">' . html_print_image("images/cross.png", true, array("border" => '0')) . '</a>';
|
||||
$data[9] = '<a href="index.php?sec=estado&sec2=operation/servers/recon_view">' . html_print_image("images/eye.png", true) . '</a>';
|
||||
$data[9] .= '<a href="index.php?sec=gservers&sec2=godmode/servers/manage_recontask&delete='.$row["id_rt"].'">' . html_print_image("images/cross.png", true, array("border" => '0')) . '</a>';
|
||||
if($mode_name != 'IPAM Recon'){
|
||||
$data[8] .= '<a href="index.php?sec=gservers&sec2=godmode/servers/manage_recontask_form&update='.$row["id_rt"].'">' .html_print_image("images/config.png", true) . '</a>';
|
||||
$data[9] .= '<a href="index.php?sec=gservers&sec2=godmode/servers/manage_recontask_form&update='.$row["id_rt"].'">' .html_print_image("images/config.png", true) . '</a>';
|
||||
} else {
|
||||
$sql_ipam = 'select id from tipam_network where id_recon_task =' . $row["id_rt"];
|
||||
$id_recon_ipam = db_get_sql($sql_ipam);
|
||||
$data[8] .= '<a href="index.php?sec=godmode/extensions&sec2=enterprise/extensions/ipam&action=edit&id=' . $id_recon_ipam . '">' . html_print_image("images/config.png", true) . '</a>';
|
||||
$data[9] .= '<a href="index.php?sec=godmode/extensions&sec2=enterprise/extensions/ipam&action=edit&id=' . $id_recon_ipam . '">' . html_print_image("images/config.png", true) . '</a>';
|
||||
}
|
||||
if($row["disabled"] == 0) {
|
||||
$data[8] .= '<a href="index.php?sec=gservers&sec2=godmode/servers/manage_recontask&id='.$row["id_rt"].'&disabled=1">' .html_print_image("images/lightbulb.png", true) . '</a>';
|
||||
$data[9] .= '<a href="index.php?sec=gservers&sec2=godmode/servers/manage_recontask&id='.$row["id_rt"].'&disabled=1">' .html_print_image("images/lightbulb.png", true) . '</a>';
|
||||
}
|
||||
else {
|
||||
$data[8] .= '<a href="index.php?sec=gservers&sec2=godmode/servers/manage_recontask&id='.$row["id_rt"].'&disabled=0">' .html_print_image("images/lightbulb_off.png", true) . '</a>';
|
||||
$data[9] .= '<a href="index.php?sec=gservers&sec2=godmode/servers/manage_recontask&id='.$row["id_rt"].'&disabled=0">' .html_print_image("images/lightbulb_off.png", true) . '</a>';
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -108,6 +108,13 @@ if (isset($_GET["update"]) || (isset($_GET["upd"]))) {
|
|||
$id_os = $row["id_os"];
|
||||
$recon_ports = $row["recon_ports"];
|
||||
$snmp_community = $row["snmp_community"];
|
||||
$snmp_version = $row["snmp_version"];
|
||||
$snmp3_auth_user = $row["snmp_auth_user"];
|
||||
$snmp3_auth_pass = $row["snmp_auth_pass"];
|
||||
$snmp3_privacy_method = $row["snmp_privacy_method"];
|
||||
$snmp3_privacy_pass = $row["snmp_privacy_pass"];
|
||||
$snmp3_auth_method = $row["snmp_auth_method"];
|
||||
$snmp3_security_level = $row["snmp_security_level"];
|
||||
$id_recon_script = $row["id_recon_script"];
|
||||
$field1 = $row["field1"];
|
||||
$field2 = $row["field2"];
|
||||
|
@ -156,6 +163,13 @@ elseif (isset($_GET["create"]) || isset($_GET["crt"])) {
|
|||
$id_group = 0;
|
||||
$create_incident = 1;
|
||||
$snmp_community = "public";
|
||||
$snmp3_auth_user = '';
|
||||
$snmp3_auth_pass = '';
|
||||
$snmp_version = 1;
|
||||
$snmp3_privacy_method = '';
|
||||
$snmp3_privacy_pass = '';
|
||||
$snmp3_auth_method = '';
|
||||
$snmp3_security_level = '';
|
||||
$id_network_profile = 0;
|
||||
$id_os = -1; // Any
|
||||
$recon_ports = ""; // Any
|
||||
|
@ -212,6 +226,13 @@ $table->rowclass[20] = "network_sweep";
|
|||
$table->rowclass[21] = "network_sweep";
|
||||
$table->rowclass[22] = "network_sweep";
|
||||
$table->rowclass[23] = "network_sweep";
|
||||
$table->rowclass[24] = "network_sweep";
|
||||
$table->rowclass[25] = "network_sweep recon_v3";
|
||||
$table->rowclass[26] = "network_sweep recon_v3";
|
||||
$table->rowclass[27] = "network_sweep recon_v3";
|
||||
$table->rowclass[28] = "network_sweep recon_v3";
|
||||
$table->rowclass[29] = "network_sweep recon_v3";
|
||||
$table->rowclass[30] = "network_sweep recon_v3";
|
||||
|
||||
$table->rowclass[6] = "recon_script";
|
||||
$table->rowclass[13] = "recon_script";
|
||||
|
@ -327,6 +348,34 @@ $table->data[12][0] = "<b>".__('SNMP Default community');
|
|||
$table->data[12][0] .= ui_print_help_tip (__('You can specify several values, separated by commas, for example: public,mysecret,1234'), true);
|
||||
$table->data[12][1] = html_print_input_text ('snmp_community', $snmp_community, '', 35, 0, true);
|
||||
|
||||
//SNMP version
|
||||
|
||||
$snmp_versions['1'] = 'v. 1';
|
||||
$snmp_versions['2'] = 'v. 2';
|
||||
$snmp_versions['2c'] = 'v. 2c';
|
||||
$snmp_versions['3'] = 'v. 3';
|
||||
$table->data[24][0] ="<b>". _('SNMP version');
|
||||
$table->data[24][1] = html_print_select ($snmp_versions, 'snmp_version', $snmp_version, '', '', 0, true);
|
||||
|
||||
$table->data[25][0] ="<b>".__('Auth user');
|
||||
$table->data[25][1] = html_print_input_text ('snmp_auth_user', $snmp3_auth_user, '', 15, 60, true, '',
|
||||
false, '', '');
|
||||
$table->data[26][0] ="<b>". __('Auth password') . ui_print_help_tip(__("The pass length must be eight character minimum."), true);
|
||||
$table->data[26][1] = html_print_input_password ('snmp_auth_pass', $snmp3_auth_pass, '', 15, 60, true, '',
|
||||
false, '');
|
||||
$table->data[26][1] .= html_print_input_hidden_extended('active_snmp_v3', 0, 'active_snmp_v3_mmen', true);
|
||||
|
||||
$table->data[27][0] ="<b>". __('Privacy method');
|
||||
$table->data[27][1] = html_print_select(array('DES' => __('DES'), 'AES' => __('AES')), 'snmp_privacy_method', $snmp3_privacy_method, '', '', '', true, false, false, '', '');
|
||||
$table->data[28][0] ="<b>". __('Privacy pass') . ui_print_help_tip(__("The pass length must be eight character minimum."), true);
|
||||
$table->data[28][1] = html_print_input_password ('snmp_privacy_pass', $snmp3_privacy_pass, '', 15, 60, true, '',
|
||||
false, '');
|
||||
$table->data[29][0] ="<b>". __('Auth method');
|
||||
$table->data[29][1] = html_print_select(array('MD5' => __('MD5'), 'SHA' => __('SHA')), 'snmp_auth_method', $snmp3_auth_method, '', '', '', true, false, false, '', '');
|
||||
$table->data[30][0] ="<b>". __('Security level');
|
||||
$table->data[30][1] = html_print_select(array('noAuthNoPriv' => __('Not auth and not privacy method'),
|
||||
'authNoPriv' => __('Auth and not privacy method'), 'authPriv' => __('Auth and privacy method')), 'snmp_security_level', $snmp3_security_level, '', '', '', true, false, false, '', '');
|
||||
|
||||
// Explanation
|
||||
$explanation = db_get_value('description', 'trecon_script', 'id_recon_script', $id_recon_script);
|
||||
|
||||
|
@ -461,9 +510,24 @@ $('select#id_recon_script').change(function() {
|
|||
get_explanation_recon_script($(this).val());
|
||||
});
|
||||
|
||||
$('select#snmp_version').change(function () {
|
||||
if (this.value == "3") {
|
||||
$(".recon_v3").show();
|
||||
$("input[name=active_snmp_v3]").val(1);
|
||||
$("input[name=snmp_community]").attr("disabled", true);
|
||||
$("input[name=vlan_enabled]").removeAttr("checked");
|
||||
$("input[name=vlan_enabled]").attr("disabled", true);
|
||||
}
|
||||
else {
|
||||
$(".recon_v3").hide();
|
||||
$("input[name=active_snmp_v3]").val(0);
|
||||
$("input[name=snmp_community]").removeAttr('disabled');
|
||||
$("input[name=vlan_enabled]").removeAttr('disabled');
|
||||
}
|
||||
});
|
||||
|
||||
$('select#mode').change(function() {
|
||||
var type = $(this).val();
|
||||
|
||||
if (type == 'recon_script') {
|
||||
$(".recon_script").show();
|
||||
$(".network_sweep").hide();
|
||||
|
@ -474,6 +538,7 @@ $('select#mode').change(function() {
|
|||
$(".recon_script").hide();
|
||||
$(".network_sweep").show();
|
||||
$('.macro_field').remove();
|
||||
$('select#snmp_version').trigger('change');
|
||||
}
|
||||
}).change();
|
||||
|
||||
|
@ -543,5 +608,5 @@ function get_explanation_recon_script (id) {
|
|||
});
|
||||
taskManager.addTask(xhr);
|
||||
}
|
||||
/* ]]> */
|
||||
|
||||
</script>
|
||||
|
|
|
@ -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"');
|
||||
}
|
||||
|
|
|
@ -38,7 +38,14 @@ if (is_ajax ()) {
|
|||
}
|
||||
|
||||
require_once($config['homedir'] . "/include/class/Tree.class.php");
|
||||
enterprise_include_once("include/class/Tree.class.php");
|
||||
require_once($config['homedir'] . "/include/class/TreeOS.class.php");
|
||||
require_once($config['homedir'] . "/include/class/TreeModuleGroup.class.php");
|
||||
require_once($config['homedir'] . "/include/class/TreeModule.class.php");
|
||||
require_once($config['homedir'] . "/include/class/TreeTag.class.php");
|
||||
require_once($config['homedir'] . "/include/class/TreeGroup.class.php");
|
||||
require_once($config['homedir'] . "/include/class/TreeGroupEdition.class.php");
|
||||
enterprise_include_once("include/class/TreePolicies.class.php");
|
||||
enterprise_include_once("include/class/TreeGroupMeta.class.php");
|
||||
require_once($config['homedir'] . "/include/functions_reporting.php");
|
||||
require_once($config['homedir'] . "/include/functions_os.php");
|
||||
|
||||
|
@ -67,17 +74,45 @@ if (is_ajax ()) {
|
|||
'tagID' => 0,
|
||||
);
|
||||
$filter = get_parameter('filter', $default_filters);
|
||||
|
||||
|
||||
$agent_a = check_acl ($config['id_user'], 0, "AR");
|
||||
$agent_w = check_acl ($config['id_user'], 0, "AW");
|
||||
$access = ($agent_a == true) ? 'AR' : (($agent_w == true) ? 'AW' : 'AR');
|
||||
if (class_exists('TreeEnterprise')) {
|
||||
$tree = new TreeEnterprise($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access);
|
||||
$switch_type = !empty($rootType) ? $rootType : $type;
|
||||
switch ($switch_type) {
|
||||
case 'os':
|
||||
$tree = new TreeOS($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access);
|
||||
break;
|
||||
case 'module_group':
|
||||
$tree = new TreeModuleGroup($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access);
|
||||
break;
|
||||
case 'module':
|
||||
$tree = new TreeModule($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access);
|
||||
break;
|
||||
case 'tag':
|
||||
$tree = new TreeTag($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access);
|
||||
break;
|
||||
case 'group':
|
||||
if(is_metaconsole()){
|
||||
if (!class_exists('TreeGroupMeta')) break;
|
||||
$tree = new TreeGroupMeta($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access);
|
||||
}
|
||||
else{
|
||||
$tree = new TreeGroup($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access);
|
||||
}
|
||||
break;
|
||||
case 'policies':
|
||||
if (!class_exists('TreePolicies')) break;
|
||||
$tree = new TreePolicies($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access);
|
||||
break;
|
||||
case 'group_edition':
|
||||
$tree = new TreeGroupEdition($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access);
|
||||
break;
|
||||
default:
|
||||
// FIXME. No error handler
|
||||
return;
|
||||
}
|
||||
else {
|
||||
$tree = new Tree($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access);
|
||||
}
|
||||
|
||||
|
||||
$tree->setFilter($filter);
|
||||
ob_clean();
|
||||
echo json_encode(array('success' => 1, 'tree' => $tree->getArray()));
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,449 @@
|
|||
<?php
|
||||
//Pandora FMS- http://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2018 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 Lesser General Public License
|
||||
// as published by the Free Software Foundation; 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.
|
||||
|
||||
global $config;
|
||||
|
||||
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;
|
||||
|
||||
parent::__construct($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access);
|
||||
|
||||
$this->L1fieldName = "id_group";
|
||||
$this->L1extraFields = array(
|
||||
"tg.nombre AS `name`",
|
||||
"tg.icon",
|
||||
"tg.id_grupo AS gid"
|
||||
);
|
||||
|
||||
$this->L2conditionInside = "AND (
|
||||
ta.id_grupo = " . $this->id . "
|
||||
OR tasg.id_group = " . $this->id . "
|
||||
)";
|
||||
}
|
||||
|
||||
public function setPropagateCounters($value) {
|
||||
$this->propagateCounters = (bool)$value;
|
||||
}
|
||||
|
||||
protected function getData() {
|
||||
if ($this->id == -1) {
|
||||
$this->getFirstLevel();
|
||||
} elseif ($this->type == 'group') {
|
||||
$this->getSecondLevel();
|
||||
} elseif ($this->type == 'agent') {
|
||||
$this->getThirdLevel();
|
||||
}
|
||||
}
|
||||
|
||||
protected function getGroupSearchFilter() {
|
||||
return "";
|
||||
}
|
||||
|
||||
protected function getFirstLevel() {
|
||||
$processed_items = $this->getProcessedGroups();
|
||||
|
||||
if (!empty($processed_items)) {
|
||||
// Filter by group name. This should be done after rerieving the items cause we need the possible items descendants
|
||||
if (!empty($this->filter['searchGroup'])) {
|
||||
// Save the groups which intersect with the user groups
|
||||
$groups = db_get_all_rows_filter('tgrupo', array('nombre' => '%' . $this->filter['searchGroup'] . '%'));
|
||||
if ($groups == false) $groups = array();
|
||||
$userGroupsACL = $this->userGroupsACL;
|
||||
$ids_hash = array_reduce($groups, function ($userGroups, $group) use ($userGroupsACL) {
|
||||
$group_id = $group['id_grupo'];
|
||||
if (isset($userGroupsACL[$group_id])) {
|
||||
$userGroups[$group_id] = $userGroupsACL[$group_id];
|
||||
}
|
||||
|
||||
return $userGroups;
|
||||
}, array());
|
||||
|
||||
$result = self::extractGroupsWithIDs($processed_items, $ids_hash);
|
||||
|
||||
$processed_items = ($result === false) ? array() : $result;
|
||||
}
|
||||
|
||||
// groupID filter. To access the view from tactical views f.e.
|
||||
if (!empty($this->filter['groupID'])) {
|
||||
$result = self::extractItemWithID($processed_items, $this->filter['groupID'], "group", $this->strictACL);
|
||||
|
||||
$processed_items = ($result === false) ? array() : array($result);
|
||||
}
|
||||
}
|
||||
|
||||
$this->tree = $processed_items;
|
||||
}
|
||||
|
||||
protected function getProcessedGroups () {
|
||||
$processed_groups = array();
|
||||
// Index and process the groups
|
||||
$groups = $this->getGroupCounters();
|
||||
|
||||
// If user have not permissions in parent, set parent node to 0 (all)
|
||||
// Avoid to do foreach for admins
|
||||
if (!users_can_manage_group_all("AR")) {
|
||||
foreach ($groups as $id => $group) {
|
||||
if (!isset($this->userGroups[$groups[$id]['parent']])) {
|
||||
$groups[$id]['parent'] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Build the group hierarchy
|
||||
foreach ($groups as $id => $group) {
|
||||
if (isset($groups[$id]['parent']) && ($groups[$id]['parent'] != 0)) {
|
||||
$parent = $groups[$id]['parent'];
|
||||
// Parent exists
|
||||
if (!isset($groups[$parent]['children'])) {
|
||||
$groups[$parent]['children'] = array();
|
||||
}
|
||||
// Store a reference to the group into the parent
|
||||
$groups[$parent]['children'][] = &$groups[$id];
|
||||
// This group was introduced into a parent
|
||||
$groups[$id]['have_parent'] = true;
|
||||
}
|
||||
}
|
||||
// Sort the children groups
|
||||
foreach ($groups as $id => $group) {
|
||||
if (isset($groups[$id]['children'])) {
|
||||
usort($groups[$id]['children'], array("Tree", "cmpSortNames"));
|
||||
}
|
||||
}
|
||||
//Filter groups and eliminates the reference to children groups out of her parent
|
||||
$groups = array_filter($groups, function ($group) {
|
||||
return !$group['have_parent'];
|
||||
});
|
||||
// Propagate child counters to her parents
|
||||
if ($this->propagateCounters) {
|
||||
TreeGroup::processCounters($groups);
|
||||
// Filter groups and eliminates the reference to empty groups
|
||||
$groups = TreeGroup::deleteEmptyGroups($groups);
|
||||
} else {
|
||||
$groups = TreeGroup::deleteEmptyGroupsNotPropagate($groups);
|
||||
}
|
||||
|
||||
usort($groups, array("Tree", "cmpSortNames"));
|
||||
return $groups;
|
||||
}
|
||||
|
||||
protected function getGroupCounters() {
|
||||
$fields = $this->getFirstLevelFields();
|
||||
$inside_fields = $this->getFirstLevelFieldsInside();
|
||||
|
||||
$group_acl = "";
|
||||
$secondary_group_acl = "";
|
||||
if (!users_can_manage_group_all("AR")) {
|
||||
$user_groups_str = implode(",", $this->userGroupsArray);
|
||||
$group_acl = " AND ta.id_grupo IN ($user_groups_str)";
|
||||
$secondary_group_acl = " AND tasg.id_group IN ($user_groups_str)";
|
||||
}
|
||||
$agent_search_filter = $this->getAgentSearchFilter();
|
||||
$agent_search_filter = preg_replace("/%/", "%%", $agent_search_filter);
|
||||
$agent_status_filter = $this->getAgentStatusFilter();
|
||||
$module_status_filter = $this->getModuleStatusFilter();
|
||||
|
||||
$module_search_inner = "";
|
||||
$module_search_filter = "";
|
||||
if (!empty($this->filter['searchModule'])) {
|
||||
$module_search_inner = "
|
||||
INNER JOIN tagente_modulo tam
|
||||
ON ta.id_agente = tam.id_agente
|
||||
INNER JOIN tagente_estado tae
|
||||
ON tae.id_agente_modulo = tam.id_agente_modulo";
|
||||
$module_search_filter = "AND tam.disabled = 0
|
||||
AND tam.nombre LIKE '%%" . $this->filter['searchModule'] . "%%' " .
|
||||
$this->getModuleStatusFilterFromTestado()
|
||||
;
|
||||
}
|
||||
|
||||
$table = is_metaconsole() ? "tmetaconsole_agent" : "tagente";
|
||||
$table_sec = is_metaconsole() ? "tmetaconsole_agent_secondary_group" : "tagent_secondary_group";
|
||||
|
||||
$sql_model = "SELECT %s FROM
|
||||
(
|
||||
SELECT COUNT(DISTINCT(ta.id_agente)) AS total, id_grupo AS g
|
||||
FROM $table ta
|
||||
$module_search_inner
|
||||
WHERE ta.disabled = 0
|
||||
%s
|
||||
$agent_search_filter
|
||||
$agent_status_filter
|
||||
$module_status_filter
|
||||
$module_search_filter
|
||||
$group_acl
|
||||
GROUP BY id_grupo
|
||||
UNION ALL
|
||||
SELECT COUNT(DISTINCT(ta.id_agente)) AS total, id_group AS g
|
||||
FROM $table ta INNER JOIN $table_sec tasg
|
||||
ON ta.id_agente = tasg.id_agent
|
||||
$module_search_inner
|
||||
WHERE ta.disabled = 0
|
||||
%s
|
||||
$agent_search_filter
|
||||
$agent_status_filter
|
||||
$module_status_filter
|
||||
$module_search_filter
|
||||
$secondary_group_acl
|
||||
GROUP BY id_group
|
||||
) x GROUP BY g";
|
||||
$sql_array = array();
|
||||
foreach ($inside_fields as $inside_field) {
|
||||
$sql_array[] = sprintf(
|
||||
$sql_model,
|
||||
$inside_field['header'],
|
||||
$inside_field['condition'],
|
||||
$inside_field['condition']
|
||||
);
|
||||
}
|
||||
$sql = "SELECT $fields FROM (" . implode(" UNION ALL ", $sql_array) . ") x2
|
||||
RIGHT JOIN tgrupo tg
|
||||
ON x2.g = tg.id_grupo
|
||||
GROUP BY tg.id_grupo";
|
||||
$stats = db_get_all_rows_sql($sql);
|
||||
|
||||
$group_stats = array();
|
||||
foreach ($stats as $group) {
|
||||
$group_stats[$group['gid']]['total_count'] = (int)$group['total_count'];
|
||||
$group_stats[$group['gid']]['total_critical_count'] = (int)$group['total_critical_count'];
|
||||
$group_stats[$group['gid']]['total_unknown_count'] = (int)$group['total_unknown_count'];
|
||||
$group_stats[$group['gid']]['total_warning_count'] = (int)$group['total_warning_count'];
|
||||
$group_stats[$group['gid']]['total_not_init_count'] = (int)$group['total_not_init_count'];
|
||||
$group_stats[$group['gid']]['total_normal_count'] = (int)$group['total_normal_count'];
|
||||
$group_stats[$group['gid']]['total_fired_count'] = (int)$group['total_alerts_count'];
|
||||
$group_stats[$group['gid']]['name'] = $group['name'];
|
||||
$group_stats[$group['gid']]['parent'] = $group['parent'];
|
||||
$group_stats[$group['gid']]['icon'] = $group['icon'];
|
||||
$group_stats[$group['gid']]['id'] = $group['gid'];
|
||||
$group_stats[$group['gid']] = $this->getProcessedItem($group_stats[$group['gid']]);
|
||||
}
|
||||
|
||||
return $group_stats;
|
||||
}
|
||||
|
||||
protected function getFirstLevelFields() {
|
||||
$fields = parent::getFirstLevelFields();
|
||||
$parent = $this->getDisplayHierarchy() ? 'tg.parent' : '0 as parent';
|
||||
return "$fields, $parent";
|
||||
}
|
||||
|
||||
protected function getProcessedModules($modules_tree) {
|
||||
|
||||
$groups = array();
|
||||
foreach ($modules_tree as $group) {
|
||||
$groups[$group["id"]] = $group;
|
||||
}
|
||||
|
||||
// Build the module hierarchy
|
||||
foreach ($groups as $id => $group) {
|
||||
if (isset($groups[$id]['parent']) && ($groups[$id]['parent'] != 0)) {
|
||||
$parent = $groups[$id]['parent'];
|
||||
// Parent exists
|
||||
if (!isset($groups[$parent]['children'])) {
|
||||
$groups[$parent]['children'] = array();
|
||||
}
|
||||
// Store a reference to the group into the parent
|
||||
$groups[$parent]['children'][] = &$groups[$id];
|
||||
// This group was introduced into a parent
|
||||
$groups[$id]['have_parent'] = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Sort the children groups
|
||||
foreach ($groups as $id => $group) {
|
||||
if (isset($groups[$id]['children'])) {
|
||||
usort($groups[$id]['children'], array("Tree", "cmpSortNames"));
|
||||
}
|
||||
}
|
||||
//Filter groups and eliminates the reference to children groups out of her parent
|
||||
$groups = array_filter($groups, function ($group) {
|
||||
return !$group['have_parent'];
|
||||
});
|
||||
|
||||
return array_values($groups);
|
||||
}
|
||||
|
||||
// FIXME: Hierarchy lops is broken
|
||||
protected function getProcessedModules_old($modules_tree) {
|
||||
|
||||
$tree_modules = array();
|
||||
$new_modules_root = array_filter($modules_tree, function ($module) {
|
||||
return (isset($module['parent']) && ($module['parent'] == 0));
|
||||
});
|
||||
|
||||
$new_modules_child = array_filter($modules_tree, function ($module) {
|
||||
return (isset($module['parent']) && ($module['parent'] != 0));
|
||||
});
|
||||
|
||||
$i = 0;
|
||||
while (!empty($new_modules_child)) {
|
||||
foreach ($new_modules_child as $i => $child) {
|
||||
TreeGroup::recursive_modules_tree_view($new_modules_root, $new_modules_child, $i, $child);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($new_modules_root as $m) {
|
||||
$tree_modules[] = $m;
|
||||
}
|
||||
return $tree_modules;
|
||||
}
|
||||
|
||||
// FIXME with getProcessedModules_old
|
||||
static function recursive_modules_tree_view (&$new_modules, &$new_modules_child, $i, $child) {
|
||||
foreach ($new_modules as $index => $module) {
|
||||
if ($module['id'] == $child['parent']) {
|
||||
$new_modules[$index]['children'][] = $child;
|
||||
unset($new_modules_child[$i]);
|
||||
break;
|
||||
}
|
||||
else if (isset($new_modules[$index]['children'])) {
|
||||
TreeGroup::recursive_modules_tree_view ($new_modules[$index]['children'], $new_modules_child, $i, $child);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static function processCounters(&$groups) {
|
||||
$all_counters = array();
|
||||
foreach ($groups as $id => $group) {
|
||||
$child_counters = array();
|
||||
if (!empty($groups[$id]['children'])) {
|
||||
$child_counters = TreeGroup::processCounters($groups[$id]['children']);
|
||||
}
|
||||
if (!empty($child_counters)) {
|
||||
foreach($child_counters as $type => $value) {
|
||||
$groups[$id]['counters'][$type] += $value;
|
||||
}
|
||||
}
|
||||
foreach($groups[$id]['counters'] as $type => $value) {
|
||||
$all_counters[$type] += $value;
|
||||
}
|
||||
}
|
||||
return $all_counters;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Recursive function to remove the empty groups
|
||||
*
|
||||
* @param groups All groups structure
|
||||
*
|
||||
* @return new_groups A new groups structure without empty groups
|
||||
*/
|
||||
protected static function deleteEmptyGroups ($groups) {
|
||||
$new_groups = array();
|
||||
foreach ($groups as $group) {
|
||||
// If a group is empty, do not add to new_groups.
|
||||
if (!isset($group['counters']['total']) || $group['counters']['total'] == 0) {
|
||||
continue;
|
||||
}
|
||||
// Tray to remove the children groups
|
||||
if (!empty($group['children'])) {
|
||||
$children = TreeGroup::deleteEmptyGroups ($group['children']);
|
||||
if (empty($children)) unset($group['children']);
|
||||
else $group['children'] = $children;
|
||||
}
|
||||
$new_groups[] = $group;
|
||||
}
|
||||
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) {
|
||||
if (isset($ids_hash[$group['id']])) {
|
||||
$result_groups[] = $group;
|
||||
}
|
||||
else if (!empty($group['children'])) {
|
||||
$result = self::extractGroupsWithIDs($group['children'], $ids_hash);
|
||||
|
||||
// Item found on children
|
||||
if (!empty($result)) {
|
||||
$result_groups = array_merge($result_groups, $result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $result_groups;
|
||||
}
|
||||
|
||||
private static function extractItemWithID ($items, $item_id, $item_type = "group", $strictACL = false) {
|
||||
foreach ($items as $item) {
|
||||
if ($item["type"] != $item_type)
|
||||
continue;
|
||||
|
||||
// Item found
|
||||
if ($strictACL && is_metaconsole()) {
|
||||
foreach ($item["id"] as $server_id => $id) {
|
||||
if ($id == $item_id)
|
||||
return $item;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ($item["id"] == $item_id)
|
||||
return $item;
|
||||
}
|
||||
|
||||
if ($item["type"] == "group" && !empty($item["children"])) {
|
||||
$result = self::extractItemWithID($item["children"], $item_id, $item_type, $strictACL);
|
||||
|
||||
// Item found on children
|
||||
if ($result !== false)
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
// Item not found
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function getDisplayHierarchy() {
|
||||
return $this->filter['searchHirearchy'] ||
|
||||
(empty($this->filter['searchAgent']) && empty($this->filter['searchModule']));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,108 @@
|
|||
<?php
|
||||
//Pandora FMS- http://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2018 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 Lesser General Public License
|
||||
// as published by the Free Software Foundation; 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.
|
||||
|
||||
global $config;
|
||||
|
||||
require_once($config['homedir']."/include/class/Tree.class.php");
|
||||
|
||||
class TreeGroupEdition extends TreeGroup {
|
||||
public function __construct($type, $rootType = '', $id = -1, $rootID = -1, $serverID = false, $childrenMethod = "on_demand", $access = 'AR') {
|
||||
global $config;
|
||||
|
||||
parent::__construct($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access);
|
||||
}
|
||||
protected function getData() {
|
||||
if ($this->id == -1) {
|
||||
$this->getFirstLevel();
|
||||
}
|
||||
}
|
||||
|
||||
protected function getProcessedGroups () {
|
||||
$processed_groups = array();
|
||||
// Index and process the groups
|
||||
$groups = $this->getGroupCounters();
|
||||
|
||||
// If user have not permissions in parent, set parent node to 0 (all)
|
||||
// Avoid to do foreach for admins
|
||||
if (!users_can_manage_group_all("AR")) {
|
||||
foreach ($groups as $id => $group) {
|
||||
if (!isset($this->userGroups[$groups[$id]['parent']])) {
|
||||
$groups[$id]['parent'] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Build the group hierarchy
|
||||
foreach ($groups as $id => $group) {
|
||||
if (isset($groups[$id]['parent']) && ($groups[$id]['parent'] != 0)) {
|
||||
$parent = $groups[$id]['parent'];
|
||||
// Parent exists
|
||||
if (!isset($groups[$parent]['children'])) {
|
||||
$groups[$parent]['children'] = array();
|
||||
}
|
||||
// Store a reference to the group into the parent
|
||||
$groups[$parent]['children'][] = &$groups[$id];
|
||||
// This group was introduced into a parent
|
||||
$groups[$id]['have_parent'] = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Sort the children groups
|
||||
foreach ($groups as $id => $group) {
|
||||
if (isset($groups[$id]['children'])) {
|
||||
usort($groups[$id]['children'], array("Tree", "cmpSortNames"));
|
||||
}
|
||||
}
|
||||
//Filter groups and eliminates the reference to children groups out of her parent
|
||||
$groups = array_filter($groups, function ($group) {
|
||||
return !$group['have_parent'];
|
||||
});
|
||||
|
||||
usort($groups, array("Tree", "cmpSortNames"));
|
||||
return $groups;
|
||||
}
|
||||
|
||||
|
||||
protected function getGroupCounters() {
|
||||
$messages = array(
|
||||
'confirm' => __('Confirm'),
|
||||
'cancel' => __('Cancel'),
|
||||
'messg' => __('Are you sure?')
|
||||
);
|
||||
$sql = "SELECT id_grupo AS gid,
|
||||
nombre as name, parent, icon
|
||||
FROM tgrupo
|
||||
";
|
||||
|
||||
$stats = db_get_all_rows_sql($sql);
|
||||
$group_stats = array();
|
||||
foreach ($stats as $group) {
|
||||
$group_stats[$group['gid']]['name'] = $group['name'];
|
||||
$group_stats[$group['gid']]['parent'] = $group['parent'];
|
||||
$group_stats[$group['gid']]['icon'] = $group['icon'];
|
||||
$group_stats[$group['gid']]['id'] = $group['gid'];
|
||||
$group_stats[$group['gid']]['type'] = 'group';
|
||||
|
||||
$group_stats[$group['gid']] = $this->getProcessedItem($group_stats[$group['gid']]);
|
||||
$group_stats[$group['gid']]['delete']['messages'] = $messages;
|
||||
$group_stats[$group['gid']]['edit'] = 1;
|
||||
$group_stats[$group['gid']]['alerts'] = '';
|
||||
}
|
||||
|
||||
return $group_stats;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,60 @@
|
|||
<?php
|
||||
//Pandora FMS- http://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2018 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 Lesser General Public License
|
||||
// as published by the Free Software Foundation; 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.
|
||||
|
||||
global $config;
|
||||
|
||||
require_once($config['homedir']."/include/class/Tree.class.php");
|
||||
|
||||
class TreeModule extends Tree {
|
||||
|
||||
public function __construct($type, $rootType = '', $id = -1, $rootID = -1, $serverID = false, $childrenMethod = "on_demand", $access = 'AR') {
|
||||
|
||||
global $config;
|
||||
|
||||
parent::__construct($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access);
|
||||
|
||||
$this->L1fieldName = 'name';
|
||||
$this->L1fieldNameSql = 'tam.nombre';
|
||||
$this->L1inner = '';
|
||||
$this->L1orderByFinal = 'name';
|
||||
|
||||
$this->L2condition = "AND tam.nombre = '" . $this->symbol2name($this->rootID) . "'";
|
||||
}
|
||||
|
||||
protected function getData() {
|
||||
if ($this->id == -1) {
|
||||
$this->getFirstLevel();
|
||||
} elseif ($this->type == 'module') {
|
||||
$this->getSecondLevel();
|
||||
} elseif ($this->type == 'agent') {
|
||||
$this->getThirdLevel();
|
||||
}
|
||||
}
|
||||
|
||||
protected function getProcessedItemsFirstLevel($items){
|
||||
$processed_items = array();
|
||||
foreach ($items as $key => $item) {
|
||||
$name = $this->name2symbol($item['name']);
|
||||
$processed_item = $this->getProcessedItem($item);
|
||||
$processed_item['id'] = $name;
|
||||
$processed_item['rootID'] = $name;
|
||||
$processed_items[] = $processed_item;
|
||||
}
|
||||
return $processed_items;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
<?php
|
||||
//Pandora FMS- http://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2018 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 Lesser General Public License
|
||||
// as published by the Free Software Foundation; 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.
|
||||
|
||||
global $config;
|
||||
|
||||
require_once($config['homedir']."/include/class/Tree.class.php");
|
||||
|
||||
class TreeModuleGroup extends Tree {
|
||||
|
||||
public function __construct($type, $rootType = '', $id = -1, $rootID = -1, $serverID = false, $childrenMethod = "on_demand", $access = 'AR') {
|
||||
|
||||
global $config;
|
||||
|
||||
parent::__construct($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access);
|
||||
|
||||
$this->L1fieldName = 'id_module_group';
|
||||
$this->L1fieldNameSql = 'tam.id_module_group';
|
||||
$this->L1extraFields = array('tmg.name', 'tmg.id_mg AS id');
|
||||
$this->L1inner = 'INNER JOIN tmodule_group tmg ON tmg.id_mg = x2.g';
|
||||
$this->L1orderByFinal = 'tmg.name';
|
||||
|
||||
$this->L2condition = "AND tam.id_module_group = " . $this->rootID;
|
||||
}
|
||||
|
||||
protected function getData() {
|
||||
if ($this->id == -1) {
|
||||
$this->getFirstLevel();
|
||||
} elseif ($this->type == 'module_group') {
|
||||
$this->getSecondLevel();
|
||||
} elseif ($this->type == 'agent') {
|
||||
$this->getThirdLevel();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
<?php
|
||||
//Pandora FMS- http://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2018 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 Lesser General Public License
|
||||
// as published by the Free Software Foundation; 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.
|
||||
|
||||
global $config;
|
||||
|
||||
require_once($config['homedir']."/include/class/Tree.class.php");
|
||||
|
||||
class TreeOS extends Tree {
|
||||
|
||||
public function __construct($type, $rootType = '', $id = -1, $rootID = -1, $serverID = false, $childrenMethod = "on_demand", $access = 'AR') {
|
||||
|
||||
global $config;
|
||||
|
||||
parent::__construct($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access);
|
||||
|
||||
$this->L1fieldName = 'id_os';
|
||||
$this->L1fieldNameSql = 'ta.id_os';
|
||||
$this->L1extraFields = array('tco.name', 'tco.id_os AS id', 'tco.icon_name AS iconHTML');
|
||||
$this->L1inner = 'INNER JOIN tconfig_os tco ON tco.id_os = x2.g';
|
||||
$this->L1orderByFinal = 'tco.name';
|
||||
|
||||
$this->L2condition = "AND ta.id_os = " . $this->rootID;
|
||||
}
|
||||
|
||||
protected function getData() {
|
||||
if ($this->id == -1) {
|
||||
$this->getFirstLevel();
|
||||
} elseif ($this->type == 'os') {
|
||||
$this->getSecondLevel();
|
||||
} elseif ($this->type == 'agent') {
|
||||
$this->getThirdLevel();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
<?php
|
||||
//Pandora FMS- http://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2018 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 Lesser General Public License
|
||||
// as published by the Free Software Foundation; 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.
|
||||
|
||||
global $config;
|
||||
|
||||
require_once($config['homedir']."/include/class/Tree.class.php");
|
||||
|
||||
class TreeTag extends Tree {
|
||||
|
||||
public function __construct($type, $rootType = '', $id = -1, $rootID = -1, $serverID = false, $childrenMethod = "on_demand", $access = 'AR') {
|
||||
|
||||
global $config;
|
||||
|
||||
parent::__construct($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access);
|
||||
|
||||
$this->L1fieldName = 'id_tag';
|
||||
$this->L1fieldNameSql = 'ttm.id_tag';
|
||||
$this->L1innerInside = '
|
||||
INNER JOIN ttag_module ttm
|
||||
ON ttm.id_agente_modulo = tam.id_agente_modulo
|
||||
';
|
||||
$this->L1extraFields = array('tt.name', 'tt.id_tag AS id');
|
||||
$this->L1inner = 'INNER JOIN ttag tt ON tt.id_tag = x2.g';
|
||||
$this->L1orderByFinal = 'tt.name';
|
||||
|
||||
$this->L2condition = "AND ttm.id_tag = " . $this->rootID;
|
||||
$this->L2inner = $this->L1innerInside;
|
||||
}
|
||||
|
||||
protected function getData() {
|
||||
if ($this->id == -1) {
|
||||
$this->getFirstLevel();
|
||||
} elseif ($this->type == 'tag') {
|
||||
$this->getSecondLevel();
|
||||
} elseif ($this->type == 'agent') {
|
||||
$this->getThirdLevel();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -22,8 +22,8 @@
|
|||
/**
|
||||
* Pandora build version and version
|
||||
*/
|
||||
$build_version = 'PC180904';
|
||||
$pandora_version = 'v7.0NG.726';
|
||||
$build_version = 'PC180918';
|
||||
$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 {
|
||||
|
@ -2684,6 +2684,9 @@ function agents_generate_name ($alias, $address = '') {
|
|||
* @return Array with the main and secondary groups
|
||||
*/
|
||||
function agents_get_all_groups_agent ($id_agent, $group = false) {
|
||||
// Cache the agent id groups
|
||||
static $cache = array();
|
||||
if (isset($cache[$id_agent])) return $cache[$id_agent];
|
||||
// Get the group if is not defined
|
||||
if ($group === false) $group = agents_get_agent_group($id_agent);
|
||||
|
||||
|
@ -2697,6 +2700,7 @@ function agents_get_all_groups_agent ($id_agent, $group = false) {
|
|||
|
||||
// Add a list of groups
|
||||
$secondary_groups['plain'][] = $group;
|
||||
$cache[$id_agent] = $secondary_groups['plain'];
|
||||
return $secondary_groups['plain'];
|
||||
}
|
||||
|
||||
|
@ -2738,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 . '%"
|
||||
|
@ -1633,23 +1638,13 @@ function get_agent_alert_fired ($id_agent, $id_alert, $period, $date = 0) {
|
|||
*
|
||||
* @return array An array with all the events happened.
|
||||
*/
|
||||
function get_module_alert_fired ($id_agent_module, $id_alert, $period, $date = 0) {
|
||||
function get_module_alert_fired ($id_agent_module, $id_alert) {
|
||||
|
||||
if (!is_numeric ($date)) {
|
||||
$date = time_w_fixed_tz($date);
|
||||
}
|
||||
if (empty ($date)) {
|
||||
$date = get_system_time();
|
||||
}
|
||||
|
||||
$datelimit = $date - $period;
|
||||
|
||||
$sql = sprintf ('SELECT timestamp
|
||||
$sql = sprintf ('SELECT *
|
||||
FROM tevento
|
||||
WHERE id_agentmodule = %d AND utimestamp > %d
|
||||
AND utimestamp <= %d
|
||||
WHERE id_agentmodule = %d
|
||||
AND id_alert_am = %d
|
||||
ORDER BY timestamp DESC', $id_agent_module, $datelimit, $date, $id_alert);
|
||||
ORDER BY timestamp DESC', $id_agent_module, $id_alert);
|
||||
|
||||
return db_get_all_rows_sql ($sql);
|
||||
}
|
||||
|
@ -1792,9 +1787,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 +1859,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,
|
||||
|
@ -516,6 +513,8 @@ function grafico_modulo_sparse_data(
|
|||
}
|
||||
$period_time_interval = $period_time_interval - $params['time_interval'];
|
||||
}
|
||||
//drag the last value to paint the graph correctly
|
||||
$acum_array_data[]= array( 0 => $start_period, 1 => $acum_array_data[$i-1][1]);
|
||||
$array_data['sum1']['data'] = $acum_array_data;
|
||||
}
|
||||
|
||||
|
@ -892,7 +891,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 +923,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 +964,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 +1224,7 @@ function graphic_combined_module (
|
|||
}
|
||||
else{
|
||||
$params['stacked'] = 'area';
|
||||
$params['projection'] = $params_combined['projection'];
|
||||
$params['projection'] = true;
|
||||
}
|
||||
|
||||
if(!isset($params_combined['labels'])){
|
||||
|
@ -1512,6 +1517,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 +1591,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 +4131,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 +4157,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 +4205,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 +4270,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 +4291,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 +5113,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
File diff suppressed because it is too large
Load Diff
|
@ -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;
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -2750,5 +2750,62 @@ function modules_get_modules_status ($mod_status_id) {
|
|||
}
|
||||
|
||||
return $mod_status_desc;
|
||||
}
|
||||
?>
|
||||
}
|
||||
|
||||
function modules_get_counter_by_states($state) {
|
||||
switch ($state) {
|
||||
case AGENT_MODULE_STATUS_CRITICAL_ALERT:
|
||||
case AGENT_MODULE_STATUS_CRITICAL_BAD:
|
||||
return "critical_count";
|
||||
case AGENT_MODULE_STATUS_WARNING_ALERT:
|
||||
case AGENT_MODULE_STATUS_WARNING:
|
||||
return "warning_count";
|
||||
break;
|
||||
case AGENT_MODULE_STATUS_UNKNOWN:
|
||||
return "unknown_count";
|
||||
case AGENT_MODULE_STATUS_NO_DATA:
|
||||
case AGENT_MODULE_STATUS_NOT_INIT:
|
||||
return "notinit_count";
|
||||
case AGENT_MODULE_STATUS_NORMAL_ALERT:
|
||||
case AGENT_MODULE_STATUS_NORMAL:
|
||||
return "normal_count";
|
||||
}
|
||||
|
||||
// If the state is not an expected state, return condition
|
||||
// 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";
|
||||
}
|
||||
?>
|
File diff suppressed because it is too large
Load Diff
|
@ -1960,6 +1960,12 @@ function reporting_html_alert_report($table, $item, $pdf = 0) {
|
|||
$table1->data = array ();
|
||||
$table1->rowspan = array();
|
||||
$table1->valign = array();
|
||||
|
||||
if ($item['data'] == null) {
|
||||
$table->data['alerts']['cell'] = ui_print_empty_data ( __('No alerts defined') , '', true) ;
|
||||
return true;
|
||||
}
|
||||
|
||||
$table1->head['agent'] = __('Agent');
|
||||
$table1->head['module'] = __('Module');
|
||||
$table1->head['template'] = __('Template');
|
||||
|
|
|
@ -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 ();
|
||||
|
|
|
@ -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>";
|
||||
|
|
|
@ -1585,6 +1585,10 @@ function display_confirm_dialog (message, ok_text, cancel_text, ok_function) {
|
|||
clean_function();
|
||||
}
|
||||
|
||||
var buttons_obj = {};
|
||||
buttons_obj[cancel_text] = clean_function;
|
||||
buttons_obj[ok_text] = ok_function_clean;
|
||||
|
||||
// Display the dialog
|
||||
$("body").append('<div id="pandora_confirm_dialog_text"><h3>' + message + '</h3></div>');
|
||||
$("#pandora_confirm_dialog_text").dialog({
|
||||
|
@ -1598,10 +1602,7 @@ function display_confirm_dialog (message, ok_text, cancel_text, ok_function) {
|
|||
},
|
||||
closeOnEscape: true,
|
||||
modal: true,
|
||||
buttons: {
|
||||
Cancel: clean_function,
|
||||
"Confirm": ok_function_clean
|
||||
}
|
||||
buttons: buttons_obj
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ var TreeController = {
|
|||
}
|
||||
|
||||
container.append($group);
|
||||
|
||||
|
||||
_.each(elements, function(element) {
|
||||
element.jqObject = _processNode($group, element);
|
||||
});
|
||||
|
@ -279,14 +279,13 @@ var TreeController = {
|
|||
|
||||
// Load leaf
|
||||
function _processNode (container, element) {
|
||||
|
||||
// type, [id], [serverID], callback
|
||||
function _getTreeDetailData (type, id, serverID, callback) {
|
||||
var lastParam = arguments[arguments.length - 1];
|
||||
var callback;
|
||||
if (typeof lastParam === 'function')
|
||||
callback = lastParam;
|
||||
|
||||
|
||||
var serverID;
|
||||
if (arguments.length >= 4)
|
||||
serverID = arguments[2];
|
||||
|
@ -296,23 +295,23 @@ var TreeController = {
|
|||
var type;
|
||||
if (arguments.length >= 2)
|
||||
type = arguments[0];
|
||||
|
||||
|
||||
if (typeof type === 'undefined')
|
||||
throw new TypeError('Type required');
|
||||
if (typeof callback === 'undefined')
|
||||
throw new TypeError('Callback required');
|
||||
|
||||
|
||||
var postData = {
|
||||
page: controller.ajaxPage,
|
||||
getDetail: 1,
|
||||
type: type
|
||||
}
|
||||
|
||||
|
||||
if (typeof id !== 'undefined')
|
||||
postData.id = id;
|
||||
if (typeof serverID !== 'undefined')
|
||||
postData.serverID = serverID;
|
||||
|
||||
|
||||
$.ajax({
|
||||
url: controller.ajaxURL,
|
||||
type: 'POST',
|
||||
|
@ -346,6 +345,36 @@ var TreeController = {
|
|||
$content.append(element.iconHTML + " ");
|
||||
}
|
||||
$content.append(element.name);
|
||||
|
||||
if(typeof element.edit != 'undefined'){
|
||||
var url_edit = controller.baseURL + "index.php?sec=gagente&sec2=godmode/groups/configure_group&tab=tree&id_group=" + element.id;
|
||||
var $updateicon = $('<img src="' + (controller.baseURL.length > 0 ? controller.baseURL : '')+ 'images/config.png" style="width:18px; vertical-align: middle;"/>')
|
||||
var $updatebtn = $('<a href = "' + url_edit + '"></a>')
|
||||
.append($updateicon);
|
||||
$content.append($updatebtn);
|
||||
}
|
||||
|
||||
if(typeof element.delete != 'undefined'){
|
||||
var url_delete = controller.baseURL + "index.php?sec=gagente&sec2=godmode/groups/group_list&tab=tree&delete_group=1&id_group=" + element.id;
|
||||
var $deleteBtn = $('<a><img src="' + (controller.baseURL.length > 0 ? controller.baseURL : '') +'images/cross.png" style="width:18px; vertical-align: middle; cursor: pointer;"/></a>');
|
||||
$deleteBtn.click(function (event){
|
||||
var ok_function = function(){
|
||||
window.location.replace(url_delete);
|
||||
};
|
||||
display_confirm_dialog(
|
||||
element.delete.messages.messg,
|
||||
element.delete.messages.confirm,
|
||||
element.delete.messages.cancel,
|
||||
ok_function
|
||||
)
|
||||
});
|
||||
$content.append($deleteBtn);
|
||||
}
|
||||
|
||||
if(typeof element.alerts != 'undefined'){
|
||||
$content.append(element.alerts);
|
||||
}
|
||||
|
||||
break;
|
||||
case 'agent':
|
||||
// Is quiet
|
||||
|
@ -583,95 +612,99 @@ var TreeController = {
|
|||
if (typeof(public_user) === 'undefined') public_user = 0;
|
||||
|
||||
if (typeof element.searchChildren != 'undefined' && element.searchChildren) {
|
||||
$node
|
||||
.removeClass("leaf-empty")
|
||||
.addClass("leaf-closed");
|
||||
if(element.rootType == "group_edition"
|
||||
&& typeof element.children == 'undefined'){
|
||||
$node.addClass("leaf-empty");
|
||||
}
|
||||
else{
|
||||
$node
|
||||
.removeClass("leaf-empty")
|
||||
.addClass("leaf-closed");
|
||||
$leafIcon.click(function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
$leafIcon.click(function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
if (!$node.hasClass("leaf-loading") && !$node.hasClass("children-loaded") && !$node.hasClass("leaf-empty")) {
|
||||
$node
|
||||
.removeClass("leaf-closed")
|
||||
.removeClass("leaf-error")
|
||||
.addClass("leaf-loading");
|
||||
|
||||
$.ajax({
|
||||
url: controller.ajaxURL,
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
data: {
|
||||
page: controller.ajaxPage,
|
||||
getChildren: 1,
|
||||
id: element.id,
|
||||
type: element.type,
|
||||
rootID: element.rootID,
|
||||
serverID: element.serverID,
|
||||
rootType: element.rootType,
|
||||
filter: controller.filter,
|
||||
hash: public_hash,
|
||||
id_user: public_user
|
||||
},
|
||||
complete: function(xhr, textStatus) {
|
||||
$node.removeClass("leaf-loading");
|
||||
$node.addClass("children-loaded");
|
||||
},
|
||||
success: function(data, textStatus, xhr) {
|
||||
if (data.success) {
|
||||
var $group = $node.children("ul.tree-group");
|
||||
|
||||
if ((typeof data.tree != 'undefined' && data.tree.length > 0) || $group.length > 0) {
|
||||
$node.addClass("leaf-open");
|
||||
|
||||
if ($group.length <= 0) {
|
||||
$group = $("<ul></ul>");
|
||||
$group
|
||||
.addClass("tree-group")
|
||||
.hide();
|
||||
$node.append($group);
|
||||
}
|
||||
|
||||
_.each(data.tree, function(element) {
|
||||
element.jqObject = _processNode($group, element);
|
||||
});
|
||||
|
||||
$group.slideDown();
|
||||
|
||||
$node.data('children', $group);
|
||||
|
||||
// Add again the hover event to the 'force_callback' elements
|
||||
forced_title_callback();
|
||||
}
|
||||
else {
|
||||
$node.addClass("leaf-empty");
|
||||
}
|
||||
}
|
||||
else {
|
||||
$node.addClass("leaf-error");
|
||||
}
|
||||
},
|
||||
error: function(xhr, textStatus, errorThrown) {
|
||||
$node.addClass("leaf-error");
|
||||
}
|
||||
});
|
||||
}
|
||||
else if (! $node.hasClass("leaf-empty")) {
|
||||
if ($node.hasClass("leaf-open")) {
|
||||
$node
|
||||
.removeClass("leaf-open")
|
||||
.addClass("leaf-closed")
|
||||
.data('children')
|
||||
.slideUp();
|
||||
}
|
||||
else {
|
||||
if (!$node.hasClass("leaf-loading") && !$node.hasClass("children-loaded") && !$node.hasClass("leaf-empty")) {
|
||||
$node
|
||||
.removeClass("leaf-closed")
|
||||
.addClass("leaf-open")
|
||||
.data('children')
|
||||
.slideDown();
|
||||
.removeClass("leaf-error")
|
||||
.addClass("leaf-loading");
|
||||
|
||||
$.ajax({
|
||||
url: controller.ajaxURL,
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
data: {
|
||||
page: controller.ajaxPage,
|
||||
getChildren: 1,
|
||||
id: element.id,
|
||||
type: element.type,
|
||||
rootID: element.rootID,
|
||||
serverID: element.serverID,
|
||||
rootType: element.rootType,
|
||||
filter: controller.filter,
|
||||
hash: public_hash,
|
||||
id_user: public_user
|
||||
},
|
||||
complete: function(xhr, textStatus) {
|
||||
$node.removeClass("leaf-loading");
|
||||
$node.addClass("children-loaded");
|
||||
},
|
||||
success: function(data, textStatus, xhr) {
|
||||
if (data.success) {
|
||||
var $group = $node.children("ul.tree-group");
|
||||
if ((typeof data.tree != 'undefined' && data.tree.length > 0) || $group.length > 0) {
|
||||
$node.addClass("leaf-open");
|
||||
|
||||
if ($group.length <= 0) {
|
||||
$group = $("<ul></ul>");
|
||||
$group
|
||||
.addClass("tree-group")
|
||||
.hide();
|
||||
$node.append($group);
|
||||
}
|
||||
|
||||
_.each(data.tree, function(element) {
|
||||
element.jqObject = _processNode($group, element);
|
||||
});
|
||||
|
||||
$group.slideDown();
|
||||
|
||||
$node.data('children', $group);
|
||||
|
||||
// Add again the hover event to the 'force_callback' elements
|
||||
forced_title_callback();
|
||||
}
|
||||
else {
|
||||
$node.addClass("leaf-empty");
|
||||
}
|
||||
}
|
||||
else {
|
||||
$node.addClass("leaf-error");
|
||||
}
|
||||
},
|
||||
error: function(xhr, textStatus, errorThrown) {
|
||||
$node.addClass("leaf-error");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
else if (! $node.hasClass("leaf-empty")) {
|
||||
if ($node.hasClass("leaf-open")) {
|
||||
$node
|
||||
.removeClass("leaf-open")
|
||||
.addClass("leaf-closed")
|
||||
.data('children')
|
||||
.slideUp();
|
||||
}
|
||||
else {
|
||||
$node
|
||||
.removeClass("leaf-closed")
|
||||
.addClass("leaf-open")
|
||||
.data('children')
|
||||
.slideDown();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return $node;
|
||||
|
|
|
@ -3709,6 +3709,57 @@ div.simple_value > a > span.text p
|
|||
color:white;
|
||||
}
|
||||
|
||||
.modaldeletebutton{
|
||||
transition-property: background-color, color;
|
||||
transition-duration: 1s;
|
||||
transition-timing-function: ease-out;
|
||||
-webkit-transition-property: background-color, color;
|
||||
-webkit-transition-duration: 1s;
|
||||
-o-transition-property: background-color, color;
|
||||
-o-transition-duration: 1s;
|
||||
cursor:pointer;
|
||||
text-align:center;
|
||||
margin-left:45px;
|
||||
float:left;
|
||||
-moz-border-radius: 3px;
|
||||
-webkit-border-radius: 3px;
|
||||
margin-bottom:30px;
|
||||
border-radius: 3px;width:90px;height:30px;background-color:white;border: 1px solid #FA5858;
|
||||
}
|
||||
|
||||
.modaldeletebuttontext{
|
||||
transition-property: background-color, color;
|
||||
transition-duration: 1s;
|
||||
transition-timing-function: ease-out;
|
||||
-webkit-transition-property: background-color, color;
|
||||
-webkit-transition-duration: 1s;
|
||||
-o-transition-property: background-color, color;
|
||||
-o-transition-duration: 1s;
|
||||
color:#FA5858;font-family:Nunito;font-size:10pt;position:relative;top:6px;
|
||||
}
|
||||
|
||||
.modaldeletebutton:hover .modaldeletebuttontext {
|
||||
transition-property: background-color, color;
|
||||
transition-duration: 1s;
|
||||
transition-timing-function: ease-out;
|
||||
-webkit-transition-property: background-color, color;
|
||||
-webkit-transition-duration: 1s;
|
||||
-o-transition-property: background-color, color;
|
||||
-o-transition-duration: 1s;
|
||||
color:white;
|
||||
}
|
||||
|
||||
.modaldeletebutton:hover {
|
||||
transition-property: background-color, color;
|
||||
transition-duration: 1s;
|
||||
transition-timing-function: ease-out;
|
||||
-webkit-transition-property: background-color, color;
|
||||
-webkit-transition-duration: 1s;
|
||||
-o-transition-property: background-color, color;
|
||||
-o-transition-duration: 1s;
|
||||
background-color:#FA5858;
|
||||
}
|
||||
|
||||
.modalgobutton{
|
||||
transition-property: background-color, color;
|
||||
transition-duration: 1s;
|
||||
|
|
|
@ -70,8 +70,8 @@
|
|||
<body>
|
||||
<div style='height: 10px'>
|
||||
<?php
|
||||
$version = '7.0NG.726';
|
||||
$build = '180904';
|
||||
$version = '7.0NG.727';
|
||||
$build = '180918';
|
||||
$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'), false, 'AR', true, true);
|
||||
|
||||
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
|
||||
|
@ -69,8 +68,6 @@ else {
|
|||
// Header
|
||||
ui_print_page_header (__("Group view"), "images/group.png", false, "", false, $updated_time);
|
||||
|
||||
$strict_user = false;
|
||||
|
||||
$total_agentes = 0;
|
||||
$monitor_ok = 0;
|
||||
$monitor_warning = 0;
|
||||
|
@ -83,9 +80,12 @@ $agents_notinit = 0;
|
|||
$all_alerts_fired = 0;
|
||||
|
||||
//Groups and tags
|
||||
$result_groups = groupview_get_groups_list($config['id_user'], $strict_user,
|
||||
($agent_a == true) ? 'AR' : (($agent_w == true) ? 'AW' : 'AR'), true, true);
|
||||
$count = count($result_groups);
|
||||
$result_groups_info = groupview_get_groups_list(
|
||||
$config['id_user'],
|
||||
($agent_a == true) ? 'AR' : (($agent_w == true) ? 'AW' : 'AR')
|
||||
);
|
||||
$result_groups = $result_groups_info['groups'];
|
||||
$count = $result_groups_info['counter'];
|
||||
|
||||
if ($result_groups[0]["_id_"] == 0) {
|
||||
$total_agentes = $result_groups[0]["_total_agents_"];
|
||||
|
@ -186,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
|
||||
|
@ -453,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 180904
|
||||
%define version 7.0NG.727
|
||||
%define release 180918
|
||||
|
||||
# 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 180904
|
||||
%define version 7.0NG.727
|
||||
%define release 180918
|
||||
%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"`
|
||||
|
|
|
@ -775,6 +775,13 @@ CREATE TABLE IF NOT EXISTS `trecon_task` (
|
|||
`alias_as_name` tinyint(2) NOT NULL default '0',
|
||||
`snmp_enabled` tinyint(1) unsigned default '0',
|
||||
`vlan_enabled` tinyint(1) unsigned default '0',
|
||||
`snmp_version` varchar(5) NOT NULL default '1',
|
||||
`snmp_auth_user` varchar(255) NOT NULL default '',
|
||||
`snmp_auth_pass` varchar(255) NOT NULL default '',
|
||||
`snmp_auth_method` varchar(25) NOT NULL default '',
|
||||
`snmp_privacy_method` varchar(25) NOT NULL default '',
|
||||
`snmp_privacy_pass` varchar(255) NOT NULL default '',
|
||||
`snmp_security_level` varchar(25) NOT NULL default '',
|
||||
PRIMARY KEY (`id_rt`),
|
||||
KEY `recon_task_daemon` (`id_recon_server`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
@ -1242,6 +1249,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;
|
||||
|
||||
|
@ -2364,6 +2372,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,
|
||||
|
@ -3329,3 +3338,15 @@ CREATE TABLE IF NOT EXISTS `tlayout_template_data` (
|
|||
PRIMARY KEY(`id`),
|
||||
FOREIGN KEY (`id_layout_template`) REFERENCES tlayout_template(`id`) ON DELETE CASCADE ON UPDATE CASCADE
|
||||
) ENGINE = InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
-- ---------------------------------------------------------------------
|
||||
-- Table `tlog_graph_models`
|
||||
-- ---------------------------------------------------------------------
|
||||
CREATE TABLE IF NOT EXISTS `tlog_graph_models` (
|
||||
`id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`title` TEXT NOT NULL,
|
||||
`regexp` TEXT NOT NULL,
|
||||
`fields` TEXT NOT NULL,
|
||||
`average` tinyint(1) NOT NULL default '0',
|
||||
PRIMARY KEY(`id`)
|
||||
) ENGINE = InnoDB DEFAULT CHARSET=utf8;
|
||||
|
|
|
@ -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'),
|
||||
|
@ -1260,3 +1260,10 @@ INSERT INTO `tprofile_view` (`id_profile`, `sec`, `sec2`, `sec3`) VALUES (5, '*'
|
|||
-- Dumping data for table `tcontainer`
|
||||
--
|
||||
INSERT INTO `tcontainer` SET `name` = 'Default graph container';
|
||||
|
||||
--
|
||||
-- Dumping data for table `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);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
package: pandorafms-server
|
||||
Version: 7.0NG.726-180904
|
||||
Version: 7.0NG.727-180918
|
||||
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-180904"
|
||||
pandora_version="7.0NG.727-180918"
|
||||
|
||||
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 = "180904";
|
||||
my $pandora_version = "7.0NG.727";
|
||||
my $pandora_build = "180918";
|
||||
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 = "180904";
|
||||
my $pandora_version = "7.0NG.727";
|
||||
my $pandora_build = "180918";
|
||||
our $VERSION = $pandora_version." ".$pandora_build;
|
||||
|
||||
our %EXPORT_TAGS = ( 'all' => [ qw() ] );
|
||||
|
|
|
@ -96,6 +96,9 @@ sub new {
|
|||
# Working SNMP community for each device.
|
||||
community_cache => {},
|
||||
|
||||
# Cache of deviced discovered.
|
||||
dicovered_cache => {},
|
||||
|
||||
# Connections between devices.
|
||||
connections => {},
|
||||
|
||||
|
@ -147,8 +150,15 @@ sub new {
|
|||
recon_timing_template => 3,
|
||||
recon_ports => '',
|
||||
resolve_names => 0,
|
||||
snmp_auth_user => '',
|
||||
snmp_auth_pass => '',
|
||||
snmp_auth_method => '',
|
||||
snmp_checks => 2,
|
||||
snmp_privacy_method => '',
|
||||
snmp_privacy_pass => '',
|
||||
snmp_security_level => '',
|
||||
snmp_timeout => 2,
|
||||
snmp_version => 1,
|
||||
subnets => [],
|
||||
@_,
|
||||
|
||||
|
@ -157,8 +167,66 @@ sub new {
|
|||
# Perform some sanity checks.
|
||||
die("No subnet was specified.") unless defined($self->{'subnets'});
|
||||
|
||||
# Disable SNMP scans if no community was given.
|
||||
$self->{'snmp_enabled'} = 0 if (scalar(@{$self->{'communities'}}) == 0);
|
||||
# Check SNMP params id SNMP is enabled
|
||||
if ($self->{'snmp_enabled'}) {
|
||||
# Check SNMP version
|
||||
if ($self->{'snmp_version'} ne '1' && $self->{'snmp_version'} ne '2'
|
||||
&& $self->{'snmp_version'} ne '2c' && $self->{'snmp_version'} ne '3'
|
||||
) {
|
||||
$self->{'snmp_enabled'} = 0;
|
||||
$self->call('message', "SNMP version " . $self->{'snmp_version'} . " not supported (only 1, 2, 2c and 3).", 5);
|
||||
}
|
||||
|
||||
# Check the version 3 parameters
|
||||
if ($self->{'snmp_version'} eq '3') {
|
||||
# Fixed some vars
|
||||
$self->{'communities'} = [];
|
||||
|
||||
# SNMP v3 checks
|
||||
if (
|
||||
$self->{'snmp_security_level'} ne 'noAuthNoPriv' &&
|
||||
$self->{'snmp_security_level'} ne 'authNoPriv' &&
|
||||
$self->{'snmp_security_level'} ne 'authPriv'
|
||||
) {
|
||||
$self->{'snmp_enabled'} = 0;
|
||||
$self->call('message', "Invalid SNMP security level " . $self->{'snmp_security_level'} . ".", 5);
|
||||
}
|
||||
if ($self->{'snmp_privacy_method'} ne 'DES' && $self->{'snmp_privacy_method'} ne 'AES') {
|
||||
$self->{'snmp_enabled'} = 0;
|
||||
$self->call('message', "Invalid SNMP privacy method " . $self->{'snmp_privacy_method'} . ".", 5);
|
||||
}
|
||||
if ($self->{'snmp_auth_method'} ne 'MD5' && $self->{'snmp_auth_method'} ne 'SHA') {
|
||||
$self->{'snmp_enabled'} = 0;
|
||||
$self->call('message', "Invalid SNMP authentication method " . $self->{'snmp_auth_method'} . ".", 5);
|
||||
}
|
||||
} else {
|
||||
# Fixed some vars
|
||||
$self->{'snmp_auth_user'} = '';
|
||||
$self->{'snmp_auth_pass'} = '';
|
||||
$self->{'snmp_auth_method'} = '';
|
||||
$self->{'snmp_privacy_method'} = '';
|
||||
$self->{'snmp_privacy_pass'} = '';
|
||||
$self->{'snmp_security_level'} = '';
|
||||
|
||||
# Disable SNMP scans if no community was given.
|
||||
if (scalar(@{$self->{'communities'}}) == 0) {
|
||||
$self->{'snmp_enabled'} = 0;
|
||||
$self->call('message', "There is not any SNMP community configured.", 5);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Remove all snmp related values if disabled
|
||||
if (!$self->{'snmp_enabled'}) {
|
||||
$self->{'communities'} = [];
|
||||
$self->{'snmp_auth_user'} = '';
|
||||
$self->{'snmp_auth_pass'} = '';
|
||||
$self->{'snmp_auth_method'} = '';
|
||||
$self->{'snmp_privacy_method'} = '';
|
||||
$self->{'snmp_privacy_pass'} = '';
|
||||
$self->{'snmp_security_level'} = '';
|
||||
}
|
||||
|
||||
return bless($self, $class);
|
||||
}
|
||||
|
@ -199,7 +267,7 @@ sub aft_connectivity($$) {
|
|||
my ($self, $switch) = @_;
|
||||
my (%mac_temp, @aft_temp);
|
||||
|
||||
return unless defined($self->get_community($switch));
|
||||
return unless ($self->is_snmp_discovered($switch));
|
||||
|
||||
$self->enable_vlan_cache();
|
||||
|
||||
|
@ -397,8 +465,7 @@ sub find_ifaces($$) {
|
|||
my ($self, $device) = @_;
|
||||
|
||||
# Does it respond to SNMP?
|
||||
my $community = $self->get_community($device);
|
||||
return unless defined($community);
|
||||
return unless ($self->is_snmp_discovered($device));
|
||||
|
||||
my @output = $self->snmp_get_value_array($device, $PandoraFMS::Recon::Base::IFINDEX);
|
||||
foreach my $if_index (@output) {
|
||||
|
@ -476,11 +543,13 @@ sub get_device($$) {
|
|||
sub get_community($$) {
|
||||
my ($self, $device) = @_;
|
||||
|
||||
return '' if ($self->{'snmp_version'} eq "3");
|
||||
|
||||
if (defined($self->{'community_cache'}->{$device})) {
|
||||
return $self->{'community_cache'}->{$device};
|
||||
}
|
||||
|
||||
return undef;
|
||||
return '';
|
||||
}
|
||||
|
||||
########################################################################################
|
||||
|
@ -787,6 +856,9 @@ sub get_visited_devices($) {
|
|||
sub get_vlans($$) {
|
||||
my ($self, $device) = @_;
|
||||
|
||||
# Disabled in verison 3
|
||||
return () if ($self->{'snmp_version'} eq "3");
|
||||
|
||||
# Is the VLAN cache disabled?
|
||||
return () unless ($self->{'__vlan_cache_enabled__'} == 1);
|
||||
|
||||
|
@ -945,6 +1017,17 @@ sub is_visited($$) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
########################################################################################
|
||||
# Returns 1 if the given device has responded successfully to a snmp request
|
||||
# Returns 0 otherwise.
|
||||
########################################################################################
|
||||
sub is_snmp_discovered($$) {
|
||||
my ($self, $device) = @_;
|
||||
|
||||
# Check if device is into discovered cache
|
||||
return (defined($self->{'discovered_cache'}->{$device})) ? 1 : 0;
|
||||
}
|
||||
|
||||
########################################################################################
|
||||
# Mark the given devices as connected to each other on the given interfaces.
|
||||
########################################################################################
|
||||
|
@ -999,23 +1082,46 @@ sub mark_visited($$) {
|
|||
}
|
||||
|
||||
########################################################################################
|
||||
# Looks for a working SNMP community for the given device. Returns 1 if one is
|
||||
# found, 0 otherwise. Updates the SNMP community cache.
|
||||
# Mark the given device as snmp discovered.
|
||||
########################################################################################
|
||||
sub mark_discovered($$) {
|
||||
my ($self, $device) = @_;
|
||||
|
||||
$self->{'discovered_cache'}->{$device} = 1;
|
||||
}
|
||||
|
||||
########################################################################################
|
||||
# Validate the configuration for the given device.
|
||||
# Returns 1 if successfull snmp contact, 0 otherwise.
|
||||
# Updates the SNMP community cache on v1, v2 and v2c.
|
||||
########################################################################################
|
||||
sub snmp_responds($$) {
|
||||
my ($self, $device) = @_;
|
||||
|
||||
# We already have a working SNMP community for this device.
|
||||
return 1 if (defined($self->get_community($device)));
|
||||
return 1 if($self->is_snmp_discovered($device));
|
||||
|
||||
return ($self->{'snmp_version'} eq "3")
|
||||
? $self->snmp_responds_v3($device)
|
||||
: $self->snmp_responds_v122c($device);
|
||||
}
|
||||
|
||||
########################################################################################
|
||||
# Looks for a working SNMP community for the given device. Returns 1 if one is
|
||||
# found, 0 otherwise. Updates the SNMP community cache.
|
||||
########################################################################################
|
||||
sub snmp_responds_v122c($$) {
|
||||
my ($self, $device) = @_;
|
||||
|
||||
foreach my $community (@{$self->{'communities'}}) {
|
||||
|
||||
# Clean blanks.
|
||||
$community =~ s/\s+//g;
|
||||
|
||||
`snmpwalk -M/dev/null -r$self->{'snmp_checks'} -t$self->{'snmp_timeout'} -v1 -On -Oe -c $community $device .0 2>/dev/null`;
|
||||
my $command = $self->snmp_get_command($device, ".0", $community);
|
||||
`$command`;
|
||||
if ($? == 0) {
|
||||
$self->set_community($device, $community);
|
||||
$self->mark_discovered($device);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
@ -1023,6 +1129,25 @@ sub snmp_responds($$) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
########################################################################################
|
||||
# Validate the SNMP v3 configuration for a device.
|
||||
# Returns 1 if successfull snmp contact, 0 otherwise.
|
||||
########################################################################################
|
||||
sub snmp_responds_v3($$) {
|
||||
my ($self, $device) = @_;
|
||||
|
||||
my $command = $self->snmp_get_command($device, ".0");
|
||||
`$command`;
|
||||
|
||||
if ($? == 0) {
|
||||
$self->mark_discovered($device);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
##############################################################################
|
||||
# Parse the local ARP cache.
|
||||
##############################################################################
|
||||
|
@ -1309,8 +1434,8 @@ sub snmp_get($$$) {
|
|||
my ($self, $device, $oid) = @_;
|
||||
my @output;
|
||||
|
||||
return () unless defined $self->is_snmp_discovered($device);
|
||||
my $community = $self->get_community($device);
|
||||
return () unless defined ($community);
|
||||
|
||||
# Check the SNMP query cache first.
|
||||
if (defined($self->{'snmp_cache'}->{"${device}_${oid}"})) {
|
||||
|
@ -1320,13 +1445,15 @@ sub snmp_get($$$) {
|
|||
# Check VLANS.
|
||||
my @vlans = $self->get_vlans($device);
|
||||
if (scalar(@vlans) == 0) {
|
||||
@output = `snmpwalk -M/dev/null -r$self->{'snmp_checks'} -t$self->{'snmp_timeout'} -v1 -On -Oe -c $community $device $oid 2>/dev/null`;
|
||||
my $command = $self->snmp_get_command($device, $oid, $community);
|
||||
@output = `$command`;
|
||||
}
|
||||
else {
|
||||
# Handle duplicate lines.
|
||||
my %output_hash;
|
||||
foreach my $vlan (@vlans) {
|
||||
foreach my $line (`snmpwalk -M/dev/null -r$self->{'snmp_checks'} -t$self->{'snmp_timeout'} -v1 -On -Oe -c $community\@$vlan $device $oid 2>/dev/null`) {
|
||||
my $command = $self->snmp_get_command($device, $oid, $community, $vlan);
|
||||
foreach my $line (`$vlan`) {
|
||||
$output_hash{$line} = 1;
|
||||
}
|
||||
}
|
||||
|
@ -1339,6 +1466,30 @@ sub snmp_get($$$) {
|
|||
return @output;
|
||||
}
|
||||
|
||||
########################################################################################
|
||||
# Get the snmpwalk command seing version 1, 2, 2c or 3.
|
||||
########################################################################################
|
||||
sub snmp_get_command {
|
||||
my ($self, $device, $oid, $community, $vlan) = @_;
|
||||
$vlan = defined($vlan) ? "\@" . $vlan : '';
|
||||
|
||||
my $command = "snmpwalk -M/dev/null -r$self->{'snmp_checks'} -t$self->{'snmp_timeout'} -v$self->{'snmp_version'} -On -Oe ";
|
||||
if ($self->{'snmp_version'} eq "3") {
|
||||
$command .= " -l$self->{'snmp_security_level'} ";
|
||||
if ($self->{'snmp_security_level'} ne "noAuthNoPriv") {
|
||||
$command .= " -u$self->{'snmp_auth_user'} -a$self->{'snmp_auth_method'} -A$self->{'snmp_auth_pass'} ";
|
||||
}
|
||||
if ($self->{'snmp_security_level'} eq "authPriv") {
|
||||
$command .= " -x$self->{'snmp_privacy_method'} -X$self->{'snmp_privacy_pass'} ";
|
||||
}
|
||||
} else {
|
||||
$command .= " -c$community$vlan ";
|
||||
}
|
||||
|
||||
return "$command $device $oid 2>/dev/null";
|
||||
|
||||
}
|
||||
|
||||
########################################################################################
|
||||
# Performs an SNMP WALK and returns the value of the given OID. Returns undef
|
||||
# on error.
|
||||
|
|
|
@ -173,7 +173,16 @@ sub data_consumer ($$) {
|
|||
pa_config => $pa_config,
|
||||
recon_ports => $task->{'recon_ports'},
|
||||
resolve_names => $task->{'resolve_names'},
|
||||
snmp_auth_user => $task->{'snmp_auth_user'},
|
||||
snmp_auth_pass => $task->{'snmp_auth_pass'},
|
||||
snmp_auth_method => $task->{'snmp_auth_method'},
|
||||
snmp_checks => $task->{'snmp_checks'},
|
||||
snmp_enabled => $task->{'snmp_enabled'},
|
||||
snmp_privacy_method => $task->{'snmp_privacy_method'},
|
||||
snmp_privacy_pass => $task->{'snmp_privacy_pass'},
|
||||
snmp_security_level => $task->{'snmp_security_level'},
|
||||
snmp_timeout => $task->{'snmp_timeout'},
|
||||
snmp_version => $task->{'snmp_version'},
|
||||
subnets => \@subnets,
|
||||
task_id => $task->{'id_rt'},
|
||||
vlan_cache_enabled => $task->{'vlan_enabled'},
|
||||
|
@ -310,10 +319,17 @@ sub PandoraFMS::Recon::Base::create_network_profile_modules($$$) {
|
|||
$self->call('message', "Network component ID " . $np_component->{'id_nc'} . " not found.", 5);
|
||||
next;
|
||||
}
|
||||
|
||||
|
||||
# Use snmp_community from network task instead the component snmp_community
|
||||
$component->{'snmp_community'} = safe_output($self->get_community($device));
|
||||
|
||||
$component->{'tcp_send'} = $self->{'snmp_version'};
|
||||
$component->{'custom_string_1'} = $self->{'snmp_privacy_method'};
|
||||
$component->{'custom_string_2'} = $self->{'snmp_privacy_pass'};
|
||||
$component->{'custom_string_3'} = $self->{'snmp_security_level'};
|
||||
$component->{'plugin_parameter'} = $self->{'snmp_auth_method'};
|
||||
$component->{'plugin_user'} = $self->{'snmp_auth_user'};
|
||||
$component->{'plugin_pass'} = $self->{'snmp_auth_pass'};
|
||||
|
||||
pandora_create_module_from_network_component($self->{'pa_config'}, $component, $agent_id, $self->{'dbh'});
|
||||
}
|
||||
}
|
||||
|
@ -466,8 +482,8 @@ sub PandoraFMS::Recon::Base::create_agent($$) {
|
|||
}
|
||||
|
||||
# Add interfaces to the agent if it responds to SNMP.
|
||||
return $agent_id unless ($self->is_snmp_discovered($device));
|
||||
my $community = $self->get_community($device);
|
||||
return $agent_id unless defined($community);
|
||||
|
||||
my @output = $self->snmp_get_value_array($device, $PandoraFMS::Recon::Base::IFINDEX);
|
||||
foreach my $if_index (@output) {
|
||||
|
@ -506,7 +522,13 @@ sub PandoraFMS::Recon::Base::create_agent($$) {
|
|||
'descripcion' => $if_desc,
|
||||
'id_agente' => $agent_id,
|
||||
'ip_target' => $device,
|
||||
'tcp_send' => 1,
|
||||
'tcp_send' => $self->{'snmp_version'},
|
||||
'custom_string_1' => $self->{'snmp_privacy_method'},
|
||||
'custom_string_2' => $self->{'snmp_privacy_pass'},
|
||||
'custom_string_3' => $self->{'snmp_security_level'},
|
||||
'plugin_parameter' => $self->{'snmp_auth_method'},
|
||||
'plugin_user' => $self->{'snmp_auth_user'},
|
||||
'plugin_pass' => $self->{'snmp_auth_pass'},
|
||||
'snmp_community' => $community,
|
||||
'snmp_oid' => "$PandoraFMS::Recon::Base::IFOPERSTATUS.$if_index"
|
||||
);
|
||||
|
@ -516,6 +538,14 @@ sub PandoraFMS::Recon::Base::create_agent($$) {
|
|||
'descripcion' => $if_desc,
|
||||
'ip_target' => $device,
|
||||
'snmp_community' => $community,
|
||||
'tcp_send' => $self->{'snmp_version'},
|
||||
'custom_string_1' => $self->{'snmp_privacy_method'},
|
||||
'custom_string_2' => $self->{'snmp_privacy_pass'},
|
||||
'custom_string_3' => $self->{'snmp_security_level'},
|
||||
'plugin_parameter' => $self->{'snmp_auth_method'},
|
||||
'plugin_user' => $self->{'snmp_auth_user'},
|
||||
'plugin_pass' => $self->{'snmp_auth_pass'},
|
||||
'tcp_send' => $self->{'snmp_version'},
|
||||
);
|
||||
pandora_update_module_from_hash ($self->{'pa_config'}, \%module, 'id_agente_modulo', $module_id, $self->{'dbh'});
|
||||
}
|
||||
|
@ -531,7 +561,13 @@ sub PandoraFMS::Recon::Base::create_agent($$) {
|
|||
'descripcion' => 'The total number of octets received on the interface, including framing characters. This object is a 64-bit version of ifInOctets.',
|
||||
'id_agente' => $agent_id,
|
||||
'ip_target' => $device,
|
||||
'tcp_send' => 1,
|
||||
'tcp_send' => $self->{'snmp_version'},
|
||||
'custom_string_1' => $self->{'snmp_privacy_method'},
|
||||
'custom_string_2' => $self->{'snmp_privacy_pass'},
|
||||
'custom_string_3' => $self->{'snmp_security_level'},
|
||||
'plugin_parameter' => $self->{'snmp_auth_method'},
|
||||
'plugin_user' => $self->{'snmp_auth_user'},
|
||||
'plugin_pass' => $self->{'snmp_auth_pass'},
|
||||
'snmp_community' => $community,
|
||||
'snmp_oid' => "$PandoraFMS::Recon::Base::IFHCINOCTECTS.$if_index");
|
||||
pandora_create_module_from_hash ($self->{'pa_config'}, \%module, $self->{'dbh'});
|
||||
|
@ -539,6 +575,13 @@ sub PandoraFMS::Recon::Base::create_agent($$) {
|
|||
my %module = (
|
||||
'ip_target' => $device,
|
||||
'snmp_community' => $community,
|
||||
'tcp_send' => $self->{'snmp_version'},
|
||||
'custom_string_1' => $self->{'snmp_privacy_method'},
|
||||
'custom_string_2' => $self->{'snmp_privacy_pass'},
|
||||
'custom_string_3' => $self->{'snmp_security_level'},
|
||||
'plugin_parameter' => $self->{'snmp_auth_method'},
|
||||
'plugin_user' => $self->{'snmp_auth_user'},
|
||||
'plugin_pass' => $self->{'snmp_auth_pass'},
|
||||
);
|
||||
pandora_update_module_from_hash ($self->{'pa_config'}, \%module, 'id_agente_modulo', $module_id, $self->{'dbh'});
|
||||
}
|
||||
|
@ -553,7 +596,13 @@ sub PandoraFMS::Recon::Base::create_agent($$) {
|
|||
'descripcion' => 'The total number of octets received on the interface, including framing characters.',
|
||||
'id_agente' => $agent_id,
|
||||
'ip_target' => $device,
|
||||
'tcp_send' => 1,
|
||||
'tcp_send' => $self->{'snmp_version'},
|
||||
'custom_string_1' => $self->{'snmp_privacy_method'},
|
||||
'custom_string_2' => $self->{'snmp_privacy_pass'},
|
||||
'custom_string_3' => $self->{'snmp_security_level'},
|
||||
'plugin_parameter' => $self->{'snmp_auth_method'},
|
||||
'plugin_user' => $self->{'snmp_auth_user'},
|
||||
'plugin_pass' => $self->{'snmp_auth_pass'},
|
||||
'snmp_community' => $community,
|
||||
'snmp_oid' => "$PandoraFMS::Recon::Base::IFINOCTECTS.$if_index");
|
||||
pandora_create_module_from_hash ($self->{'pa_config'}, \%module, $self->{'dbh'});
|
||||
|
@ -561,6 +610,13 @@ sub PandoraFMS::Recon::Base::create_agent($$) {
|
|||
my %module = (
|
||||
'ip_target' => $device,
|
||||
'snmp_community' => $community,
|
||||
'tcp_send' => $self->{'snmp_version'},
|
||||
'custom_string_1' => $self->{'snmp_privacy_method'},
|
||||
'custom_string_2' => $self->{'snmp_privacy_pass'},
|
||||
'custom_string_3' => $self->{'snmp_security_level'},
|
||||
'plugin_parameter' => $self->{'snmp_auth_method'},
|
||||
'plugin_user' => $self->{'snmp_auth_user'},
|
||||
'plugin_pass' => $self->{'snmp_auth_pass'},
|
||||
);
|
||||
pandora_update_module_from_hash ($self->{'pa_config'}, \%module, 'id_agente_modulo', $module_id, $self->{'dbh'});
|
||||
}
|
||||
|
@ -577,7 +633,13 @@ sub PandoraFMS::Recon::Base::create_agent($$) {
|
|||
'descripcion' => 'The total number of octets received on the interface, including framing characters. This object is a 64-bit version of ifOutOctets.',
|
||||
'id_agente' => $agent_id,
|
||||
'ip_target' => $device,
|
||||
'tcp_send' => 1,
|
||||
'tcp_send' => $self->{'snmp_version'},
|
||||
'custom_string_1' => $self->{'snmp_privacy_method'},
|
||||
'custom_string_2' => $self->{'snmp_privacy_pass'},
|
||||
'custom_string_3' => $self->{'snmp_security_level'},
|
||||
'plugin_parameter' => $self->{'snmp_auth_method'},
|
||||
'plugin_user' => $self->{'snmp_auth_user'},
|
||||
'plugin_pass' => $self->{'snmp_auth_pass'},
|
||||
'snmp_community' => $community,
|
||||
'snmp_oid' => "$PandoraFMS::Recon::Base::IFHCOUTOCTECTS.$if_index");
|
||||
pandora_create_module_from_hash ($self->{'pa_config'}, \%module, $self->{'dbh'});
|
||||
|
@ -585,6 +647,14 @@ sub PandoraFMS::Recon::Base::create_agent($$) {
|
|||
my %module = (
|
||||
'ip_target' => $device,
|
||||
'snmp_community' => $community,
|
||||
'tcp_send' => $self->{'snmp_version'},
|
||||
'tcp_send' => $self->{'snmp_version'},
|
||||
'custom_string_1' => $self->{'snmp_privacy_method'},
|
||||
'custom_string_2' => $self->{'snmp_privacy_pass'},
|
||||
'custom_string_3' => $self->{'snmp_security_level'},
|
||||
'plugin_parameter' => $self->{'snmp_auth_method'},
|
||||
'plugin_user' => $self->{'snmp_auth_user'},
|
||||
'plugin_pass' => $self->{'snmp_auth_pass'},
|
||||
);
|
||||
pandora_update_module_from_hash ($self->{'pa_config'}, \%module, 'id_agente_modulo', $module_id, $self->{'dbh'});
|
||||
}
|
||||
|
@ -599,7 +669,13 @@ sub PandoraFMS::Recon::Base::create_agent($$) {
|
|||
'descripcion' => 'The total number of octets received on the interface, including framing characters.',
|
||||
'id_agente' => $agent_id,
|
||||
'ip_target' => $device,
|
||||
'tcp_send' => 1,
|
||||
'tcp_send' => $self->{'snmp_version'},
|
||||
'custom_string_1' => $self->{'snmp_privacy_method'},
|
||||
'custom_string_2' => $self->{'snmp_privacy_pass'},
|
||||
'custom_string_3' => $self->{'snmp_security_level'},
|
||||
'plugin_parameter' => $self->{'snmp_auth_method'},
|
||||
'plugin_user' => $self->{'snmp_auth_user'},
|
||||
'plugin_pass' => $self->{'snmp_auth_pass'},
|
||||
'snmp_community' => $community,
|
||||
'snmp_oid' => "$PandoraFMS::Recon::Base::IFOUTOCTECTS.$if_index");
|
||||
pandora_create_module_from_hash ($self->{'pa_config'}, \%module, $self->{'dbh'});
|
||||
|
@ -607,6 +683,14 @@ sub PandoraFMS::Recon::Base::create_agent($$) {
|
|||
my %module = (
|
||||
'ip_target' => $device,
|
||||
'snmp_community' => $community,
|
||||
'tcp_send' => $self->{'snmp_version'},
|
||||
'tcp_send' => $self->{'snmp_version'},
|
||||
'custom_string_1' => $self->{'snmp_privacy_method'},
|
||||
'custom_string_2' => $self->{'snmp_privacy_pass'},
|
||||
'custom_string_3' => $self->{'snmp_security_level'},
|
||||
'plugin_parameter' => $self->{'snmp_auth_method'},
|
||||
'plugin_user' => $self->{'snmp_auth_user'},
|
||||
'plugin_pass' => $self->{'snmp_auth_pass'},
|
||||
);
|
||||
pandora_update_module_from_hash ($self->{'pa_config'}, \%module, 'id_agente_modulo', $module_id, $self->{'dbh'});
|
||||
}
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
# Pandora FMS Server
|
||||
#
|
||||
%define name pandorafms_server
|
||||
%define version 7.0NG.726
|
||||
%define release 180904
|
||||
%define version 7.0NG.727
|
||||
%define release 180918
|
||||
|
||||
Summary: Pandora FMS Server
|
||||
Name: %{name}
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
# Pandora FMS Server
|
||||
#
|
||||
%define name pandorafms_server
|
||||
%define version 7.0NG.726
|
||||
%define release 180904
|
||||
%define version 7.0NG.727
|
||||
%define release 180918
|
||||
|
||||
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="180904"
|
||||
PI_VERSION="7.0NG.727"
|
||||
PI_BUILD="180918"
|
||||
|
||||
MODE=$1
|
||||
if [ $# -gt 1 ]; then
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue