Resolved merge conflict and fixed bugs
This commit is contained in:
commit
dab4676a33
|
@ -1,5 +1,5 @@
|
|||
# Base config file for Pandora FMS agents
|
||||
# Version 7.0NG.738, AIX version
|
||||
# Version 7.0NG.740, 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.738, FreeBSD Version
|
||||
# Version 7.0NG.740, 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.738, HP-UX Version
|
||||
# Version 7.0NG.740, 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.738, GNU/Linux
|
||||
# Version 7.0NG.740, 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.738, GNU/Linux
|
||||
# Version 7.0NG.740, 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.738, Solaris Version
|
||||
# Version 7.0NG.740, 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.738
|
||||
# Version 7.0NG.740
|
||||
|
||||
# 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.738, AIX version
|
||||
# Version 7.0NG.740, 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.738
|
||||
# Version 7.0NG.740
|
||||
# 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.738, HPUX Version
|
||||
# Version 7.0NG.740, HPUX Version
|
||||
|
||||
# General Parameters
|
||||
# ==================
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# Base config file for Pandora FMS agents
|
||||
# Version 7.0NG.738
|
||||
# Version 7.0NG.740
|
||||
# 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.738
|
||||
# Version 7.0NG.740
|
||||
# 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.738
|
||||
# Version 7.0NG.740
|
||||
# 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.738, Solaris version
|
||||
# Version 7.0NG.740, Solaris version
|
||||
|
||||
# General Parameters
|
||||
# ==================
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# Base config file for Pandora FMS agents
|
||||
# Version 7.0NG.738, AIX version
|
||||
# Version 7.0NG.740, 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.738-190923
|
||||
Version: 7.0NG.740-191029
|
||||
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.738-190923"
|
||||
pandora_version="7.0NG.740-191029"
|
||||
|
||||
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.738, GNU/Linux
|
||||
# Version 7.0NG.740, 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.738, FreeBSD Version
|
||||
# Version 7.0NG.740, 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.738, HP-UX Version
|
||||
# Version 7.0NG.740, 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.738, GNU/Linux
|
||||
# Version 7.0NG.740, 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.738, GNU/Linux
|
||||
# Version 7.0NG.740, 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.738, NetBSD Version
|
||||
# Version 7.0NG.740, 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.738, Solaris Version
|
||||
# Version 7.0NG.740, 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.738';
|
||||
use constant AGENT_BUILD => '190923';
|
||||
use constant AGENT_VERSION => '7.0NG.740';
|
||||
use constant AGENT_BUILD => '191029';
|
||||
|
||||
# Agent log default file size maximum and instances
|
||||
use constant DEFAULT_MAX_LOG_SIZE => 600000;
|
||||
|
@ -239,6 +239,15 @@ my $tentacle_pid = undef;
|
|||
# PID of udp_server
|
||||
my $udp_server_pid = undef;
|
||||
|
||||
# BrokerFlag
|
||||
my $BrokerFlag = 0;
|
||||
|
||||
# Global loop counter.
|
||||
my $LoopCounter = 0;
|
||||
|
||||
# Define a max value for loopCounter to avoid overflow.
|
||||
use constant MAX_LOOP_COUNTER => 1000000000;
|
||||
|
||||
################################################################################
|
||||
# Print usage information and exit.
|
||||
################################################################################
|
||||
|
@ -1385,6 +1394,7 @@ sub sleep_agent {
|
|||
exit (0);
|
||||
}
|
||||
|
||||
$LoopCounter = ($LoopCounter + 1) % MAX_LOOP_COUNTER;
|
||||
return $iter_base_time;
|
||||
}
|
||||
|
||||
|
@ -1699,6 +1709,14 @@ sub exec_module {
|
|||
}
|
||||
|
||||
# Check module interval
|
||||
if ($BrokerFlag > 0) {
|
||||
if ($LoopCounter == 0) {
|
||||
$module->{'counter'} = $module->{'intensive_interval'};
|
||||
} else {
|
||||
$module->{'counter'} = (($LoopCounter -1 ) % $module->{'intensive_interval'});
|
||||
}
|
||||
}
|
||||
|
||||
if (++($module->{'counter'}) < $module->{'intensive_interval'}) {
|
||||
$ThreadSem->up () if (defined ($ThreadSem) && $Conf{'agent_threads'} > 1);
|
||||
return;
|
||||
|
@ -2985,7 +3003,6 @@ while (1) {
|
|||
@BrokerPid = ();
|
||||
my @broker_agents = read_config ('broker_agent');
|
||||
foreach my $broker_agent (@broker_agents) {
|
||||
|
||||
# Create broker conf file if it does not exist
|
||||
if (! -e "$ConfDir/${broker_agent}.conf") {
|
||||
write_broker_conf($broker_agent);
|
||||
|
@ -2995,6 +3012,8 @@ while (1) {
|
|||
|
||||
# Broker agent
|
||||
if ($main_agent == 0) {
|
||||
# Mark broker flag.
|
||||
$BrokerFlag = 1;
|
||||
|
||||
# Set the configuration file
|
||||
$ConfFile = "${broker_agent}.conf";
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
#Pandora FMS Linux Agent
|
||||
#
|
||||
%define name pandorafms_agent_unix
|
||||
%define version 7.0NG.738
|
||||
%define release 190923
|
||||
%define version 7.0NG.740
|
||||
%define release 191029
|
||||
|
||||
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.738
|
||||
%define release 190923
|
||||
%define version 7.0NG.740
|
||||
%define release 191029
|
||||
|
||||
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.738"
|
||||
PI_BUILD="190923"
|
||||
PI_VERSION="7.0NG.740"
|
||||
PI_BUILD="191029"
|
||||
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.738
|
||||
# Version 7.0NG.740
|
||||
|
||||
# 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.738}
|
||||
{Pandora FMS Windows Agent v7.0NG.740}
|
||||
|
||||
ApplicationID
|
||||
{17E3D2CF-CA02-406B-8A80-9D31C17BD08F}
|
||||
|
@ -186,7 +186,7 @@ UpgradeApplicationID
|
|||
{}
|
||||
|
||||
Version
|
||||
{190923}
|
||||
{191029}
|
||||
|
||||
ViewReadme
|
||||
{Yes}
|
||||
|
|
|
@ -1423,48 +1423,48 @@ Pandora_Module::evaluatePreconditions () {
|
|||
output += (char *) buffer;
|
||||
}
|
||||
|
||||
try {
|
||||
double_output = Pandora_Strutils::strtodouble (output);
|
||||
} catch (Pandora_Strutils::Invalid_Conversion e) {
|
||||
double_output = 0;
|
||||
try {
|
||||
double_output = Pandora_Strutils::strtodouble (output);
|
||||
} catch (Pandora_Strutils::Invalid_Conversion e) {
|
||||
double_output = 0;
|
||||
}
|
||||
|
||||
if (dwRet == WAIT_OBJECT_0) {
|
||||
break;
|
||||
} else if(this->getTimeout() < GetTickCount() - tickbase) {
|
||||
/* STILL_ACTIVE */
|
||||
TerminateProcess(pi.hThread, STILL_ACTIVE);
|
||||
pandoraLog ("evaluatePreconditions: %s timed out (retcode: %d)", this->module_name.c_str (), STILL_ACTIVE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (dwRet == WAIT_OBJECT_0) {
|
||||
break;
|
||||
} else if(this->getTimeout() < GetTickCount() - tickbase) {
|
||||
/* STILL_ACTIVE */
|
||||
TerminateProcess(pi.hThread, STILL_ACTIVE);
|
||||
pandoraLog ("evaluatePreconditions: %s timed out (retcode: %d)", this->module_name.c_str (), STILL_ACTIVE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
GetExitCodeProcess (pi.hProcess, &retval);
|
||||
|
||||
GetExitCodeProcess (pi.hProcess, &retval);
|
||||
|
||||
if (retval != 0) {
|
||||
if (! TerminateJobObject (job, 0)) {
|
||||
pandoraLog ("evaluatePreconditions: TerminateJobObject failed. (error %d)",
|
||||
GetLastError ());
|
||||
if (retval != 0) {
|
||||
if (! TerminateJobObject (job, 0)) {
|
||||
pandoraLog ("evaluatePreconditions: TerminateJobObject failed. (error %d)",
|
||||
GetLastError ());
|
||||
}
|
||||
if (retval != STILL_ACTIVE) {
|
||||
pandoraLog ("evaluatePreconditions: %s did not executed well (retcode: %d)",
|
||||
this->module_name.c_str (), retval);
|
||||
}
|
||||
/* Close job, process and thread handles. */
|
||||
CloseHandle (job);
|
||||
CloseHandle (pi.hProcess);
|
||||
CloseHandle (pi.hThread);
|
||||
CloseHandle (new_stdout);
|
||||
CloseHandle (out_read);
|
||||
return 0;
|
||||
}
|
||||
if (retval != STILL_ACTIVE) {
|
||||
pandoraLog ("evaluatePreconditions: %s did not executed well (retcode: %d)",
|
||||
this->module_name.c_str (), retval);
|
||||
}
|
||||
|
||||
/* Close job, process and thread handles. */
|
||||
CloseHandle (job);
|
||||
CloseHandle (pi.hProcess);
|
||||
CloseHandle (pi.hThread);
|
||||
CloseHandle (new_stdout);
|
||||
CloseHandle (out_read);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Close job, process and thread handles. */
|
||||
CloseHandle (job);
|
||||
CloseHandle (pi.hProcess);
|
||||
CloseHandle (pi.hThread);
|
||||
}
|
||||
|
||||
CloseHandle (new_stdout);
|
||||
CloseHandle (out_read);
|
||||
|
||||
|
@ -1693,4 +1693,18 @@ Pandora_Module::getAsync () {
|
|||
return this->async;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get current exections
|
||||
*/
|
||||
long
|
||||
Pandora_Module::getExecutions () {
|
||||
return this->executions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set current execution (global) used for brokers.
|
||||
*/
|
||||
void
|
||||
Pandora_Module::setExecutions (long executions) {
|
||||
this->executions = executions;
|
||||
}
|
||||
|
|
|
@ -234,6 +234,8 @@ namespace Pandora_Modules {
|
|||
int getTimeout ();
|
||||
string getSave ();
|
||||
bool getAsync ();
|
||||
void setExecutions(long executions=0);
|
||||
long getExecutions();
|
||||
|
||||
virtual string getXml ();
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ using namespace Pandora;
|
|||
using namespace Pandora_Strutils;
|
||||
|
||||
#define PATH_SIZE _MAX_PATH+1
|
||||
#define PANDORA_VERSION ("7.0NG.738(Build 190923)")
|
||||
#define PANDORA_VERSION ("7.0NG.740(Build 191029)")
|
||||
|
||||
string pandora_path;
|
||||
string pandora_dir;
|
||||
|
|
|
@ -1849,7 +1849,7 @@ Pandora_Windows_Service::sendBufferedXml (string path) {
|
|||
}
|
||||
|
||||
void
|
||||
Pandora_Windows_Service::pandora_run_broker (string config) {
|
||||
Pandora_Windows_Service::pandora_run_broker (string config, long executions) {
|
||||
Pandora_Agent_Conf *conf = NULL;
|
||||
string server_addr;
|
||||
unsigned char data_flag = 0;
|
||||
|
@ -1877,6 +1877,9 @@ Pandora_Windows_Service::pandora_run_broker (string config) {
|
|||
|
||||
module = this->broker_modules->getCurrentValue ();
|
||||
|
||||
/* Keep executions matching main agent */
|
||||
module->setExecutions(executions);
|
||||
|
||||
/* Check preconditions */
|
||||
if (module->evaluatePreconditions () == 0) {
|
||||
pandoraDebug ("Preconditions not matched for module %s", module->getName ().c_str ());
|
||||
|
@ -2074,7 +2077,7 @@ Pandora_Windows_Service::pandora_run (int forced_run) {
|
|||
check_broker_agents(all_conf);
|
||||
for (i=0;i<num;i++){
|
||||
pandora_init_broker(all_conf[i]);
|
||||
pandora_run_broker(all_conf[i]);
|
||||
pandora_run_broker(all_conf[i], execution_number);
|
||||
}
|
||||
delete []all_conf;
|
||||
|
||||
|
|
|
@ -87,7 +87,7 @@ namespace Pandora {
|
|||
int checkConfig (string file);
|
||||
void purgeDiskCollections ();
|
||||
void pandora_init_broker (string file_conf);
|
||||
void pandora_run_broker (string config);
|
||||
void pandora_run_broker (string config, long executions=0);
|
||||
int count_broker_agents();
|
||||
void check_broker_agents(string *all_conf);
|
||||
int launchTentacleProxy();
|
||||
|
|
|
@ -11,7 +11,7 @@ BEGIN
|
|||
VALUE "LegalCopyright", "Artica ST"
|
||||
VALUE "OriginalFilename", "PandoraAgent.exe"
|
||||
VALUE "ProductName", "Pandora FMS Windows Agent"
|
||||
VALUE "ProductVersion", "(7.0NG.738(Build 190923))"
|
||||
VALUE "ProductVersion", "(7.0NG.740(Build 191029))"
|
||||
VALUE "FileVersion", "1.0.0.0"
|
||||
END
|
||||
END
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
package: pandorafms-console
|
||||
Version: 7.0NG.738-190923
|
||||
Version: 7.0NG.740-191029
|
||||
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.738-190923"
|
||||
pandora_version="7.0NG.740-191029"
|
||||
|
||||
package_pear=0
|
||||
package_pandora=1
|
||||
|
|
|
@ -238,18 +238,6 @@ function output_xml_report($id)
|
|||
echo '<line_separator><![CDATA['.io_safe_output($item['line_separator']).']]></line_separator>';
|
||||
echo '<column_separator><![CDATA['.io_safe_output($item['header_definition']).']]></column_separator>';
|
||||
break;
|
||||
|
||||
case 'TTRT':
|
||||
break;
|
||||
|
||||
case 'TTO':
|
||||
break;
|
||||
|
||||
case 'MTBF':
|
||||
break;
|
||||
|
||||
case 'MTTR':
|
||||
break;
|
||||
}
|
||||
|
||||
echo "</item>\n";
|
||||
|
|
|
@ -375,18 +375,6 @@ function process_upload_xml_report($xml, $group_filter=0)
|
|||
$values['line_separator'] = io_safe_input($item['line_separator']);
|
||||
$values['column_separator'] = io_safe_input($item['column_separator']);
|
||||
break;
|
||||
|
||||
case 'TTRT':
|
||||
break;
|
||||
|
||||
case 'TTO':
|
||||
break;
|
||||
|
||||
case 'MTBF':
|
||||
break;
|
||||
|
||||
case 'MTTR':
|
||||
break;
|
||||
}
|
||||
|
||||
if (empty($agents_item)) {
|
||||
|
|
|
@ -0,0 +1,66 @@
|
|||
<?php
|
||||
|
||||
// Pandora FMS - http://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2019 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; 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 __DIR__.'/../include/config.php';
|
||||
require_once __DIR__.'/../include/auth/mysql.php';
|
||||
require_once __DIR__.'/../include/functions.php';
|
||||
require_once __DIR__.'/../include/functions_db.php';
|
||||
/*
|
||||
* Review if sample agent is active and deploys configuration for
|
||||
* visual consoles if necessary
|
||||
*/
|
||||
global $config;
|
||||
|
||||
// Deployment of sample agent for visual consoles.
|
||||
if ($config['sample_agent'] == 1 && !isset($config['sample_agent_deployed'])) {
|
||||
$id_agente = db_get_sql('SELECT id_agente FROM tagente WHERE nombre = "Sample_Agent";');
|
||||
$modules = db_get_all_rows_filter('tagente_modulo', ['id_agente' => $id_agente], 'id_agente_modulo');
|
||||
$count_modules = count($modules);
|
||||
|
||||
// Update of layout 1 (Rack sample).
|
||||
$images_rack_server = [
|
||||
'rack_server_rack',
|
||||
'rack_server',
|
||||
'rack_switch',
|
||||
'rack_firewall',
|
||||
'rack_double_server',
|
||||
'rack_frame',
|
||||
'rack_pdu',
|
||||
];
|
||||
$query = 'UPDATE `tlayout_data` SET `id_agent` = '.$id_agente.', `id_agente_modulo` = CASE ';
|
||||
for ($i = 0; $i < $count_modules; $i++) {
|
||||
$query .= 'WHEN `image` = "'.$images_rack_server[$i].'" THEN '.$modules[$i]['id_agente_modulo'].' ';
|
||||
}
|
||||
|
||||
$query .= 'END WHERE `id_layout` = 1 AND `image` IN ("'.implode('","', $images_rack_server).'");';
|
||||
|
||||
db_process_sql($query);
|
||||
// Update of layout 2 (Dashboard).
|
||||
$query = 'UPDATE `tlayout_data` SET `id_agent`= '.$id_agente.', `id_agente_modulo` = CASE ';
|
||||
$query .= 'WHEN `id` = 107 THEN '.$modules[0]['id_agente_modulo'].' ';
|
||||
$query .= 'WHEN `id` = 108 THEN '.$modules[1]['id_agente_modulo'].' ';
|
||||
$query .= 'WHEN `id` = 109 THEN '.$modules[2]['id_agente_modulo'].' ';
|
||||
$query .= 'WHEN `id` = 110 THEN '.$modules[2]['id_agente_modulo'].' ';
|
||||
$query .= 'WHEN `id` = 111 THEN '.$modules[3]['id_agente_modulo'].' ';
|
||||
$query .= 'WHEN `id` = 112 THEN '.$modules[4]['id_agente_modulo'].' ';
|
||||
$query .= 'WHEN `id` = 113 THEN '.$modules[5]['id_agente_modulo'].' ';
|
||||
$query .= 'WHEN `id` = 114 THEN '.$modules[6]['id_agente_modulo'].' ';
|
||||
$query .= 'END WHERE `id_layout` = 2 AND `id` IN (107,108,109,110,111,112,113,114);';
|
||||
|
||||
db_process_sql($query);
|
||||
|
||||
// This setting will avoid regenerate all the times the visual consoles.
|
||||
config_update_value('sample_agent_deployed', 1);
|
||||
}
|
||||
|
||||
extensions_add_main_function('sample_agent_deployment');
|
|
@ -15,9 +15,30 @@ UPDATE `tlayout_data` SET `height` = 70 , `width` = 70 WHERE `height` = 0 && `wi
|
|||
(`type` = 10 && `image` IS NOT NULL && `image` != '' && `image` != 'none') ||
|
||||
(`type` = 11 && `image` IS NOT NULL && `image` != '' && `image` != 'none' && `show_statistics` = 0));
|
||||
|
||||
INSERT INTO `tconfig` (`token`, `value`) VALUES ('integria_enabled', 0);
|
||||
INSERT INTO `tconfig` (`token`, `value`) VALUES ('integria_user', '');
|
||||
INSERT INTO `tconfig` (`token`, `value`) VALUES ('integria_pass', '');
|
||||
INSERT INTO `tconfig` (`token`, `value`) VALUES ('integria_hostname', '');
|
||||
INSERT INTO `tconfig` (`token`, `value`) VALUES ('integria_api_pass', '');
|
||||
INSERT INTO `tconfig` (`token`, `value`) VALUES ('integria_req_timeout', 5);
|
||||
INSERT INTO `tconfig` (`token`, `value`) VALUES ('default_group', '');
|
||||
INSERT INTO `tconfig` (`token`, `value`) VALUES ('default_criticity', '');
|
||||
INSERT INTO `tconfig` (`token`, `value`) VALUES ('default_creator', '');
|
||||
INSERT INTO `tconfig` (`token`, `value`) VALUES ('default_owner', '');
|
||||
INSERT INTO `tconfig` (`token`, `value`) VALUES ('incident_type', '');
|
||||
INSERT INTO `tconfig` (`token`, `value`) VALUES ('incident_status', '');
|
||||
INSERT INTO `tconfig` (`token`, `value`) VALUES ('incident_title', '');
|
||||
INSERT INTO `tconfig` (`token`, `value`) VALUES ('incident_content', '');
|
||||
INSERT INTO `tconfig` (`token`, `value`) VALUES ('cr_default_group', '');
|
||||
INSERT INTO `tconfig` (`token`, `value`) VALUES ('cr_default_criticity', '');
|
||||
INSERT INTO `tconfig` (`token`, `value`) VALUES ('cr_default_creator', '');
|
||||
INSERT INTO `tconfig` (`token`, `value`) VALUES ('cr_default_owner', '');
|
||||
INSERT INTO `tconfig` (`token`, `value`) VALUES ('cr_incident_type', '');
|
||||
INSERT INTO `tconfig` (`token`, `value`) VALUES ('cr_incident_status', '');
|
||||
INSERT INTO `tconfig` (`token`, `value`) VALUES ('cr_incident_title', '');
|
||||
INSERT INTO `tconfig` (`token`, `value`) VALUES ('cr_incident_content', '');
|
||||
|
||||
ALTER TABLE `treport_content` ADD COLUMN `uncompressed_module` TINYINT DEFAULT '0';
|
||||
ALTER TABLE `treport_content_template` ADD COLUMN `uncompressed_module` TINYINT DEFAULT '0';
|
||||
|
||||
|
||||
COMMIT;
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
START TRANSACTION;
|
||||
|
||||
ALTER TABLE `tlayout_template_data` ADD COLUMN `cache_expiration` INTEGER UNSIGNED NOT NULL DEFAULT 0;
|
||||
|
||||
COMMIT;
|
|
@ -1247,19 +1247,39 @@ ALTER TABLE titem MODIFY `source_data` int(10) unsigned;
|
|||
INSERT INTO `tconfig` (`token`, `value`) VALUES ('big_operation_step_datos_purge', '100');
|
||||
INSERT INTO `tconfig` (`token`, `value`) VALUES ('small_operation_step_datos_purge', '1000');
|
||||
INSERT INTO `tconfig` (`token`, `value`) VALUES ('days_autodisable_deletion', '30');
|
||||
INSERT INTO `tconfig` (`token`, `value`) VALUES ('MR', 31);
|
||||
INSERT INTO `tconfig` (`token`, `value`) VALUES ('MR', 32);
|
||||
INSERT INTO `tconfig` (`token`, `value`) VALUES ('custom_docs_logo', 'default_docs.png');
|
||||
INSERT INTO `tconfig` (`token`, `value`) VALUES ('custom_support_logo', 'default_support.png');
|
||||
INSERT INTO `tconfig` (`token`, `value`) VALUES ('custom_logo_white_bg_preview', 'pandora_logo_head_white_bg.png');
|
||||
UPDATE tconfig SET value = 'https://licensing.artica.es/pandoraupdate7/server.php' WHERE token='url_update_manager';
|
||||
DELETE FROM `tconfig` WHERE `token` = 'current_package_enterprise';
|
||||
INSERT INTO `tconfig` (`token`, `value`) VALUES ('current_package_enterprise', '737');
|
||||
INSERT INTO `tconfig` (`token`, `value`) VALUES ('current_package_enterprise', '739');
|
||||
INSERT INTO `tconfig` (`token`, `value`) VALUES ('status_monitor_fields', 'policy,agent,data_type,module_name,server_type,interval,status,graph,warn,data,timestamp');
|
||||
UPDATE `tconfig` SET `value` = 'mini_severity,evento,id_agente,estado,timestamp' WHERE `token` LIKE 'event_fields';
|
||||
DELETE FROM `tconfig` WHERE `token` LIKE 'integria_enabled';
|
||||
DELETE FROM `tconfig` WHERE `token` LIKE 'integria_api_password';
|
||||
DELETE FROM `tconfig` WHERE `token` LIKE 'integria_inventory';
|
||||
DELETE FROM `tconfig` WHERE `token` LIKE 'integria_url';
|
||||
INSERT INTO `tconfig` (`token`, `value`) VALUES ('integria_user', '');
|
||||
INSERT INTO `tconfig` (`token`, `value`) VALUES ('integria_pass', '');
|
||||
INSERT INTO `tconfig` (`token`, `value`) VALUES ('integria_hostname', '');
|
||||
INSERT INTO `tconfig` (`token`, `value`) VALUES ('integria_api_pass', '');
|
||||
INSERT INTO `tconfig` (`token`, `value`) VALUES ('integria_req_timeout', 5);
|
||||
INSERT INTO `tconfig` (`token`, `value`) VALUES ('default_group', '');
|
||||
INSERT INTO `tconfig` (`token`, `value`) VALUES ('default_criticity', '');
|
||||
INSERT INTO `tconfig` (`token`, `value`) VALUES ('default_creator', '');
|
||||
INSERT INTO `tconfig` (`token`, `value`) VALUES ('default_owner', '');
|
||||
INSERT INTO `tconfig` (`token`, `value`) VALUES ('incident_type', '');
|
||||
INSERT INTO `tconfig` (`token`, `value`) VALUES ('incident_status', '');
|
||||
INSERT INTO `tconfig` (`token`, `value`) VALUES ('incident_title', '');
|
||||
INSERT INTO `tconfig` (`token`, `value`) VALUES ('incident_content', '');
|
||||
INSERT INTO `tconfig` (`token`, `value`) VALUES ('cr_default_group', '');
|
||||
INSERT INTO `tconfig` (`token`, `value`) VALUES ('cr_default_criticity', '');
|
||||
INSERT INTO `tconfig` (`token`, `value`) VALUES ('cr_default_creator', '');
|
||||
INSERT INTO `tconfig` (`token`, `value`) VALUES ('cr_default_owner', '');
|
||||
INSERT INTO `tconfig` (`token`, `value`) VALUES ('cr_incident_type', '');
|
||||
INSERT INTO `tconfig` (`token`, `value`) VALUES ('cr_incident_status', '');
|
||||
INSERT INTO `tconfig` (`token`, `value`) VALUES ('cr_incident_title', '');
|
||||
INSERT INTO `tconfig` (`token`, `value`) VALUES ('cr_incident_content', '');
|
||||
|
||||
-- ---------------------------------------------------------------------
|
||||
-- Table `tconfig_os`
|
||||
|
@ -1887,6 +1907,7 @@ CREATE TABLE IF NOT EXISTS `tlayout_template_data` (
|
|||
`linked_layout_status_as_service_warning` FLOAT(20, 3) NOT NULL default 0,
|
||||
`linked_layout_status_as_service_critical` FLOAT(20, 3) NOT NULL default 0,
|
||||
`linked_layout_node_id` INT(10) NOT NULL default 0,
|
||||
`cache_expiration` INTEGER UNSIGNED NOT NULL default 0,
|
||||
PRIMARY KEY(`id`),
|
||||
FOREIGN KEY (`id_layout_template`) REFERENCES tlayout_template(`id`) ON DELETE CASCADE ON UPDATE CASCADE
|
||||
) ENGINE = InnoDB DEFAULT CHARSET=utf8;
|
||||
|
|
|
@ -33,7 +33,7 @@ ui_require_css_file('firts_task');
|
|||
);
|
||||
?>
|
||||
</p>
|
||||
<form action="index.php?sec=estado&sec2=godmode/agentes/planned_downtime.editor" method="post">
|
||||
<form action="index.php?sec=extensions&sec2=godmode/agentes/planned_downtime.editor" method="post">
|
||||
<input type="submit" class="button_task" value="<?php echo __('Create Planned Downtime'); ?>" />
|
||||
</form>
|
||||
</div>
|
||||
|
|
|
@ -765,7 +765,7 @@ $table_adv_agent_icon .= html_print_select(
|
|||
).'</div>';
|
||||
|
||||
if ($config['activate_gis']) {
|
||||
$table_adv_gis = '<div class="label_select_simple label_simple_one_item"><p class="input_label input_label_simple">'.__('Ignore new GIS data:').'</p>';
|
||||
$table_adv_gis = '<div class="label_select_simple label_simple_one_item"><p class="input_label input_label_simple">'.__('Update new GIS data:').'</p>';
|
||||
if ($new_agent) {
|
||||
$update_gis_data = true;
|
||||
}
|
||||
|
|
|
@ -1382,8 +1382,8 @@ if ($update_module || $create_module) {
|
|||
$ff_event_normal = (int) get_parameter('ff_event_normal');
|
||||
$ff_event_warning = (int) get_parameter('ff_event_warning');
|
||||
$ff_event_critical = (int) get_parameter('ff_event_critical');
|
||||
$ff_type = (int) get_parameter('ff_type');
|
||||
$each_ff = (int) get_parameter('each_ff');
|
||||
$ff_type = (int) get_parameter('ff_type', $module['ff_type']);
|
||||
$each_ff = (int) get_parameter('each_ff', $module['each_ff']);
|
||||
$ff_timeout = (int) get_parameter('ff_timeout');
|
||||
$unit = (string) get_parameter('unit');
|
||||
$id_tag = (array) get_parameter('id_tag_selected');
|
||||
|
|
|
@ -842,7 +842,9 @@ foreach ($modules as $module) {
|
|||
$module['str_warning'],
|
||||
$module['max_critical'],
|
||||
$module['min_critical'],
|
||||
$module['str_critical']
|
||||
$module['str_critical'],
|
||||
$module['warning_inverse'],
|
||||
$module['critical_inverse']
|
||||
);
|
||||
} else {
|
||||
$data[7] = '';
|
||||
|
|
|
@ -1191,49 +1191,54 @@ $table_relations->data[-1][3] .= html_print_image('images/lock.png', true).'</a>
|
|||
$table_relations->data[-1][4] = '<a id="delete_relation_button" href="">';
|
||||
$table_relations->data[-1][4] .= html_print_image('images/cross.png', true).'</a>';
|
||||
|
||||
$module_relations = modules_get_relations(['id_module' => $id_agent_module]);
|
||||
if (!$module_relations) {
|
||||
$module_relations = [];
|
||||
}
|
||||
|
||||
$relations_count = 0;
|
||||
foreach ($module_relations as $key => $module_relation) {
|
||||
if ($module_relation['module_a'] == $id_agent_module) {
|
||||
$module_id = $module_relation['module_b'];
|
||||
$agent_id = modules_give_agent_id_from_module_id(
|
||||
$module_relation['module_b']
|
||||
);
|
||||
} else {
|
||||
$module_id = $module_relation['module_a'];
|
||||
$agent_id = modules_give_agent_id_from_module_id(
|
||||
$module_relation['module_a']
|
||||
);
|
||||
if ($id_agent_module) {
|
||||
$module_relations = modules_get_relations(['id_module' => $id_agent_module]);
|
||||
|
||||
if (!$module_relations) {
|
||||
$module_relations = [];
|
||||
}
|
||||
|
||||
$agent_name = ui_print_agent_name($agent_id, true);
|
||||
$relations_count = 0;
|
||||
foreach ($module_relations as $key => $module_relation) {
|
||||
if ($module_relation['module_a'] == $id_agent_module) {
|
||||
$module_id = $module_relation['module_b'];
|
||||
$agent_id = modules_give_agent_id_from_module_id(
|
||||
$module_relation['module_b']
|
||||
);
|
||||
} else {
|
||||
$module_id = $module_relation['module_a'];
|
||||
$agent_id = modules_give_agent_id_from_module_id(
|
||||
$module_relation['module_a']
|
||||
);
|
||||
}
|
||||
|
||||
$module_name = modules_get_agentmodule_name($module_id);
|
||||
if (empty($module_name) || $module_name == 'false') {
|
||||
$module_name = $module_id;
|
||||
$agent_name = ui_print_agent_name($agent_id, true);
|
||||
|
||||
$module_name = modules_get_agentmodule_name($module_id);
|
||||
if (empty($module_name) || $module_name == 'false') {
|
||||
$module_name = $module_id;
|
||||
}
|
||||
|
||||
if ($module_relation['disable_update']) {
|
||||
$disabled_update_class = '';
|
||||
} else {
|
||||
$disabled_update_class = 'alpha50';
|
||||
}
|
||||
|
||||
// Agent name.
|
||||
$table_relations->data[$relations_count][0] = $agent_name;
|
||||
// Module name.
|
||||
$table_relations->data[$relations_count][1] = "<a href='index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&id_agente=".$agent_id.'&tab=module&edit_module=1&id_agent_module='.$module_id."'>".ui_print_truncate_text($module_name, 'module_medium', true, true, true, '[…]').'</a>';
|
||||
// Type.
|
||||
$table_relations->data[$relations_count][2] = ($module_relation['type'] === 'direct') ? __('Direct') : __('Failover');
|
||||
// Lock relationship updates.
|
||||
$table_relations->data[$relations_count][3] = '<a id="disable_updates_button" class="'.$disabled_update_class.'"href="javascript: change_lock_relation('.$relations_count.', '.$module_relation['id'].');">'.html_print_image('images/lock.png', true).'</a>';
|
||||
// Delete relationship.
|
||||
$table_relations->data[$relations_count][4] = '<a id="delete_relation_button" href="javascript: delete_relation('.$relations_count.', '.$module_relation['id'].');">'.html_print_image('images/cross.png', true).'</a>';
|
||||
$relations_count++;
|
||||
}
|
||||
|
||||
if ($module_relation['disable_update']) {
|
||||
$disabled_update_class = '';
|
||||
} else {
|
||||
$disabled_update_class = 'alpha50';
|
||||
}
|
||||
|
||||
// Agent name.
|
||||
$table_relations->data[$relations_count][0] = $agent_name;
|
||||
// Module name.
|
||||
$table_relations->data[$relations_count][1] = "<a href='index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&id_agente=".$agent_id.'&tab=module&edit_module=1&id_agent_module='.$module_id."'>".ui_print_truncate_text($module_name, 'module_medium', true, true, true, '[…]').'</a>';
|
||||
// Type.
|
||||
$table_relations->data[$relations_count][2] = ($module_relation['type'] === 'direct') ? __('Direct') : __('Failover');
|
||||
// Lock relationship updates.
|
||||
$table_relations->data[$relations_count][3] = '<a id="disable_updates_button" class="'.$disabled_update_class.'"href="javascript: change_lock_relation('.$relations_count.', '.$module_relation['id'].');">'.html_print_image('images/lock.png', true).'</a>';
|
||||
// Delete relationship.
|
||||
$table_relations->data[$relations_count][4] = '<a id="delete_relation_button" href="javascript: delete_relation('.$relations_count.', '.$module_relation['id'].');">'.html_print_image('images/cross.png', true).'</a>';
|
||||
$relations_count++;
|
||||
}
|
||||
|
||||
html_print_input_hidden('module_relations_count', $relations_count);
|
||||
|
|
|
@ -827,7 +827,7 @@ $table->data[5][1] = "
|
|||
</table>
|
||||
</div>';
|
||||
|
||||
echo '<form method="POST" action="index.php?sec=estado&sec2=godmode/agentes/planned_downtime.editor">';
|
||||
echo '<form method="POST" action="index.php?sec=extensions&sec2=godmode/agentes/planned_downtime.editor">';
|
||||
|
||||
if ($id_downtime > 0) {
|
||||
echo '<table width=100% border=0 cellpadding=4 >';
|
||||
|
@ -929,7 +929,7 @@ if ($id_downtime > 0) {
|
|||
$disabled_add_button = true;
|
||||
}
|
||||
|
||||
echo "<form method=post action='index.php?sec=estado&sec2=godmode/agentes/planned_downtime.editor&id_downtime=$id_downtime'>";
|
||||
echo "<form method=post action='index.php?sec=extensions&sec2=godmode/agentes/planned_downtime.editor&id_downtime=$id_downtime'>";
|
||||
html_print_select_groups(false, $access, true, 'filter_group', $filter_group, '', '', '', false, false, true, '', false, 'min-width:180px;margin-right:15px;');
|
||||
|
||||
html_print_checkbox('recursion', 1, $recursion, false, false, '');
|
||||
|
@ -939,7 +939,7 @@ if ($id_downtime > 0) {
|
|||
echo '</form>';
|
||||
// Show available agents to include into downtime
|
||||
echo '<h4>'.__('Available agents').':</h4>';
|
||||
echo "<form method=post action='index.php?sec=estado&sec2=godmode/agentes/planned_downtime.editor&insert_downtime_agent=1&id_downtime=$id_downtime'>";
|
||||
echo "<form method=post action='index.php?sec=extensions&sec2=godmode/agentes/planned_downtime.editor&insert_downtime_agent=1&id_downtime=$id_downtime'>";
|
||||
|
||||
echo html_print_select($agents, 'id_agents[]', -1, '', _('Any'), -2, false, true, true, '', false, 'width: 180px;');
|
||||
|
||||
|
@ -1085,7 +1085,7 @@ if ($id_downtime > 0) {
|
|||
$data[5] = '<a href="javascript:show_editor_module('.$downtime_agent['id_agente'].');">'.html_print_image('images/config.png', true, ['border' => '0', 'alt' => __('Delete')]).'</a>';
|
||||
}
|
||||
|
||||
$data[5] .= '<a href="index.php?sec=estado&sec2=godmode/agentes/planned_downtime.editor&id_agent='.$downtime_agent['id_agente'].'&delete_downtime_agent=1&id_downtime_agent='.$downtime_agent['id'].'&id_downtime='.$id_downtime.'">'.html_print_image('images/cross.png', true, ['border' => '0', 'alt' => __('Delete')]).'</a>';
|
||||
$data[5] .= '<a href="index.php?sec=extensions&sec2=godmode/agentes/planned_downtime.editor&id_agent='.$downtime_agent['id_agente'].'&delete_downtime_agent=1&id_downtime_agent='.$downtime_agent['id'].'&id_downtime='.$id_downtime.'">'.html_print_image('images/cross.png', true, ['border' => '0', 'alt' => __('Delete')]).'</a>';
|
||||
}
|
||||
|
||||
$table->data['agent_'.$downtime_agent['id_agente']] = $data;
|
||||
|
|
|
@ -357,7 +357,7 @@ if (!$downtimes && !$filter_performed) {
|
|||
// No downtimes cause the user performed a search.
|
||||
else if (!$downtimes) {
|
||||
// Filter form.
|
||||
echo "<form method='post' action='index.php?sec=estado&sec2=godmode/agentes/planned_downtime.list'>";
|
||||
echo "<form method='post' action='index.php?sec=extensions&sec2=godmode/agentes/planned_downtime.list'>";
|
||||
html_print_table($table_form);
|
||||
echo '</form>';
|
||||
|
||||
|
@ -369,7 +369,7 @@ else if (!$downtimes) {
|
|||
// Create button.
|
||||
if ($write_permisson) {
|
||||
echo ' ';
|
||||
echo '<form method="post" action="index.php?sec=estado&sec2=godmode/agentes/planned_downtime.editor" style="display: inline;">';
|
||||
echo '<form method="post" action="index.php?sec=extensions&sec2=godmode/agentes/planned_downtime.editor" style="display: inline;">';
|
||||
html_print_submit_button(__('Create'), 'create', false, 'class="sub next"');
|
||||
echo '</form>';
|
||||
}
|
||||
|
@ -378,11 +378,11 @@ else if (!$downtimes) {
|
|||
}
|
||||
// Has downtimes.
|
||||
else {
|
||||
echo "<form method='post' action='index.php?sec=estado&sec2=godmode/agentes/planned_downtime.list'>";
|
||||
echo "<form method='post' action='index.php?sec=extensions&sec2=godmode/agentes/planned_downtime.list'>";
|
||||
html_print_table($table_form);
|
||||
echo '</form>';
|
||||
|
||||
ui_pagination($downtimes_number, "index.php?sec=estado&sec2=godmode/agentes/planned_downtime.list&$filter_params_str", $offset);
|
||||
ui_pagination($downtimes_number, "index.php?sec=extensions&sec2=godmode/agentes/planned_downtime.list&$filter_params_str", $offset);
|
||||
|
||||
// User groups with AR, AD or AW permission.
|
||||
$groupsAD = users_get_groups($config['id_user'], $access);
|
||||
|
@ -476,7 +476,7 @@ else {
|
|||
if (in_array($downtime['id_group'], $groupsAD)) {
|
||||
// Stop button
|
||||
if ($downtime['type_execution'] == 'once' && $downtime['executed'] == 1) {
|
||||
$data['stop'] = '<a href="index.php?sec=gagente&sec2=godmode/agentes/planned_downtime.list'.'&stop_downtime=1&id_downtime='.$downtime['id'].'&'.$filter_params_str.'">'.html_print_image('images/cancel.png', true, ['title' => __('Stop downtime')]);
|
||||
$data['stop'] = '<a href="index.php?sec=extensions&sec2=godmode/agentes/planned_downtime.list'.'&stop_downtime=1&id_downtime='.$downtime['id'].'&'.$filter_params_str.'">'.html_print_image('images/cancel.png', true, ['title' => __('Stop downtime')]);
|
||||
} else {
|
||||
$data['stop'] = '';
|
||||
}
|
||||
|
@ -484,12 +484,12 @@ else {
|
|||
// Edit & delete buttons.
|
||||
if ($downtime['executed'] == 0) {
|
||||
// Edit.
|
||||
$data['edit'] = '<a href="index.php?sec=estado&sec2=godmode/agentes/planned_downtime.editor&edit_downtime=1&id_downtime='.$downtime['id'].'">'.html_print_image('images/config.png', true, ['title' => __('Update')]).'</a>';
|
||||
$data['edit'] = '<a href="index.php?sec=extensions&sec2=godmode/agentes/planned_downtime.editor&edit_downtime=1&id_downtime='.$downtime['id'].'">'.html_print_image('images/config.png', true, ['title' => __('Update')]).'</a>';
|
||||
// Delete.
|
||||
$data['delete'] = '<a id="delete_downtime" href="index.php?sec=gagente&sec2=godmode/agentes/planned_downtime.list'.'&delete_downtime=1&id_downtime='.$downtime['id'].'&'.$filter_params_str.'">'.html_print_image('images/cross.png', true, ['title' => __('Delete')]);
|
||||
$data['delete'] = '<a id="delete_downtime" href="index.php?sec=extensions&sec2=godmode/agentes/planned_downtime.list'.'&delete_downtime=1&id_downtime='.$downtime['id'].'&'.$filter_params_str.'">'.html_print_image('images/cross.png', true, ['title' => __('Delete')]);
|
||||
} else if ($downtime['executed'] == 1 && $downtime['type_execution'] == 'once') {
|
||||
// Edit.
|
||||
$data['edit'] = '<a href="index.php?sec=estado&sec2=godmode/agentes/planned_downtime.editor&edit_downtime=1&id_downtime='.$downtime['id'].'">'.html_print_image('images/config.png', true, ['title' => __('Update')]).'</a>';
|
||||
$data['edit'] = '<a href="index.php?sec=extensions&sec2=godmode/agentes/planned_downtime.editor&edit_downtime=1&id_downtime='.$downtime['id'].'">'.html_print_image('images/config.png', true, ['title' => __('Update')]).'</a>';
|
||||
// Delete.
|
||||
$data['delete'] = __('N/A');
|
||||
} else {
|
||||
|
@ -515,7 +515,7 @@ else {
|
|||
}
|
||||
|
||||
html_print_table($table);
|
||||
ui_pagination($downtimes_number, "index.php?sec=estado&sec2=godmode/agentes/planned_downtime.list&$filter_params_str", $offset, 0, false, 'offset', true, 'pagination-bottom');
|
||||
ui_pagination($downtimes_number, "index.php?sec=extensions&sec2=godmode/agentes/planned_downtime.list&$filter_params_str", $offset, 0, false, 'offset', true, 'pagination-bottom');
|
||||
echo '<div class="action-buttons" style="width: '.$table->width.'">';
|
||||
|
||||
// CSV export button.
|
||||
|
@ -532,7 +532,7 @@ else {
|
|||
// Create button.
|
||||
if ($write_permisson) {
|
||||
echo ' ';
|
||||
echo '<form method="post" action="index.php?sec=estado&sec2=godmode/agentes/planned_downtime.editor" style="display: inline;">';
|
||||
echo '<form method="post" action="index.php?sec=extensions&sec2=godmode/agentes/planned_downtime.editor" style="display: inline;">';
|
||||
html_print_submit_button(__('Create'), 'create', false, 'class="sub next"');
|
||||
echo '</form>';
|
||||
}
|
||||
|
@ -559,7 +559,7 @@ $(document).ready (function () {
|
|||
|
||||
if (<?php echo json_encode($malformed_downtimes_exist); ?> && <?php echo json_encode($migrate_malformed == false); ?>) {
|
||||
if (confirm("<?php echo __('WARNING: There are malformed planned downtimes').'.\n'.__('Do you want to migrate automatically the malformed items?'); ?>")) {
|
||||
window.location.href = "index.php?sec=estado&sec2=godmode/agentes/planned_downtime.list&migrate_malformed=1";
|
||||
window.location.href = "index.php?sec=extensions&sec2=godmode/agentes/planned_downtime.list&migrate_malformed=1";
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -29,599 +29,43 @@
|
|||
// Begin.
|
||||
global $config;
|
||||
|
||||
// Check access.
|
||||
check_login();
|
||||
require_once $config['homedir'].'/include/class/CredentialStore.class.php';
|
||||
|
||||
if (! check_acl($config['id_user'], 0, 'PM')) {
|
||||
db_pandora_audit(
|
||||
'ACL Violation',
|
||||
'Trying to access event viewer'
|
||||
);
|
||||
$ajaxPage = 'godmode/groups/credential_store';
|
||||
|
||||
// Control call flow.
|
||||
try {
|
||||
// User access and validation is being processed on class constructor.
|
||||
$cs = new CredentialStore($ajaxPage);
|
||||
} catch (Exception $e) {
|
||||
if (is_ajax()) {
|
||||
return ['error' => 'noaccess'];
|
||||
echo json_encode(['error' => '[CredentialStore]'.$e->getMessage() ]);
|
||||
exit;
|
||||
} else {
|
||||
echo '[CredentialStore]'.$e->getMessage();
|
||||
}
|
||||
|
||||
include 'general/noaccess.php';
|
||||
// Stop this execution, but continue 'globally'.
|
||||
return;
|
||||
}
|
||||
|
||||
// Required files.
|
||||
ui_require_css_file('credential_store');
|
||||
require_once $config['homedir'].'/include/functions_credential_store.php';
|
||||
require_once $config['homedir'].'/include/functions_io.php';
|
||||
|
||||
// AJAX controller.
|
||||
if (is_ajax()) {
|
||||
$draw = get_parameter('draw', 0);
|
||||
$filter = get_parameter('filter', []);
|
||||
$get_key = get_parameter('get_key', 0);
|
||||
$new_form = get_parameter('new_form', 0);
|
||||
$new_key = get_parameter('new_key', 0);
|
||||
$update_key = get_parameter('update_key', 0);
|
||||
$delete_key = get_parameter('delete_key', 0);
|
||||
$method = get_parameter('method');
|
||||
|
||||
if ($new_form) {
|
||||
echo print_inputs();
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($delete_key) {
|
||||
$identifier = get_parameter('identifier', null);
|
||||
|
||||
if (empty($identifier)) {
|
||||
ajax_msg('error', __('identifier cannot be empty'));
|
||||
}
|
||||
|
||||
if (db_process_sql_delete(
|
||||
'tcredential_store',
|
||||
['identifier' => $identifier]
|
||||
) === false
|
||||
) {
|
||||
ajax_msg('error', $config['dbconnection']->error, true);
|
||||
if (method_exists($cs, $method) === true) {
|
||||
if ($cs->ajaxMethod($method) === true) {
|
||||
$cs->{$method}();
|
||||
} else {
|
||||
ajax_msg('result', $identifier, true);
|
||||
$cs->error('Unavailable method.');
|
||||
}
|
||||
} else {
|
||||
$cs->error('Method not found. ['.$method.']');
|
||||
}
|
||||
|
||||
if ($update_key) {
|
||||
$data = get_parameter('values', null);
|
||||
|
||||
if ($data === null || !is_array($data)) {
|
||||
echo json_encode(['error' => __('Invalid parameters, please retry')]);
|
||||
exit;
|
||||
}
|
||||
|
||||
$values = [];
|
||||
foreach ($data as $key => $value) {
|
||||
if ($key == 'identifier') {
|
||||
$identifier = base64_decode($value);
|
||||
} else if ($key == 'product') {
|
||||
$product = base64_decode($value);
|
||||
} else {
|
||||
$values[$key] = base64_decode($value);
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($identifier)) {
|
||||
ajax_msg('error', __('identifier cannot be empty'));
|
||||
}
|
||||
|
||||
if (empty($product)) {
|
||||
ajax_msg('error', __('product cannot be empty'));
|
||||
}
|
||||
|
||||
if (db_process_sql_update(
|
||||
'tcredential_store',
|
||||
$values,
|
||||
['identifier' => $identifier]
|
||||
) === false
|
||||
) {
|
||||
ajax_msg('error', $config['dbconnection']->error);
|
||||
} else {
|
||||
ajax_msg('result', $identifier);
|
||||
}
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($new_key) {
|
||||
$data = get_parameter('values', null);
|
||||
|
||||
if ($data === null || !is_array($data)) {
|
||||
echo json_encode(['error' => __('Invalid parameters, please retry')]);
|
||||
exit;
|
||||
}
|
||||
|
||||
$values = [];
|
||||
foreach ($data as $key => $value) {
|
||||
$values[$key] = base64_decode($value);
|
||||
if ($key == 'identifier') {
|
||||
$values[$key] = preg_replace('/\s+/', '-', trim($values[$key]));
|
||||
}
|
||||
}
|
||||
|
||||
$identifier = $values['identifier'];
|
||||
|
||||
if (empty($identifier)) {
|
||||
ajax_msg('error', __('identifier cannot be empty'));
|
||||
}
|
||||
|
||||
if (empty($values['product'])) {
|
||||
ajax_msg('error', __('product cannot be empty'));
|
||||
}
|
||||
|
||||
if (db_process_sql_insert('tcredential_store', $values) === false) {
|
||||
ajax_msg('error', $config['dbconnection']->error);
|
||||
} else {
|
||||
ajax_msg('result', $identifier);
|
||||
}
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($get_key) {
|
||||
$identifier = get_parameter('identifier', null);
|
||||
|
||||
$key = get_key($identifier);
|
||||
echo print_inputs($key);
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($draw) {
|
||||
// Datatables offset, limit and order.
|
||||
$start = get_parameter('start', 0);
|
||||
$length = get_parameter('length', $config['block_size']);
|
||||
$order = get_datatable_order(true);
|
||||
try {
|
||||
ob_start();
|
||||
|
||||
$fields = [
|
||||
'cs.*',
|
||||
'tg.nombre as `group`',
|
||||
];
|
||||
|
||||
// Retrieve data.
|
||||
$data = credentials_get_all(
|
||||
// Fields.
|
||||
$fields,
|
||||
// Filter.
|
||||
$filter,
|
||||
// Offset.
|
||||
$start,
|
||||
// Limit.
|
||||
$length,
|
||||
// Order.
|
||||
$order['direction'],
|
||||
// Sort field.
|
||||
$order['field']
|
||||
);
|
||||
|
||||
// Retrieve counter.
|
||||
$count = credentials_get_all(
|
||||
'count',
|
||||
$filter
|
||||
);
|
||||
|
||||
if ($data) {
|
||||
$data = array_reduce(
|
||||
$data,
|
||||
function ($carry, $item) {
|
||||
// Transforms array of arrays $data into an array
|
||||
// of objects, making a post-process of certain fields.
|
||||
$tmp = (object) $item;
|
||||
$tmp->username = io_safe_output($tmp->username);
|
||||
|
||||
if (empty($tmp->group)) {
|
||||
$tmp->group = __('All');
|
||||
} else {
|
||||
$tmp->group = io_safe_output($tmp->group);
|
||||
}
|
||||
|
||||
$carry[] = $tmp;
|
||||
return $carry;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
// Datatables format: RecordsTotal && recordsfiltered.
|
||||
echo json_encode(
|
||||
[
|
||||
'data' => $data,
|
||||
'recordsTotal' => $count,
|
||||
'recordsFiltered' => $count,
|
||||
]
|
||||
);
|
||||
// Capture output.
|
||||
$response = ob_get_clean();
|
||||
} catch (Exception $e) {
|
||||
return json_encode(['error' => $e->getMessage()]);
|
||||
}
|
||||
|
||||
// If not valid, show error with issue.
|
||||
json_decode($response);
|
||||
if (json_last_error() == JSON_ERROR_NONE) {
|
||||
// If valid dump.
|
||||
echo $response;
|
||||
} else {
|
||||
echo json_encode(
|
||||
['error' => $response]
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
// Stop any execution.
|
||||
exit;
|
||||
} else {
|
||||
// Run.
|
||||
$cs->run();
|
||||
}
|
||||
|
||||
// Datatables list.
|
||||
try {
|
||||
$columns = [
|
||||
'group',
|
||||
'identifier',
|
||||
'product',
|
||||
'username',
|
||||
'options',
|
||||
];
|
||||
|
||||
$column_names = [
|
||||
__('Group'),
|
||||
__('Identifier'),
|
||||
__('Product'),
|
||||
__('User'),
|
||||
[
|
||||
'text' => __('Options'),
|
||||
'class' => 'action_buttons',
|
||||
],
|
||||
];
|
||||
|
||||
$table_id = 'keystore';
|
||||
// Load datatables user interface.
|
||||
ui_print_datatable(
|
||||
[
|
||||
'id' => $table_id,
|
||||
'class' => 'info_table',
|
||||
'style' => 'width: 100%',
|
||||
'columns' => $columns,
|
||||
'column_names' => $column_names,
|
||||
'ajax_url' => 'godmode/groups/credential_store',
|
||||
'ajax_postprocess' => 'process_datatables_item(item)',
|
||||
'no_sortable_columns' => [-1],
|
||||
'order' => [
|
||||
'field' => 'identifier',
|
||||
'direction' => 'asc',
|
||||
],
|
||||
'search_button_class' => 'sub filter float-right',
|
||||
'form' => [
|
||||
'inputs' => [
|
||||
[
|
||||
'label' => __('Group'),
|
||||
'type' => 'select',
|
||||
'id' => 'filter_id_group',
|
||||
'name' => 'filter_id_group',
|
||||
'options' => users_get_groups_for_select(
|
||||
$config['id_user'],
|
||||
'AR',
|
||||
true,
|
||||
true,
|
||||
false
|
||||
),
|
||||
],
|
||||
[
|
||||
'label' => __('Free search'),
|
||||
'type' => 'text',
|
||||
'class' => 'mw250px',
|
||||
'id' => 'free_search',
|
||||
'name' => 'free_search',
|
||||
],
|
||||
],
|
||||
],
|
||||
]
|
||||
);
|
||||
} catch (Exception $e) {
|
||||
echo $e->getMessage();
|
||||
}
|
||||
|
||||
// Auxiliar div.
|
||||
$new = '<div id="new_key" style="display: none"><form id="form_new">';
|
||||
$new .= '</form></div>';
|
||||
$details = '<div id="info_key" style="display: none"><form id="form_update">';
|
||||
$details .= '</form></div>';
|
||||
$aux = '<div id="aux" style="display: none"></div>';
|
||||
|
||||
|
||||
echo $new.$details.$aux;
|
||||
|
||||
// Create button.
|
||||
echo '<div class="w100p flex-content-right">';
|
||||
html_print_submit_button(
|
||||
__('Add key'),
|
||||
'create',
|
||||
false,
|
||||
'class="sub next"'
|
||||
);
|
||||
echo '</div>';
|
||||
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
function process_datatables_item(item) {
|
||||
item.options = '<a href="javascript:" onclick="display_key(\'';
|
||||
item.options += item.identifier;
|
||||
item.options += '\')" ><?php echo html_print_image('images/eye.png', true, ['title' => __('Show')]); ?></a>';
|
||||
|
||||
item.options += '<a href="javascript:" onclick="delete_key(\'';
|
||||
item.options += item.identifier;
|
||||
item.options += '\')" ><?php echo html_print_image('images/cross.png', true, ['title' => __('Delete')]); ?></a>';
|
||||
}
|
||||
|
||||
function handle_response(data) {
|
||||
var title = "<?php echo __('Success'); ?>";
|
||||
var text = '';
|
||||
var failed = 0;
|
||||
try {
|
||||
data = JSON.parse(data);
|
||||
text = data['result'];
|
||||
} catch (err) {
|
||||
title = "<?php echo __('Failed'); ?>";
|
||||
text = err.message;
|
||||
failed = 1;
|
||||
}
|
||||
if (!failed && data['error'] != undefined) {
|
||||
title = "<?php echo __('Failed'); ?>";
|
||||
text = data['error'];
|
||||
failed = 1;
|
||||
}
|
||||
|
||||
$('#aux').empty();
|
||||
$('#aux').html(text);
|
||||
$('#aux').dialog({
|
||||
width: 450,
|
||||
position: {
|
||||
my: 'center',
|
||||
at: 'center',
|
||||
of: window,
|
||||
collision: 'fit'
|
||||
},
|
||||
title: title,
|
||||
buttons: [
|
||||
{
|
||||
text: 'OK',
|
||||
click: function(e) {
|
||||
if (!failed) {
|
||||
dt_<?php echo $table_id; ?>.draw(0);
|
||||
$(".ui-dialog-content").dialog("close");
|
||||
cleanupDOM();
|
||||
} else {
|
||||
$(this).dialog('close');
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
function delete_key(id) {
|
||||
$('#aux').empty();
|
||||
$('#aux').text('<?php echo __('Are you sure?'); ?>');
|
||||
$('#aux').dialog({
|
||||
title: '<?php echo __('Delete'); ?> ' + id,
|
||||
buttons: [
|
||||
{
|
||||
class: 'ui-widget ui-state-default ui-corner-all ui-button-text-only sub upd submit-cancel',
|
||||
text: '<?php echo __('Cancel'); ?>',
|
||||
click: function(e) {
|
||||
$(this).dialog('close');
|
||||
cleanupDOM();
|
||||
|
||||
}
|
||||
},
|
||||
{
|
||||
text: 'Delete',
|
||||
class: 'ui-widget ui-state-default ui-corner-all ui-button-text-only sub ok submit-next',
|
||||
click: function(e) {
|
||||
$.ajax({
|
||||
method: 'post',
|
||||
url: '<?php echo ui_get_full_url('ajax.php', false, false, false); ?>',
|
||||
data: {
|
||||
page: 'godmode/groups/credential_store',
|
||||
delete_key: 1,
|
||||
identifier: id
|
||||
},
|
||||
datatype: "json",
|
||||
success: function (data) {
|
||||
handle_response(data);
|
||||
},
|
||||
error: function(e) {
|
||||
handle_response(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
function display_key(id) {
|
||||
$('#form_update').empty();
|
||||
$('#form_update').html('Loading...');
|
||||
$.ajax({
|
||||
method: 'post',
|
||||
url: '<?php echo ui_get_full_url('ajax.php', false, false, false); ?>',
|
||||
data: {
|
||||
page: 'godmode/groups/credential_store',
|
||||
get_key: 1,
|
||||
identifier: id
|
||||
},
|
||||
success: function (data) {
|
||||
$('#info_key').dialog({
|
||||
width: 580,
|
||||
height: 400,
|
||||
position: {
|
||||
my: 'center',
|
||||
at: 'center',
|
||||
of: window,
|
||||
collision: 'fit'
|
||||
},
|
||||
title: id,
|
||||
buttons: [
|
||||
{
|
||||
class: 'ui-widget ui-state-default ui-corner-all ui-button-text-only sub upd submit-cancel',
|
||||
text: '<?php echo __('Cancel'); ?>',
|
||||
click: function(e) {
|
||||
$(this).dialog('close');
|
||||
cleanupDOM();
|
||||
}
|
||||
},
|
||||
{
|
||||
text: 'Update',
|
||||
class: 'ui-widget ui-state-default ui-corner-all ui-button-text-only sub ok submit-next',
|
||||
click: function(e) {
|
||||
var values = {};
|
||||
|
||||
$('#form_update :input').each(function() {
|
||||
values[this.name] = btoa($(this).val());
|
||||
});
|
||||
|
||||
$.ajax({
|
||||
method: 'post',
|
||||
url: '<?php echo ui_get_full_url('ajax.php', false, false, false); ?>',
|
||||
data: {
|
||||
page: 'godmode/groups/credential_store',
|
||||
update_key: 1,
|
||||
values: values
|
||||
},
|
||||
datatype: "json",
|
||||
success: function (data) {
|
||||
handle_response(data);
|
||||
},
|
||||
error: function(e) {
|
||||
handle_response(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
$('#form_update').html(data);
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
function cleanupDOM() {
|
||||
$('#div-identifier').empty();
|
||||
$('#div-product').empty();
|
||||
$('#div-username').empty();
|
||||
$('#div-password').empty();
|
||||
$('#div-extra_1').empty();
|
||||
$('#div-extra_2').empty();
|
||||
}
|
||||
|
||||
function calculate_inputs() {
|
||||
if ($('#product :selected').val() == "CUSTOM") {
|
||||
$('#div-username label').text('<?php echo __('User'); ?>');
|
||||
$('#div-password label').text('<?php echo __('Password'); ?>');
|
||||
$('#div-extra_1').hide();
|
||||
$('#div-extra_2').hide();
|
||||
} else if ($('#product :selected').val() == "AWS") {
|
||||
$('#div-username label').text('<?php echo __('Access key ID'); ?>');
|
||||
$('#div-password label').text('<?php echo __('Secret access key'); ?>');
|
||||
$('#div-extra_1').hide();
|
||||
$('#div-extra_2').hide();
|
||||
} else if ($('#product :selected').val() == "AZURE") {
|
||||
$('#div-username label').text('<?php echo __('Client ID'); ?>');
|
||||
$('#div-password label').text('<?php echo __('Application secret'); ?>');
|
||||
$('#div-extra_1 label').text('<?php echo __('Tenant or domain name'); ?>');
|
||||
$('#div-extra_2 label').text('<?php echo __('Subscription id'); ?>');
|
||||
$('#div-extra_1').show();
|
||||
$('#div-extra_2').show();
|
||||
}
|
||||
}
|
||||
|
||||
function add_key() {
|
||||
// Clear form.
|
||||
$('#form_update').empty();
|
||||
$('#form_update').html('Loading...');
|
||||
$.ajax({
|
||||
method: 'post',
|
||||
url: '<?php echo ui_get_full_url('ajax.php', false, false, false); ?>',
|
||||
data: {
|
||||
page: 'godmode/groups/credential_store',
|
||||
new_form: 1
|
||||
},
|
||||
success: function(data) {
|
||||
$('#form_new').html(data);
|
||||
$('#id_group').val(0);
|
||||
// By default CUSTOM.
|
||||
$('#product').val('CUSTOM');
|
||||
calculate_inputs();
|
||||
|
||||
$('#product').on('change', function() {
|
||||
calculate_inputs()
|
||||
});
|
||||
|
||||
// Show form.
|
||||
$('#new_key').dialog({
|
||||
width: 580,
|
||||
height: 400,
|
||||
position: {
|
||||
my: 'center',
|
||||
at: 'center',
|
||||
of: window,
|
||||
collision: 'fit'
|
||||
},
|
||||
title: "<?php echo __('Register new key into keystore'); ?>",
|
||||
buttons: [
|
||||
{
|
||||
class: 'ui-widget ui-state-default ui-corner-all ui-button-text-only sub upd submit-cancel',
|
||||
text: "<?php echo __('Cancel'); ?>",
|
||||
click: function(e) {
|
||||
$(this).dialog('close');
|
||||
cleanupDOM();
|
||||
}
|
||||
},
|
||||
{
|
||||
class: 'ui-widget ui-state-default ui-corner-all ui-button-text-only sub ok submit-next',
|
||||
text: 'OK',
|
||||
click: function(e) {
|
||||
var values = {};
|
||||
$('#form_new :input').each(function() {
|
||||
values[this.name] = btoa($(this).val());
|
||||
});
|
||||
|
||||
$.ajax({
|
||||
method: 'post',
|
||||
url: '<?php echo ui_get_full_url('ajax.php', false, false, false); ?>',
|
||||
data: {
|
||||
page: 'godmode/groups/credential_store',
|
||||
new_key: 1,
|
||||
values: values
|
||||
},
|
||||
datatype: "json",
|
||||
success: function (data) {
|
||||
handle_response(data);
|
||||
},
|
||||
error: function(e) {
|
||||
handle_response(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
]
|
||||
});
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
}
|
||||
$(document).ready(function(){
|
||||
|
||||
$("#submit-create").on('click', function(){
|
||||
add_key();
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
|
|
|
@ -59,8 +59,10 @@ if ($update_agents) {
|
|||
$values['id_grupo'] = get_parameter('group');
|
||||
}
|
||||
|
||||
if (get_parameter('interval', 0) != 0) {
|
||||
$values['intervalo'] = get_parameter('interval');
|
||||
if (!(get_parameter('interval_select') == -1 && empty(get_parameter('interval_text')))) {
|
||||
if (get_parameter('interval', 0) != 0) {
|
||||
$values['intervalo'] = get_parameter('interval');
|
||||
}
|
||||
}
|
||||
|
||||
if (get_parameter('id_os', '') != -1) {
|
||||
|
@ -199,7 +201,7 @@ if ($update_agents) {
|
|||
}
|
||||
|
||||
// Update the configuration files.
|
||||
if ($result && ($old_interval_value != $values['intervalo'])) {
|
||||
if ($result && ($old_interval_value != $values['intervalo']) && !empty($values['intervalo'])) {
|
||||
enterprise_hook(
|
||||
'config_agents_update_config_token',
|
||||
[
|
||||
|
@ -523,7 +525,7 @@ $table->data[1][1] = html_print_select_groups(false, 'AR', false, 'group', $grou
|
|||
|
||||
$table->data[2][0] = __('Interval');
|
||||
|
||||
$table->data[2][1] = html_print_extended_select_for_time('interval', 0, '', __('No change'), '0', 10, true, 'width: 150px');
|
||||
$table->data[2][1] = html_print_extended_select_for_time('interval', 0, '', __('No change'), '0', 10, true, 'width: 150px', false);
|
||||
|
||||
$table->data[3][0] = __('OS');
|
||||
$table->data[3][1] = html_print_select_from_sql(
|
||||
|
|
|
@ -21,27 +21,42 @@ require_once 'include/functions_menu.php';
|
|||
$menu_godmode = [];
|
||||
$menu_godmode['class'] = 'godmode';
|
||||
|
||||
|
||||
if (check_acl($config['id_user'], 0, 'PM')) {
|
||||
if (check_acl($config['id_user'], 0, 'AR')
|
||||
|| check_acl($config['id_user'], 0, 'AW')
|
||||
|| check_acl($config['id_user'], 0, 'RR')
|
||||
|| check_acl($config['id_user'], 0, 'RW')
|
||||
|| check_acl($config['id_user'], 0, 'PM')
|
||||
) {
|
||||
$sub = [];
|
||||
$sub['godmode/servers/discovery&wiz=main']['text'] = __('Main');
|
||||
$sub['godmode/servers/discovery&wiz=main']['id'] = 'Discovery';
|
||||
|
||||
$sub['godmode/servers/discovery&wiz=tasklist']['text'] = __('Task list');
|
||||
$sub['godmode/servers/discovery&wiz=tasklist']['id'] = 'tasklist';
|
||||
|
||||
$sub2 = [];
|
||||
$sub2['godmode/servers/discovery&wiz=hd&mode=netscan']['text'] = __('Network scan');
|
||||
enterprise_hook('hostdevices_submenu');
|
||||
$sub2['godmode/servers/discovery&wiz=hd&mode=customnetscan']['text'] = __('Custom network scan');
|
||||
$sub2['godmode/servers/discovery&wiz=hd&mode=managenetscanscripts']['text'] = __('Manage scan scripts');
|
||||
$sub['godmode/servers/discovery&wiz=hd']['text'] = __('Host & devices');
|
||||
$sub['godmode/servers/discovery&wiz=hd']['id'] = 'hd';
|
||||
$sub['godmode/servers/discovery&wiz=hd']['sub2'] = $sub2;
|
||||
if (check_acl($config['id_user'], 0, 'AW')
|
||||
|| check_acl($config['id_user'], 0, 'PM')
|
||||
) {
|
||||
if (check_acl($config['id_user'], 0, 'AW')) {
|
||||
$sub2 = [];
|
||||
$sub2['godmode/servers/discovery&wiz=hd&mode=netscan']['text'] = __('Network scan');
|
||||
enterprise_hook('hostdevices_submenu');
|
||||
$sub2['godmode/servers/discovery&wiz=hd&mode=customnetscan']['text'] = __('Custom network scan');
|
||||
}
|
||||
|
||||
enterprise_hook('applications_menu');
|
||||
enterprise_hook('cloud_menu');
|
||||
enterprise_hook('console_task_menu');
|
||||
if (check_acl($config['id_user'], 0, 'PM')) {
|
||||
$sub2['godmode/servers/discovery&wiz=hd&mode=managenetscanscripts']['text'] = __('Manage scan scripts');
|
||||
}
|
||||
|
||||
$sub['godmode/servers/discovery&wiz=hd']['text'] = __('Host & devices');
|
||||
$sub['godmode/servers/discovery&wiz=hd']['id'] = 'hd';
|
||||
$sub['godmode/servers/discovery&wiz=hd']['sub2'] = $sub2;
|
||||
}
|
||||
|
||||
if (check_acl($config['id_user'], 0, 'AW')) {
|
||||
enterprise_hook('applications_menu');
|
||||
enterprise_hook('cloud_menu');
|
||||
enterprise_hook('console_task_menu');
|
||||
}
|
||||
|
||||
// Add to menu.
|
||||
$menu_godmode['discovery']['text'] = __('Discovery');
|
||||
|
@ -92,7 +107,7 @@ if (!empty($sub)) {
|
|||
}
|
||||
|
||||
$sub = [];
|
||||
if (check_acl($config['id_user'], 0, 'AW')) {
|
||||
if (check_acl($config['id_user'], 0, 'PM')) {
|
||||
$sub['godmode/groups/group_list']['text'] = __('Manage agents groups');
|
||||
$sub['godmode/groups/group_list']['id'] = 'Manage agents groups';
|
||||
}
|
||||
|
@ -295,6 +310,9 @@ if (check_acl($config['id_user'], 0, 'PM')) {
|
|||
$sub2['godmode/setup/setup&section=ehorus']['text'] = __('eHorus');
|
||||
$sub2['godmode/setup/setup&section=ehorus']['refr'] = 0;
|
||||
|
||||
$sub2['godmode/setup/setup&section=integria']['text'] = __('Integria IMS');
|
||||
$sub2['godmode/setup/setup&section=integria']['refr'] = 0;
|
||||
|
||||
$sub2['godmode/setup/setup&section=notifications']['text'] = __('Notifications');
|
||||
$sub2['godmode/setup/setup&section=notifications']['refr'] = 0;
|
||||
|
||||
|
@ -381,9 +399,6 @@ if (is_array($config['extensions'])) {
|
|||
if (strlen($extmenu['fatherId']) > 0) {
|
||||
if (array_key_exists('subfatherId', $extmenu)) {
|
||||
if (strlen($extmenu['subfatherId']) > 0) {
|
||||
if ($extmenu['name'] = 'DB schema check') {
|
||||
}
|
||||
|
||||
$menu_godmode[$extmenu['fatherId']]['sub'][$extmenu['subfatherId']]['sub2'][$extmenu['sec2']]['text'] = __($extmenu['name']);
|
||||
$menu_godmode[$extmenu['fatherId']]['sub'][$extmenu['subfatherId']]['sub2'][$extmenu['sec2']]['id'] = $extmenu['name'];
|
||||
$menu_godmode[$extmenu['fatherId']]['sub'][$extmenu['subfatherId']]['sub2'][$extmenu['sec2']]['refr'] = 0;
|
||||
|
|
|
@ -16,10 +16,10 @@ global $config;
|
|||
// Check user credentials
|
||||
check_login();
|
||||
|
||||
if (! check_acl($config['id_user'], 0, 'RR')) {
|
||||
if (! check_acl($config['id_user'], 0, 'RR') || enterprise_installed() === false) {
|
||||
db_pandora_audit(
|
||||
'ACL Violation',
|
||||
'Trying to access Inventory Module Management'
|
||||
'Trying to access Graph container'
|
||||
);
|
||||
include 'general/noaccess.php';
|
||||
return;
|
||||
|
|
|
@ -71,10 +71,12 @@ switch ($activeTab) {
|
|||
break;
|
||||
}
|
||||
|
||||
$buttons['graph_container'] = [
|
||||
'active' => false,
|
||||
'text' => '<a href="index.php?sec=reporting&sec2=godmode/reporting/graph_container">'.html_print_image('images/graph-container.png', true, ['title' => __('Graphs containers')]).'</a>',
|
||||
];
|
||||
if ($enterpriseEnable) {
|
||||
$buttons['graph_container'] = [
|
||||
'active' => false,
|
||||
'text' => '<a href="index.php?sec=reporting&sec2=godmode/reporting/graph_container">'.html_print_image('images/graph-container.png', true, ['title' => __('Graphs containers')]).'</a>',
|
||||
];
|
||||
}
|
||||
|
||||
$delete_graph = (bool) get_parameter('delete_graph');
|
||||
$view_graph = (bool) get_parameter('view_graph');
|
||||
|
@ -257,11 +259,6 @@ $table_aux = new stdClass();
|
|||
$table->cellspacing = 0;
|
||||
$table->align = [];
|
||||
$table->head = [];
|
||||
if ($report_w || $report_m) {
|
||||
$table->align[5] = 'left';
|
||||
$table->head[5] = html_print_checkbox('all_delete', 0, false, true, false);
|
||||
$table->size[5] = '20px';
|
||||
}
|
||||
|
||||
$table->head[0] = __('Graph name');
|
||||
$table->head[1] = __('Description');
|
||||
|
@ -280,6 +277,12 @@ $table_aux = new stdClass();
|
|||
$table->size[4] = '90px';
|
||||
}
|
||||
|
||||
if ($report_w || $report_m) {
|
||||
$table->align[5] = 'left';
|
||||
$table->head[5] = html_print_checkbox('all_delete', 0, false, true, false);
|
||||
$table->size[5] = '20px';
|
||||
}
|
||||
|
||||
$table->data = [];
|
||||
|
||||
$result_graphs = array_slice($graphs, $offset, $config['block_size']);
|
||||
|
@ -287,10 +290,6 @@ $table_aux = new stdClass();
|
|||
foreach ($result_graphs as $graph) {
|
||||
$data = [];
|
||||
|
||||
if ($report_m) {
|
||||
$data[5] .= html_print_checkbox_extended('delete_multiple[]', $graph['id_graph'], false, false, '', 'class="check_delete" style="margin-left:2px;"', true);
|
||||
}
|
||||
|
||||
$data[0] = '<a href="index.php?sec=reporting&sec2=operation/reporting/graph_viewer&view_graph=1&id='.$graph['id_graph'].'">'.ui_print_truncate_text($graph['name'], 70).'</a>';
|
||||
|
||||
$data[1] = ui_print_truncate_text($graph['description'], 70);
|
||||
|
@ -309,6 +308,10 @@ $table_aux = new stdClass();
|
|||
return false;">'.html_print_image('images/cross.png', true, ['alt' => __('Delete'), 'title' => __('Delete')]).'</a>';
|
||||
}
|
||||
|
||||
if ($report_m) {
|
||||
$data[5] .= html_print_checkbox_extended('delete_multiple[]', $graph['id_graph'], false, false, '', 'class="check_delete" style="margin-left:2px;"', true);
|
||||
}
|
||||
|
||||
array_push($table->data, $data);
|
||||
}
|
||||
|
||||
|
|
|
@ -233,12 +233,14 @@ switch ($action) {
|
|||
|
||||
$style = json_decode(io_safe_output($item['style']), true);
|
||||
|
||||
$name_from_template = $style['name_label'];
|
||||
|
||||
$show_in_same_row = $style['show_in_same_row'];
|
||||
$show_in_landscape = $style['show_in_landscape'];
|
||||
$hide_notinit_agents = $style['hide_notinit_agents'];
|
||||
$dyn_height = $style['dyn_height'];
|
||||
$type = $item['type'];
|
||||
$name = $item['name'];
|
||||
$name = $style['name_label'];
|
||||
|
||||
switch ($type) {
|
||||
case 'event_report_log':
|
||||
|
@ -480,50 +482,6 @@ switch ($action) {
|
|||
$period = $item['period'];
|
||||
break;
|
||||
|
||||
case 'TTRT':
|
||||
$description = $item['description'];
|
||||
$idAgentModule = $item['id_agent_module'];
|
||||
$idAgent = db_get_value_filter(
|
||||
'id_agente',
|
||||
'tagente_modulo',
|
||||
['id_agente_modulo' => $idAgentModule]
|
||||
);
|
||||
$period = $item['period'];
|
||||
break;
|
||||
|
||||
case 'TTO':
|
||||
$description = $item['description'];
|
||||
$idAgentModule = $item['id_agent_module'];
|
||||
$idAgent = db_get_value_filter(
|
||||
'id_agente',
|
||||
'tagente_modulo',
|
||||
['id_agente_modulo' => $idAgentModule]
|
||||
);
|
||||
$period = $item['period'];
|
||||
break;
|
||||
|
||||
case 'MTBF':
|
||||
$description = $item['description'];
|
||||
$idAgentModule = $item['id_agent_module'];
|
||||
$idAgent = db_get_value_filter(
|
||||
'id_agente',
|
||||
'tagente_modulo',
|
||||
['id_agente_modulo' => $idAgentModule]
|
||||
);
|
||||
$period = $item['period'];
|
||||
break;
|
||||
|
||||
case 'MTTR':
|
||||
$description = $item['description'];
|
||||
$idAgentModule = $item['id_agent_module'];
|
||||
$idAgent = db_get_value_filter(
|
||||
'id_agente',
|
||||
'tagente_modulo',
|
||||
['id_agente_modulo' => $idAgentModule]
|
||||
);
|
||||
$period = $item['period'];
|
||||
break;
|
||||
|
||||
case 'alert_report_module':
|
||||
$description = $item['description'];
|
||||
$idAgentModule = $item['id_agent_module'];
|
||||
|
@ -788,10 +746,6 @@ switch ($action) {
|
|||
case 'avg_value':
|
||||
case 'projection_graph':
|
||||
case 'prediction_date':
|
||||
case 'TTRT':
|
||||
case 'TTO':
|
||||
case 'MTBF':
|
||||
case 'MTTR':
|
||||
case 'simple_baseline_graph':
|
||||
case 'event_report_log':
|
||||
case 'increment':
|
||||
|
@ -869,18 +823,33 @@ $class = 'databox filters';
|
|||
</td>
|
||||
<td style="">
|
||||
<?php
|
||||
html_print_input_text(
|
||||
'name',
|
||||
$name,
|
||||
'',
|
||||
80,
|
||||
100,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
'',
|
||||
'fullwidth'
|
||||
);
|
||||
if ($name_from_template != '') {
|
||||
html_print_input_text(
|
||||
'name',
|
||||
$name_from_template,
|
||||
'',
|
||||
80,
|
||||
100,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
'',
|
||||
'fullwidth'
|
||||
);
|
||||
} else {
|
||||
html_print_input_text(
|
||||
'name',
|
||||
$name,
|
||||
'',
|
||||
80,
|
||||
100,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
'',
|
||||
'fullwidth'
|
||||
);
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
|
@ -3738,10 +3707,6 @@ $(document).ready (function () {
|
|||
case 'event_report_module':
|
||||
case 'simple_graph':
|
||||
case 'simple_baseline_graph':
|
||||
case 'TTRT':
|
||||
case 'TTO':
|
||||
case 'MTBF':
|
||||
case 'MTTR':
|
||||
case 'prediction_date':
|
||||
case 'projection_graph':
|
||||
case 'avg_value':
|
||||
|
@ -3779,10 +3744,6 @@ $(document).ready (function () {
|
|||
case 'event_report_module':
|
||||
case 'simple_graph':
|
||||
case 'simple_baseline_graph':
|
||||
case 'TTRT':
|
||||
case 'TTO':
|
||||
case 'MTBF':
|
||||
case 'MTTR':
|
||||
case 'prediction_date':
|
||||
case 'projection_graph':
|
||||
case 'avg_value':
|
||||
|
@ -4815,38 +4776,6 @@ function chooseType() {
|
|||
$("#row_historical_db_check").hide();
|
||||
break;
|
||||
|
||||
case 'TTRT':
|
||||
$("#row_description").show();
|
||||
$("#row_agent").show();
|
||||
$("#row_module").show();
|
||||
$("#row_period").show();
|
||||
$("#row_historical_db_check").hide();
|
||||
break;
|
||||
|
||||
case 'TTO':
|
||||
$("#row_description").show();
|
||||
$("#row_agent").show();
|
||||
$("#row_module").show();
|
||||
$("#row_period").show();
|
||||
$("#row_historical_db_check").hide();
|
||||
break;
|
||||
|
||||
case 'MTBF':
|
||||
$("#row_description").show();
|
||||
$("#row_agent").show();
|
||||
$("#row_module").show();
|
||||
$("#row_period").show();
|
||||
$("#row_historical_db_check").hide();
|
||||
break;
|
||||
|
||||
case 'MTTR':
|
||||
$("#row_description").show();
|
||||
$("#row_agent").show();
|
||||
$("#row_module").show();
|
||||
$("#row_period").show();
|
||||
$("#row_historical_db_check").hide();
|
||||
break;
|
||||
|
||||
case 'alert_report_module':
|
||||
$("#row_description").show();
|
||||
$("#row_agent").show();
|
||||
|
@ -5199,10 +5128,6 @@ function chooseType() {
|
|||
case 'min_value':
|
||||
case 'max_value':
|
||||
case 'avg_value':
|
||||
case 'TTRT':
|
||||
case 'TTO':
|
||||
case 'MTBF':
|
||||
case 'MTTR':
|
||||
case 'simple_baseline_graph':
|
||||
$("#row_label").show();
|
||||
break;
|
||||
|
|
|
@ -1,18 +1,34 @@
|
|||
<?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.
|
||||
/**
|
||||
* Report item list.
|
||||
*
|
||||
* @category Reporting
|
||||
* @package Pandora FMS
|
||||
* @subpackage Community
|
||||
* @version 1.0.0
|
||||
* @license See below
|
||||
*
|
||||
* ______ ___ _______ _______ ________
|
||||
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
|
||||
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
|
||||
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
|
||||
*
|
||||
* ============================================================================
|
||||
* Copyright (c) 2005-2019 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.
|
||||
* ============================================================================
|
||||
*/
|
||||
|
||||
global $config;
|
||||
|
||||
// Login check
|
||||
// Login check.
|
||||
check_login();
|
||||
|
||||
if (! check_acl($config['id_user'], 0, 'RW')) {
|
||||
|
@ -39,12 +55,16 @@ switch ($config['dbtype']) {
|
|||
'type'
|
||||
);
|
||||
break;
|
||||
|
||||
default:
|
||||
// Default.
|
||||
break;
|
||||
}
|
||||
|
||||
$report_w = check_acl($config['id_user'], 0, 'RW');
|
||||
$report_m = check_acl($config['id_user'], 0, 'RM');
|
||||
|
||||
if ($config['metaconsole'] == 1 and defined('METACONSOLE')) {
|
||||
if (is_metaconsole()) {
|
||||
$agents = [];
|
||||
$agents = metaconsole_get_report_agents($idReport);
|
||||
$modules = [];
|
||||
|
@ -52,7 +72,7 @@ if ($config['metaconsole'] == 1 and defined('METACONSOLE')) {
|
|||
$types = [];
|
||||
$types = metaconsole_get_report_types($idReport);
|
||||
} else {
|
||||
// FORM FILTER
|
||||
// FORM FILTER.
|
||||
switch ($config['dbtype']) {
|
||||
case 'mysql':
|
||||
case 'postgresql':
|
||||
|
@ -87,7 +107,10 @@ if ($config['metaconsole'] == 1 and defined('METACONSOLE')) {
|
|||
ON (t4.id_agent = t5.id_agente OR t4.id_agente = t5.id_agente)
|
||||
WHERE t4.id_report = '.$idReport
|
||||
);
|
||||
break;
|
||||
|
||||
default:
|
||||
// Default.
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -124,6 +147,10 @@ if ($config['metaconsole'] == 1 and defined('METACONSOLE')) {
|
|||
WHERE t1.id_report = '.$idReport
|
||||
);
|
||||
break;
|
||||
|
||||
default:
|
||||
// Default.
|
||||
break;
|
||||
}
|
||||
|
||||
if ($rows === false) {
|
||||
|
@ -135,8 +162,8 @@ if ($config['metaconsole'] == 1 and defined('METACONSOLE')) {
|
|||
$modules[$row['id_agent_module']] = $row['nombre'];
|
||||
}
|
||||
|
||||
// Filter report items created from metaconsole in normal console list and the opposite
|
||||
if (defined('METACONSOLE') and $config['metaconsole'] == 1) {
|
||||
// Filter report items created from metaconsole in normal console list and the opposite.
|
||||
if (is_metaconsole()) {
|
||||
$where_types = ' AND ((server_name IS NOT NULL AND length(server_name) != 0) OR '.$type_escaped.' IN (\'general\',\'SLA\',\'exception\',\'top_n\'))';
|
||||
} else {
|
||||
$where_types = ' AND ((server_name IS NULL OR length(server_name) = 0) OR '.$type_escaped.' IN (\'general\',\'SLA\',\'exception\',\'top_n\'))';
|
||||
|
@ -184,7 +211,6 @@ if (!defined('METACONSOLE')) {
|
|||
$table->data[0][1] .= html_print_select($modules, 'module_filter', $moduleFilter, '', __('All'), 0, true);
|
||||
$table->data[0][2] = __('Type');
|
||||
$table->data[0][2] .= html_print_select($types, 'type_filter', $typeFilter, '', __('All'), 0, true);
|
||||
// $table->data[1][2] = $table->data[1][3] = '';
|
||||
$form = '<form method="post" action ="index.php?sec=reporting&sec2=godmode/reporting/reporting_builder&tab=list_items&action=filter&id_report='.$idReport.'">';
|
||||
$form .= html_print_table($table, true);
|
||||
$form .= '<div class="action-buttons" style="width: '.$table->width.'">';
|
||||
|
@ -265,13 +291,6 @@ if ($moduleFilter != 0) {
|
|||
$where .= ' AND id_agent_module = '.$moduleFilter;
|
||||
}
|
||||
|
||||
// Filter report items created from metaconsole in normal console list and the opposite
|
||||
if (defined('METACONSOLE') and $config['metaconsole'] == 1) {
|
||||
$where .= ' AND ((server_name IS NOT NULL AND length(server_name) != 0) '.'OR '.$type_escaped.' IN (\'general\', \'SLA\', \'exception\', \'availability\', \'availability_graph\', \'top_n\',\'SLA_monthly\',\'SLA_weekly\',\'SLA_hourly\',\'text\'))';
|
||||
} else {
|
||||
$where .= ' AND ((server_name IS NULL OR length(server_name) = 0) '.'OR '.$type_escaped.' IN (\'general\', \'SLA\', \'exception\', \'availability\', \'top_n\'))';
|
||||
}
|
||||
|
||||
switch ($config['dbtype']) {
|
||||
case 'mysql':
|
||||
$items = db_get_all_rows_sql(
|
||||
|
@ -306,13 +325,17 @@ switch ($config['dbtype']) {
|
|||
'AND',
|
||||
false
|
||||
);
|
||||
// Delete rnum row generated by oracle_recode_query() function
|
||||
// Delete rnum row generated by oracle_recode_query() function.
|
||||
if ($items !== false) {
|
||||
for ($i = 0; $i < count($items); $i++) {
|
||||
unset($items[$i]['rnum']);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
// Default.
|
||||
break;
|
||||
}
|
||||
|
||||
$countItems = db_get_sql(
|
||||
|
@ -421,29 +444,30 @@ foreach ($items as $item) {
|
|||
|
||||
$row[1] = get_report_name($item['type']);
|
||||
|
||||
if ($item['type'] == 'custom_graph') {
|
||||
$custom_graph_name = db_get_row_sql('select name from tgraph where id_graph = '.$item['id_gs']);
|
||||
$row[1] = get_report_name($item['type']).' ('.$custom_graph_name['name'].')';
|
||||
}
|
||||
|
||||
$server_name = $item['server_name'];
|
||||
|
||||
if (($config['metaconsole'] == 1) && ($server_name != '') && defined('METACONSOLE')) {
|
||||
if (is_metaconsole()) {
|
||||
$connection = metaconsole_get_connection($server_name);
|
||||
if (metaconsole_load_external_db($connection) != NOERR) {
|
||||
// ui_print_error_message ("Error connecting to ".$server_name);
|
||||
}
|
||||
}
|
||||
|
||||
if ($item['type'] == 'custom_graph') {
|
||||
$custom_graph_name = db_get_row_sql('SELECT name FROM tgraph WHERE id_graph = '.$item['id_gs']);
|
||||
$row[1] = get_report_name($item['type']).' ('.$custom_graph_name['name'].')';
|
||||
}
|
||||
|
||||
|
||||
if ($item['id_agent'] == 0) {
|
||||
$is_inventory_item = $item['type'] == 'inventory' || $item['type'] == 'inventory_changes';
|
||||
|
||||
// Due to SLA or top N or general report items
|
||||
// Due to SLA or top N or general report items.
|
||||
if (!$is_inventory_item && ($item['id_agent_module'] == '' || $item['id_agent_module'] == 0)) {
|
||||
$row[2] = '';
|
||||
$row[3] = '';
|
||||
} else {
|
||||
// The inventory items have the agents and modules in json format in the field external_source
|
||||
// The inventory items have the agents and modules in json format in the field external_source.
|
||||
if ($is_inventory_item) {
|
||||
$external_source = json_decode($item['external_source'], true);
|
||||
$agents = $external_source['id_agents'];
|
||||
|
@ -489,11 +513,18 @@ foreach ($items as $item) {
|
|||
$row[4] = '-';
|
||||
}
|
||||
|
||||
if ($item['name'] == '' && $item['description'] == '') {
|
||||
$row[5] = '-';
|
||||
} else {
|
||||
$text = empty($item['name']) ? $item['description'] : $item['name'];
|
||||
$style = json_decode(io_safe_output($item['style']), true);
|
||||
|
||||
if ($style['name_label'] != '') {
|
||||
$text = empty($style['name_label']) ? $item['description'] : $style['name_label'];
|
||||
$row[5] = ui_print_truncate_text($text, 'description', true, true);
|
||||
} else {
|
||||
if ($item['name'] == '' && $item['description'] == '') {
|
||||
$row[5] = '-';
|
||||
} else {
|
||||
$text = empty($item['name']) ? $item['description'] : $item['name'];
|
||||
$row[5] = ui_print_truncate_text($text, 'description', true, true);
|
||||
}
|
||||
}
|
||||
|
||||
$row[6] = '';
|
||||
|
@ -515,7 +546,7 @@ foreach ($items as $item) {
|
|||
|
||||
$table->data[] = $row;
|
||||
$count++;
|
||||
// Restore db connection
|
||||
// Restore db connection.
|
||||
if (($config['metaconsole'] == 1) && ($server_name != '') && defined('METACONSOLE')) {
|
||||
metaconsole_restore_db();
|
||||
}
|
||||
|
|
|
@ -2006,10 +2006,6 @@ switch ($action) {
|
|||
case 'avg_value':
|
||||
case 'projection_graph':
|
||||
case 'prediction_date':
|
||||
case 'TTRT':
|
||||
case 'TTO':
|
||||
case 'MTBF':
|
||||
case 'MTTR':
|
||||
case 'simple_baseline_graph':
|
||||
case 'nt_top_n':
|
||||
if ($label != '') {
|
||||
|
@ -2612,10 +2608,6 @@ switch ($action) {
|
|||
case 'avg_value':
|
||||
case 'projection_graph':
|
||||
case 'prediction_date':
|
||||
case 'TTRT':
|
||||
case 'TTO':
|
||||
case 'MTBF':
|
||||
case 'MTTR':
|
||||
case 'simple_baseline_graph':
|
||||
case 'nt_top_n':
|
||||
if ($label != '') {
|
||||
|
@ -3142,17 +3134,19 @@ if ($enterpriseEnable && defined('METACONSOLE')) {
|
|||
break;
|
||||
}
|
||||
|
||||
ui_print_page_header(
|
||||
$textReportName,
|
||||
'images/op_reporting.png',
|
||||
false,
|
||||
$helpers,
|
||||
false,
|
||||
$buttons,
|
||||
false,
|
||||
'',
|
||||
60
|
||||
);
|
||||
if ($action !== 'update' && !is_metaconsole()) {
|
||||
ui_print_page_header(
|
||||
$textReportName,
|
||||
'images/op_reporting.png',
|
||||
false,
|
||||
$helpers,
|
||||
false,
|
||||
$buttons,
|
||||
false,
|
||||
'',
|
||||
60
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if ($resultOperationDB !== null) {
|
||||
|
@ -3174,6 +3168,26 @@ if ($resultOperationDB !== null) {
|
|||
__('Successfull action'),
|
||||
__('Unsuccessful action<br><br>'.$err)
|
||||
);
|
||||
|
||||
if ($action == 'update') {
|
||||
$buttons[$activeTab]['active'] = false;
|
||||
$activeTab = 'list_items';
|
||||
$buttons[$activeTab]['active'] = true;
|
||||
|
||||
if (!is_metaconsole()) {
|
||||
ui_print_page_header(
|
||||
$textReportName,
|
||||
'images/op_reporting.png',
|
||||
false,
|
||||
$helpers,
|
||||
false,
|
||||
$buttons,
|
||||
false,
|
||||
'',
|
||||
60
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
switch ($activeTab) {
|
||||
|
|
|
@ -4,7 +4,14 @@ global $config;
|
|||
|
||||
check_login();
|
||||
|
||||
if (! check_acl($config['id_user'], 0, 'AW')) {
|
||||
if (! check_acl($config['id_user'], 0, 'AR')
|
||||
&& ! check_acl($config['id_user'], 0, 'AW')
|
||||
&& ! check_acl($config['id_user'], 0, 'AM')
|
||||
&& ! check_acl($config['id_user'], 0, 'RR')
|
||||
&& ! check_acl($config['id_user'], 0, 'RW')
|
||||
&& ! check_acl($config['id_user'], 0, 'RM')
|
||||
&& ! check_acl($config['id_user'], 0, 'PM')
|
||||
) {
|
||||
db_pandora_audit(
|
||||
'ACL Violation',
|
||||
'Trying to access Server Management'
|
||||
|
@ -134,11 +141,18 @@ if ($classname_selected === null) {
|
|||
$classname = basename($classpath, '.class.php');
|
||||
$obj = new $classname();
|
||||
|
||||
$button = $obj->load();
|
||||
|
||||
if ($button === false) {
|
||||
// No acess, skip.
|
||||
continue;
|
||||
}
|
||||
|
||||
// DiscoveryTaskList must be first button.
|
||||
if ($classname == 'DiscoveryTaskList') {
|
||||
array_unshift($wiz_data, $obj->load());
|
||||
array_unshift($wiz_data, $button);
|
||||
} else {
|
||||
$wiz_data[] = $obj->load();
|
||||
$wiz_data[] = $button;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -928,10 +928,10 @@ if (($create != '') || ($view != '')) {
|
|||
$other['plugin_type'] = $plugin_meta['plugin_type'];
|
||||
$other['macros'] = urlencode($plugin_meta['macros']);
|
||||
$other['parameters'] = urlencode($plugin_meta['parameters']);
|
||||
$other = implode('%7C', $other);
|
||||
$other = implode('%7E', $other);
|
||||
|
||||
$auth_token = json_decode($value['auth_token']);
|
||||
$url = $value['server_url'].'include/api.php?op=set&op2=push_plugin'.'&id='.$pluginid.'&other_mode=url_encode_separator_%7C&other='.$other."&apipass=$auth_token->api_password"."&user=$auth_token->console_user&pass=$auth_token->console_password";
|
||||
$url = $value['server_url'].'include/api.php?op=set&op2=push_plugin'.'&id='.$pluginid.'&other_mode=url_encode_separator_%7E&other='.$other."&apipass=$auth_token->api_password"."&user=$auth_token->console_user&pass=$auth_token->console_password";
|
||||
$file_path = realpath($plugin_meta['execute']);
|
||||
$post = '';
|
||||
if (file_exists($file_path)) {
|
||||
|
|
|
@ -117,6 +117,11 @@ if (check_acl($config['id_user'], 0, 'AW')) {
|
|||
}
|
||||
}
|
||||
|
||||
$buttons['integria'] = [
|
||||
'active' => false,
|
||||
'text' => '<a href="'.ui_get_full_url('index.php?sec=gsetup&sec2=godmode/setup/setup§ion=integria').'">'.html_print_image('images/integria.png', true, ['title' => __('Integria IMS')]).'</a>',
|
||||
];
|
||||
|
||||
$buttons['ehorus'] = [
|
||||
'active' => false,
|
||||
'text' => '<a href="'.ui_get_full_url('index.php?sec=gsetup&sec2=godmode/setup/setup§ion=ehorus').'">'.html_print_image('images/ehorus/ehorus.png', true, ['title' => __('eHorus')]).'</a>',
|
||||
|
@ -167,6 +172,12 @@ switch ($section) {
|
|||
$help_header = 'setup_ehorus_tab';
|
||||
break;
|
||||
|
||||
case 'integria':
|
||||
$buttons['integria']['active'] = true;
|
||||
$subpage = ' » '.__('Integria IMS');
|
||||
$help_header = 'setup_integria_tab';
|
||||
break;
|
||||
|
||||
case 'notifications':
|
||||
$buttons['notifications']['active'] = true;
|
||||
$subpage = ' » '.__('Notifications');
|
||||
|
@ -228,6 +239,10 @@ switch ($section) {
|
|||
include_once $config['homedir'].'/godmode/setup/setup_ehorus.php';
|
||||
break;
|
||||
|
||||
case 'integria':
|
||||
include_once $config['homedir'].'/godmode/setup/setup_integria.php';
|
||||
break;
|
||||
|
||||
case 'notifications':
|
||||
include_once $config['homedir'].'/godmode/setup/setup_notifications.php';
|
||||
break;
|
||||
|
|
|
@ -0,0 +1,702 @@
|
|||
<?php
|
||||
/**
|
||||
* ______ ___ _______ _______ ________
|
||||
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
|
||||
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
|
||||
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
|
||||
*
|
||||
* ============================================================================
|
||||
* Copyright (c) 2005-2019 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.
|
||||
* ============================================================================
|
||||
*/
|
||||
|
||||
global $config;
|
||||
|
||||
check_login();
|
||||
|
||||
if (! check_acl($config['id_user'], 0, 'PM') && ! is_user_admin($config['id_user'])) {
|
||||
db_pandora_audit('ACL Violation', 'Trying to access Setup Management');
|
||||
include 'general/noaccess.php';
|
||||
return;
|
||||
}
|
||||
|
||||
require_once $config['homedir'].'/include/functions_integriaims.php';
|
||||
|
||||
if (is_ajax()) {
|
||||
$integria_user = get_parameter('integria_user', '');
|
||||
$integria_pass = get_parameter('integria_pass', '');
|
||||
$integria_api_hostname = get_parameter('api_hostname', '');
|
||||
$integria_api_pass = get_parameter('api_pass', '');
|
||||
|
||||
$login_result = integria_api_call($integria_api_hostname, $integria_user, $integria_pass, $integria_api_pass, 'get_login', []);
|
||||
|
||||
if ($login_result != false) {
|
||||
echo json_encode(['login' => 1]);
|
||||
} else {
|
||||
echo json_encode(['login' => 0]);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$has_connection = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_login', []);
|
||||
|
||||
if ($has_connection === false && $config['integria_enabled']) {
|
||||
ui_print_error_message(__('Integria IMS API is not reachable'));
|
||||
}
|
||||
|
||||
if (get_parameter('update_config', 0) == 1) {
|
||||
// Try to retrieve event response 'Create incident in IntegriaIMS from event' to check if it exists.
|
||||
$event_response_exists = db_get_row_filter('tevent_response', ['name' => io_safe_input('Create ticket in IntegriaIMS from event')]);
|
||||
|
||||
// Try to retrieve command 'Integia IMS Ticket' to check if it exists.
|
||||
$command_exists = db_get_row_filter('talert_commands', ['name' => io_safe_input('Integria IMS Ticket')]);
|
||||
|
||||
if ($config['integria_enabled'] == 1) {
|
||||
if ($event_response_exists === false) {
|
||||
// Create 'Create incident in IntegriaIMS from event' event response only when user enables IntegriaIMS integration and it does not exist in database.
|
||||
db_process_sql_insert(
|
||||
'tevent_response',
|
||||
[
|
||||
'name' => io_safe_input('Create ticket in IntegriaIMS from event'),
|
||||
'description' => io_safe_input('Create a ticket in Integria IMS from an event'),
|
||||
'target' => io_safe_input('index.php?sec=incident&sec2=operation/incidents/configure_integriaims_incident&from_event=_event_id_'),
|
||||
'type' => 'url',
|
||||
'id_group' => '0',
|
||||
'modal_width' => '0',
|
||||
'modal_height' => '0',
|
||||
'new_window' => '1',
|
||||
'params' => '',
|
||||
'server_to_exec' => '0',
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
if ($command_exists === false) {
|
||||
// Create 'Integria IMS Ticket' command only when user enables IntegriaIMS integration and it does not exist in database.
|
||||
$id_command_inserted = db_process_sql_insert(
|
||||
'talert_commands',
|
||||
[
|
||||
'name' => io_safe_input('Integria IMS Ticket'),
|
||||
'command' => io_safe_input('Internal type'),
|
||||
'internal' => 1,
|
||||
'description' => io_safe_input('Create a ticket in Integria IMS'),
|
||||
'fields_descriptions' => '["'.io_safe_input('Ticket title').'","'.io_safe_input('Ticket group ID').'","'.io_safe_input('Ticket priority').'","'.io_safe_input('Ticket owner').'","'.io_safe_input('Ticket type').'","'.io_safe_input('Ticket status').'","'.io_safe_input('Ticket description').'"]',
|
||||
]
|
||||
);
|
||||
|
||||
// Create 'Create Integria IMS Ticket' action only when user enables IntegriaIMS integration and command exists in database.
|
||||
$action_values = [
|
||||
'field1' => io_safe_input($config['incident_title']),
|
||||
'field1_recovery' => io_safe_input($config['incident_title']),
|
||||
'field2' => io_safe_input($config['default_group']),
|
||||
'field2_recovery' => io_safe_input($config['default_group']),
|
||||
'field3' => io_safe_input($config['default_criticity']),
|
||||
'field3_recovery' => io_safe_input($config['default_criticity']),
|
||||
'field4' => io_safe_input($config['default_owner']),
|
||||
'field4_recovery' => io_safe_input($config['default_owner']),
|
||||
'field5' => io_safe_input($config['incident_type']),
|
||||
'field5_recovery' => io_safe_input($config['incident_type']),
|
||||
'field6' => io_safe_input($config['incident_status']),
|
||||
'field6_recovery' => io_safe_input($config['incident_status']),
|
||||
'field7' => io_safe_input($config['incident_content']),
|
||||
'field7_recovery' => io_safe_input($config['incident_content']),
|
||||
'id_group' => 0,
|
||||
'action_threshold' => 0,
|
||||
];
|
||||
|
||||
alerts_create_alert_action(io_safe_input('Create Integria IMS ticket'), $id_command_inserted, $action_values);
|
||||
} else {
|
||||
// Update 'Create Integria IMS Ticket' action when setup data is updated, user enables IntegriaIMS integration and command does exist in database.
|
||||
db_process_sql_update(
|
||||
'talert_actions',
|
||||
[
|
||||
'field1' => io_safe_input($config['incident_title']),
|
||||
'field1_recovery' => io_safe_input($config['incident_title']),
|
||||
'field2' => io_safe_input($config['default_group']),
|
||||
'field2_recovery' => io_safe_input($config['default_group']),
|
||||
'field3' => io_safe_input($config['default_criticity']),
|
||||
'field3_recovery' => io_safe_input($config['default_criticity']),
|
||||
'field4' => io_safe_input($config['default_owner']),
|
||||
'field4_recovery' => io_safe_input($config['default_owner']),
|
||||
'field5' => io_safe_input($config['incident_type']),
|
||||
'field5_recovery' => io_safe_input($config['incident_type']),
|
||||
'field6' => io_safe_input($config['incident_status']),
|
||||
'field6_recovery' => io_safe_input($config['incident_status']),
|
||||
'field7' => io_safe_input($config['incident_content']),
|
||||
'field7_recovery' => io_safe_input($config['incident_content']),
|
||||
],
|
||||
['name' => io_safe_input('Create Integria IMS ticket')]
|
||||
);
|
||||
}
|
||||
} else {
|
||||
if ($event_response_exists != false) {
|
||||
// Delete 'Create incident in IntegriaIMS from event' event response if it does exist and IntegriaIMS integration is disabled.
|
||||
db_process_sql_delete('tevent_response', ['name' => io_safe_input('Create ticket in IntegriaIMS from event')]);
|
||||
}
|
||||
|
||||
if ($command_exists != false) {
|
||||
// Delete 'Integria IMS Ticket' command if it does exist and IntegriaIMS integration is disabled.
|
||||
db_process_sql_delete('talert_commands', ['name' => io_safe_input('Integria IMS Ticket')]);
|
||||
|
||||
// Delete 'Create Integria IMS Ticket' action if command exists and IntegriaIMS integration is disabled.
|
||||
db_process_sql_delete('talert_actions', ['name' => io_safe_input('Create Integria IMS ticket')]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Get parameters from Integria IMS API.
|
||||
$integria_group_values = [];
|
||||
$integria_criticity_values = [];
|
||||
$integria_users_values = [];
|
||||
$integria_types_values = [];
|
||||
$integria_status_values = [];
|
||||
|
||||
$integria_groups_csv = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_groups', []);
|
||||
|
||||
get_array_from_csv_data_pair($integria_groups_csv, $integria_group_values);
|
||||
|
||||
$integria_status_csv = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_incidents_status', []);
|
||||
|
||||
get_array_from_csv_data_pair($integria_status_csv, $integria_status_values);
|
||||
|
||||
$integria_criticity_levels_csv = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_incident_priorities', []);
|
||||
|
||||
get_array_from_csv_data_pair($integria_criticity_levels_csv, $integria_criticity_values);
|
||||
|
||||
$integria_users_csv = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_users', []);
|
||||
|
||||
$csv_array = explode("\n", $integria_users_csv);
|
||||
|
||||
foreach ($csv_array as $csv_line) {
|
||||
if (!empty($csv_line)) {
|
||||
$integria_users_values[$csv_line] = $csv_line;
|
||||
}
|
||||
}
|
||||
|
||||
$integria_types_csv = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_types', []);
|
||||
|
||||
get_array_from_csv_data_pair($integria_types_csv, $integria_types_values);
|
||||
|
||||
// Enable table.
|
||||
$table_enable = new StdClass();
|
||||
$table_enable->data = [];
|
||||
$table_enable->width = '100%';
|
||||
$table_enable->id = 'integria-enable-setup';
|
||||
$table_enable->class = 'databox filters';
|
||||
$table_enable->size['name'] = '30%';
|
||||
$table_enable->style['name'] = 'font-weight: bold';
|
||||
|
||||
// Enable Integria.
|
||||
$row = [];
|
||||
$row['name'] = __('Enable Integria IMS');
|
||||
$row['control'] = html_print_checkbox_switch('integria_enabled', 1, $config['integria_enabled'], true);
|
||||
$table_enable->data['integria_enabled'] = $row;
|
||||
|
||||
// Remote config table.
|
||||
$table_remote = new StdClass();
|
||||
$table_remote->data = [];
|
||||
$table_remote->width = '100%';
|
||||
$table_remote->styleTable = 'margin-bottom: 10px;';
|
||||
$table_remote->id = 'integria-remote-setup';
|
||||
$table_remote->class = 'databox filters';
|
||||
$table_remote->size['name'] = '30%';
|
||||
$table_remote->style['name'] = 'font-weight: bold';
|
||||
|
||||
// Integria user.
|
||||
$row = [];
|
||||
$row['name'] = __('User');
|
||||
$row['control'] = html_print_input_text('integria_user', $config['integria_user'], '', 30, 100, true);
|
||||
$table_remote->data['integria_user'] = $row;
|
||||
|
||||
// Integria password.
|
||||
$row = [];
|
||||
$row['name'] = __('Password');
|
||||
$row['control'] = html_print_input_password('integria_pass', io_output_password($config['integria_pass']), '', 30, 100, true);
|
||||
$table_remote->data['integria_pass'] = $row;
|
||||
|
||||
// Integria hostname.
|
||||
$row = [];
|
||||
$row['name'] = __('API Hostname');
|
||||
$row['control'] = html_print_input_text('integria_hostname', $config['integria_hostname'], '', 30, 100, true);
|
||||
$row['control'] .= ui_print_help_tip(__('Hostname of Integria IMS\' API (scheme must be specified. Example: http://192.168.0.0)'), true);
|
||||
$table_remote->data['integria_hostname'] = $row;
|
||||
|
||||
// API password.
|
||||
$row = [];
|
||||
$row['name'] = __('API Password');
|
||||
$row['control'] = html_print_input_password('integria_api_pass', io_output_password($config['integria_api_pass']), '', 30, 100, true);
|
||||
$row['control'] .= ui_print_help_tip(__('Password of Integria IMS\' API'), true);
|
||||
$table_remote->data['integria_api_pass'] = $row;
|
||||
|
||||
// Request timeout.
|
||||
$row = [];
|
||||
$row['name'] = __('Request timeout');
|
||||
$row['control'] = html_print_input_text('integria_req_timeout', $config['integria_req_timeout'], '', 3, 10, true);
|
||||
$row['control'] .= ui_print_help_tip(__('Time in seconds to set the maximum time of the requests to the Integria API').'. '.__('0 to disable'), true);
|
||||
$table_remote->data['integria_req_timeout'] = $row;
|
||||
|
||||
// Alert settings.
|
||||
$table_alert_settings = new StdClass();
|
||||
$table_alert_settings->data = [];
|
||||
$table_alert_settings->width = '100%';
|
||||
$table_alert_settings->styleTable = 'margin-bottom: 10px;';
|
||||
$table_alert_settings->id = 'integria-cr-settings-setup';
|
||||
$table_alert_settings->class = 'databox filters';
|
||||
$table_alert_settings->size['name'] = '30%';
|
||||
$table_alert_settings->style['name'] = 'font-weight: bold';
|
||||
|
||||
// Alert incident title.
|
||||
$row = [];
|
||||
$row['name'] = __('Title');
|
||||
$row['control'] = html_print_input_text(
|
||||
'incident_title',
|
||||
$config['incident_title'],
|
||||
__('Name'),
|
||||
50,
|
||||
100,
|
||||
true,
|
||||
false,
|
||||
false
|
||||
).ui_print_help_icon('alert_macros', true);
|
||||
$table_alert_settings->data['custom_response_incident_title'] = $row;
|
||||
|
||||
// Alert incident description.
|
||||
$row = [];
|
||||
$row['name'] = __('Description');
|
||||
$row['control'] = html_print_input_text(
|
||||
'incident_content',
|
||||
$config['incident_content'],
|
||||
'',
|
||||
50,
|
||||
100,
|
||||
true,
|
||||
false,
|
||||
false
|
||||
).ui_print_help_icon('alert_macros', true);
|
||||
$table_alert_settings->data['custom_response_incident_content'] = $row;
|
||||
|
||||
// Alert default group.
|
||||
$row = [];
|
||||
$row['name'] = __('Group');
|
||||
$row['control'] = html_print_select(
|
||||
$integria_group_values,
|
||||
'default_group',
|
||||
$config['default_group'],
|
||||
'',
|
||||
__('Select'),
|
||||
0,
|
||||
true,
|
||||
false,
|
||||
true,
|
||||
'',
|
||||
false
|
||||
);
|
||||
$table_alert_settings->data['custom_response_def_group'] = $row;
|
||||
|
||||
// Alert default criticity.
|
||||
$row = [];
|
||||
$row['name'] = __('Priority');
|
||||
$row['control'] = html_print_select(
|
||||
$integria_criticity_values,
|
||||
'default_criticity',
|
||||
$config['default_criticity'],
|
||||
'',
|
||||
__('Select'),
|
||||
0,
|
||||
true,
|
||||
false,
|
||||
true,
|
||||
'',
|
||||
false
|
||||
);
|
||||
$table_alert_settings->data['custom_response_def_criticity'] = $row;
|
||||
|
||||
// Alert default owner.
|
||||
$row = [];
|
||||
$row['name'] = __('Owner');
|
||||
$row['control'] = html_print_autocomplete_users_from_integria(
|
||||
'default_owner',
|
||||
$config['default_owner'],
|
||||
true
|
||||
);
|
||||
|
||||
$table_alert_settings->data['custom_response_def_owner'] = $row;
|
||||
|
||||
// Alert default incident type.
|
||||
$row = [];
|
||||
$row['name'] = __('Type');
|
||||
$row['control'] = html_print_select(
|
||||
$integria_types_values,
|
||||
'incident_type',
|
||||
$config['incident_type'],
|
||||
'',
|
||||
__('Select'),
|
||||
0,
|
||||
true,
|
||||
false,
|
||||
true,
|
||||
'',
|
||||
false
|
||||
);
|
||||
$table_alert_settings->data['custom_response_incident_type'] = $row;
|
||||
|
||||
// Alert default incident status.
|
||||
$row = [];
|
||||
$row['name'] = __('Status');
|
||||
$row['control'] = html_print_select(
|
||||
$integria_status_values,
|
||||
'incident_status',
|
||||
$config['incident_status'],
|
||||
'',
|
||||
__('Select'),
|
||||
0,
|
||||
true,
|
||||
false,
|
||||
true,
|
||||
'',
|
||||
false
|
||||
);
|
||||
$table_alert_settings->data['custom_response_incident_status'] = $row;
|
||||
|
||||
// Custom response settings.
|
||||
$table_cr_settings = new StdClass();
|
||||
$table_cr_settings->data = [];
|
||||
$table_cr_settings->width = '100%';
|
||||
$table_cr_settings->styleTable = 'margin-bottom: 10px;';
|
||||
$table_cr_settings->id = 'integria-cr-settings-setup';
|
||||
$table_cr_settings->class = 'databox filters';
|
||||
$table_cr_settings->size['name'] = '30%';
|
||||
$table_cr_settings->style['name'] = 'font-weight: bold';
|
||||
|
||||
// Custom response incident title.
|
||||
$row = [];
|
||||
$row['name'] = __('Title');
|
||||
$row['control'] = html_print_input_text(
|
||||
'cr_incident_title',
|
||||
$config['cr_incident_title'],
|
||||
__('Name'),
|
||||
50,
|
||||
100,
|
||||
true,
|
||||
false,
|
||||
false
|
||||
).ui_print_help_icon('response_macros', true);
|
||||
$table_cr_settings->data['custom_response_incident_title'] = $row;
|
||||
|
||||
// Custom response incident description.
|
||||
$row = [];
|
||||
$row['name'] = __('Description');
|
||||
$row['control'] = html_print_input_text(
|
||||
'cr_incident_content',
|
||||
$config['cr_incident_content'],
|
||||
'',
|
||||
50,
|
||||
100,
|
||||
true,
|
||||
false,
|
||||
false
|
||||
).ui_print_help_icon('response_macros', true);
|
||||
$table_cr_settings->data['custom_response_incident_content'] = $row;
|
||||
|
||||
// Custom response default group.
|
||||
$row = [];
|
||||
$row['name'] = __('Group');
|
||||
$row['control'] = html_print_select(
|
||||
$integria_group_values,
|
||||
'cr_default_group',
|
||||
$config['cr_default_group'],
|
||||
'',
|
||||
__('Select'),
|
||||
0,
|
||||
true,
|
||||
false,
|
||||
true,
|
||||
'',
|
||||
false
|
||||
);
|
||||
$table_cr_settings->data['custom_response_def_group'] = $row;
|
||||
|
||||
// Custom response default criticity.
|
||||
$row = [];
|
||||
$row['name'] = __('Priority');
|
||||
$row['control'] = html_print_select(
|
||||
$integria_criticity_values,
|
||||
'cr_default_criticity',
|
||||
$config['cr_default_criticity'],
|
||||
'',
|
||||
__('Select'),
|
||||
0,
|
||||
true,
|
||||
false,
|
||||
true,
|
||||
'',
|
||||
false
|
||||
);
|
||||
$table_cr_settings->data['custom_response_def_criticity'] = $row;
|
||||
|
||||
// Custom response default owner.
|
||||
$row = [];
|
||||
$row['name'] = __('Owner');
|
||||
$row['control'] = html_print_autocomplete_users_from_integria(
|
||||
'cr_default_owner',
|
||||
$config['cr_default_owner'],
|
||||
true
|
||||
);
|
||||
|
||||
$table_cr_settings->data['custom_response_def_owner'] = $row;
|
||||
|
||||
// Custom response default incident type.
|
||||
$row = [];
|
||||
$row['name'] = __('Type');
|
||||
$row['control'] = html_print_select(
|
||||
$integria_types_values,
|
||||
'cr_incident_type',
|
||||
$config['cr_incident_type'],
|
||||
'',
|
||||
__('Select'),
|
||||
0,
|
||||
true,
|
||||
false,
|
||||
true,
|
||||
'',
|
||||
false
|
||||
);
|
||||
$table_cr_settings->data['custom_response_incident_type'] = $row;
|
||||
|
||||
// Custom response default incident status.
|
||||
$row = [];
|
||||
$row['name'] = __('Status');
|
||||
$row['control'] = html_print_select(
|
||||
$integria_status_values,
|
||||
'cr_incident_status',
|
||||
$config['cr_incident_status'],
|
||||
'',
|
||||
__('Select'),
|
||||
0,
|
||||
true,
|
||||
false,
|
||||
true,
|
||||
'',
|
||||
false
|
||||
);
|
||||
$table_cr_settings->data['custom_response_incident_status'] = $row;
|
||||
|
||||
// Test.
|
||||
$row = [];
|
||||
$row['name'] = __('Test');
|
||||
$row['control'] = html_print_button(__('Start'), 'test-integria', false, '', 'class="sub next"', true);
|
||||
$row['control'] .= '<span id="test-integria-spinner" style="display:none;"> '.html_print_image('images/spinner.gif', true).'</span>';
|
||||
$row['control'] .= '<span id="test-integria-success" style="display:none;"> '.html_print_image('images/status_sets/default/severity_normal.png', true).'</span>';
|
||||
$row['control'] .= '<span id="test-integria-failure" style="display:none;"> '.html_print_image('images/status_sets/default/severity_critical.png', true).'</span>';
|
||||
$row['control'] .= ' <span id="test-integria-message" style="display:none;"></span>';
|
||||
$table_remote->data['integria_test'] = $row;
|
||||
|
||||
// Print.
|
||||
echo '<div style="text-align: center; padding-bottom: 20px;">';
|
||||
echo '<a target="_blank" rel="noopener noreferrer" href="http://integriaims.com">';
|
||||
html_print_image('images/integria_logo.png');
|
||||
echo '</a>';
|
||||
echo '<br />';
|
||||
echo '<div style="font-family: lato, "Helvetica Neue", Helvetica, Arial, sans-serif; color: #515151;">';
|
||||
echo __('Integria IMS');
|
||||
echo '</div>';
|
||||
echo '<a target="_blank" rel="noopener noreferrer" href="https://integriaims.com">';
|
||||
echo 'https://integriaims.com';
|
||||
echo '</a>';
|
||||
echo '</div>';
|
||||
|
||||
echo "<form method='post'>";
|
||||
html_print_input_hidden('update_config', 1);
|
||||
|
||||
// Form enable.
|
||||
echo '<div id="form_enable">';
|
||||
html_print_table($table_enable);
|
||||
echo '</div>';
|
||||
|
||||
// Form remote.
|
||||
echo '<div id="form_remote">';
|
||||
echo '<fieldset>';
|
||||
echo '<legend>'.__('Integria API settings').'</legend>';
|
||||
|
||||
html_print_table($table_remote);
|
||||
|
||||
echo '</fieldset>';
|
||||
echo '</div>';
|
||||
|
||||
if ($has_connection != false) {
|
||||
// Form alert default settings.
|
||||
echo '<div id="form_alert_settings">';
|
||||
echo '<fieldset>';
|
||||
echo '<legend>'.__('Alert default values').'</legend>';
|
||||
|
||||
html_print_table($table_alert_settings);
|
||||
|
||||
echo '</fieldset>';
|
||||
echo '</div>';
|
||||
|
||||
// Form custom response default settings.
|
||||
echo '<div id="form_custom_response_settings">';
|
||||
echo '<fieldset>';
|
||||
echo '<legend>'.__('Event custom response default values').'</legend>';
|
||||
|
||||
html_print_table($table_cr_settings);
|
||||
|
||||
echo '</fieldset>';
|
||||
echo '</div>';
|
||||
|
||||
echo '<div class="action-buttons" style="width: '.$table_remote->width.'">';
|
||||
html_print_submit_button(__('Update'), 'update_button', false, 'class="sub upd"');
|
||||
echo '</div>';
|
||||
} else {
|
||||
echo '<div class="action-buttons" style="width: '.$table_remote->width.'">';
|
||||
html_print_submit_button(__('Update and continue'), 'update_button', false, 'class="sub next"');
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
|
||||
echo '</form>';
|
||||
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
if(!$('input:checkbox[name="integria_enabled"]').is(':checked')) {
|
||||
$('#form_remote').hide();
|
||||
$('#form_custom_response_settings').hide();
|
||||
} else {
|
||||
$('#form_remote').show();
|
||||
$('#form_custom_response_settings').show();
|
||||
}
|
||||
|
||||
$('#form_enable').css('margin-bottom','20px');
|
||||
var showFields = function () {
|
||||
$('#form_remote').show();
|
||||
$('#form_custom_response_settings').show();
|
||||
}
|
||||
var hideFields = function () {
|
||||
$('#form_remote').hide();
|
||||
$('#form_custom_response_settings').hide();
|
||||
}
|
||||
|
||||
var hideUserPass = function () {
|
||||
$('#integria-remote-setup-integria_user').hide();
|
||||
$('#integria-remote-setup-integria_pass').hide();
|
||||
}
|
||||
|
||||
var showUserPass = function () {
|
||||
$('#integria-remote-setup-integria_user').show();
|
||||
$('#integria-remote-setup-integria_pass').show();
|
||||
}
|
||||
|
||||
var handleEnable = function (event) {
|
||||
var is_checked = $('input:checkbox[name="integria_enabled"]').is(':checked');
|
||||
|
||||
if (event.target.value == '1' && is_checked) {
|
||||
showFields();
|
||||
$('input:checkbox[name="integria_enabled"]').attr('checked', true);
|
||||
}
|
||||
else {
|
||||
hideFields();
|
||||
$('input:checkbox[name="integria_enabled"]').attr('checked', false);
|
||||
};
|
||||
}
|
||||
|
||||
$('input:checkbox[name="integria_enabled"]').change(handleEnable);
|
||||
|
||||
var handleTest = function (event) {
|
||||
var user = $('input#text-integria_user').val();
|
||||
var pass = $('input#password-integria_pass').val();
|
||||
var host = $('input#text-integria_hostname').val();
|
||||
var timeout = Number.parseInt($('input#text-integria_req_timeout').val(), 10);
|
||||
|
||||
var timeoutMessage = '<?php echo __('Connection timeout'); ?>';
|
||||
var badRequestMessage = '<?php echo __('Empty user or password'); ?>';
|
||||
var notFoundMessage = '<?php echo __('User not found'); ?>';
|
||||
var invalidPassMessage = '<?php echo __('Invalid password'); ?>';
|
||||
|
||||
var hideLoadingImage = function () {
|
||||
$('span#test-integria-spinner').hide();
|
||||
}
|
||||
var showLoadingImage = function () {
|
||||
$('span#test-integria-spinner').show();
|
||||
}
|
||||
var hideSuccessImage = function () {
|
||||
$('span#test-integria-success').hide();
|
||||
}
|
||||
var showSuccessImage = function () {
|
||||
$('span#test-integria-success').show();
|
||||
}
|
||||
var hideFailureImage = function () {
|
||||
$('span#test-integria-failure').hide();
|
||||
}
|
||||
var showFailureImage = function () {
|
||||
$('span#test-integria-failure').show();
|
||||
}
|
||||
var hideMessage = function () {
|
||||
$('span#test-integria-message').hide();
|
||||
}
|
||||
var showMessage = function () {
|
||||
$('span#test-integria-message').show();
|
||||
}
|
||||
var changeTestMessage = function (message) {
|
||||
$('span#test-integria-message').text(message);
|
||||
}
|
||||
|
||||
hideSuccessImage();
|
||||
hideFailureImage();
|
||||
hideMessage();
|
||||
showLoadingImage();
|
||||
|
||||
var integria_user = $('input[name=integria_user]').val();
|
||||
var integria_pass = $('input[name=integria_pass]').val();
|
||||
var api_hostname = $('input[name=integria_hostname]').val();
|
||||
var api_pass = $('input[name=integria_api_pass]').val();
|
||||
|
||||
var data = {
|
||||
page: "godmode/setup/setup_integria",
|
||||
check_api_access: 1,
|
||||
integria_user: integria_user,
|
||||
integria_pass: integria_pass,
|
||||
api_hostname: api_hostname,
|
||||
api_pass: api_pass,
|
||||
}
|
||||
|
||||
// AJAX call to check API connection.
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "ajax.php",
|
||||
dataType: "json",
|
||||
timeout: timeout ? timeout * 1000 : 0,
|
||||
data: data
|
||||
})
|
||||
.done(function(data, textStatus, xhr) {
|
||||
if (data.login == '1') {
|
||||
showSuccessImage();
|
||||
} else {
|
||||
showFailureImage();
|
||||
showMessage();
|
||||
}
|
||||
|
||||
})
|
||||
.fail(function(xhr, textStatus, errorThrown) {
|
||||
showFailureImage();
|
||||
showMessage();
|
||||
})
|
||||
.always(function(xhr, textStatus) {
|
||||
hideLoadingImage();
|
||||
});
|
||||
}
|
||||
$('input#button-test-integria').click(handleTest);
|
||||
|
||||
|
||||
|
||||
</script>
|
|
@ -18,7 +18,7 @@ check_login();
|
|||
|
||||
enterprise_hook('open_meta_frame');
|
||||
|
||||
if (! check_acl($config['id_user'], 0, 'PM')) {
|
||||
if (! check_acl($config['id_user'], 0, 'UM')) {
|
||||
db_pandora_audit(
|
||||
'ACL Violation',
|
||||
'Trying to access Profile Management'
|
||||
|
@ -320,24 +320,29 @@ if ($id_profile || $new_profile) {
|
|||
$table->data['IM'] = $row;
|
||||
$table->data[] = '<hr>';
|
||||
|
||||
$disable_option = 'javascript: return false;';
|
||||
if (check_acl($config['id_user'], 0, 'PM') || users_is_admin()) {
|
||||
$disable_option = '';
|
||||
}
|
||||
|
||||
// Users
|
||||
$row = [];
|
||||
$row['name'] = __('Manage users');
|
||||
$row['input'] = html_print_checkbox('user_management', 1, $user_management, true);
|
||||
$row['input'] = html_print_checkbox('user_management', 1, $user_management, true, false, $disable_option);
|
||||
$table->data['UM'] = $row;
|
||||
$table->data[] = '<hr>';
|
||||
|
||||
// DB
|
||||
$row = [];
|
||||
$row['name'] = __('Manage database');
|
||||
$row['input'] = html_print_checkbox('db_management', 1, $db_management, true);
|
||||
$row['input'] = html_print_checkbox('db_management', 1, $db_management, true, false, $disable_option);
|
||||
$table->data['DM'] = $row;
|
||||
$table->data[] = '<hr>';
|
||||
|
||||
// Pandora
|
||||
$row = [];
|
||||
$row['name'] = __('%s management', get_product_name());
|
||||
$row['input'] = html_print_checkbox('pandora_management', 1, $pandora_management, true);
|
||||
$row['input'] = html_print_checkbox('pandora_management', 1, $pandora_management, true, false, $disable_option);
|
||||
$table->data['PM'] = $row;
|
||||
$table->data[] = '<hr>';
|
||||
|
||||
|
@ -359,3 +364,18 @@ if ($id_profile || $new_profile) {
|
|||
}
|
||||
|
||||
enterprise_hook('close_meta_frame');
|
||||
|
||||
?>
|
||||
|
||||
<script type="text/javascript" language="javascript">
|
||||
$(document).ready (function () {
|
||||
var disable_option = '<?php echo $disable_option; ?>';
|
||||
|
||||
if (disable_option != '') {
|
||||
var ids = ['#checkbox-db_management', '#checkbox-user_management', '#checkbox-pandora_management'];
|
||||
ids.forEach(id => {
|
||||
$(id).css({'cursor':'not-allowed', 'opacity':'0.5'});
|
||||
});
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
|
|
@ -828,7 +828,7 @@ $values = [
|
|||
0 => __('No'),
|
||||
];
|
||||
|
||||
$table->data[12][0] = __('Home screen').ui_print_help_tip(__('User can customize the home page. By default, will display \'Agent Detail\'. Example: Select \'Other\' and type sec=estado&sec2=operation/agentes/estado_agente to show agent detail view'), true);
|
||||
$table->data[12][0] = __('Home screen').ui_print_help_tip(__('User can customize the home page. By default, will display \'Agent Detail\'. Example: Select \'Other\' and type index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=1 to show agent detail view'), true);
|
||||
$values = [
|
||||
'Default' => __('Default'),
|
||||
'Visual console' => __('Visual console'),
|
||||
|
|
|
@ -362,7 +362,10 @@ foreach ($profiles as $profile) {
|
|||
$data['PM'] = ($profile['pandora_management'] ? $img : '');
|
||||
$table->cellclass[]['operations'] = 'action_buttons';
|
||||
$data['operations'] = '<a href="index.php?sec='.$sec.'&sec2=godmode/users/configure_profile&id='.$profile['id_perfil'].'&pure='.$pure.'">'.html_print_image('images/config.png', true, ['title' => __('Edit')]).'</a>';
|
||||
$data['operations'] .= '<a href="index.php?sec='.$sec.'&sec2=godmode/users/profile_list&delete_profile=1&id='.$profile['id_perfil'].'&pure='.$pure.'" onClick="if (!confirm(\' '.__('Are you sure?').'\')) return false;">'.html_print_image('images/cross.png', true).'</a>';
|
||||
if (check_acl($config['id_user'], 0, 'PM') || users_is_admin()) {
|
||||
$data['operations'] .= '<a href="index.php?sec='.$sec.'&sec2=godmode/users/profile_list&delete_profile=1&id='.$profile['id_perfil'].'&pure='.$pure.'" onClick="if (!confirm(\' '.__('Are you sure?').'\')) return false;">'.html_print_image('images/cross.png', true).'</a>';
|
||||
}
|
||||
|
||||
array_push($table->data, $data);
|
||||
}
|
||||
|
||||
|
|
|
@ -420,7 +420,9 @@ else {
|
|||
$u = get_user_info($key);
|
||||
$g = users_get_groups($key, 'AR', $u['is_admin']);
|
||||
$result = array_intersect($g, $own_groups);
|
||||
if (!$usr['is_admin'] && !empty($result)) {
|
||||
|
||||
// Show users without profile too.
|
||||
if (!$usr['is_admin'] && !empty($result) || (!$usr['is_admin'] && db_get_all_rows_field_filter('tusuario_perfil', 'id_usuario', $usr['id_user']) === false)) {
|
||||
$info[$key] = $usr;
|
||||
}
|
||||
|
||||
|
|
|
@ -200,7 +200,7 @@ class DiscoveryTaskList extends Wizard
|
|||
{
|
||||
global $config;
|
||||
|
||||
if (! check_acl($config['id_user'], 0, 'PM')) {
|
||||
if (! check_acl($config['id_user'], 0, 'AW')) {
|
||||
db_pandora_audit(
|
||||
'ACL Violation',
|
||||
'Trying to access recon task viewer'
|
||||
|
@ -241,7 +241,7 @@ class DiscoveryTaskList extends Wizard
|
|||
{
|
||||
global $config;
|
||||
|
||||
if (! check_acl($config['id_user'], 0, 'PM')) {
|
||||
if (!$this->aclMulticheck('RR|RW|RM|PM')) {
|
||||
db_pandora_audit(
|
||||
'ACL Violation',
|
||||
'Trying to access recon task viewer'
|
||||
|
@ -270,7 +270,7 @@ class DiscoveryTaskList extends Wizard
|
|||
{
|
||||
global $config;
|
||||
|
||||
if (! check_acl($config['id_user'], 0, 'PM')) {
|
||||
if (! check_acl($config['id_user'], 0, 'RM')) {
|
||||
db_pandora_audit(
|
||||
'ACL Violation',
|
||||
'Trying to access recon task viewer'
|
||||
|
@ -313,13 +313,9 @@ class DiscoveryTaskList extends Wizard
|
|||
|
||||
check_login();
|
||||
|
||||
if (! check_acl($config['id_user'], 0, 'PM')) {
|
||||
db_pandora_audit(
|
||||
'ACL Violation',
|
||||
'Trying to access recon task viewer'
|
||||
);
|
||||
include 'general/noaccess.php';
|
||||
return false;
|
||||
if (!$this->aclMulticheck('AR|AW|AM')) {
|
||||
// Tasklist are allowed only of agent managers.
|
||||
return '';
|
||||
}
|
||||
|
||||
// Get all discovery servers.
|
||||
|
@ -341,7 +337,7 @@ class DiscoveryTaskList extends Wizard
|
|||
// --------------------------------
|
||||
// FORCE A RECON TASK
|
||||
// --------------------------------
|
||||
if (check_acl($config['id_user'], 0, 'PM')) {
|
||||
if (check_acl($config['id_user'], 0, 'AW')) {
|
||||
if (isset($_GET['force'])) {
|
||||
$id = (int) get_parameter_get('force', 0);
|
||||
servers_force_recon_task($id);
|
||||
|
@ -387,8 +383,10 @@ class DiscoveryTaskList extends Wizard
|
|||
// Operations.
|
||||
$table->headstyle[9] .= 'min-width: 150px; width: 150px;';
|
||||
|
||||
$table->head[0] = __('Force');
|
||||
$table->align[0] = 'left';
|
||||
if (check_acl($config['id_user'], 0, 'AW')) {
|
||||
$table->head[0] = __('Force');
|
||||
$table->align[0] = 'left';
|
||||
}
|
||||
|
||||
$table->head[1] = __('Task name');
|
||||
$table->align[1] = 'left';
|
||||
|
@ -455,11 +453,13 @@ class DiscoveryTaskList extends Wizard
|
|||
}
|
||||
|
||||
if ($task['disabled'] == 0 && $server_name !== '') {
|
||||
$data[0] = '<a href="'.ui_get_full_url(
|
||||
'index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=tasklist&server_id='.$id_server.'&force='.$task['id_rt']
|
||||
).'">';
|
||||
$data[0] .= html_print_image('images/target.png', true, ['title' => __('Force')]);
|
||||
$data[0] .= '</a>';
|
||||
if (check_acl($config['id_user'], 0, 'AW')) {
|
||||
$data[0] = '<a href="'.ui_get_full_url(
|
||||
'index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=tasklist&server_id='.$id_server.'&force='.$task['id_rt']
|
||||
).'">';
|
||||
$data[0] .= html_print_image('images/target.png', true, ['title' => __('Force')]);
|
||||
$data[0] .= '</a>';
|
||||
}
|
||||
} else if ($task['disabled'] == 2) {
|
||||
$data[0] = ui_print_help_tip(
|
||||
__('This task has not been completely defined, please edit it'),
|
||||
|
@ -622,18 +622,20 @@ class DiscoveryTaskList extends Wizard
|
|||
&& $task['type'] != DISCOVERY_APP_ORACLE
|
||||
&& $task['type'] != DISCOVERY_CLOUD_AWS_RDS
|
||||
) {
|
||||
$data[9] .= '<a href="#" onclick="show_map('.$task['id_rt'].',\''.$task['name'].'\')">';
|
||||
$data[9] .= html_print_image(
|
||||
'images/dynamic_network_icon.png',
|
||||
true
|
||||
);
|
||||
$data[9] .= '</a>';
|
||||
if (check_acl($config['id_user'], 0, 'MR')) {
|
||||
$data[9] .= '<a href="#" onclick="show_map('.$task['id_rt'].',\''.$task['name'].'\')">';
|
||||
$data[9] .= html_print_image(
|
||||
'images/dynamic_network_icon.png',
|
||||
true
|
||||
);
|
||||
$data[9] .= '</a>';
|
||||
}
|
||||
}
|
||||
|
||||
if (check_acl(
|
||||
$config['id_user'],
|
||||
$task['id_group'],
|
||||
'PM'
|
||||
'AW'
|
||||
)
|
||||
) {
|
||||
if ($ipam === true) {
|
||||
|
@ -733,6 +735,16 @@ class DiscoveryTaskList extends Wizard
|
|||
{
|
||||
if ($script !== false) {
|
||||
switch ($script['type']) {
|
||||
case DISCOVERY_SCRIPT_APP_VMWARE:
|
||||
return 'wiz=app&mode=vmware&page=0';
|
||||
|
||||
case DISCOVERY_SCRIPT_IPAM_RECON:
|
||||
return '';
|
||||
|
||||
case DISCOVERY_SCRIPT_IPMI_RECON:
|
||||
default:
|
||||
return 'wiz=hd&mode=customnetscan';
|
||||
|
||||
case DISCOVERY_SCRIPT_CLOUD_AWS:
|
||||
switch ($task['type']) {
|
||||
case DISCOVERY_CLOUD_AWS_EC2:
|
||||
|
@ -744,16 +756,6 @@ class DiscoveryTaskList extends Wizard
|
|||
default:
|
||||
return 'wiz=cloud';
|
||||
}
|
||||
|
||||
case DISCOVERY_SCRIPT_APP_VMWARE:
|
||||
return 'wiz=app&mode=vmware&page=0';
|
||||
|
||||
case DISCOVERY_SCRIPT_IPAM_RECON:
|
||||
return '';
|
||||
|
||||
case DISCOVERY_SCRIPT_IPMI_RECON:
|
||||
default:
|
||||
return 'wiz=hd&mode=customnetscan';
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -87,6 +87,7 @@ class HostDevices extends Wizard
|
|||
) {
|
||||
$this->setBreadcrum([]);
|
||||
|
||||
$this->access = 'AW';
|
||||
$this->task = [];
|
||||
$this->msg = $msg;
|
||||
$this->icon = $icon;
|
||||
|
@ -100,6 +101,32 @@ class HostDevices extends Wizard
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks if environment is ready,
|
||||
* returns array
|
||||
* icon: icon to be displayed
|
||||
* label: label to be displayed
|
||||
*
|
||||
* @return array With data.
|
||||
**/
|
||||
public function load()
|
||||
{
|
||||
global $config;
|
||||
// Check access.
|
||||
check_login();
|
||||
|
||||
if (! $this->aclMulticheck('AW|PM')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return [
|
||||
'icon' => $this->icon,
|
||||
'label' => $this->label,
|
||||
'url' => $this->url,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Run wizard manager.
|
||||
*
|
||||
|
@ -116,37 +143,42 @@ class HostDevices extends Wizard
|
|||
|
||||
if ($mode === null) {
|
||||
$buttons = [];
|
||||
$buttons[] = [
|
||||
'url' => $this->url.'&mode=netscan',
|
||||
'icon' => 'images/wizard/netscan.png',
|
||||
'label' => __('Net Scan'),
|
||||
];
|
||||
|
||||
if (enterprise_installed()) {
|
||||
if (check_acl($config['id_user'], 0, $this->access)) {
|
||||
$buttons[] = [
|
||||
'url' => $this->url.'&mode=importcsv',
|
||||
'icon' => ENTERPRISE_DIR.'/images/wizard/csv.png',
|
||||
'label' => __('Import CSV'),
|
||||
'url' => $this->url.'&mode=netscan',
|
||||
'icon' => 'images/wizard/netscan.png',
|
||||
'label' => __('Net Scan'),
|
||||
];
|
||||
|
||||
if (enterprise_installed()) {
|
||||
$buttons[] = [
|
||||
'url' => $this->url.'&mode=importcsv',
|
||||
'icon' => ENTERPRISE_DIR.'/images/wizard/csv.png',
|
||||
'label' => __('Import CSV'),
|
||||
];
|
||||
|
||||
$buttons[] = [
|
||||
'url' => $this->url.'&mode=deploy',
|
||||
'icon' => ENTERPRISE_DIR.'/images/wizard/deployment.png',
|
||||
'label' => __('Agent deployment'),
|
||||
];
|
||||
}
|
||||
|
||||
$buttons[] = [
|
||||
'url' => $this->url.'&mode=deploy',
|
||||
'icon' => ENTERPRISE_DIR.'/images/wizard/deployment.png',
|
||||
'label' => __('Agent deployment'),
|
||||
'url' => $this->url.'&mode=customnetscan',
|
||||
'icon' => '/images/wizard/customnetscan.png',
|
||||
'label' => __('Custom NetScan'),
|
||||
];
|
||||
}
|
||||
|
||||
$buttons[] = [
|
||||
'url' => $this->url.'&mode=customnetscan',
|
||||
'icon' => '/images/wizard/customnetscan.png',
|
||||
'label' => __('Custom NetScan'),
|
||||
];
|
||||
|
||||
$buttons[] = [
|
||||
'url' => $this->url.'&mode=managenetscanscripts',
|
||||
'icon' => '/images/wizard/managenetscanscripts.png',
|
||||
'label' => __('Manage NetScan scripts'),
|
||||
];
|
||||
if (check_acl($config['id_user'], 0, 'PM')) {
|
||||
$buttons[] = [
|
||||
'url' => $this->url.'&mode=managenetscanscripts',
|
||||
'icon' => '/images/wizard/managenetscanscripts.png',
|
||||
'label' => __('Manage NetScan scripts'),
|
||||
];
|
||||
}
|
||||
|
||||
$this->prepareBreadcrum(
|
||||
[
|
||||
|
@ -311,11 +343,11 @@ class HostDevices extends Wizard
|
|||
) {
|
||||
// Default values, no data received.
|
||||
// User is accesing directly to this page.
|
||||
if (users_is_admin() !== true && check_acl(
|
||||
if (check_acl(
|
||||
$config['id_usuario'],
|
||||
$this->task['id_group'],
|
||||
'PM'
|
||||
) !== true
|
||||
$this->access
|
||||
) != true
|
||||
) {
|
||||
$this->msg = __('You have no access to edit this task.');
|
||||
return false;
|
||||
|
@ -487,7 +519,7 @@ class HostDevices extends Wizard
|
|||
|
||||
check_login();
|
||||
|
||||
if (! check_acl($config['id_user'], 0, 'PM')) {
|
||||
if (! check_acl($config['id_user'], 0, $this->access)) {
|
||||
db_pandora_audit(
|
||||
'ACL Violation',
|
||||
'Trying to access Agent Management'
|
||||
|
@ -529,11 +561,11 @@ class HostDevices extends Wizard
|
|||
|
||||
// Check ACL. If user is not able to manage target task,
|
||||
// redirect him to main page.
|
||||
if (users_is_admin() !== true && check_acl(
|
||||
if (check_acl(
|
||||
$config['id_usuario'],
|
||||
$this->task['id_group'],
|
||||
'PM'
|
||||
) !== true
|
||||
$this->access
|
||||
) != true
|
||||
) {
|
||||
$form['form']['action'] = $this->url.'&mode=netscan&page='.($this->page - 1);
|
||||
}
|
||||
|
@ -750,7 +782,7 @@ class HostDevices extends Wizard
|
|||
[
|
||||
'name' => 'id_group',
|
||||
'returnAllGroup' => false,
|
||||
'privilege' => 'PM',
|
||||
'privilege' => $this->access,
|
||||
'type' => 'select_groups',
|
||||
'selected' => $this->task['id_group'],
|
||||
'return' => true,
|
||||
|
|
|
@ -87,6 +87,13 @@ class Wizard
|
|||
*/
|
||||
public $msg;
|
||||
|
||||
/**
|
||||
* Defines access level to use this util.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $access = 'AR';
|
||||
|
||||
|
||||
/**
|
||||
* Setter for breadcrum
|
||||
|
@ -234,6 +241,42 @@ class Wizard
|
|||
public function run()
|
||||
{
|
||||
ui_require_css_file('wizard');
|
||||
// Check access.
|
||||
check_login();
|
||||
|
||||
if (! $this->aclMulticheck()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check multiple acl perms.
|
||||
*
|
||||
* @param string $access Access in PM|AR|RR format. Optional.
|
||||
*
|
||||
* @return boolean Alowed or not.
|
||||
*/
|
||||
public function aclMulticheck($access=null)
|
||||
{
|
||||
global $config;
|
||||
|
||||
if (isset($access)) {
|
||||
$perms = explode('|', $access);
|
||||
} else {
|
||||
$perms = explode('|', $this->access);
|
||||
}
|
||||
|
||||
$allowed = false;
|
||||
foreach ($perms as $perm) {
|
||||
$allowed = $allowed || (bool) check_acl(
|
||||
$config['id_user'],
|
||||
0,
|
||||
$perm
|
||||
);
|
||||
}
|
||||
|
||||
return $allowed;
|
||||
}
|
||||
|
||||
|
||||
|
@ -247,6 +290,14 @@ class Wizard
|
|||
**/
|
||||
public function load()
|
||||
{
|
||||
global $config;
|
||||
// Check access.
|
||||
check_login();
|
||||
|
||||
if (! $this->aclMulticheck()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return [
|
||||
'icon' => $this->icon,
|
||||
'label' => $this->label,
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 895 B |
Binary file not shown.
After Width: | Height: | Size: 4.5 KiB |
Binary file not shown.
After Width: | Height: | Size: 14 KiB |
|
@ -0,0 +1,60 @@
|
|||
<?php
|
||||
/**
|
||||
* Integria incidents management.
|
||||
*
|
||||
* @category Ajax library.
|
||||
* @package Pandora FMS
|
||||
* @subpackage Modules.
|
||||
* @version 1.0.0
|
||||
* @license See below
|
||||
*
|
||||
* ______ ___ _______ _______ ________
|
||||
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
|
||||
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
|
||||
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
|
||||
*
|
||||
* ============================================================================
|
||||
* Copyright (c) 2005-2019 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.
|
||||
* ============================================================================
|
||||
*/
|
||||
|
||||
if (check_login()) {
|
||||
global $config;
|
||||
|
||||
include_once $config['homedir'].'/include/functions_integriaims.php';
|
||||
|
||||
$get_users = get_parameter('get_users');
|
||||
$search_term = get_parameter('search_term', '');
|
||||
|
||||
if ($get_users) {
|
||||
$integria_users_csv = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_users', []);
|
||||
|
||||
$csv_array = explode("\n", $integria_users_csv);
|
||||
|
||||
foreach ($csv_array as $csv_line) {
|
||||
if (!empty($csv_line)) {
|
||||
$integria_users_values[$csv_line] = $csv_line;
|
||||
}
|
||||
}
|
||||
|
||||
$integria_users_filtered_values = array_filter(
|
||||
$integria_users_values,
|
||||
function ($item) use ($search_term) {
|
||||
if (strpos($item, $search_term) !== false) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
echo json_encode($integria_users_filtered_values);
|
||||
return;
|
||||
}
|
||||
}
|
|
@ -1113,7 +1113,7 @@ if (check_login()) {
|
|||
}
|
||||
|
||||
if ($module['id_tipo_modulo'] != 25) {
|
||||
$data[6] = ui_print_module_warn_value($module['max_warning'], $module['min_warning'], $module['str_warning'], $module['max_critical'], $module['min_critical'], $module['str_critical']);
|
||||
$data[6] = ui_print_module_warn_value($module['max_warning'], $module['min_warning'], $module['str_warning'], $module['max_critical'], $module['min_critical'], $module['str_critical'], $module['warning_inverse'], $module['critical_inverse']);
|
||||
} else {
|
||||
$data[6] = '';
|
||||
}
|
||||
|
|
|
@ -1,15 +1,32 @@
|
|||
<?php
|
||||
// Pandora FMS- http://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2011 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.
|
||||
/**
|
||||
* Pandora FMS integration API.
|
||||
*
|
||||
* @category API
|
||||
* @package Pandora FMS
|
||||
* @subpackage Console
|
||||
* @version 1.0.0
|
||||
* @license See below
|
||||
*
|
||||
* ______ ___ _______ _______ ________
|
||||
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
|
||||
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
|
||||
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
|
||||
*
|
||||
* ============================================================================
|
||||
* Copyright (c) 2005-2019 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.
|
||||
* ============================================================================
|
||||
*/
|
||||
|
||||
// Begin.
|
||||
require_once 'config.php';
|
||||
require_once 'functions_api.php';
|
||||
|
||||
|
@ -18,7 +35,7 @@ global $config;
|
|||
define('DEBUG', 0);
|
||||
define('VERBOSE', 0);
|
||||
|
||||
// TESTING THE UPDATE MANAGER
|
||||
// TESTING THE UPDATE MANAGER.
|
||||
enterprise_include_once('include/functions_enterprise_api.php');
|
||||
|
||||
$ipOrigin = $_SERVER['REMOTE_ADDR'];
|
||||
|
@ -41,26 +58,30 @@ $info = get_parameter('info', '');
|
|||
$other = parseOtherParameter($otherSerialize, $otherMode);
|
||||
|
||||
$other = parseOtherParameter($otherSerialize, $otherMode);
|
||||
$apiPassword = io_output_password(db_get_value_filter('value', 'tconfig', ['token' => 'api_password']));
|
||||
$apiPassword = io_output_password(
|
||||
db_get_value_filter(
|
||||
'value',
|
||||
'tconfig',
|
||||
['token' => 'api_password']
|
||||
)
|
||||
);
|
||||
|
||||
$correctLogin = false;
|
||||
$no_login_msg = '';
|
||||
|
||||
// Clean unwanted output
|
||||
// Clean unwanted output.
|
||||
ob_clean();
|
||||
|
||||
// READ THIS:
|
||||
// Special call without checks to retrieve version and build of the Pandora FMS
|
||||
// This info is avalable from the web console without login
|
||||
// Don't change the format, it is parsed by applications
|
||||
switch ($info) {
|
||||
case 'version':
|
||||
if (!$config['MR']) {
|
||||
$config['MR'] = 0;
|
||||
}
|
||||
|
||||
echo 'Pandora FMS '.$pandora_version.' - '.$build_version.' MR'.$config['MR'];
|
||||
// Don't change the format, it is parsed by applications.
|
||||
if ($info == 'version') {
|
||||
if (!$config['MR']) {
|
||||
$config['MR'] = 0;
|
||||
}
|
||||
|
||||
echo 'Pandora FMS '.$pandora_version.' - '.$build_version.' MR'.$config['MR'];
|
||||
exit;
|
||||
}
|
||||
|
||||
|
@ -68,14 +89,19 @@ if (isInACL($ipOrigin)) {
|
|||
if (empty($apiPassword) || (!empty($apiPassword) && $api_password === $apiPassword)) {
|
||||
$user_in_db = process_user_login($user, $password, true);
|
||||
if ($user_in_db !== false) {
|
||||
$config['id_usuario'] = $user_in_db;
|
||||
// Compat.
|
||||
$config['id_user'] = $user_in_db;
|
||||
$correctLogin = true;
|
||||
|
||||
if (session_status() === PHP_SESSION_NONE) {
|
||||
session_start();
|
||||
$_SESSION = [];
|
||||
}
|
||||
|
||||
$_SESSION['id_usuario'] = $user;
|
||||
|
||||
config_prepare_session();
|
||||
session_write_close();
|
||||
} else {
|
||||
$no_login_msg = 'Incorrect user credentials';
|
||||
|
@ -84,7 +110,7 @@ if (isInACL($ipOrigin)) {
|
|||
$no_login_msg = 'Incorrect given API password';
|
||||
}
|
||||
} else {
|
||||
$no_login_msg = "IP $ipOrigin is not in ACL list";
|
||||
$no_login_msg = 'IP '.$ipOrigin.' is not in ACL list';
|
||||
}
|
||||
|
||||
if ($correctLogin) {
|
||||
|
@ -93,11 +119,14 @@ if ($correctLogin) {
|
|||
} else {
|
||||
$function_name = '';
|
||||
|
||||
// Check if is an extension function and get the function name
|
||||
// Check if is an extension function and get the function name.
|
||||
if ($op2 == 'extension') {
|
||||
$extension_api_url = $config['homedir'].'/'.EXTENSIONS_DIR."/$ext_name/$ext_name.api.php";
|
||||
// The extension API file must exist and the extension must be enabled
|
||||
if (file_exists($extension_api_url) && !in_array($ext_name, extensions_get_disabled_extensions())) {
|
||||
$extension_api_url = $config['homedir'].'/'.EXTENSIONS_DIR.'/'.$ext_name.'/'.$ext_name.'.api.php';
|
||||
// The extension API file must exist and the extension must be
|
||||
// enabled.
|
||||
if (file_exists($extension_api_url)
|
||||
&& !in_array($ext_name, extensions_get_disabled_extensions())
|
||||
) {
|
||||
include_once $extension_api_url;
|
||||
$function_name = 'apiextension_'.$op.'_'.$ext_function;
|
||||
}
|
||||
|
@ -107,16 +136,19 @@ if ($correctLogin) {
|
|||
if ($op == 'set' && $id) {
|
||||
switch ($op2) {
|
||||
case 'update_agent':
|
||||
|
||||
case 'add_module_in_conf':
|
||||
case 'update_module_in_conf':
|
||||
case 'delete_module_in_conf':
|
||||
|
||||
$id_os = db_get_value_sql('select id_os from tagente where id_agente = '.$id);
|
||||
|
||||
if ($id_os == 100) {
|
||||
returnError('not_allowed_operation_cluster', $returnType);
|
||||
return false;
|
||||
$agent = agents_locate_agent($id);
|
||||
if ($agent !== false) {
|
||||
$id_os = $agent['id_os'];
|
||||
if ($id_os == 100) {
|
||||
returnError(
|
||||
'not_allowed_operation_cluster',
|
||||
$returnType
|
||||
);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -127,12 +159,16 @@ if ($correctLogin) {
|
|||
case 'create_snmp_module':
|
||||
case 'delete_module':
|
||||
case 'delete_agent':
|
||||
|
||||
$id_os = db_get_value_sql('select id_os from tagente where nombre = "'.$id.'"');
|
||||
|
||||
if ($id_os == 100) {
|
||||
returnError('not_allowed_operation_cluster', $returnType);
|
||||
return false;
|
||||
$agent = agents_locate_agent($id);
|
||||
if ($agent !== false) {
|
||||
$id_os = $agent['id_os'];
|
||||
if ($id_os == 100) {
|
||||
returnError(
|
||||
'not_allowed_operation_cluster',
|
||||
$returnType
|
||||
);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -141,60 +177,98 @@ if ($correctLogin) {
|
|||
case 'update_data_module':
|
||||
case 'update_snmp_module':
|
||||
|
||||
$id_os = db_get_value_sql('select id_os from tagente where id_agente = (select id_agente from tagente_modulo where id_agente_modulo ='.$id.')');
|
||||
$id_os = db_get_value_sql(
|
||||
sprintf(
|
||||
'SELECT id_os
|
||||
FROM tagente
|
||||
WHERE id_agente = (
|
||||
SELECT id_agente
|
||||
FROM tagente_modulo
|
||||
WHERE id_agente_modulo = %d
|
||||
)',
|
||||
$id
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
if ($id_os == 100) {
|
||||
returnError('not_allowed_operation_cluster', $returnType);
|
||||
returnError(
|
||||
'not_allowed_operation_cluster',
|
||||
$returnType
|
||||
);
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'delete_user_permission':
|
||||
|
||||
if ($user_db === '') {
|
||||
returnError(__('User or group not specified'), __('User, group not specified'));
|
||||
returnError(
|
||||
__('User or group not specified'),
|
||||
__('User, group not specified')
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
$id_os = api_set_delete_user_profiles($thrash1, $thrash2, $other, $returnType);
|
||||
$id_os = api_set_delete_user_profiles(
|
||||
$thrash1,
|
||||
$thrash2,
|
||||
$other,
|
||||
$returnType
|
||||
);
|
||||
|
||||
if ($id_os != 100) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($id_os == false) {
|
||||
returnError('not_allowed_operation_cluster', $returnType);
|
||||
returnError(
|
||||
'not_allowed_operation_cluster',
|
||||
$returnType
|
||||
);
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'add_permission_user_to_group':
|
||||
|
||||
if ($user_db == null || $group_db == null || $id_up == null) {
|
||||
returnError(__('User, group or profile not specified'), __('User, group or profile status not specified'));
|
||||
if ($user_db == null
|
||||
|| $group_db == null
|
||||
|| $id_up == null
|
||||
) {
|
||||
returnError(
|
||||
__('User, group or profile not specified'),
|
||||
__('User, group or profile status not specified')
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
$id_os = api_set_add_permission_user_to_group($thrash1, $thrash2, $other, $returnType);
|
||||
$id_os = api_set_add_permission_user_to_group(
|
||||
$thrash1,
|
||||
$thrash2,
|
||||
$other,
|
||||
$returnType
|
||||
);
|
||||
|
||||
if ($id_os != 100) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($id_os == false) {
|
||||
returnError('not_allowed_operation_cluster', $returnType);
|
||||
returnError(
|
||||
'not_allowed_operation_cluster',
|
||||
$returnType
|
||||
);
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
// break;
|
||||
// Ignore.
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check if the function exists
|
||||
// Check if the function exists.
|
||||
if (function_exists($function_name)) {
|
||||
if (!DEBUG) {
|
||||
error_reporting(0);
|
||||
|
@ -205,18 +279,37 @@ if ($correctLogin) {
|
|||
ini_set('display_errors', 1);
|
||||
}
|
||||
|
||||
call_user_func($function_name, $id, $id2, $other, $returnType, $user_in_db);
|
||||
call_user_func(
|
||||
$function_name,
|
||||
$id,
|
||||
$id2,
|
||||
$other,
|
||||
$returnType,
|
||||
$user_in_db
|
||||
);
|
||||
} else {
|
||||
returnError('no_exist_operation', $returnType);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// TODO: Implement a new switch in config to enable / disable
|
||||
// ACL auth failure: if enabled and have lots of traffic can produce millions
|
||||
// of records and a considerable OVERHEAD in the system :(
|
||||
// db_pandora_audit("API access Failed", $no_login_msg, $user, $ipOrigin);
|
||||
/*
|
||||
* //TODO: Implement a new switch in config to enable / disable
|
||||
* ACL auth failure: if enabled and have lots of traffic can produce
|
||||
* millions of records and a considerable OVERHEAD in the system :(
|
||||
* db_pandora_audit("API access Failed", $no_login_msg, $user, $ipOrigin);
|
||||
*/
|
||||
|
||||
sleep(15);
|
||||
|
||||
// Protection on DoS attacks
|
||||
// Protection on DoS attacks.
|
||||
echo 'auth error';
|
||||
}
|
||||
|
||||
// Logout.
|
||||
if (session_status() === PHP_SESSION_ACTIVE) {
|
||||
$_SESSION = [];
|
||||
// Could give a warning if no session file is created. Ignore.
|
||||
@session_destroy();
|
||||
header_remove('Set-Cookie');
|
||||
setcookie(session_name(), $_COOKIE[session_name()], (time() - 4800), '/');
|
||||
}
|
||||
|
|
|
@ -1,22 +1,39 @@
|
|||
<?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 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.
|
||||
// Global & session manageme
|
||||
session_id($_REQUEST['session_id']);
|
||||
/**
|
||||
* Generate charts with given parameters.
|
||||
*
|
||||
* @category ChartGenerator.
|
||||
* @package Pandora FMS
|
||||
* @subpackage Opensource.
|
||||
* @version 1.0.0
|
||||
* @license See below
|
||||
*
|
||||
* ______ ___ _______ _______ ________
|
||||
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
|
||||
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
|
||||
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
|
||||
*
|
||||
* ============================================================================
|
||||
* Copyright (c) 2005-2019 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.
|
||||
* ============================================================================
|
||||
*/
|
||||
|
||||
// Begin.
|
||||
require_once 'config.php';
|
||||
require_once $config['homedir'].'/include/auth/mysql.php';
|
||||
require_once $config['homedir'].'/include/functions.php';
|
||||
require_once $config['homedir'].'/include/functions_db.php';
|
||||
|
||||
require_once __DIR__.'/config.php';
|
||||
require_once __DIR__.'/functions.php';
|
||||
require_once __DIR__.'/functions_db.php';
|
||||
require_once __DIR__.'/auth/mysql.php';
|
||||
require_once $config['homedir'].'/include/lib/User.php';
|
||||
require_once $config['homedir'].'/include/functions_reporting.php';
|
||||
require_once $config['homedir'].'/include/functions_graph.php';
|
||||
require_once $config['homedir'].'/include/functions_custom_graphs.php';
|
||||
|
@ -24,32 +41,91 @@ require_once $config['homedir'].'/include/functions_modules.php';
|
|||
require_once $config['homedir'].'/include/functions_agents.php';
|
||||
require_once $config['homedir'].'/include/functions_tags.php';
|
||||
|
||||
check_login();
|
||||
|
||||
/**
|
||||
* Echo to stdout a PhantomJS callback call.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function echoPhantomCallback()
|
||||
{
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
$('document').ready(function () {
|
||||
setTimeout(function () {
|
||||
try {
|
||||
var status = window.callPhantom({ status: "loaded" });
|
||||
} catch (error) {
|
||||
console.log("CALLBACK ERROR", error.message)
|
||||
}
|
||||
}, 100);
|
||||
});
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
|
||||
|
||||
// Initialize session.
|
||||
global $config;
|
||||
// get_parameter(array)('data', '');
|
||||
|
||||
// Try to initialize session using existing php session id.
|
||||
$user = new PandoraFMS\User(['phpsessionid' => $_REQUEST['session_id']]);
|
||||
if (check_login(false) === false) {
|
||||
// Error handler.
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<title>Access denied</title>
|
||||
<link rel="stylesheet" href="styles/pandora.css" type="text/css" />
|
||||
<link rel="stylesheet" href="styles/pandora_minimal.css" type="text/css" />
|
||||
<link rel="stylesheet" href="styles/js/jquery-ui.min.css" type="text/css" />
|
||||
<link rel="stylesheet" href="styles/js/jquery-ui_custom.css" type="text/css" />
|
||||
<script language="javascript" type='text/javascript' src='javascript/pandora.js'></script>
|
||||
<script language="javascript" type='text/javascript' src='javascript/jquery-3.3.1.min.js'></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Access is not granted</h1>
|
||||
<?php echoPhantomCallback(); ?>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
<?php
|
||||
exit;
|
||||
}
|
||||
|
||||
// Access granted.
|
||||
$params = json_decode($_REQUEST['data'], true);
|
||||
|
||||
// Metaconsole connection to the node
|
||||
// Metaconsole connection to the node.
|
||||
$server_id = $params['server_id'];
|
||||
|
||||
if ($config['metaconsole'] && !empty($server_id)) {
|
||||
$server = metaconsole_get_connection_by_id($server_id);
|
||||
// Error connecting
|
||||
// Error connecting.
|
||||
if (metaconsole_connect($server) !== NOERR) {
|
||||
echo '<html>';
|
||||
echo '<body>';
|
||||
ui_print_error_message(__('There was a problem connecting with the node'));
|
||||
echo '</body>';
|
||||
echo '</html>';
|
||||
?>
|
||||
<html>
|
||||
<body>
|
||||
<?php
|
||||
ui_print_error_message(
|
||||
__('There was a problem connecting with the node')
|
||||
);
|
||||
echoPhantomCallback();
|
||||
?>
|
||||
</body>
|
||||
</html>
|
||||
<?php
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$user_language = get_user_language($config['id_user']);
|
||||
if (file_exists('languages/'.$user_language.'.mo')) {
|
||||
$l10n = new gettext_reader(new CachedFileReader('languages/'.$user_language.'.mo'));
|
||||
if (file_exists('languages/'.$user_language.'.mo') === true) {
|
||||
$cfr = new CachedFileReader('languages/'.$user_language.'.mo');
|
||||
$l10n = new gettext_reader($cfr);
|
||||
$l10n->load_tables();
|
||||
}
|
||||
|
||||
|
@ -85,16 +161,18 @@ if (file_exists('languages/'.$user_language.'.mo')) {
|
|||
<body bgcolor="#ffffff" style='background:#ffffff;'>
|
||||
<?php
|
||||
$params['only_image'] = false;
|
||||
$params['width'] = (int) $_REQUEST['viewport_width'];
|
||||
$params['menu'] = false;
|
||||
$params['width'] = (int) $_REQUEST['viewport_width'];
|
||||
$params['menu'] = false;
|
||||
|
||||
if ((!isset($params['width']) || ($params['width'] <= 0))) {
|
||||
if ((isset($params['width']) === false
|
||||
|| ($params['width'] <= 0))
|
||||
) {
|
||||
$params['width'] = 650;
|
||||
}
|
||||
|
||||
$params_combined = json_decode($_REQUEST['data_combined'], true);
|
||||
$module_list = json_decode($_REQUEST['data_module_list'], true);
|
||||
$type_graph_pdf = $_REQUEST['type_graph_pdf'];
|
||||
$module_list = json_decode($_REQUEST['data_module_list'], true);
|
||||
$type_graph_pdf = $_REQUEST['type_graph_pdf'];
|
||||
|
||||
echo '<div>';
|
||||
switch ($type_graph_pdf) {
|
||||
|
@ -208,25 +286,12 @@ if (file_exists('languages/'.$user_language.'.mo')) {
|
|||
break;
|
||||
|
||||
default:
|
||||
// code...
|
||||
// Code...
|
||||
break;
|
||||
}
|
||||
|
||||
echo '</div>';
|
||||
|
||||
echoPhantomCallback();
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
$('document').ready(function () {
|
||||
setTimeout(function () {
|
||||
try {
|
||||
var status = window.callPhantom({ status: "loaded" });
|
||||
} catch (error) {
|
||||
console.log("CALLBACK ERROR", error.message)
|
||||
}
|
||||
}, 100);
|
||||
});
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -209,6 +209,12 @@ class ConsoleSupervisor
|
|||
|
||||
$this->getUMMessages();
|
||||
|
||||
/*
|
||||
* Check if the Server and Console has
|
||||
* the same versions.
|
||||
*/
|
||||
$this->checkConsoleServerVersions();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -435,6 +441,12 @@ class ConsoleSupervisor
|
|||
|
||||
$this->getUMMessages();
|
||||
|
||||
/*
|
||||
* Check if the Server and Console has
|
||||
* the same versions.
|
||||
*/
|
||||
$this->checkConsoleServerVersions();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -873,18 +885,20 @@ class ConsoleSupervisor
|
|||
{
|
||||
global $config;
|
||||
|
||||
$remote_config_dir = io_safe_output($config['remote_config']);
|
||||
|
||||
if (enterprise_installed()
|
||||
&& isset($config['license_nms'])
|
||||
&& $config['license_nms'] != 1
|
||||
) {
|
||||
if (is_readable($config['remote_config']) !== true) {
|
||||
if (is_readable($remote_config_dir) !== true) {
|
||||
$this->notify(
|
||||
[
|
||||
'type' => 'NOTIF.PERMISSIONS.REMOTE_CONFIG',
|
||||
'title' => __('Remote configuration directory is not readable'),
|
||||
'message' => __(
|
||||
'Remote configuration directory %s is not readable. Please, adjust configuration.',
|
||||
$config['remote_config']
|
||||
$remote_config_dir
|
||||
),
|
||||
'url' => ui_get_full_url('index.php?sec=general&sec2=godmode/setup/setup§ion=general'),
|
||||
]
|
||||
|
@ -896,14 +910,14 @@ class ConsoleSupervisor
|
|||
);
|
||||
}
|
||||
|
||||
if (is_writable($config['remote_config'].'/conf') !== true) {
|
||||
if (is_writable($remote_config_dir.'/conf') !== true) {
|
||||
$this->notify(
|
||||
[
|
||||
'type' => 'NOTIF.PERMISSIONS.REMOTE_CONFIG.CONF',
|
||||
'title' => __('Remote configuration directory is not writable'),
|
||||
'message' => __(
|
||||
'Remote configuration directory %s is not writable. Please, adjust configuration.',
|
||||
$config['remote_config'].'/conf'
|
||||
$remote_config_dir.'/conf'
|
||||
),
|
||||
'url' => ui_get_full_url('index.php?sec=general&sec2=godmode/setup/setup§ion=general'),
|
||||
]
|
||||
|
@ -914,14 +928,14 @@ class ConsoleSupervisor
|
|||
);
|
||||
}
|
||||
|
||||
if (is_writable($config['remote_config'].'/collections') !== true) {
|
||||
if (is_writable($remote_config_dir.'/collections') !== true) {
|
||||
$this->notify(
|
||||
[
|
||||
'type' => 'NOTIF.PERMISSIONS.REMOTE_CONFIG.COLLECTIONS',
|
||||
'title' => __('Remote collections directory is not writable'),
|
||||
'message' => __(
|
||||
'Collections directory %s is not writable. Please, adjust configuration.',
|
||||
$config['remote_config'].'/collections'
|
||||
$remote_config_dir.'/collections'
|
||||
),
|
||||
'url' => ui_get_full_url('index.php?sec=general&sec2=godmode/setup/setup§ion=general'),
|
||||
]
|
||||
|
@ -932,14 +946,14 @@ class ConsoleSupervisor
|
|||
);
|
||||
}
|
||||
|
||||
if (is_writable($config['remote_config'].'/md5') !== true) {
|
||||
if (is_writable($remote_config_dir.'/md5') !== true) {
|
||||
$this->notify(
|
||||
[
|
||||
'type' => 'NOTIF.PERMISSIONS.REMOTE_CONFIG.MD5',
|
||||
'title' => __('Remote md5 directory is not writable'),
|
||||
'message' => __(
|
||||
'MD5 directory %s is not writable. Please, adjust configuration.',
|
||||
$config['remote_config'].'/md5'
|
||||
$remote_config_dir.'/md5'
|
||||
),
|
||||
'url' => ui_get_full_url('index.php?sec=general&sec2=godmode/setup/setup§ion=general'),
|
||||
]
|
||||
|
@ -957,7 +971,7 @@ class ConsoleSupervisor
|
|||
$MAX_BADXML_FILES_DATA_IN = 150;
|
||||
|
||||
$filecount = $this->countFiles(
|
||||
$config['remote_config'],
|
||||
$remote_config_dir,
|
||||
'',
|
||||
$MAX_FILES_DATA_IN
|
||||
);
|
||||
|
@ -970,7 +984,7 @@ class ConsoleSupervisor
|
|||
'message' => __(
|
||||
'There are more than %d files in %s. Consider checking DataServer performance',
|
||||
$MAX_FILES_DATA_IN,
|
||||
$config['remote_config']
|
||||
$remote_config_dir
|
||||
),
|
||||
'url' => ui_get_full_url('index.php?sec=general&sec2=godmode/setup/setup§ion=perf'),
|
||||
]
|
||||
|
@ -980,7 +994,7 @@ class ConsoleSupervisor
|
|||
}
|
||||
|
||||
$filecount = $this->countFiles(
|
||||
$config['remote_config'],
|
||||
$remote_config_dir,
|
||||
'/^.*BADXML$/',
|
||||
$MAX_BADXML_FILES_DATA_IN
|
||||
);
|
||||
|
@ -993,7 +1007,7 @@ class ConsoleSupervisor
|
|||
'message' => __(
|
||||
'There are more than %d files in %s. Consider checking software agents.',
|
||||
$MAX_BADXML_FILES_DATA_IN,
|
||||
$config['remote_config']
|
||||
$remote_config_dir
|
||||
),
|
||||
'url' => ui_get_full_url('index.php?sec=general&sec2=godmode/setup/setup§ion=perf'),
|
||||
]
|
||||
|
@ -1266,7 +1280,8 @@ class ConsoleSupervisor
|
|||
$PHPSerialize_precision = ini_get('serialize_precision');
|
||||
|
||||
// PhantomJS status.
|
||||
$result_ejecution = exec($config['phantomjs_bin'].'/phantomjs --version');
|
||||
$phantomjs_dir = io_safe_output($config['phantomjs_bin']);
|
||||
$result_ejecution = exec($phantomjs_dir.'/phantomjs --version');
|
||||
|
||||
// PHP version checks.
|
||||
$php_version = phpversion();
|
||||
|
@ -1451,8 +1466,9 @@ class ConsoleSupervisor
|
|||
'type' => 'NOTIF.PHP.SERIALIZE_PRECISION',
|
||||
'title' => sprintf(
|
||||
__("Not recommended '%s' value in PHP configuration"),
|
||||
'serialze_precision'
|
||||
), 'message' => sprintf(
|
||||
'serialize_precision'
|
||||
),
|
||||
'message' => sprintf(
|
||||
__('Recommended value is: %s'),
|
||||
sprintf('-1')
|
||||
).'<br><br>'.__('Please, change it on your PHP configuration file (php.ini) or contact with administrator'),
|
||||
|
@ -2061,8 +2077,10 @@ class ConsoleSupervisor
|
|||
{
|
||||
global $config;
|
||||
|
||||
if (($config['fontpath'] == '')
|
||||
|| (file_exists($config['fontpath']) === false)
|
||||
$fontpath = io_safe_output($config['fontpath']);
|
||||
|
||||
if (($fontpath == '')
|
||||
|| (file_exists($fontpath) === false)
|
||||
) {
|
||||
$this->notify(
|
||||
[
|
||||
|
@ -2328,4 +2346,35 @@ class ConsoleSupervisor
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if all servers and console versions are the same
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function checkConsoleServerVersions()
|
||||
{
|
||||
global $config;
|
||||
// List all servers except satellite server
|
||||
$server_version_list = db_get_all_rows_sql(
|
||||
'SELECT name, version FROM tserver WHERE server_type != '.SERVER_TYPE_ENTERPRISE_SATELLITE
|
||||
);
|
||||
|
||||
foreach ($server_version_list as $server) {
|
||||
if (strpos($server['version'], $config['current_package_enterprise']) === false) {
|
||||
$title_ver_misaligned = $server['name'].' version misaligned with Console';
|
||||
$message_ver_misaligned = 'Server '.$server['name'].' and this console have different versions. This might cause several malfunctions. Please, update this server.';
|
||||
|
||||
$this->notify(
|
||||
[
|
||||
'type' => 'NOTIF.SERVER.MISALIGNED',
|
||||
'title' => __($title_ver_misaligned),
|
||||
'message' => __($message_ver_misaligned),
|
||||
'url' => ui_get_full_url('index.php?sec=messages&sec2=godmode/update_manager/update_manager&tab=online'),
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -65,6 +65,8 @@ class CustomNetScan extends Wizard
|
|||
$this->url = ui_get_full_url(
|
||||
'index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=hd'
|
||||
);
|
||||
|
||||
$this->access = 'AW';
|
||||
$this->page = $page;
|
||||
$this->breadcrum = $breadcrum;
|
||||
}
|
||||
|
@ -77,6 +79,8 @@ class CustomNetScan extends Wizard
|
|||
*/
|
||||
public function parseNetScan()
|
||||
{
|
||||
global $config;
|
||||
|
||||
if (isset($this->page) === true && $this->page === 0) {
|
||||
// Check if we're updating a task.
|
||||
$task_id = get_parameter('task', null);
|
||||
|
@ -145,11 +149,11 @@ class CustomNetScan extends Wizard
|
|||
) {
|
||||
// Default values, no data received.
|
||||
// User is accesing directly to this page.
|
||||
if (users_is_admin() !== true && check_acl(
|
||||
$config['id_usuario'],
|
||||
if (check_acl(
|
||||
$config['id_user'],
|
||||
$this->task['id_group'],
|
||||
'PM'
|
||||
) !== true
|
||||
$this->access
|
||||
) != true
|
||||
) {
|
||||
$this->msg = __('You have no access to edit this task.');
|
||||
return false;
|
||||
|
@ -275,7 +279,7 @@ class CustomNetScan extends Wizard
|
|||
{
|
||||
global $config;
|
||||
|
||||
if (!check_acl($config['id_user'], 0, 'PM')) {
|
||||
if (!check_acl($config['id_user'], 0, $this->access)) {
|
||||
db_pandora_audit(
|
||||
'ACL Violation',
|
||||
'Trying to access Custom Net Scan.'
|
||||
|
@ -317,11 +321,11 @@ class CustomNetScan extends Wizard
|
|||
|
||||
// Check ACL. If user is not able to manage target task,
|
||||
// redirect him to main page.
|
||||
if (users_is_admin() !== true && check_acl(
|
||||
$config['id_usuario'],
|
||||
if (check_acl(
|
||||
$config['id_user'],
|
||||
$this->task['id_group'],
|
||||
'PM'
|
||||
) !== true
|
||||
$this->access
|
||||
) != true
|
||||
) {
|
||||
$form['form']['action'] = $this->url.'&mode=customnetscan&page='.($this->page - 1);
|
||||
}
|
||||
|
@ -496,7 +500,7 @@ class CustomNetScan extends Wizard
|
|||
'arguments' => [
|
||||
'name' => 'id_group',
|
||||
'returnAllGroup' => false,
|
||||
'privilege' => 'PM',
|
||||
'privilege' => $this->access,
|
||||
'type' => 'select_groups',
|
||||
'selected' => $this->task['id_group'],
|
||||
'return' => true,
|
||||
|
|
|
@ -65,6 +65,8 @@ class ManageNetScanScripts extends Wizard
|
|||
$this->url = ui_get_full_url(
|
||||
'index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=hd'
|
||||
);
|
||||
|
||||
$this->access = 'PM';
|
||||
$this->page = $page;
|
||||
$this->breadcrum = $breadcrum;
|
||||
}
|
||||
|
@ -81,7 +83,7 @@ class ManageNetScanScripts extends Wizard
|
|||
{
|
||||
global $config;
|
||||
|
||||
if (check_acl($config['id_user'], 0, 'AW') === 0) {
|
||||
if (check_acl($config['id_user'], 0, $this->access) === 0) {
|
||||
db_pandora_audit(
|
||||
'ACL Violation',
|
||||
'Trying to access Net Scan Script.'
|
||||
|
|
|
@ -2642,8 +2642,17 @@ class NetworkMap
|
|||
*/
|
||||
public function loadMapData()
|
||||
{
|
||||
global $config;
|
||||
|
||||
$networkmap = $this->map;
|
||||
|
||||
// ACL.
|
||||
$networkmap_write = check_acl(
|
||||
$config['id_user'],
|
||||
$networkmap['id_group'],
|
||||
'MW'
|
||||
);
|
||||
|
||||
$simulate = false;
|
||||
if (isset($networkmap['__simulated']) === false) {
|
||||
$networkmap['filter'] = json_decode(
|
||||
|
@ -2711,6 +2720,7 @@ class NetworkMap
|
|||
$output .= 'var networkmap_center = [ '.$networkmap['center_x'].', '.$networkmap['center_y']."];\n";
|
||||
$output .= 'var networkmap_dimensions = [ '.$networkmap['width'].', '.$networkmap['height']."];\n";
|
||||
$output .= 'var enterprise_installed = '.((int) enterprise_installed()).";\n";
|
||||
$output .= 'var networkmap_write = '.$networkmap_write.";\n";
|
||||
$output .= 'var node_radius = '.$networkmap['filter']['node_radius'].";\n";
|
||||
$output .= 'var networkmap_holding_area_dimensions = '.json_encode($networkmap['filter']['holding_area']).";\n";
|
||||
$output .= "var networkmap = {'nodes': [], 'links': []};\n";
|
||||
|
|
|
@ -1075,6 +1075,8 @@ class Tree
|
|||
ON ta.id_agente = tasg.id_agent
|
||||
LEFT JOIN talert_template_modules tatm
|
||||
ON tatm.id_agent_module = tam.id_agente_modulo
|
||||
AND tatm.id_alert_template = 1
|
||||
OR tatm.id_alert_template = NULL
|
||||
$inner
|
||||
WHERE tam.disabled = 0 AND ta.disabled = 0
|
||||
$condition
|
||||
|
|
|
@ -104,7 +104,7 @@ class TreeService extends Tree
|
|||
break;
|
||||
|
||||
case SERVICE_STATUS_WARNING:
|
||||
$processed_items[$row['id']][$key]['statusImageHTML'] = '<img src="images/status_sets/default/agent_warning_ball.png" data-title="WARNING status." data-use_title_for_force_title="1" class="forced_title" alt="WARNING status." />';
|
||||
$processed_items[$row['id']]['statusImageHTML'] = '<img src="images/status_sets/default/agent_warning_ball.png" data-title="WARNING status." data-use_title_for_force_title="1" class="forced_title" alt="WARNING status." />';
|
||||
break;
|
||||
|
||||
case SERVICE_STATUS_UNKNOWN:
|
||||
|
|
|
@ -20,8 +20,8 @@
|
|||
/**
|
||||
* Pandora build version and version
|
||||
*/
|
||||
$build_version = 'PC190923';
|
||||
$pandora_version = 'v7.0NG.738';
|
||||
$build_version = 'PC191029';
|
||||
$pandora_version = 'v7.0NG.740';
|
||||
|
||||
// Do not overwrite default timezone set if defined.
|
||||
$script_tz = @date_default_timezone_get();
|
||||
|
|
|
@ -3789,11 +3789,20 @@ function series_type_graph_array($data, $show_elements_graph)
|
|||
} else if (strpos($key, 'percentil') !== false) {
|
||||
$data_return['series_type'][$key] = 'percentil';
|
||||
if ($show_elements_graph['percentil']) {
|
||||
$data_return['legend'][$key] = __('Percentil').' '.$config['percentil'].'º '.__('of module').' ';
|
||||
if ($show_elements_graph['unit']) {
|
||||
$name_legend = $data_return['legend'][$key] = $value['agent_alias'].' / '.$value['module_name'].' / '.__('Unit ').' '.$show_elements_graph['unit'].': ';
|
||||
$name_legend = __('Percentil').' ';
|
||||
$name_legend .= $config['percentil'].'º ';
|
||||
$name_legend .= __('of module').' ';
|
||||
$name_legend .= $value['agent_alias'].' / ';
|
||||
$name_legend .= $value['module_name'].' / ';
|
||||
$name_legend .= __('Unit ').' ';
|
||||
$name_legend .= $show_elements_graph['unit'].': ';
|
||||
} else {
|
||||
$name_legend = $data_return['legend'][$key] = $value['agent_alias'].' / '.$value['module_name'].': ';
|
||||
$name_legend = __('Percentil').' ';
|
||||
$name_legend .= $config['percentil'].'º ';
|
||||
$name_legend .= __('of module').' ';
|
||||
$name_legend .= $value['agent_alias'].' / ';
|
||||
$name_legend .= $value['module_name'].': ';
|
||||
}
|
||||
|
||||
$data_return['legend'][$key] .= $name_legend;
|
||||
|
@ -4086,7 +4095,7 @@ function mask2cidr($mask)
|
|||
function get_help_info($section_name)
|
||||
{
|
||||
global $config;
|
||||
// hd($section_name);
|
||||
|
||||
$user_language = get_user_language($id_user);
|
||||
|
||||
$es = false;
|
||||
|
@ -5412,7 +5421,6 @@ function get_help_info($section_name)
|
|||
break;
|
||||
}
|
||||
|
||||
// hd($result);
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1434,6 +1434,92 @@ function config_update_config()
|
|||
}
|
||||
break;
|
||||
|
||||
case 'integria':
|
||||
if (!config_update_value('integria_enabled', (int) get_parameter('integria_enabled', 0))) {
|
||||
$error_update[] = __('Enable Integria IMS');
|
||||
}
|
||||
|
||||
if (!config_update_value('integria_user', (string) get_parameter('integria_user', $config['integria_user']))) {
|
||||
$error_update[] = __('Integria user');
|
||||
}
|
||||
|
||||
if (!config_update_value('integria_pass', io_input_password((string) get_parameter('integria_pass', $config['integria_pass'])))) {
|
||||
$error_update[] = __('Integria password');
|
||||
}
|
||||
|
||||
if (!config_update_value('integria_hostname', (string) get_parameter('integria_hostname', $config['integria_hostname']))) {
|
||||
$error_update[] = __('integria API hostname');
|
||||
}
|
||||
|
||||
if (!config_update_value('integria_api_pass', io_input_password((string) get_parameter('integria_api_pass', $config['integria_api_pass'])))) {
|
||||
$error_update[] = __('Integria API password');
|
||||
}
|
||||
|
||||
if (!config_update_value('integria_req_timeout', (int) get_parameter('integria_req_timeout', $config['integria_req_timeout']))) {
|
||||
$error_update[] = __('Integria request timeout');
|
||||
}
|
||||
|
||||
if (!config_update_value('default_group', (int) get_parameter('default_group', $config['default_group']))) {
|
||||
$error_update[] = __('Integria default group');
|
||||
}
|
||||
|
||||
if (!config_update_value('cr_default_group', (int) get_parameter('cr_default_group', $config['cr_default_group']))) {
|
||||
$error_update[] = __('Integria custom response default group');
|
||||
}
|
||||
|
||||
if (!config_update_value('default_criticity', (int) get_parameter('default_criticity', $config['default_criticity']))) {
|
||||
$error_update[] = __('Integria default priority');
|
||||
}
|
||||
|
||||
if (!config_update_value('cr_default_criticity', (int) get_parameter('cr_default_criticity', $config['cr_default_criticity']))) {
|
||||
$error_update[] = __('Integria custom response default priority');
|
||||
}
|
||||
|
||||
if (!config_update_value('default_creator', (string) get_parameter('default_creator', $config['default_creator']))) {
|
||||
$error_update[] = __('Integria default creator');
|
||||
}
|
||||
|
||||
if (!config_update_value('default_owner', (string) get_parameter('default_owner', $config['default_owner']))) {
|
||||
$error_update[] = __('Integria default owner');
|
||||
}
|
||||
|
||||
if (!config_update_value('cr_default_owner', (string) get_parameter('cr_default_owner', $config['cr_default_owner']))) {
|
||||
$error_update[] = __('Integria custom response default owner');
|
||||
}
|
||||
|
||||
if (!config_update_value('incident_type', (int) get_parameter('incident_type', $config['incident_type']))) {
|
||||
$error_update[] = __('Integria default ticket type');
|
||||
}
|
||||
|
||||
if (!config_update_value('cr_incident_type', (int) get_parameter('cr_incident_type', $config['cr_incident_type']))) {
|
||||
$error_update[] = __('Integria custom response default ticket type');
|
||||
}
|
||||
|
||||
if (!config_update_value('incident_status', (int) get_parameter('incident_status', $config['incident_status']))) {
|
||||
$error_update[] = __('Integria default ticket status');
|
||||
}
|
||||
|
||||
if (!config_update_value('cr_incident_status', (int) get_parameter('cr_incident_status', $config['cr_incident_status']))) {
|
||||
$error_update[] = __('Integria custom response default ticket status');
|
||||
}
|
||||
|
||||
if (!config_update_value('incident_title', (string) get_parameter('incident_title', $config['incident_title']))) {
|
||||
$error_update[] = __('Integria default ticket title');
|
||||
}
|
||||
|
||||
if (!config_update_value('cr_incident_title', (string) get_parameter('cr_incident_title', $config['cr_incident_title']))) {
|
||||
$error_update[] = __('Integria custom response default ticket title');
|
||||
}
|
||||
|
||||
if (!config_update_value('incident_content', (string) get_parameter('incident_content', $config['incident_content']))) {
|
||||
$error_update[] = __('Integria default ticket content');
|
||||
}
|
||||
|
||||
if (!config_update_value('cr_incident_content', (string) get_parameter('cr_incident_content', $config['cr_incident_content']))) {
|
||||
$error_update[] = __('Integria custom response default ticket content');
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
// Ignore.
|
||||
break;
|
||||
|
@ -1500,7 +1586,7 @@ function config_process_config()
|
|||
|
||||
if (!isset($config['remote_config'])) {
|
||||
if ($is_windows) {
|
||||
$default = 'C:\\PandoraFMS\\Pandora_Server\\data_in';
|
||||
$default = 'C:\PandoraFMS\Pandora_Server\data_in';
|
||||
} else {
|
||||
$default = '/var/spool/pandora/data_in';
|
||||
}
|
||||
|
@ -1510,7 +1596,7 @@ function config_process_config()
|
|||
|
||||
if (!isset($config['phantomjs_bin'])) {
|
||||
if ($is_windows) {
|
||||
$default = 'C:\\PandoraFMS\\phantomjs';
|
||||
$default = 'C:\PandoraFMS\Pandora_Server\bin';
|
||||
} else {
|
||||
$default = '/usr/bin';
|
||||
}
|
||||
|
@ -1760,7 +1846,13 @@ function config_process_config()
|
|||
}
|
||||
|
||||
if (!isset($config['auditdir'])) {
|
||||
config_update_value('auditdir', '/var/www/html/pandora_console');
|
||||
$auditdir = '/var/www/html/pandora_console';
|
||||
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
|
||||
// Windows.
|
||||
$auditdir = $config['homedir'];
|
||||
}
|
||||
|
||||
config_update_value('auditdir', $auditdir);
|
||||
}
|
||||
|
||||
if (!isset($config['elasticsearch_ip'])) {
|
||||
|
@ -1794,6 +1886,7 @@ function config_process_config()
|
|||
/*
|
||||
* Parse the ACL IP list for access API
|
||||
*/
|
||||
|
||||
$temp_list_ACL_IPs_for_API = [];
|
||||
if (isset($config['list_ACL_IPs_for_API'])) {
|
||||
if (!empty($config['list_ACL_IPs_for_API'])) {
|
||||
|
@ -1804,13 +1897,16 @@ function config_process_config()
|
|||
$config['list_ACL_IPs_for_API'] = $temp_list_ACL_IPs_for_API;
|
||||
$keysConfig = array_keys($config);
|
||||
|
||||
// This is not set here. The first time, when no
|
||||
// setup is done, update_manager extension manage it
|
||||
// the first time make a conenction and disable itself
|
||||
// Not Managed here !
|
||||
// if (!isset ($config["autoupdate"])) {
|
||||
// config_update_value ('autoupdate', true);.
|
||||
// }
|
||||
/*
|
||||
* This is not set here. The first time, when no
|
||||
* setup is done, update_manager extension manage it
|
||||
* the first time make a conenction and disable itself
|
||||
* Not Managed here !
|
||||
* if (!isset ($config["autoupdate"])) {
|
||||
* config_update_value ('autoupdate', true);.
|
||||
* }
|
||||
*/
|
||||
|
||||
include_once $config['homedir'].'/include/auth/mysql.php';
|
||||
include_once $config['homedir'].'/include/functions_io.php';
|
||||
|
||||
|
@ -1819,10 +1915,16 @@ function config_process_config()
|
|||
// user, and should be in pandora root. By default, Pandora adds
|
||||
// /attachment to this, so by default is the pandora console home
|
||||
// dir.
|
||||
$attachment_store_path = $config['homedir'].'/attachment';
|
||||
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
|
||||
// Windows.
|
||||
$attachment_store_path = $config['homedir'].'\attachment';
|
||||
}
|
||||
|
||||
if (!isset($config['attachment_store'])) {
|
||||
config_update_value(
|
||||
'attachment_store',
|
||||
io_safe_input($config['homedir']).'/attachment'
|
||||
$attachment_store_path
|
||||
);
|
||||
} else {
|
||||
// Fixed when the user moves the pandora console to another dir
|
||||
|
@ -1830,16 +1932,23 @@ function config_process_config()
|
|||
if (!is_dir($config['attachment_store'])) {
|
||||
config_update_value(
|
||||
'attachment_store',
|
||||
$config['homedir'].'/attachment'
|
||||
$attachment_store_path
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($config['fontpath'])) {
|
||||
$home = str_replace('\\', '/', $config['homedir']);
|
||||
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
|
||||
// Windows.
|
||||
$fontpath = $config['homedir'].'\include\fonts\smallfont.ttf';
|
||||
} else {
|
||||
$home = str_replace('\\', '/', $config['homedir']);
|
||||
$fontpath = $home.'/include/fonts/smallfont.ttf';
|
||||
}
|
||||
|
||||
config_update_value(
|
||||
'fontpath',
|
||||
$home.'/include/fonts/smallfont.ttf'
|
||||
$fontpath
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -2077,7 +2186,7 @@ function config_process_config()
|
|||
|
||||
if (!isset($config['netflow_path'])) {
|
||||
if ($is_windows) {
|
||||
$default = 'C:\\PandoraFMS\\Pandora_Server\\data_in\\netflow';
|
||||
$default = 'C:\PandoraFMS\Pandora_Server\data_in\netflow';
|
||||
} else {
|
||||
$default = '/var/spool/pandora/data_in/netflow';
|
||||
}
|
||||
|
@ -2639,6 +2748,10 @@ function config_process_config()
|
|||
config_update_value('zoom_graph', 1);
|
||||
}
|
||||
|
||||
if (!isset($config['percentil'])) {
|
||||
config_update_value('percentil', 95);
|
||||
}
|
||||
|
||||
if (!isset($config['render_proc_ok'])) {
|
||||
config_update_value('render_proc_ok', __('Ok'));
|
||||
}
|
||||
|
@ -2820,6 +2933,19 @@ function config_process_config()
|
|||
}
|
||||
}
|
||||
|
||||
// Integria.
|
||||
if (!isset($config['integria_enabled'])) {
|
||||
config_update_value('integria_enabled', 0);
|
||||
}
|
||||
|
||||
if (!isset($config['integria_req_timeout'])) {
|
||||
config_update_value('integria_req_timeout', 5);
|
||||
}
|
||||
|
||||
if (!isset($config['integria_hostname'])) {
|
||||
config_update_value('integria_hostname', '');
|
||||
}
|
||||
|
||||
// Finally, check if any value was overwritten in a form.
|
||||
config_update_config();
|
||||
}
|
||||
|
|
|
@ -24,422 +24,8 @@
|
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* ============================================================================
|
||||
*
|
||||
* Moved to CredentialStore.class.php
|
||||
*/
|
||||
|
||||
// Begin.
|
||||
|
||||
|
||||
/**
|
||||
* Returns an array with all the credentials matching filter and ACL.
|
||||
*
|
||||
* @param array $fields Fields array or 'count' keyword to retrieve count.
|
||||
* @param array $filter Filters to be applied.
|
||||
* @param integer $offset Offset (pagination).
|
||||
* @param integer $limit Limit (pagination).
|
||||
* @param string $order Sort order.
|
||||
* @param string $sort_field Sort field.
|
||||
*
|
||||
* @return array With all results or false if error.
|
||||
* @throws Exception On error.
|
||||
*/
|
||||
function credentials_get_all(
|
||||
$fields,
|
||||
array $filter,
|
||||
$offset=null,
|
||||
$limit=null,
|
||||
$order=null,
|
||||
$sort_field=null
|
||||
) {
|
||||
$sql_filters = [];
|
||||
$order_by = '';
|
||||
$pagination = '';
|
||||
|
||||
global $config;
|
||||
|
||||
if (!is_array($filter)) {
|
||||
error_log('[credential_get_all] Filter must be an array.');
|
||||
throw new Exception('[credential_get_all] Filter must be an array.');
|
||||
}
|
||||
|
||||
$count = false;
|
||||
if (!is_array($fields) && $fields == 'count') {
|
||||
$fields = ['cs.*'];
|
||||
$count = true;
|
||||
} else if (!is_array($fields)) {
|
||||
error_log('[credential_get_all] Fields must be an array or "count".');
|
||||
throw new Exception('[credential_get_all] Fields must be an array or "count".');
|
||||
}
|
||||
|
||||
if (isset($filter['product']) && !empty($filter['product'])) {
|
||||
$sql_filters[] = sprintf(' AND cs.product = "%s"', $filter['product']);
|
||||
}
|
||||
|
||||
if (isset($filter['free_search']) && !empty($filter['free_search'])) {
|
||||
$sql_filters[] = vsprintf(
|
||||
' AND (lower(cs.username) like lower("%%%s%%")
|
||||
OR cs.identifier like "%%%s%%"
|
||||
OR lower(cs.product) like lower("%%%s%%"))',
|
||||
array_fill(0, 3, $filter['free_search'])
|
||||
);
|
||||
}
|
||||
|
||||
if (isset($filter['filter_id_group']) && $filter['filter_id_group'] > 0) {
|
||||
$propagate = db_get_value(
|
||||
'propagate',
|
||||
'tgrupo',
|
||||
'id_grupo',
|
||||
$filter['filter_id_group']
|
||||
);
|
||||
|
||||
if (!$propagate) {
|
||||
$sql_filters[] = sprintf(
|
||||
' AND cs.id_group = %d ',
|
||||
$filter['filter_id_group']
|
||||
);
|
||||
} else {
|
||||
$groups = [ $filter['filter_id_group'] ];
|
||||
$childrens = groups_get_childrens($id_group, null, true);
|
||||
if (!empty($childrens)) {
|
||||
foreach ($childrens as $child) {
|
||||
$groups[] = (int) $child['id_grupo'];
|
||||
}
|
||||
}
|
||||
|
||||
$filter['filter_id_group'] = $groups;
|
||||
$sql_filters[] = sprintf(
|
||||
' AND cs.id_group IN (%s) ',
|
||||
join(',', $filter['filter_id_group'])
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($filter['group_list']) && is_array($filter['group_list'])) {
|
||||
$sql_filters[] = sprintf(
|
||||
' AND cs.id_group IN (%s) ',
|
||||
join(',', $filter['group_list'])
|
||||
);
|
||||
}
|
||||
|
||||
if (isset($order)) {
|
||||
$dir = 'asc';
|
||||
if ($order == 'desc') {
|
||||
$dir = 'desc';
|
||||
};
|
||||
|
||||
if (in_array(
|
||||
$sort_field,
|
||||
[
|
||||
'group',
|
||||
'identifier',
|
||||
'product',
|
||||
'username',
|
||||
'options',
|
||||
]
|
||||
)
|
||||
) {
|
||||
$order_by = sprintf(
|
||||
'ORDER BY `%s` %s',
|
||||
$sort_field,
|
||||
$dir
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($limit) && $limit > 0
|
||||
&& isset($offset) && $offset >= 0
|
||||
) {
|
||||
$pagination = sprintf(
|
||||
' LIMIT %d OFFSET %d ',
|
||||
$limit,
|
||||
$offset
|
||||
);
|
||||
}
|
||||
|
||||
$sql = sprintf(
|
||||
'SELECT %s
|
||||
FROM tcredential_store cs
|
||||
LEFT JOIN tgrupo tg
|
||||
ON tg.id_grupo = cs.id_group
|
||||
WHERE 1=1
|
||||
%s
|
||||
%s
|
||||
%s',
|
||||
join(',', $fields),
|
||||
join(' ', $sql_filters),
|
||||
$order_by,
|
||||
$pagination
|
||||
);
|
||||
|
||||
if ($count) {
|
||||
$sql = sprintf('SELECT count(*) as n FROM ( %s ) tt', $sql);
|
||||
|
||||
return db_get_value_sql($sql);
|
||||
}
|
||||
|
||||
return db_get_all_rows_sql($sql);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retrieves target key from keystore or false in case of error.
|
||||
*
|
||||
* @param string $identifier Key identifier.
|
||||
*
|
||||
* @return array Key or false if error.
|
||||
*/
|
||||
function get_key($identifier)
|
||||
{
|
||||
return db_get_row_filter(
|
||||
'tcredential_store',
|
||||
[ 'identifier' => $identifier ]
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Minor function to dump json message as ajax response.
|
||||
*
|
||||
* @param string $type Type: result || error.
|
||||
* @param string $msg Message.
|
||||
* @param boolean $delete Deletion messages.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function ajax_msg($type, $msg, $delete=false)
|
||||
{
|
||||
$msg_err = 'Failed while saving: %s';
|
||||
$msg_ok = 'Successfully saved into keystore ';
|
||||
|
||||
if ($delete) {
|
||||
$msg_err = 'Failed while removing: %s';
|
||||
$msg_ok = 'Successfully deleted ';
|
||||
}
|
||||
|
||||
if ($type == 'error') {
|
||||
echo json_encode(
|
||||
[
|
||||
$type => ui_print_error_message(
|
||||
__(
|
||||
$msg_err,
|
||||
$msg
|
||||
),
|
||||
'',
|
||||
true
|
||||
),
|
||||
]
|
||||
);
|
||||
} else {
|
||||
echo json_encode(
|
||||
[
|
||||
$type => ui_print_success_message(
|
||||
__(
|
||||
$msg_ok,
|
||||
$msg
|
||||
),
|
||||
'',
|
||||
true
|
||||
),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Generates inputs for new/update forms.
|
||||
*
|
||||
* @param array $values Values or null.
|
||||
*
|
||||
* @return string Inputs.
|
||||
*/
|
||||
function print_inputs($values=null)
|
||||
{
|
||||
if (!is_array($values)) {
|
||||
$values = [];
|
||||
}
|
||||
|
||||
$return = '';
|
||||
$return .= html_print_input(
|
||||
[
|
||||
'label' => __('Identifier'),
|
||||
'name' => 'identifier',
|
||||
'input_class' => 'flex-row',
|
||||
'type' => 'text',
|
||||
'value' => $values['identifier'],
|
||||
'disabled' => (bool) $values['identifier'],
|
||||
'return' => true,
|
||||
'script' => 'alert(\'puta\')',
|
||||
]
|
||||
);
|
||||
$return .= html_print_input(
|
||||
[
|
||||
'label' => __('Group'),
|
||||
'name' => 'id_group',
|
||||
'id' => 'id_group',
|
||||
'input_class' => 'flex-row',
|
||||
'type' => 'select_groups',
|
||||
'selected' => $values['id_group'],
|
||||
'return' => true,
|
||||
'class' => 'w50p',
|
||||
]
|
||||
);
|
||||
$return .= html_print_input(
|
||||
[
|
||||
'label' => __('Product'),
|
||||
'name' => 'product',
|
||||
'input_class' => 'flex-row',
|
||||
'type' => 'select',
|
||||
'script' => 'calculate_inputs()',
|
||||
'fields' => [
|
||||
'CUSTOM' => __('Custom'),
|
||||
'AWS' => __('Aws'),
|
||||
'AZURE' => __('Azure'),
|
||||
// 'GOOGLE' => __('Google'),
|
||||
],
|
||||
'selected' => $values['product'],
|
||||
'disabled' => (bool) $values['product'],
|
||||
'return' => true,
|
||||
]
|
||||
);
|
||||
$user_label = __('Username');
|
||||
$pass_label = __('Password');
|
||||
$extra_1_label = __('Extra');
|
||||
$extra_2_label = __('Extra (2)');
|
||||
$extra1 = true;
|
||||
$extra2 = true;
|
||||
|
||||
// Remember to update credential_store.php also.
|
||||
switch ($values['product']) {
|
||||
case 'AWS':
|
||||
$user_label = __('Access key ID');
|
||||
$pass_label = __('Secret access key');
|
||||
$extra1 = false;
|
||||
$extra2 = false;
|
||||
break;
|
||||
|
||||
case 'AZURE':
|
||||
$user_label = __('Account ID');
|
||||
$pass_label = __('Application secret');
|
||||
$extra_1_label = __('Tenant or domain name');
|
||||
$extra_2_label = __('Subscription id');
|
||||
break;
|
||||
|
||||
case 'GOOGLE':
|
||||
// Need further investigation.
|
||||
case 'CUSTOM':
|
||||
$user_label = __('Account ID');
|
||||
$pass_label = __('Password');
|
||||
$extra1 = false;
|
||||
$extra2 = false;
|
||||
default:
|
||||
// Use defaults.
|
||||
break;
|
||||
}
|
||||
|
||||
$return .= html_print_input(
|
||||
[
|
||||
'label' => $user_label,
|
||||
'name' => 'username',
|
||||
'input_class' => 'flex-row',
|
||||
'type' => 'text',
|
||||
'value' => $values['username'],
|
||||
'return' => true,
|
||||
]
|
||||
);
|
||||
$return .= html_print_input(
|
||||
[
|
||||
'label' => $pass_label,
|
||||
'name' => 'password',
|
||||
'input_class' => 'flex-row',
|
||||
'type' => 'password',
|
||||
'value' => $values['password'],
|
||||
'return' => true,
|
||||
]
|
||||
);
|
||||
if ($extra1) {
|
||||
$return .= html_print_input(
|
||||
[
|
||||
'label' => $extra_1_label,
|
||||
'name' => 'extra_1',
|
||||
'input_class' => 'flex-row',
|
||||
'type' => 'text',
|
||||
'value' => $values['extra_1'],
|
||||
'return' => true,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
if ($extra2) {
|
||||
$return .= html_print_input(
|
||||
[
|
||||
'label' => $extra_2_label,
|
||||
'name' => 'extra_2',
|
||||
'input_class' => 'flex-row',
|
||||
'type' => 'text',
|
||||
'value' => $values['extra_2'],
|
||||
'return' => true,
|
||||
'display' => $extra2,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retrieve all identifiers available for current user.
|
||||
*
|
||||
* @param string $product Target product.
|
||||
*
|
||||
* @return array Of account identifiers.
|
||||
*/
|
||||
function credentials_list_accounts($product)
|
||||
{
|
||||
global $config;
|
||||
|
||||
check_login();
|
||||
|
||||
include_once $config['homedir'].'/include/functions_users.php';
|
||||
|
||||
static $user_groups;
|
||||
|
||||
if (!isset($user_groups)) {
|
||||
$user_groups = users_get_groups(
|
||||
$config['id_user'],
|
||||
'AR'
|
||||
);
|
||||
|
||||
// Always add group 'ALL' because 'ALL' group credentials
|
||||
// must be available for all users.
|
||||
if (is_array($user_groups)) {
|
||||
$user_groups = ([0] + array_keys($user_groups));
|
||||
} else {
|
||||
$user_groups = [0];
|
||||
}
|
||||
}
|
||||
|
||||
$creds = credentials_get_all(
|
||||
['identifier'],
|
||||
[
|
||||
'product' => $product,
|
||||
'group_list' => $user_groups,
|
||||
]
|
||||
);
|
||||
|
||||
if ($creds === false) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$ret = array_reduce(
|
||||
$creds,
|
||||
function ($carry, $item) {
|
||||
$carry[$item['identifier']] = $item['identifier'];
|
||||
return $carry;
|
||||
}
|
||||
);
|
||||
|
||||
return $ret;
|
||||
}
|
||||
// Deprecated.
|
||||
|
|
|
@ -124,8 +124,26 @@ function custom_graphs_get_user($id_user=0, $only_names=false, $returnAllGroup=t
|
|||
}
|
||||
|
||||
$groups = users_get_groups($id_user, $privileges, $returnAllGroup);
|
||||
$all_graphs = [];
|
||||
if (is_metaconsole()) {
|
||||
$servers = metaconsole_get_connection_names();
|
||||
foreach ($servers as $key => $server) {
|
||||
$connection = metaconsole_get_connection($server);
|
||||
if (metaconsole_connect($connection) != NOERR) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$all_graph = db_get_all_rows_in_table('tgraph', 'name');
|
||||
if ($all_graph !== false) {
|
||||
$all_graphs = array_merge($all_graphs, $all_graph);
|
||||
}
|
||||
|
||||
metaconsole_restore_db();
|
||||
}
|
||||
} else {
|
||||
$all_graphs = db_get_all_rows_in_table('tgraph', 'name');
|
||||
}
|
||||
|
||||
$all_graphs = db_get_all_rows_in_table('tgraph', 'name');
|
||||
if ($all_graphs === false) {
|
||||
return [];
|
||||
}
|
||||
|
|
|
@ -2739,6 +2739,10 @@ function events_get_agent(
|
|||
$date = time_w_fixed_tz($date);
|
||||
}
|
||||
|
||||
if (is_metaconsole() && $events_group === false) {
|
||||
$id_server = true;
|
||||
}
|
||||
|
||||
if (empty($date)) {
|
||||
$date = get_system_time();
|
||||
}
|
||||
|
@ -4378,7 +4382,7 @@ function events_page_general($event)
|
|||
|
||||
$data = [];
|
||||
$data[0] = __('Event name');
|
||||
$data[1] = events_display_name($event['evento']);
|
||||
$data[1] = '<span style="word-break: break-word;">'.events_display_name($event['evento']).'</span>';
|
||||
$table_general->data[] = $data;
|
||||
|
||||
$data = [];
|
||||
|
@ -4611,7 +4615,7 @@ function events_page_comments($event, $ajax=false)
|
|||
foreach ($comm as $c) {
|
||||
$data[0] = '<b>'.$c['action'].' by '.$c['id_user'].'</b>';
|
||||
$data[0] .= '<br><br><i>'.date($config['date_format'], $c['utimestamp']).'</i>';
|
||||
$data[1] = $c['comment'];
|
||||
$data[1] = '<p style="word-break: break-word;">'.$c['comment'].'</p>';
|
||||
$table_comments->data[] = $data;
|
||||
}
|
||||
}
|
||||
|
@ -6634,3 +6638,297 @@ function events_get_secondary_groups_left_join($table)
|
|||
return 'LEFT JOIN tmetaconsole_agent_secondary_group tasg
|
||||
ON te.id_agente = tasg.id_tagente AND te.server_id = tasg.id_tmetaconsole_setup';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Replace macros in any string given an event id.
|
||||
* If server_id > 0, it's a metaconsole query.
|
||||
*
|
||||
* @param integer $event_id Event identifier.
|
||||
* @param integer $value String value in which we want to apply macros.
|
||||
*
|
||||
* @return string The response text with the macros applied.
|
||||
*/
|
||||
function events_get_field_value_by_event_id(
|
||||
int $event_id,
|
||||
$value
|
||||
) {
|
||||
global $config;
|
||||
|
||||
$meta = false;
|
||||
$event = db_get_row('tevento', 'id_evento', $event_id);
|
||||
|
||||
// Replace each macro.
|
||||
if (strpos($value, '_agent_address_') !== false) {
|
||||
if ($meta) {
|
||||
$agente_table_name = 'tmetaconsole_agent';
|
||||
$filter = [
|
||||
'id_tagente' => $event['id_agente'],
|
||||
'id_tmetaconsole_setup' => $server_id,
|
||||
];
|
||||
} else {
|
||||
$agente_table_name = 'tagente';
|
||||
$filter = ['id_agente' => $event['id_agente']];
|
||||
}
|
||||
|
||||
$ip = db_get_value_filter('direccion', $agente_table_name, $filter);
|
||||
// If agent does not have an IP, display N/A.
|
||||
if ($ip === false) {
|
||||
$ip = __('N/A');
|
||||
}
|
||||
|
||||
$value = str_replace('_agent_address_', $ip, $value);
|
||||
}
|
||||
|
||||
if (strpos($value, '_agent_id_') !== false) {
|
||||
$value = str_replace('_agent_id_', $event['id_agente'], $value);
|
||||
}
|
||||
|
||||
if (strpos($value, '_module_address_') !== false) {
|
||||
if ($event['id_agentmodule'] != 0) {
|
||||
if ($meta) {
|
||||
$server = metaconsole_get_connection_by_id($server_id);
|
||||
metaconsole_connect($server);
|
||||
}
|
||||
|
||||
$module = db_get_row('tagente_modulo', 'id_agente_modulo', $event['id_agentmodule']);
|
||||
if (empty($module['ip_target'])) {
|
||||
$module['ip_target'] = __('N/A');
|
||||
}
|
||||
|
||||
$value = str_replace('_module_address_', $module['ip_target'], $value);
|
||||
if (empty($module['nombre'])) {
|
||||
$module['nombre'] = __('N/A');
|
||||
}
|
||||
|
||||
if ($meta) {
|
||||
metaconsole_restore_db();
|
||||
}
|
||||
} else {
|
||||
$value = str_replace('_module_address_', __('N/A'), $value);
|
||||
}
|
||||
}
|
||||
|
||||
if (strpos($value, '_module_name_') !== false) {
|
||||
if ($event['id_agentmodule'] != 0) {
|
||||
if ($meta) {
|
||||
$server = metaconsole_get_connection_by_id($server_id);
|
||||
metaconsole_connect($server);
|
||||
}
|
||||
|
||||
$module = db_get_row('tagente_modulo', 'id_agente_modulo', $event['id_agentmodule']);
|
||||
if (empty($module['ip_target'])) {
|
||||
$module['ip_target'] = __('N/A');
|
||||
}
|
||||
|
||||
$value = str_replace(
|
||||
'_module_name_',
|
||||
io_safe_output($module['nombre']),
|
||||
$value
|
||||
);
|
||||
|
||||
if ($meta) {
|
||||
metaconsole_restore_db();
|
||||
}
|
||||
} else {
|
||||
$value = str_replace('_module_name_', __('N/A'), $value);
|
||||
}
|
||||
}
|
||||
|
||||
if (strpos($value, '_event_id_') !== false) {
|
||||
$value = str_replace('_event_id_', $event['id_evento'], $value);
|
||||
}
|
||||
|
||||
if (strpos($value, '_user_id_') !== false) {
|
||||
if (!empty($event['id_usuario'])) {
|
||||
$value = str_replace('_user_id_', $event['id_usuario'], $value);
|
||||
} else {
|
||||
$value = str_replace('_user_id_', __('N/A'), $value);
|
||||
}
|
||||
}
|
||||
|
||||
if (strpos($value, '_group_id_') !== false) {
|
||||
$value = str_replace('_group_id_', $event['id_grupo'], $value);
|
||||
}
|
||||
|
||||
if (strpos($value, '_group_name_') !== false) {
|
||||
$value = str_replace(
|
||||
'_group_name_',
|
||||
groups_get_name($event['id_grupo'], true),
|
||||
$value
|
||||
);
|
||||
}
|
||||
|
||||
if (strpos($value, '_event_utimestamp_') !== false) {
|
||||
$value = str_replace(
|
||||
'_event_utimestamp_',
|
||||
$event['utimestamp'],
|
||||
$value
|
||||
);
|
||||
}
|
||||
|
||||
if (strpos($value, '_event_date_') !== false) {
|
||||
$value = str_replace(
|
||||
'_event_date_',
|
||||
date($config['date_format'], $event['utimestamp']),
|
||||
$value
|
||||
);
|
||||
}
|
||||
|
||||
if (strpos($value, '_event_text_') !== false) {
|
||||
$value = str_replace(
|
||||
'_event_text_',
|
||||
events_display_name($event['evento']),
|
||||
$value
|
||||
);
|
||||
}
|
||||
|
||||
if (strpos($value, '_event_type_') !== false) {
|
||||
$value = str_replace(
|
||||
'_event_type_',
|
||||
events_print_type_description($event['event_type'], true),
|
||||
$value
|
||||
);
|
||||
}
|
||||
|
||||
if (strpos($value, '_alert_id_') !== false) {
|
||||
$value = str_replace(
|
||||
'_alert_id_',
|
||||
empty($event['is_alert_am']) ? __('N/A') : $event['is_alert_am'],
|
||||
$value
|
||||
);
|
||||
}
|
||||
|
||||
if (strpos($value, '_event_severity_id_') !== false) {
|
||||
$value = str_replace('_event_severity_id_', $event['criticity'], $value);
|
||||
}
|
||||
|
||||
if (strpos($value, '_event_severity_text_') !== false) {
|
||||
$value = str_replace(
|
||||
'_event_severity_text_',
|
||||
get_priority_name($event['criticity']),
|
||||
$value
|
||||
);
|
||||
}
|
||||
|
||||
if (strpos($value, '_module_id_') !== false) {
|
||||
$value = str_replace('_module_id_', $event['id_agentmodule'], $value);
|
||||
}
|
||||
|
||||
if (strpos($value, '_event_tags_') !== false) {
|
||||
$value = str_replace('_event_tags_', $event['tags'], $value);
|
||||
}
|
||||
|
||||
if (strpos($value, '_event_extra_id_') !== false) {
|
||||
if (empty($event['id_extra'])) {
|
||||
$value = str_replace('_event_extra_id_', __('N/A'), $value);
|
||||
} else {
|
||||
$value = str_replace('_event_extra_id_', $event['id_extra'], $value);
|
||||
}
|
||||
}
|
||||
|
||||
if (strpos($value, '_event_source_') !== false) {
|
||||
$value = str_replace('_event_source_', $event['source'], $value);
|
||||
}
|
||||
|
||||
if (strpos($value, '_event_instruction_') !== false) {
|
||||
$value = str_replace(
|
||||
'_event_instruction_',
|
||||
events_display_instructions($event['event_type'], $event, false),
|
||||
$value
|
||||
);
|
||||
}
|
||||
|
||||
if (strpos($value, '_owner_user_') !== false) {
|
||||
if (empty($event['owner_user'])) {
|
||||
$value = str_replace('_owner_user_', __('N/A'), $value);
|
||||
} else {
|
||||
$value = str_replace('_owner_user_', $event['owner_user'], $value);
|
||||
}
|
||||
}
|
||||
|
||||
if (strpos($value, '_event_status_') !== false) {
|
||||
$event_st = events_display_status($event['estado']);
|
||||
$value = str_replace('_event_status_', $event_st['title'], $value);
|
||||
}
|
||||
|
||||
if (strpos($value, '_group_custom_id_') !== false) {
|
||||
$group_custom_id = db_get_value_sql(
|
||||
sprintf(
|
||||
'SELECT custom_id FROM tgrupo WHERE id_grupo=%s',
|
||||
$event['id_grupo']
|
||||
)
|
||||
);
|
||||
$event_st = events_display_status($event['estado']);
|
||||
$value = str_replace('_group_custom_id_', $group_custom_id, $value);
|
||||
}
|
||||
|
||||
// Parse the event custom data.
|
||||
if (!empty($event['custom_data'])) {
|
||||
$custom_data = json_decode(base64_decode($event['custom_data']));
|
||||
foreach ($custom_data as $key => $val) {
|
||||
$value = str_replace('_customdata_'.$key.'_', $val, $value);
|
||||
}
|
||||
}
|
||||
|
||||
// This will replace the macro with the current logged user.
|
||||
if (strpos($value, '_current_user_') !== false) {
|
||||
$value = str_replace('_current_user_', $config['id_user'], $value);
|
||||
}
|
||||
|
||||
return $value;
|
||||
|
||||
}
|
||||
|
||||
|
||||
function events_get_instructions($event)
|
||||
{
|
||||
if (!is_array($event)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
switch ($event['event_type']) {
|
||||
case 'going_unknown':
|
||||
if ($event['unknown_instructions'] != '') {
|
||||
$value = str_replace("\n", '<br>', io_safe_output($event['unknown_instructions']));
|
||||
}
|
||||
break;
|
||||
|
||||
case 'going_up_warning':
|
||||
case 'going_down_warning':
|
||||
if ($event['warning_instructions'] != '') {
|
||||
$value = str_replace("\n", '<br>', io_safe_output($event['warning_instructions']));
|
||||
}
|
||||
break;
|
||||
|
||||
case 'going_up_critical':
|
||||
case 'going_down_critical':
|
||||
if ($event['critical_instructions'] != '') {
|
||||
$value = str_replace("\n", '<br>', io_safe_output($event['critical_instructions']));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (!isset($value)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$max_text_length = 300;
|
||||
$over_text = io_safe_output($value);
|
||||
if (strlen($over_text) > ($max_text_length + 3)) {
|
||||
$over_text = substr($over_text, 0, $max_text_length).'...';
|
||||
}
|
||||
|
||||
$output = '<div id="hidden_event_instructions_'.$event['id_evento'].'"';
|
||||
$output .= ' style="display: none; width: 100%; height: 100%; overflow: auto; padding: 10px; font-size: 14px; line-height: 16px; font-family: mono,monospace; text-align: left">';
|
||||
$output .= $value;
|
||||
$output .= '</div>';
|
||||
$output .= '<center>';
|
||||
$output .= '<span id="value_event_'.$event['id_evento'].'" style="white-space: nowrap;">';
|
||||
$output .= '<span id="value_event_text_'.$event['id_evento'].'"></span>';
|
||||
$output .= '<a href="javascript:show_instructions('.$event['id_evento'].')">';
|
||||
$output .= html_print_image('images/default_list.png', true, ['title' => $over_text]).'</a></span>';
|
||||
$output .= '</center>';
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -295,12 +295,41 @@ function grafico_modulo_sparse_data(
|
|||
return false;
|
||||
}
|
||||
|
||||
$array_data['sum'.$series_suffix]['agent_module_id'] = $agent_module_id;
|
||||
$array_data['sum'.$series_suffix]['id_module_type'] = $data_module_graph['id_module_type'];
|
||||
$array_data['sum'.$series_suffix]['agent_name'] = $data_module_graph['agent_name'];
|
||||
$array_data['sum'.$series_suffix]['module_name'] = $data_module_graph['module_name'];
|
||||
$array_data['sum'.$series_suffix]['agent_alias'] = $data_module_graph['agent_alias'];
|
||||
$array_data['sum'.$series_suffix]['unit'] = $data_module_graph['unit'];
|
||||
$array_data = series_suffix_leyend(
|
||||
'sum',
|
||||
$series_suffix,
|
||||
$agent_module_id,
|
||||
$data_module_graph,
|
||||
$array_data
|
||||
);
|
||||
|
||||
if ($params['percentil']) {
|
||||
$array_data = series_suffix_leyend(
|
||||
'percentil',
|
||||
$series_suffix,
|
||||
$agent_module_id,
|
||||
$data_module_graph,
|
||||
$array_data
|
||||
);
|
||||
}
|
||||
|
||||
if ($params['type_mode_graph']) {
|
||||
$array_data = series_suffix_leyend(
|
||||
'min',
|
||||
$series_suffix,
|
||||
$agent_module_id,
|
||||
$data_module_graph,
|
||||
$array_data
|
||||
);
|
||||
|
||||
$array_data = series_suffix_leyend(
|
||||
'max',
|
||||
$series_suffix,
|
||||
$agent_module_id,
|
||||
$data_module_graph,
|
||||
$array_data
|
||||
);
|
||||
}
|
||||
|
||||
// This is for a specific type of report that consists in passing
|
||||
// an interval and doing the average sum and avg.
|
||||
|
@ -378,12 +407,6 @@ function grafico_modulo_sparse_data(
|
|||
$array_data['sum1']['data'] = $acum_array_data;
|
||||
}
|
||||
|
||||
if ($params['percentil']) {
|
||||
$percentil_value = $array_data['percentil'.$series_suffix]['data'][0][1];
|
||||
} else {
|
||||
$percentil_value = 0;
|
||||
}
|
||||
|
||||
$events = [];
|
||||
if (isset($array_data['sum'.$series_suffix]['max'])) {
|
||||
$max = $array_data['sum'.$series_suffix]['max'];
|
||||
|
@ -1471,8 +1494,6 @@ function graphic_combined_module(
|
|||
$min = $array_data['sum'.$i]['min'];
|
||||
$avg = $array_data['sum'.$i]['avg'];
|
||||
|
||||
$percentil_value = $array_data['percentil'.$i]['data'][0][1];
|
||||
|
||||
if ($config['fixed_graph'] == false) {
|
||||
$water_mark = [
|
||||
'file' => $config['homedir'].'/images/logo_vertical_water.png',
|
||||
|
@ -1521,7 +1542,8 @@ function graphic_combined_module(
|
|||
$array_data,
|
||||
$params_combined['average'],
|
||||
$params_combined['summatory'],
|
||||
$params_combined['modules_series']
|
||||
$params_combined['modules_series'],
|
||||
$date_array
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -2222,7 +2244,7 @@ function graphic_combined_module(
|
|||
* @param boolean $average Average.
|
||||
* @param boolean $summatory Summatory.
|
||||
* @param boolean $modules_series Series module.
|
||||
* @param boolean $baseline Baseline data.
|
||||
* @param array $date_array Date data.
|
||||
*
|
||||
* @return array Data.
|
||||
*/
|
||||
|
@ -2231,106 +2253,82 @@ function combined_graph_summatory_average(
|
|||
$average=false,
|
||||
$summatory=false,
|
||||
$modules_series=false,
|
||||
$baseline=false
|
||||
$date_array=[]
|
||||
) {
|
||||
if (isset($array_data) && is_array($array_data)) {
|
||||
$reduce_array = [];
|
||||
foreach ($array_data as $key => $value) {
|
||||
if (strpos($key, 'sum') !== false) {
|
||||
$data_array_reverse[$key] = array_reverse($value['data']);
|
||||
if (!$modules_series) {
|
||||
unset($array_data[$key]);
|
||||
}
|
||||
$last = $date_array['start_date'];
|
||||
$reduce_array = array_reduce(
|
||||
$value['data'],
|
||||
function ($carry, $item) use ($date_array, $last, $reduce_array) {
|
||||
$slice_start = $date_array['start_date'];
|
||||
$iterator = $last;
|
||||
|
||||
// JS to PHP timestamp format.
|
||||
$item[0] /= 1000;
|
||||
while ($iterator <= $date_array['final_date']) {
|
||||
if ($item[0] >= $slice_start && $item[0] < $iterator) {
|
||||
$array = [];
|
||||
$val = 0;
|
||||
$n = 0;
|
||||
|
||||
if (is_array($reduce_array[$slice_start])) {
|
||||
$val = $reduce_array[$slice_start]['value'];
|
||||
$n = ($reduce_array[$slice_start]['n'] + 1);
|
||||
}
|
||||
|
||||
$array['value'] = ($item[1] + $val);
|
||||
$array['n'] = $n;
|
||||
$array['t'] = ($slice_start * 1000);
|
||||
|
||||
$carry[$slice_start] = $array;
|
||||
$last = $iterator;
|
||||
break;
|
||||
} else {
|
||||
$slice_start = $iterator;
|
||||
$iterator += 300;
|
||||
}
|
||||
}
|
||||
|
||||
$i++;
|
||||
return $carry;
|
||||
},
|
||||
$reduce_array
|
||||
);
|
||||
}
|
||||
|
||||
if (!$modules_series) {
|
||||
unset($array_data[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($data_array_reverse) && is_array($data_array_reverse)) {
|
||||
$array_sum_reverse = [];
|
||||
$array_avg_reverse = [];
|
||||
$data_array_prev = false;
|
||||
$data_array_pop = [];
|
||||
$count = 0;
|
||||
$reduce_array_summatory = [];
|
||||
$reduce_array_average = [];
|
||||
$i = 0;
|
||||
foreach ($reduce_array as $item) {
|
||||
$reduce_array_summatory[$i][0] = $item['t'];
|
||||
$reduce_array_summatory[$i][1] = $item['value'];
|
||||
|
||||
$count_data_array_reverse = count($data_array_reverse['sum0']);
|
||||
while ($count_data_array_reverse > 0) {
|
||||
foreach ($data_array_reverse as $key_reverse => $value_reverse) {
|
||||
if (is_array($value_reverse) && count($value_reverse) > 0) {
|
||||
$data_array_pop[$key_reverse] = array_pop(
|
||||
$data_array_reverse[$key_reverse]
|
||||
);
|
||||
}
|
||||
}
|
||||
$reduce_array_average[$i][0] = $item['t'];
|
||||
$reduce_array_average[$i][1] = ($item['value'] / ($item['n'] + 1));
|
||||
|
||||
if (isset($data_array_pop) && is_array($data_array_pop)) {
|
||||
$acum_data = 0;
|
||||
$acum_array = [];
|
||||
$sum_data = 0;
|
||||
$count_pop = 0;
|
||||
foreach ($data_array_pop as $key_pop => $value_pop) {
|
||||
if ($value_pop[0] > $acum_data) {
|
||||
if ($acum_data != 0) {
|
||||
$sum_data = ($sum_data + $data_array_prev[$key_pop][1]);
|
||||
$data_array_reverse[$key_pop][] = $value_pop;
|
||||
$data_array_prev[$acum_key] = $acum_array;
|
||||
} else {
|
||||
if ($data_array_prev[$key_pop] == false) {
|
||||
$data_array_prev[$key_pop] = $value_pop;
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
|
||||
$acum_key = $key_pop;
|
||||
$acum_data = $value_pop[0];
|
||||
$acum_array = $value_pop;
|
||||
$sum_data = $value_pop[1];
|
||||
}
|
||||
} else if ($value_pop[0] < $acum_data) {
|
||||
$sum_data = ($sum_data + $data_array_prev[$key_pop][1]);
|
||||
$data_array_reverse[$acum_key][] = $acum_array;
|
||||
$data_array_prev[$key_pop] = $value_pop;
|
||||
$acum_key = $key_pop;
|
||||
$acum_data = $value_pop[0];
|
||||
$acum_array = $value_pop;
|
||||
} else if ($value_pop[0] == $acum_data) {
|
||||
$data_array_prev[$key_pop] = $value_pop;
|
||||
$sum_data += $value_pop[1];
|
||||
}
|
||||
if ($summatory && isset($reduce_array_summatory)
|
||||
&& is_array($reduce_array_summatory)
|
||||
&& count($reduce_array_summatory) > 0
|
||||
) {
|
||||
$array_data['summatory']['data'] = $reduce_array_summatory;
|
||||
}
|
||||
|
||||
$count_pop++;
|
||||
}
|
||||
|
||||
if ($summatory) {
|
||||
$array_sum_reverse[$count][0] = $acum_data;
|
||||
$array_sum_reverse[$count][1] = $sum_data;
|
||||
}
|
||||
|
||||
if ($average) {
|
||||
$array_avg_reverse[$count][0] = $acum_data;
|
||||
$array_avg_reverse[$count][1] = ($sum_data / $count_pop);
|
||||
}
|
||||
}
|
||||
|
||||
$count++;
|
||||
$count_data_array_reverse--;
|
||||
}
|
||||
|
||||
if ($summatory && isset($array_sum_reverse)
|
||||
&& is_array($array_sum_reverse)
|
||||
&& count($array_sum_reverse) > 0
|
||||
) {
|
||||
$array_data['summatory']['data'] = $array_sum_reverse;
|
||||
$array_data['summatory']['color'] = 'purple';
|
||||
}
|
||||
|
||||
if ($average && isset($array_avg_reverse)
|
||||
&& is_array($array_avg_reverse)
|
||||
&& count($array_avg_reverse) > 0
|
||||
) {
|
||||
if ($baseline) {
|
||||
$array_data['baseline']['data'] = $array_avg_reverse;
|
||||
$array_data['baseline']['color'] = 'green';
|
||||
} else {
|
||||
$array_data['average']['data'] = $array_avg_reverse;
|
||||
$array_data['average']['color'] = 'orange';
|
||||
}
|
||||
}
|
||||
if ($average && isset($reduce_array_average)
|
||||
&& is_array($reduce_array_average)
|
||||
&& count($reduce_array_average) > 0
|
||||
) {
|
||||
$array_data['average']['data'] = $reduce_array_average;
|
||||
}
|
||||
|
||||
return $array_data;
|
||||
|
@ -3191,6 +3189,21 @@ function graphic_incident_source($width=320, $height=200)
|
|||
}
|
||||
|
||||
|
||||
function series_suffix_leyend($series_name, $series_suffix, $id_agent, $data_module_graph, $array_data)
|
||||
{
|
||||
global $config;
|
||||
|
||||
$array_data[$series_name.$series_suffix]['agent_module_id'] = $id_agent;
|
||||
$array_data[$series_name.$series_suffix]['id_module_type'] = $data_module_graph['id_module_type'];
|
||||
$array_data[$series_name.$series_suffix]['agent_name'] = $data_module_graph['agent_name'];
|
||||
$array_data[$series_name.$series_suffix]['module_name'] = $data_module_graph['module_name'];
|
||||
$array_data[$series_name.$series_suffix]['agent_alias'] = $data_module_graph['agent_alias'];
|
||||
$array_data[$series_name.$series_suffix]['unit'] = $data_module_graph['unit'];
|
||||
|
||||
return $array_data;
|
||||
}
|
||||
|
||||
|
||||
function graph_events_validated($width=300, $height=200, $extra_filters=[], $meta=false, $history=false)
|
||||
{
|
||||
global $config;
|
||||
|
@ -3582,7 +3595,32 @@ function graph_custom_sql_graph(
|
|||
|
||||
$SQL_GRAPH_MAX_LABEL_SIZE = 20;
|
||||
|
||||
if (is_metaconsole()) {
|
||||
$server = metaconsole_get_connection_names();
|
||||
$connection = metaconsole_get_connection($server);
|
||||
metaconsole_connect($connection);
|
||||
}
|
||||
|
||||
$report_content = db_get_row('treport_content', 'id_rc', $id);
|
||||
|
||||
if ($report_content == false || $report_content == '') {
|
||||
$report_content = db_get_row('treport_content_template', 'id_rc', $id);
|
||||
}
|
||||
|
||||
if ($report_content == false || $report_content == '') {
|
||||
enterprise_hook('metaconsole_restore_db');
|
||||
$report_content = db_get_row('treport_content', 'id_rc', $id);
|
||||
if ($report_content == false || $report_content == '') {
|
||||
$report_content = db_get_row('treport_content_template', 'id_rc', $id);
|
||||
}
|
||||
|
||||
if (is_metaconsole()) {
|
||||
$server = metaconsole_get_connection_names();
|
||||
$connection = metaconsole_get_connection($server);
|
||||
metaconsole_connect($connection);
|
||||
}
|
||||
}
|
||||
|
||||
if ($id != null) {
|
||||
$historical_db = db_get_value_sql('SELECT historical_db from treport_content where id_rc ='.$id);
|
||||
} else {
|
||||
|
@ -3596,22 +3634,9 @@ function graph_custom_sql_graph(
|
|||
$sql = io_safe_output($sql['sql']);
|
||||
}
|
||||
|
||||
if (($config['metaconsole'] == 1) && defined('METACONSOLE')) {
|
||||
$metaconsole_connection = enterprise_hook('metaconsole_get_connection', [$report_content['server_name']]);
|
||||
|
||||
if ($metaconsole_connection === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (enterprise_hook('metaconsole_load_external_db', [$metaconsole_connection]) != NOERR) {
|
||||
// ui_print_error_message ("Error connecting to ".$server_name);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$data_result = db_get_all_rows_sql($sql, $historical_db);
|
||||
|
||||
if (($config['metaconsole'] == 1) && defined('METACONSOLE')) {
|
||||
if (is_metaconsole()) {
|
||||
enterprise_hook('metaconsole_restore_db');
|
||||
}
|
||||
|
||||
|
|
|
@ -1475,6 +1475,14 @@ function html_print_input_password(
|
|||
$attr['class'] = $class;
|
||||
}
|
||||
|
||||
if ($disabled === false) {
|
||||
// Trick to avoid password completion on most browsers.
|
||||
if ($autocomplete !== 'on') {
|
||||
$disabled = true;
|
||||
$attr['onfocus'] = "this.removeAttribute('readonly');";
|
||||
}
|
||||
}
|
||||
|
||||
return html_print_input_text_extended($name, $value, 'password-'.$name, $alt, $size, $maxlength, $disabled, '', $attr, $return, true, '', $autocomplete);
|
||||
}
|
||||
|
||||
|
@ -3375,3 +3383,116 @@ function html_print_input($data, $wrapper='div', $input_only=false)
|
|||
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Print an autocomplete input filled out with Integria IMS users.
|
||||
*
|
||||
* @param string $name The name of ajax control, by default is "users".
|
||||
* @param string $default The default value to show in the ajax control.
|
||||
* @param boolean $return If it is true return a string with the output instead to echo the output.
|
||||
* @param string $size Size.
|
||||
*
|
||||
* @return mixed If the $return is true, return the output as string.
|
||||
*/
|
||||
function html_print_autocomplete_users_from_integria(
|
||||
$name='users',
|
||||
$default='',
|
||||
$return=false,
|
||||
$size='30',
|
||||
$disable=false,
|
||||
$required=false
|
||||
) {
|
||||
global $config;
|
||||
|
||||
ob_start();
|
||||
|
||||
$attrs = ['style' => 'background: url(images/user_green.png) no-repeat right;'];
|
||||
|
||||
if ($required) {
|
||||
$attrs['required'] = 'required';
|
||||
}
|
||||
|
||||
html_print_input_text_extended(
|
||||
$name,
|
||||
$default,
|
||||
'text-'.$name,
|
||||
'',
|
||||
$size,
|
||||
100,
|
||||
$disable,
|
||||
'',
|
||||
$attrs
|
||||
);
|
||||
html_print_input_hidden($name.'_hidden', $id_agent_module);
|
||||
|
||||
ui_print_help_tip(__('Type at least two characters to search the user.'), false);
|
||||
|
||||
$javascript_ajax_page = ui_get_full_url('ajax.php', false, false, false, false);
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
function escapeHTML (str)
|
||||
{
|
||||
var div = document.createElement('div');
|
||||
var text = document.createTextNode(str);
|
||||
div.appendChild(text);
|
||||
return div.innerHTML;
|
||||
}
|
||||
|
||||
$(document).ready (function () {
|
||||
$("#text-<?php echo $name; ?>").autocomplete({
|
||||
minLength: 2,
|
||||
source: function( request, response ) {
|
||||
var term = request.term; //Word to search
|
||||
|
||||
data_params = {
|
||||
page: "include/ajax/integria_incidents.ajax",
|
||||
search_term: term,
|
||||
get_users: 1,
|
||||
};
|
||||
|
||||
jQuery.ajax ({
|
||||
data: data_params,
|
||||
async: false,
|
||||
type: "POST",
|
||||
url: action="<?php echo $javascript_ajax_page; ?>",
|
||||
timeout: 10000,
|
||||
dataType: "json",
|
||||
success: function (data) {
|
||||
temp = [];
|
||||
$.each(data, function (id, module) {
|
||||
temp.push({
|
||||
'value' : id,
|
||||
'label' : module});
|
||||
});
|
||||
|
||||
response(temp);
|
||||
}
|
||||
});
|
||||
},
|
||||
change: function( event, ui ) {
|
||||
if (!ui.item)
|
||||
$("input[name='<?php echo $name; ?>_hidden']")
|
||||
.val(0);
|
||||
return false;
|
||||
},
|
||||
select: function( event, ui ) {
|
||||
$("input[name='<?php echo $name; ?>_hidden']")
|
||||
.val(ui.item.value);
|
||||
|
||||
$("#text-<?php echo $name; ?>").val( ui.item.label );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
</script>
|
||||
<?php
|
||||
$output = ob_get_clean();
|
||||
|
||||
if ($return) {
|
||||
return $output;
|
||||
} else {
|
||||
echo $output;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,420 @@
|
|||
<?php
|
||||
|
||||
// Pandora FMS - http://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2009 Artica Soluciones Tecnologicas
|
||||
// Please see http://pandorafms.org for full contribution list
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU 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.
|
||||
|
||||
/**
|
||||
* @package Include
|
||||
* @subpackage Incidents
|
||||
*/
|
||||
|
||||
global $config;
|
||||
|
||||
require_once $config['homedir'].'/include/functions_ui.php';
|
||||
require_once $config['homedir'].'/include/functions_html.php';
|
||||
require_once $config['homedir'].'/include/functions.php';
|
||||
|
||||
|
||||
/**
|
||||
* Show header tabs.
|
||||
*
|
||||
* @param string $active_tab Current tab or false for View page.
|
||||
* @param number $view Id of incident. Show View tab.
|
||||
*
|
||||
* @return html Print tabs in header.
|
||||
*/
|
||||
function integriaims_tabs($active_tab, $view=false)
|
||||
{
|
||||
global $config;
|
||||
|
||||
$url_tabs = ui_get_full_url('index.php?sec=incident&sec2=operation/incidents/');
|
||||
|
||||
$setup_tab['text'] = '<a href="'.ui_get_full_url('index.php?sec=general&sec2=godmode/setup/setup§ion=integria').'">'.html_print_image('images/setup.png', true, ['title' => __('Configure Integria IMS')]).'</a>';
|
||||
$list_tab['text'] = '<a href="'.$url_tabs.'list_integriaims_incidents">'.html_print_image('images/list.png', true, ['title' => __('Ticket list')]).'</a>';
|
||||
$create_tab['text'] = '<a href="'.$url_tabs.'configure_integriaims_incident">'.html_print_image('images/pencil.png', true, ['title' => __('New ticket')]).'</a>';
|
||||
|
||||
switch ($active_tab) {
|
||||
case 'setup_tab':
|
||||
$setup_tab['active'] = true;
|
||||
$list_tab['active'] = false;
|
||||
$create_tab['active'] = false;
|
||||
break;
|
||||
|
||||
case 'list_tab':
|
||||
$setup_tab['active'] = false;
|
||||
$list_tab['active'] = true;
|
||||
$create_tab['active'] = false;
|
||||
break;
|
||||
|
||||
case 'create_tab':
|
||||
$setup_tab['active'] = false;
|
||||
$list_tab['active'] = false;
|
||||
$create_tab['active'] = true;
|
||||
break;
|
||||
|
||||
default:
|
||||
$setup_tab['active'] = false;
|
||||
$list_tab['active'] = false;
|
||||
$create_tab['active'] = false;
|
||||
break;
|
||||
}
|
||||
|
||||
if ($view) {
|
||||
$create_tab['text'] = '<a href="'.$url_tabs.'configure_integriaims_incident&incident_id='.$view.'">'.html_print_image('images/pencil.png', true, ['title' => __('Edit ticket')]).'</a>';
|
||||
$view_tab['text'] = '<a href="'.$url_tabs.'dashboard_detail_integriaims_incident&incident_id='.$view.'">'.html_print_image('images/operation.png', true, ['title' => __('View ticket')]).'</a>';
|
||||
// When the current page is the View page.
|
||||
if (!$active_tab) {
|
||||
$view_tab['active'] = true;
|
||||
}
|
||||
}
|
||||
|
||||
$onheader = [];
|
||||
|
||||
if (check_acl($config['id_user'], 0, 'IR') && $view) {
|
||||
$onheader['view'] = $view_tab;
|
||||
}
|
||||
|
||||
if (check_acl($config['id_user'], 0, 'PM')) {
|
||||
$onheader['configure'] = $setup_tab;
|
||||
}
|
||||
|
||||
if (check_acl($config['id_user'], 0, 'IR')) {
|
||||
$onheader['list'] = $list_tab;
|
||||
}
|
||||
|
||||
if (check_acl($config['id_user'], 0, 'IW')) {
|
||||
$onheader['create'] = $create_tab;
|
||||
}
|
||||
|
||||
return $onheader;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets all the details of Integria IMS API
|
||||
*
|
||||
* @param string $details Type of API call.
|
||||
* @param number $detail_index Send index if you want return the text.
|
||||
*
|
||||
* @return string or array with result of API call.
|
||||
*/
|
||||
function integriaims_get_details($details, $detail_index=false)
|
||||
{
|
||||
global $config;
|
||||
|
||||
switch ($details) {
|
||||
case 'status':
|
||||
$operation = 'get_incidents_status';
|
||||
break;
|
||||
|
||||
case 'group':
|
||||
$operation = 'get_groups';
|
||||
break;
|
||||
|
||||
case 'priority':
|
||||
$operation = 'get_incident_priorities';
|
||||
break;
|
||||
|
||||
case 'resolution':
|
||||
$operation = 'get_incidents_resolutions';
|
||||
break;
|
||||
|
||||
case 'type':
|
||||
$operation = 'get_types';
|
||||
break;
|
||||
|
||||
default:
|
||||
// code...
|
||||
break;
|
||||
}
|
||||
|
||||
$api_call = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], $operation);
|
||||
$result = [];
|
||||
get_array_from_csv_data_pair($api_call, $result);
|
||||
|
||||
if ($detail_index !== false) {
|
||||
if ($result[$detail_index] == '' || $result[$detail_index] === null) {
|
||||
return __('None');
|
||||
} else {
|
||||
return $result[$detail_index];
|
||||
}
|
||||
} else {
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Perform an API call to Integria IMS.
|
||||
*
|
||||
* @param string API host URL.
|
||||
* @param string User name.
|
||||
* @param string User password.
|
||||
* @param string API password.
|
||||
* @param string API Operation.
|
||||
* @param array Array with parameters required by the API function.
|
||||
*
|
||||
* @return boolean True if API request succeeded, false if API request failed.
|
||||
*/
|
||||
function integria_api_call($api_hostname, $user, $user_pass, $api_pass, $operation, $params_array=[], $show_credentials_error_msg=false)
|
||||
{
|
||||
$params_string = implode(',', $params_array);
|
||||
|
||||
$url_data = [
|
||||
'user' => $user,
|
||||
'user_pass' => $user_pass,
|
||||
'pass' => $api_pass,
|
||||
'op' => $operation,
|
||||
'params' => html_entity_decode($params_string),
|
||||
];
|
||||
|
||||
// Build URL for API request.
|
||||
$url = $api_hostname.'/integria/include/api.php';
|
||||
|
||||
// ob_start();
|
||||
// $out = fopen('php://output', 'w');
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $url_data);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_VERBOSE, true);
|
||||
curl_setopt($ch, CURLOPT_STDERR, $out);
|
||||
$result = curl_exec($ch);
|
||||
|
||||
// fclose($out);
|
||||
// $debug = ob_get_clean();
|
||||
$http_status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
|
||||
$error = false;
|
||||
|
||||
if ($result === false) {
|
||||
$error = curl_error($ch);
|
||||
}
|
||||
|
||||
curl_close($ch);
|
||||
|
||||
if ($error === true || $http_status !== 200) {
|
||||
if ($show_credentials_error_msg === true) {
|
||||
ui_print_error_message(__('API request failed. Please check Integria IMS\' access credentials in Pandora setup.'));
|
||||
}
|
||||
|
||||
return false;
|
||||
} else {
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Parse CSV consisting of one or more lines of the form key-value pair into an array.
|
||||
function get_array_from_csv_data_pair($csv_data, &$array_values)
|
||||
{
|
||||
$csv_array = explode("\n", $csv_data);
|
||||
|
||||
foreach ($csv_array as $csv_value) {
|
||||
if (empty($csv_value)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$new_csv_value = str_getcsv($csv_value);
|
||||
|
||||
$array_values[$new_csv_value[0]] = $new_csv_value[1];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Parse CSV consisting of all lines into an array.
|
||||
*
|
||||
* @param string $csv_data Data returned of csv api call.
|
||||
* @param string $array_values Returned array.
|
||||
* @param array $index Array to create an associative index (opcional).
|
||||
*/
|
||||
function get_array_from_csv_data_all($csv_data, &$array_values, $index=false)
|
||||
{
|
||||
$csv_array = explode("\n", $csv_data);
|
||||
|
||||
foreach ($csv_array as $csv_value) {
|
||||
if (empty($csv_value)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$new_csv_value = str_getcsv($csv_value);
|
||||
|
||||
if ($index !== false) {
|
||||
foreach ($new_csv_value as $key => $value) {
|
||||
$new_csv_value_index[$index[$key]] = str_replace(':::', ',', $value);
|
||||
;
|
||||
}
|
||||
|
||||
$array_values[$new_csv_value[0]] = $new_csv_value_index;
|
||||
} else {
|
||||
$new_csv_value_comma = array_map(
|
||||
function ($item) {
|
||||
return str_replace(':::', ',', $item);
|
||||
},
|
||||
$new_csv_value
|
||||
);
|
||||
$array_values[$new_csv_value[0]] = $new_csv_value_comma;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Print priority for Integria IMS with colors.
|
||||
*
|
||||
* @param string $priority value of priority in Integria IMS.
|
||||
* @param string $priority_label text shown in color box.
|
||||
*
|
||||
* @return HTML code to print the color box.
|
||||
*/
|
||||
function ui_print_integria_incident_priority($priority, $priority_label)
|
||||
{
|
||||
global $config;
|
||||
|
||||
$output = '';
|
||||
switch ($priority) {
|
||||
case 0:
|
||||
$color = COL_UNKNOWN;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
$color = COL_NORMAL;
|
||||
break;
|
||||
|
||||
case 10:
|
||||
$color = COL_NOTINIT;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
$color = COL_WARNING;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
$color = COL_ALERTFIRED;
|
||||
break;
|
||||
|
||||
case 4:
|
||||
$color = COL_CRITICAL;
|
||||
break;
|
||||
}
|
||||
|
||||
$output = '<div class="priority" style="background: '.$color.'">';
|
||||
$output .= $priority_label;
|
||||
$output .= '</div>';
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get tickets from Integria IMS.
|
||||
*
|
||||
* @param array $tickets_filters Filters to send to API.
|
||||
*
|
||||
* @return array Tickets returned by API call.
|
||||
*/
|
||||
function get_tickets_integriaims($tickets_filters)
|
||||
{
|
||||
global $config;
|
||||
|
||||
// Filters.
|
||||
$incident_text = $tickets_filters['incident_text'];
|
||||
$incident_status = $tickets_filters['incident_status'];
|
||||
$incident_group = $tickets_filters['incident_group'];
|
||||
$incident_owner = $tickets_filters['incident_owner'];
|
||||
$incident_creator = $tickets_filters['incident_creator'];
|
||||
$incident_priority = $tickets_filters['incident_priority'];
|
||||
$incident_resolution = $tickets_filters['incident_resolution'];
|
||||
$created_from = $tickets_filters['created_from'];
|
||||
$created_to = $tickets_filters['created_to'];
|
||||
|
||||
// API call.
|
||||
$result_api_call_list = integria_api_call(
|
||||
$config['integria_hostname'],
|
||||
$config['integria_user'],
|
||||
$config['integria_pass'],
|
||||
$config['integria_api_pass'],
|
||||
'get_incidents',
|
||||
[
|
||||
$incident_text,
|
||||
$incident_status,
|
||||
$incident_group,
|
||||
$incident_priority,
|
||||
'0',
|
||||
$incident_owner,
|
||||
$incident_creator,
|
||||
]
|
||||
);
|
||||
|
||||
// Return array of api call 'get_incidents'.
|
||||
$array_get_incidents = [];
|
||||
get_array_from_csv_data_all($result_api_call_list, $array_get_incidents);
|
||||
|
||||
// Modify $array_get_incidents if filter for resolution exists.
|
||||
$filter_resolution = [];
|
||||
foreach ($array_get_incidents as $key => $value) {
|
||||
if ($incident_resolution !== '' && ($array_get_incidents[$key][12] == $incident_resolution)) {
|
||||
$filter_resolution[$key] = $array_get_incidents[$key];
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if ($incident_resolution !== '') {
|
||||
$array_get_incidents = $filter_resolution;
|
||||
}
|
||||
|
||||
// Modify $array_get_incidents if filter for date is selected.
|
||||
if ($created_from !== '' && $created_to !== '') {
|
||||
$date = [];
|
||||
$date_utimestamp = [];
|
||||
foreach ($array_get_incidents as $key => $value) {
|
||||
// Change format date / to -.
|
||||
$date[$key] = date('Y-m-d', strtotime($array_get_incidents[$key][9]));
|
||||
// Covert date to utimestamp.
|
||||
$date_utimestamp[$key] = strtotime($date[$key]);
|
||||
}
|
||||
|
||||
// Change format date / to -.
|
||||
$created_from_date = date('Y-m-d', strtotime($created_from));
|
||||
$created_to_date = date('Y-m-d', strtotime($created_to));
|
||||
|
||||
// Covert date to utimestamp.
|
||||
$created_from_timestamp = strtotime($created_from_date);
|
||||
$created_to_timestamp = strtotime($created_to_date);
|
||||
|
||||
// Dates within the selected period.
|
||||
$selected_period = array_filter(
|
||||
$date_utimestamp,
|
||||
function ($value) use ($created_from_timestamp, $created_to_timestamp) {
|
||||
return ($value >= $created_from_timestamp && $value <= $created_to_timestamp);
|
||||
}
|
||||
);
|
||||
|
||||
// Return incidents with the correct dates.
|
||||
$filter_date = [];
|
||||
foreach ($array_get_incidents as $key => $value) {
|
||||
foreach ($selected_period as $index => $value) {
|
||||
if ($array_get_incidents[$key][0] == $index) {
|
||||
$filter_date[$key] = $array_get_incidents[$key];
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$array_get_incidents = $filter_date;
|
||||
}
|
||||
|
||||
return $array_get_incidents;
|
||||
}
|
|
@ -507,7 +507,7 @@ function ___($string /*, variable arguments */)
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
/**
|
||||
* json_encode for multibyte characters.
|
||||
*
|
||||
* @param string Text string to be encoded.
|
||||
|
@ -528,7 +528,7 @@ function io_json_mb_encode($string, $encode_options=0)
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
/**
|
||||
* Prepare the given password to be stored in the Pandora FMS Database,
|
||||
* encrypting it if necessary.
|
||||
*
|
||||
|
@ -541,16 +541,22 @@ function io_input_password($password)
|
|||
global $config;
|
||||
|
||||
enterprise_include_once('include/functions_crypto.php');
|
||||
$ciphertext = enterprise_hook('openssl_encrypt_decrypt', ['encrypt', io_safe_output($password)]);
|
||||
$ciphertext = enterprise_hook(
|
||||
'openssl_encrypt_decrypt',
|
||||
[
|
||||
'encrypt',
|
||||
io_safe_input($password),
|
||||
]
|
||||
);
|
||||
if ($ciphertext === ENTERPRISE_NOT_HOOK) {
|
||||
return $password;
|
||||
return io_safe_input($password);
|
||||
}
|
||||
|
||||
return $ciphertext;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
/**
|
||||
* Process the given password read from the Pandora FMS Database,
|
||||
* decrypting it if necessary.
|
||||
*
|
||||
|
@ -563,10 +569,17 @@ function io_output_password($password)
|
|||
global $config;
|
||||
|
||||
enterprise_include_once('include/functions_crypto.php');
|
||||
$plaintext = enterprise_hook('openssl_encrypt_decrypt', ['decrypt', io_safe_output($password)]);
|
||||
$plaintext = enterprise_hook(
|
||||
'openssl_encrypt_decrypt',
|
||||
[
|
||||
'decrypt',
|
||||
$password,
|
||||
]
|
||||
);
|
||||
|
||||
if ($plaintext === ENTERPRISE_NOT_HOOK) {
|
||||
return $password;
|
||||
return io_safe_output($password);
|
||||
}
|
||||
|
||||
return $plaintext;
|
||||
return io_safe_output($plaintext);
|
||||
}
|
||||
|
|
|
@ -2654,21 +2654,18 @@ function modules_get_relations($params=[])
|
|||
}
|
||||
|
||||
$modules_type = '';
|
||||
$modules_type_filter = '';
|
||||
if (isset($params['modules_type'])) {
|
||||
$modules_type = $params['modules_type'];
|
||||
$module_type = 'INNER JOIN ttipo_modulo ttm ON tam.id_tipo_modulo = ttm.id_tipo';
|
||||
$modules_type_filter = sprintf(
|
||||
"AND ttm.nombre = '%s'",
|
||||
$params['modules_type']
|
||||
);
|
||||
}
|
||||
|
||||
$sql = 'SELECT DISTINCT tmr.id, tmr.module_a, tmr.module_b,
|
||||
tmr.disable_update, tmr.type
|
||||
FROM tmodule_relationship tmr,
|
||||
tagente_modulo tam,
|
||||
tagente ta,
|
||||
ttipo_modulo ttm
|
||||
WHERE ';
|
||||
|
||||
$agent_filter = '';
|
||||
if ($id_agent > 0) {
|
||||
$agent_filter = sprintf('AND ta.id_agente = %d', $id_agent);
|
||||
$distinct = '';
|
||||
if (empty($params)) {
|
||||
$distinct = 'DISTINCT';
|
||||
}
|
||||
|
||||
$module_a_filter = '';
|
||||
|
@ -2678,6 +2675,11 @@ function modules_get_relations($params=[])
|
|||
$module_b_filter = sprintf('AND tmr.module_b = %d', $id_module);
|
||||
}
|
||||
|
||||
$agent_filter = '';
|
||||
if ($id_agent > 0) {
|
||||
$agent_filter = sprintf('AND ta.id_agente = %d', $id_agent);
|
||||
}
|
||||
|
||||
$disabled_update_filter = '';
|
||||
if ($disabled_update >= 0) {
|
||||
$disabled_update_filter = sprintf(
|
||||
|
@ -2686,22 +2688,25 @@ function modules_get_relations($params=[])
|
|||
);
|
||||
}
|
||||
|
||||
$modules_type_filter = '';
|
||||
if ($modules_type != '') {
|
||||
$modules_type_filter = sprintf(
|
||||
"AND (tam.id_tipo_modulo = ttm.id_tipo AND ttm.nombre = '%s')",
|
||||
$modules_type
|
||||
);
|
||||
}
|
||||
|
||||
$sql .= "( (tmr.module_a = tam.id_agente_modulo
|
||||
$module_a_filter)
|
||||
OR (tmr.module_b = tam.id_agente_modulo
|
||||
$module_b_filter) )
|
||||
AND tam.id_agente = ta.id_agente
|
||||
$agent_filter
|
||||
$disabled_update_filter
|
||||
$modules_type_filter";
|
||||
$sql = sprintf(
|
||||
'SELECT %s tmr.id, tmr.module_a, tmr.module_b,
|
||||
tmr.disable_update, tmr.type
|
||||
FROM tmodule_relationship tmr
|
||||
INNER JOIN tagente_modulo tam
|
||||
ON (tmr.module_a = tam.id_agente_modulo %s)
|
||||
OR (tmr.module_b = tam.id_agente_modulo %s)
|
||||
INNER JOIN tagente ta
|
||||
ON tam.id_agente = ta.id_agente
|
||||
%s
|
||||
WHERE 1=1 %s %s %s',
|
||||
$distinct,
|
||||
$module_a_filter,
|
||||
$module_b_filter,
|
||||
$module_type,
|
||||
$agent_filter,
|
||||
$disabled_update_filter,
|
||||
$modules_type_filter
|
||||
);
|
||||
|
||||
return db_get_all_rows_sql($sql);
|
||||
}
|
||||
|
|
|
@ -2327,7 +2327,13 @@ function migrate_older_open_maps($id)
|
|||
$new_map_filter = [];
|
||||
$new_map_filter['dont_show_subgroups'] = $old_networkmap['dont_show_subgroups'];
|
||||
$new_map_filter['node_radius'] = 40;
|
||||
$new_map_filter['id_migrate_map'] = $id;
|
||||
$new_map_filter['x_offs'] = 0;
|
||||
$new_map_filter['y_offs'] = 0;
|
||||
$new_map_filter['z_dash'] = '0.5';
|
||||
$new_map_filter['node_sep'] = '0.1';
|
||||
$new_map_filter['rank_sep'] = 1;
|
||||
$new_map_filter['mindist'] = 1;
|
||||
$new_map_filter['kval'] = '0.1';
|
||||
$map_values['filter'] = json_encode($new_map_filter);
|
||||
|
||||
$map_values['description'] = 'Mapa open migrado';
|
||||
|
@ -2340,11 +2346,7 @@ function migrate_older_open_maps($id)
|
|||
$map_values['source_period'] = 60;
|
||||
$map_values['source'] = 0;
|
||||
$map_values['source_data'] = $old_networkmap['id_group'];
|
||||
if ($old_networkmap['type'] == 'radial_dinamic') {
|
||||
$map_values['generation_method'] = 6;
|
||||
} else {
|
||||
$map_values['generation_method'] = 4;
|
||||
}
|
||||
$map_values['generation_method'] = 3;
|
||||
|
||||
$map_values['generated'] = 0;
|
||||
|
||||
|
|
|
@ -748,7 +748,9 @@ function planned_downtimes_created($values)
|
|||
'return' => false,
|
||||
'message' => __('Not created. Error inserting data').'. '.__('The end date must be higher than the current time'),
|
||||
];
|
||||
} else if ($values['type_execution'] == 'once' && $values['date_from'] >= $values['date_to']) {
|
||||
} else if ($values['type_execution'] == 'once' && ($values['date_from'] > $values['date_to'])
|
||||
|| (($values['date_from'] == $values['date_to']) && ($values['periodically_time_from'] >= $values['periodically_time_to']))
|
||||
) {
|
||||
return [
|
||||
'return' => false,
|
||||
'message' => __('Not created. Error inserting data').'. '.__('The end date must be higher than the start date'),
|
||||
|
@ -794,6 +796,11 @@ function planned_downtimes_created($values)
|
|||
'return' => false,
|
||||
'message' => __('Not created. Error inserting data').'. '.__('There is no group with such id'),
|
||||
];
|
||||
} else if (!$values['date_from'] || !$values['date_to']) {
|
||||
return [
|
||||
'return' => false,
|
||||
'message' => __('Not created. Error inserting data').'. '.__('Date is wrong formatted'),
|
||||
];
|
||||
} else {
|
||||
if (trim(io_safe_output($values['name'])) != '') {
|
||||
if (!$check) {
|
||||
|
|
|
@ -224,7 +224,12 @@ function reporting_make_reporting_data(
|
|||
|
||||
// General reports with 0 period means last value
|
||||
// Avoid to overwrite it by template value.
|
||||
if (!empty($period) && ($content['type'] !== 'general' && $content['period'] != 0)) {
|
||||
$general_last_value = false;
|
||||
if ($content['type'] === 'general' && $content['period'] == 0) {
|
||||
$general_last_value = true;
|
||||
}
|
||||
|
||||
if (!empty($period) && $general_last_value === false) {
|
||||
$content['period'] = $period;
|
||||
}
|
||||
|
||||
|
@ -282,6 +287,15 @@ function reporting_make_reporting_data(
|
|||
$agents_to_macro = $content['id_agent'];
|
||||
}
|
||||
|
||||
// Metaconsole connection.
|
||||
if (is_metaconsole()) {
|
||||
$server = metaconsole_get_connection_names();
|
||||
$connection = metaconsole_get_connection($server);
|
||||
if (metaconsole_connect($connection) != NOERR) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($content['style']['name_label'])) {
|
||||
// Add macros name.
|
||||
$items_label = [];
|
||||
|
@ -294,14 +308,6 @@ function reporting_make_reporting_data(
|
|||
$metaconsole_on = is_metaconsole();
|
||||
$server_name = $content['server_name'];
|
||||
|
||||
// Metaconsole connection.
|
||||
if ($metaconsole_on && $server_name != '') {
|
||||
$connection = metaconsole_get_connection($server_name);
|
||||
if (!metaconsole_load_external_db($connection)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
$items_label['agent_description'] = agents_get_description(
|
||||
$content['id_agent']
|
||||
);
|
||||
|
@ -505,42 +511,6 @@ function reporting_make_reporting_data(
|
|||
);
|
||||
break;
|
||||
|
||||
case 'MTTR':
|
||||
$report['contents'][] = reporting_value(
|
||||
$report,
|
||||
$content,
|
||||
'MTTR',
|
||||
$pdf
|
||||
);
|
||||
break;
|
||||
|
||||
case 'MTBF':
|
||||
$report['contents'][] = reporting_value(
|
||||
$report,
|
||||
$content,
|
||||
'MTBF',
|
||||
$pdf
|
||||
);
|
||||
break;
|
||||
|
||||
case 'TTO':
|
||||
$report['contents'][] = reporting_value(
|
||||
$report,
|
||||
$content,
|
||||
'TTO',
|
||||
$pdf
|
||||
);
|
||||
break;
|
||||
|
||||
case 'TTRT':
|
||||
$report['contents'][] = reporting_value(
|
||||
$report,
|
||||
$content,
|
||||
'TTRT',
|
||||
$pdf
|
||||
);
|
||||
break;
|
||||
|
||||
case 'agent_configuration':
|
||||
$report['contents'][] = io_safe_output(
|
||||
reporting_agent_configuration(
|
||||
|
@ -2823,13 +2793,12 @@ function reporting_group_report($report, $content)
|
|||
$content['name'] = __('Group Report');
|
||||
}
|
||||
|
||||
if ($config['metaconsole']) {
|
||||
$id_meta = metaconsole_get_id_server($content['server_name']);
|
||||
|
||||
$server = metaconsole_get_connection_by_id($id_meta);
|
||||
metaconsole_connect($server);
|
||||
if (is_metaconsole()) {
|
||||
$server = metaconsole_get_connection_names();
|
||||
$connection = metaconsole_get_connection($server);
|
||||
}
|
||||
|
||||
$return['server_name'] = $server[0];
|
||||
$return['title'] = $content['name'];
|
||||
$return['subtitle'] = groups_get_name($content['id_group'], true);
|
||||
$return['description'] = $content['description'];
|
||||
|
@ -3105,6 +3074,13 @@ function reporting_historical_data($report, $content)
|
|||
$content['name'] = __('Historical data');
|
||||
}
|
||||
|
||||
if (is_metaconsole()) {
|
||||
$id_meta = metaconsole_get_id_server($content['server_name']);
|
||||
|
||||
$server = metaconsole_get_connection_by_id($id_meta);
|
||||
$connection = metaconsole_connect($server);
|
||||
}
|
||||
|
||||
$id_agent = agents_get_module_id(
|
||||
$content['id_agent_module']
|
||||
);
|
||||
|
@ -3196,6 +3172,10 @@ function reporting_historical_data($report, $content)
|
|||
|
||||
$return['data'] = $data;
|
||||
|
||||
if (is_metaconsole() && $connection > 0) {
|
||||
metaconsole_restore_db();
|
||||
}
|
||||
|
||||
return reporting_check_structure_content($return);
|
||||
}
|
||||
|
||||
|
@ -3264,6 +3244,7 @@ function reporting_database_serialized($report, $content)
|
|||
}
|
||||
|
||||
$return['keys'] = $keys;
|
||||
$return['agent_name_db'] = agents_get_name($id_agent);
|
||||
$return['agent_name'] = $agent_alias;
|
||||
$return['module_name'] = $module_name;
|
||||
|
||||
|
@ -3476,7 +3457,7 @@ function reporting_network_interfaces_report($report, $content, $type='dinamic',
|
|||
$return['failed'] = null;
|
||||
$return['data'] = [];
|
||||
|
||||
if ($config['metaconsole']) {
|
||||
if (is_metaconsole()) {
|
||||
$server_names = metaconsole_get_connection_names();
|
||||
if (isset($server_names) && is_array($server_names)) {
|
||||
foreach ($server_names as $key => $value) {
|
||||
|
@ -3493,7 +3474,8 @@ function reporting_network_interfaces_report($report, $content, $type='dinamic',
|
|||
$content,
|
||||
$report,
|
||||
$fullscale,
|
||||
$pdf
|
||||
$pdf,
|
||||
$id_meta
|
||||
);
|
||||
metaconsole_restore_db();
|
||||
}
|
||||
|
@ -4178,6 +4160,19 @@ function reporting_sql_graph(
|
|||
$return['description'] = $content['description'];
|
||||
$return['date'] = reporting_get_date_text();
|
||||
|
||||
$module_source = db_get_all_rows_sql(
|
||||
'SELECT id_agent_module
|
||||
FROM tgraph_source
|
||||
WHERE id_graph = '.$content['id_gs']
|
||||
);
|
||||
|
||||
if (isset($module_source) && is_array($module_source)) {
|
||||
$modules = [];
|
||||
foreach ($module_source as $key => $value) {
|
||||
$modules[$key] = $value['id_agent_module'];
|
||||
}
|
||||
}
|
||||
|
||||
switch ($type) {
|
||||
case 'dinamic':
|
||||
case 'static':
|
||||
|
@ -4194,6 +4189,16 @@ function reporting_sql_graph(
|
|||
break;
|
||||
|
||||
case 'data':
|
||||
$data = [];
|
||||
foreach ($modules as $key => $value) {
|
||||
$data[$value] = modules_get_agentmodule_data(
|
||||
$value,
|
||||
$content['period'],
|
||||
$report['datetime']
|
||||
);
|
||||
}
|
||||
|
||||
$return['chart'] = $data;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -4267,6 +4272,7 @@ function reporting_monitor_report($report, $content)
|
|||
);
|
||||
}
|
||||
|
||||
$return['agent_name_db'] = agents_get_name($id_agent);
|
||||
$return['agent_name'] = $agent_alias;
|
||||
$return['module_name'] = $module_name;
|
||||
|
||||
|
@ -4394,6 +4400,7 @@ function reporting_netflow(
|
|||
switch ($type) {
|
||||
case 'dinamic':
|
||||
case 'static':
|
||||
case 'data':
|
||||
$return['chart'] = netflow_draw_item(
|
||||
($report['datetime'] - $content['period']),
|
||||
$report['datetime'],
|
||||
|
@ -4438,6 +4445,7 @@ function reporting_prediction_date($report, $content)
|
|||
$agent_name = io_safe_output(
|
||||
modules_get_agentmodule_agent_alias($content['id_agent_module'])
|
||||
);
|
||||
$agent_name_db = io_safe_output(modules_get_agentmodule_agent_name($content['id_agent_module']));
|
||||
|
||||
$return['title'] = $content['name'];
|
||||
$return['subtitle'] = $agent_name.' - '.$module_name;
|
||||
|
@ -4445,6 +4453,7 @@ function reporting_prediction_date($report, $content)
|
|||
$return['date'] = reporting_get_date_text($report, $content);
|
||||
$return['label'] = (isset($content['style']['label'])) ? $content['style']['label'] : '';
|
||||
|
||||
$return['agent_name_db'] = $agent_name_db;
|
||||
$return['agent_name'] = $agent_name;
|
||||
$return['module_name'] = $module_name;
|
||||
|
||||
|
@ -4489,12 +4498,14 @@ function reporting_projection_graph(
|
|||
|
||||
$module_name = io_safe_output(modules_get_agentmodule_name($content['id_agent_module']));
|
||||
$agent_name = io_safe_output(modules_get_agentmodule_agent_alias($content['id_agent_module']));
|
||||
$agent_name_db = io_safe_output(modules_get_agentmodule_agent_name($content['id_agent_module']));
|
||||
|
||||
$return['title'] = $content['name'];
|
||||
$return['subtitle'] = $agent_name.' - '.$module_name;
|
||||
$return['description'] = $content['description'];
|
||||
$return['date'] = reporting_get_date_text($report, $content);
|
||||
$return['label'] = (isset($content['style']['label'])) ? $content['style']['label'] : '';
|
||||
$return['agent_name_db'] = $agent_name_db;
|
||||
$return['agent_name'] = $agent_name;
|
||||
$return['module_name'] = $module_name;
|
||||
|
||||
|
@ -4690,22 +4701,6 @@ function reporting_value($report, $content, $type, $pdf=false)
|
|||
case 'sum':
|
||||
$return['type'] = 'sumatory';
|
||||
break;
|
||||
|
||||
case 'MTTR':
|
||||
$return['type'] = 'MTTR';
|
||||
break;
|
||||
|
||||
case 'MTBF':
|
||||
$return['type'] = 'MTBF';
|
||||
break;
|
||||
|
||||
case 'TTO':
|
||||
$return['type'] = 'TTO';
|
||||
break;
|
||||
|
||||
case 'TTRT':
|
||||
$return['type'] = 'TTRT';
|
||||
break;
|
||||
}
|
||||
|
||||
if (empty($content['name'])) {
|
||||
|
@ -4725,22 +4720,6 @@ function reporting_value($report, $content, $type, $pdf=false)
|
|||
case 'sum':
|
||||
$content['name'] = __('Summatory');
|
||||
break;
|
||||
|
||||
case 'MTTR':
|
||||
$content['name'] = __('MTTR');
|
||||
break;
|
||||
|
||||
case 'MTBF':
|
||||
$content['name'] = __('MTBF');
|
||||
break;
|
||||
|
||||
case 'TTO':
|
||||
$content['name'] = __('TTO');
|
||||
break;
|
||||
|
||||
case 'TTRT':
|
||||
$content['name'] = __('TTRT');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4757,6 +4736,9 @@ function reporting_value($report, $content, $type, $pdf=false)
|
|||
$agent_name = io_safe_output(
|
||||
modules_get_agentmodule_agent_alias($content['id_agent_module'])
|
||||
);
|
||||
$agent_name_db = io_safe_output(
|
||||
modules_get_agentmodule_agent_name($content['id_agent_module'])
|
||||
);
|
||||
$unit = db_get_value(
|
||||
'unit',
|
||||
'tagente_modulo',
|
||||
|
@ -4773,6 +4755,7 @@ function reporting_value($report, $content, $type, $pdf=false)
|
|||
$return['id_agent'] = $content['id_agent'];
|
||||
$return['id_agent_module'] = $content['id_agent_module'];
|
||||
|
||||
$return['agent_name_db'] = $agent_name_db;
|
||||
$return['agent_name'] = $agent_name;
|
||||
$return['module_name'] = $module_name;
|
||||
|
||||
|
@ -4865,22 +4848,23 @@ function reporting_value($report, $content, $type, $pdf=false)
|
|||
|
||||
if ($content['visual_format'] != 2) {
|
||||
$time_begin = db_get_row_sql('select utimestamp from tagente_datos where id_agente_modulo ='.$content['id_agent_module'], true);
|
||||
for ($i = $report['datetime']; $i > ($report['datetime'] - $content['period']); $i -= $content['lapse']) {
|
||||
|
||||
for ($i = ($report['datetime'] - $content['period']); $i < $report['datetime']; $i += $content['lapse']) {
|
||||
$row = [];
|
||||
$row[__('Lapse')] = date('Y-m-d H:i:s', ($i - $content['lapse'] + 1)).' to '.date('Y-m-d H:i:s', $i);
|
||||
$row[__('Lapse')] = date('Y-m-d H:i:s', ($i + 1)).' to '.date('Y-m-d H:i:s', (($i + $content['lapse']) ));
|
||||
|
||||
if ($i > $time_begin['utimestamp']) {
|
||||
switch ($type) {
|
||||
case 'max':
|
||||
$row[__('Maximun')] = format_for_graph(reporting_get_agentmodule_data_max($content['id_agent_module'], $content['lapse'], $i), $config['graph_precision']).' '.$unit;
|
||||
$row[__('Maximun')] = format_for_graph(reporting_get_agentmodule_data_max($content['id_agent_module'], $content['lapse'], ($i + $content['lapse'])), $config['graph_precision']).' '.$unit;
|
||||
break;
|
||||
|
||||
case 'min':
|
||||
$row[__('Maximun')] = format_for_graph(reporting_get_agentmodule_data_min($content['id_agent_module'], $content['lapse'], $i), $config['graph_precision']).' '.$unit;
|
||||
$row[__('Maximun')] = format_for_graph(reporting_get_agentmodule_data_min($content['id_agent_module'], $content['lapse'], ($i + $content['lapse'])), $config['graph_precision']).' '.$unit;
|
||||
break;
|
||||
|
||||
case 'avg':
|
||||
$row[__('Maximun')] = format_for_graph(reporting_get_agentmodule_data_average($content['id_agent_module'], $content['lapse'], $i), $config['graph_precision']).' '.$unit;
|
||||
$row[__('Maximun')] = format_for_graph(reporting_get_agentmodule_data_average($content['id_agent_module'], $content['lapse'], ($i + $content['lapse'])), $config['graph_precision']).' '.$unit;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
|
@ -4912,50 +4896,6 @@ function reporting_value($report, $content, $type, $pdf=false)
|
|||
$formated_value = format_for_graph($value, $config['graph_precision']).' '.$unit;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'MTTR':
|
||||
$value = reporting_get_agentmodule_mttr(
|
||||
$content['id_agent_module'],
|
||||
$content['period'],
|
||||
$report['datetime']
|
||||
);
|
||||
$formated_value = null;
|
||||
break;
|
||||
|
||||
case 'MTBF':
|
||||
$value = reporting_get_agentmodule_mtbf(
|
||||
$content['id_agent_module'],
|
||||
$content['period'],
|
||||
$report['datetime']
|
||||
);
|
||||
$formated_value = null;
|
||||
break;
|
||||
|
||||
case 'TTO':
|
||||
$value = reporting_get_agentmodule_tto(
|
||||
$content['id_agent_module'],
|
||||
$content['period'],
|
||||
$report['datetime']
|
||||
);
|
||||
if ($value == 0) {
|
||||
$formated_value = null;
|
||||
} else {
|
||||
$formated_value = human_time_description_raw($value);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'TTRT':
|
||||
$value = reporting_get_agentmodule_ttr(
|
||||
$content['id_agent_module'],
|
||||
$content['period'],
|
||||
$report['datetime']
|
||||
);
|
||||
if ($value == 0) {
|
||||
$formated_value = null;
|
||||
} else {
|
||||
$formated_value = human_time_description_raw($value);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
$return['data'] = [
|
||||
|
@ -7488,10 +7428,12 @@ function reporting_custom_graph(
|
|||
|
||||
if ($type_report == 'custom_graph') {
|
||||
if (is_metaconsole()) {
|
||||
$id_meta = metaconsole_get_id_server($content['server_name']);
|
||||
$server = metaconsole_get_connection_by_id($id_meta);
|
||||
if (metaconsole_connect($server) != NOERR) {
|
||||
return false;
|
||||
$servers = metaconsole_get_connection_names();
|
||||
foreach ($servers as $server) {
|
||||
$connection = metaconsole_get_connection($server);
|
||||
if (metaconsole_connect($connection) != NOERR) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7543,8 +7485,35 @@ function reporting_custom_graph(
|
|||
$content['name'] = __('Simple graph');
|
||||
}
|
||||
|
||||
$module_source = db_get_all_rows_sql(
|
||||
'SELECT id_agent_module
|
||||
FROM tgraph_source
|
||||
WHERE id_graph = '.$content['id_gs']
|
||||
);
|
||||
|
||||
if (isset($module_source) && is_array($module_source)) {
|
||||
$modules = [];
|
||||
foreach ($module_source as $key => $value) {
|
||||
$modules[$key] = $value['id_agent_module'];
|
||||
}
|
||||
}
|
||||
|
||||
$agent_description = agents_get_description($id_agent);
|
||||
$agent_group = agents_get_agent_group($id_agent);
|
||||
$agent_address = agents_get_address($id_agent);
|
||||
$agent_alias = agents_get_alias($id_agent);
|
||||
$module_name = modules_get_agentmodule_name(
|
||||
$id_agent_module
|
||||
);
|
||||
|
||||
$module_description = modules_get_agentmodule_descripcion(
|
||||
$id_agent_module
|
||||
);
|
||||
|
||||
$return['title'] = $content['name'];
|
||||
$return['subtitle'] = io_safe_output($graph['name']);
|
||||
$return['agent_name'] = $agent_alias;
|
||||
$return['module_name'] = $module_name;
|
||||
$return['description'] = $content['description'];
|
||||
$return['date'] = reporting_get_date_text(
|
||||
$report,
|
||||
|
@ -7588,6 +7557,19 @@ function reporting_custom_graph(
|
|||
);
|
||||
|
||||
break;
|
||||
|
||||
case 'data':
|
||||
$data = [];
|
||||
foreach ($modules as $key => $value) {
|
||||
$data[$value] = modules_get_agentmodule_data(
|
||||
$value,
|
||||
$content['period'],
|
||||
$report['datetime']
|
||||
);
|
||||
}
|
||||
|
||||
$return['chart'] = $data;
|
||||
break;
|
||||
}
|
||||
|
||||
if ($type_report == 'custom_graph') {
|
||||
|
@ -7672,6 +7654,7 @@ function reporting_simple_graph(
|
|||
|
||||
$return['title'] = $content['name'];
|
||||
$return['subtitle'] = $agent_alias.' - '.$module_name;
|
||||
$return['agent_name_db'] = agents_get_name($id_agent);
|
||||
$return['agent_name'] = $agent_alias;
|
||||
$return['module_name'] = $module_name;
|
||||
$return['description'] = $content['description'];
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue