Merge remote-tracking branch 'origin/develop' into 4689-mostrar-instrucciones-en-la-vista-de-eventos

Conflicts:
	pandora_console/include/functions_events.php
This commit is contained in:
Kike 2019-10-03 15:59:15 +02:00
commit b25c9ca793
97 changed files with 11916 additions and 1444 deletions

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents # Base config file for Pandora FMS agents
# Version 7.0NG.738, AIX version # Version 7.0NG.739, AIX version
# Licensed under GPL license v2, # Licensed under GPL license v2,
# Copyright (c) 2003-2010 Artica Soluciones Tecnologicas # Copyright (c) 2003-2010 Artica Soluciones Tecnologicas
# http://www.pandorafms.com # http://www.pandorafms.com

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents # Base config file for Pandora FMS agents
# Version 7.0NG.738, FreeBSD Version # Version 7.0NG.739, FreeBSD Version
# Licensed under GPL license v2, # Licensed under GPL license v2,
# Copyright (c) 2003-2010 Artica Soluciones Tecnologicas # Copyright (c) 2003-2010 Artica Soluciones Tecnologicas
# http://www.pandorafms.com # http://www.pandorafms.com

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents # Base config file for Pandora FMS agents
# Version 7.0NG.738, HP-UX Version # Version 7.0NG.739, HP-UX Version
# Licensed under GPL license v2, # Licensed under GPL license v2,
# Copyright (c) 2003-2009 Artica Soluciones Tecnologicas # Copyright (c) 2003-2009 Artica Soluciones Tecnologicas
# http://www.pandorafms.com # http://www.pandorafms.com

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents # Base config file for Pandora FMS agents
# Version 7.0NG.738, GNU/Linux # Version 7.0NG.739, GNU/Linux
# Licensed under GPL license v2, # Licensed under GPL license v2,
# Copyright (c) 2003-2009 Artica Soluciones Tecnologicas # Copyright (c) 2003-2009 Artica Soluciones Tecnologicas
# http://www.pandorafms.com # http://www.pandorafms.com

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents # Base config file for Pandora FMS agents
# Version 7.0NG.738, GNU/Linux # Version 7.0NG.739, GNU/Linux
# Licensed under GPL license v2, # Licensed under GPL license v2,
# Copyright (c) 2003-2009 Artica Soluciones Tecnologicas # Copyright (c) 2003-2009 Artica Soluciones Tecnologicas
# http://www.pandorafms.com # http://www.pandorafms.com

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents # Base config file for Pandora FMS agents
# Version 7.0NG.738, Solaris Version # Version 7.0NG.739, Solaris Version
# Licensed under GPL license v2, # Licensed under GPL license v2,
# Copyright (c) 2003-2009 Artica Soluciones Tecnologicas # Copyright (c) 2003-2009 Artica Soluciones Tecnologicas
# http://www.pandorafms.com # http://www.pandorafms.com

View File

@ -1,6 +1,6 @@
# Base config file for Pandora FMS Windows Agent # Base config file for Pandora FMS Windows Agent
# (c) 2006-2010 Artica Soluciones Tecnologicas # (c) 2006-2010 Artica Soluciones Tecnologicas
# Version 7.0NG.738 # Version 7.0NG.739
# This program is Free Software, you can redistribute it and/or modify it # 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 # under the terms of the GNU General Public Licence as published by the Free Software

View File

@ -1,6 +1,6 @@
# Fichero de configuracion base de agentes de Pandora # Fichero de configuracion base de agentes de Pandora
# Base config file for Pandora agents # Base config file for Pandora agents
# Version 7.0NG.738, AIX version # Version 7.0NG.739, AIX version
# General Parameters # General Parameters
# ================== # ==================

View File

@ -1,6 +1,6 @@
# Fichero de configuracion base de agentes de Pandora # Fichero de configuracion base de agentes de Pandora
# Base config file for Pandora agents # Base config file for Pandora agents
# Version 7.0NG.738 # Version 7.0NG.739
# FreeBSD/IPSO version # FreeBSD/IPSO version
# Licenced under GPL licence, 2003-2007 Sancho Lerena # Licenced under GPL licence, 2003-2007 Sancho Lerena

View File

@ -1,6 +1,6 @@
# Fichero de configuracion base de agentes de Pandora # Fichero de configuracion base de agentes de Pandora
# Base config file for Pandora agents # Base config file for Pandora agents
# Version 7.0NG.738, HPUX Version # Version 7.0NG.739, HPUX Version
# General Parameters # General Parameters
# ================== # ==================

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents # Base config file for Pandora FMS agents
# Version 7.0NG.738 # Version 7.0NG.739
# Licensed under GPL license v2, # Licensed under GPL license v2,
# (c) 2003-2010 Artica Soluciones Tecnologicas # (c) 2003-2010 Artica Soluciones Tecnologicas
# please visit http://pandora.sourceforge.net # please visit http://pandora.sourceforge.net

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents # Base config file for Pandora FMS agents
# Version 7.0NG.738 # Version 7.0NG.739
# Licensed under GPL license v2, # Licensed under GPL license v2,
# (c) 2003-2009 Artica Soluciones Tecnologicas # (c) 2003-2009 Artica Soluciones Tecnologicas
# please visit http://pandora.sourceforge.net # please visit http://pandora.sourceforge.net

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents # Base config file for Pandora FMS agents
# Version 7.0NG.738 # Version 7.0NG.739
# Licensed under GPL license v2, # Licensed under GPL license v2,
# please visit http://pandora.sourceforge.net # please visit http://pandora.sourceforge.net

View File

@ -1,6 +1,6 @@
# Fichero de configuracion base de agentes de Pandora # Fichero de configuracion base de agentes de Pandora
# Base config file for Pandora agents # Base config file for Pandora agents
# Version 7.0NG.738, Solaris version # Version 7.0NG.739, Solaris version
# General Parameters # General Parameters
# ================== # ==================

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents # Base config file for Pandora FMS agents
# Version 7.0NG.738, AIX version # Version 7.0NG.739, AIX version
# Licensed under GPL license v2, # Licensed under GPL license v2,
# Copyright (c) 2003-2010 Artica Soluciones Tecnologicas # Copyright (c) 2003-2010 Artica Soluciones Tecnologicas
# http://www.pandorafms.com # http://www.pandorafms.com

View File

@ -1,5 +1,5 @@
package: pandorafms-agent-unix package: pandorafms-agent-unix
Version: 7.0NG.738-190920 Version: 7.0NG.739-191003
Architecture: all Architecture: all
Priority: optional Priority: optional
Section: admin Section: admin

View File

@ -14,7 +14,7 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. # GNU General Public License for more details.
pandora_version="7.0NG.738-190920" pandora_version="7.0NG.739-191003"
echo "Test if you has the tools for to make the packages." echo "Test if you has the tools for to make the packages."
whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents # Base config file for Pandora FMS agents
# Version 7.0NG.738, GNU/Linux # Version 7.0NG.739, GNU/Linux
# Licensed under GPL license v2, # Licensed under GPL license v2,
# Copyright (c) 2003-2012 Artica Soluciones Tecnologicas # Copyright (c) 2003-2012 Artica Soluciones Tecnologicas
# http://www.pandorafms.com # http://www.pandorafms.com

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents # Base config file for Pandora FMS agents
# Version 7.0NG.738, FreeBSD Version # Version 7.0NG.739, FreeBSD Version
# Licensed under GPL license v2, # Licensed under GPL license v2,
# Copyright (c) 2003-2016 Artica Soluciones Tecnologicas # Copyright (c) 2003-2016 Artica Soluciones Tecnologicas
# http://www.pandorafms.com # http://www.pandorafms.com

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents # Base config file for Pandora FMS agents
# Version 7.0NG.738, HP-UX Version # Version 7.0NG.739, HP-UX Version
# Licensed under GPL license v2, # Licensed under GPL license v2,
# Copyright (c) 2003-2009 Artica Soluciones Tecnologicas # Copyright (c) 2003-2009 Artica Soluciones Tecnologicas
# http://www.pandorafms.com # http://www.pandorafms.com

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents # Base config file for Pandora FMS agents
# Version 7.0NG.738, GNU/Linux # Version 7.0NG.739, GNU/Linux
# Licensed under GPL license v2, # Licensed under GPL license v2,
# Copyright (c) 2003-2014 Artica Soluciones Tecnologicas # Copyright (c) 2003-2014 Artica Soluciones Tecnologicas
# http://www.pandorafms.com # http://www.pandorafms.com

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents # Base config file for Pandora FMS agents
# Version 7.0NG.738, GNU/Linux # Version 7.0NG.739, GNU/Linux
# Licensed under GPL license v2, # Licensed under GPL license v2,
# Copyright (c) 2003-2009 Artica Soluciones Tecnologicas # Copyright (c) 2003-2009 Artica Soluciones Tecnologicas
# http://www.pandorafms.com # http://www.pandorafms.com

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents # Base config file for Pandora FMS agents
# Version 7.0NG.738, NetBSD Version # Version 7.0NG.739, NetBSD Version
# Licensed under GPL license v2, # Licensed under GPL license v2,
# Copyright (c) 2003-2010 Artica Soluciones Tecnologicas # Copyright (c) 2003-2010 Artica Soluciones Tecnologicas
# http://www.pandorafms.com # http://www.pandorafms.com

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents # Base config file for Pandora FMS agents
# Version 7.0NG.738, Solaris Version # Version 7.0NG.739, Solaris Version
# Licensed under GPL license v2, # Licensed under GPL license v2,
# Copyright (c) 2003-2009 Artica Soluciones Tecnologicas # Copyright (c) 2003-2009 Artica Soluciones Tecnologicas
# http://www.pandorafms.com # http://www.pandorafms.com

View File

@ -41,8 +41,8 @@ my $Sem = undef;
# Semaphore used to control the number of threads # Semaphore used to control the number of threads
my $ThreadSem = undef; my $ThreadSem = undef;
use constant AGENT_VERSION => '7.0NG.738'; use constant AGENT_VERSION => '7.0NG.739';
use constant AGENT_BUILD => '190920'; use constant AGENT_BUILD => '191003';
# Agent log default file size maximum and instances # Agent log default file size maximum and instances
use constant DEFAULT_MAX_LOG_SIZE => 600000; use constant DEFAULT_MAX_LOG_SIZE => 600000;
@ -239,6 +239,15 @@ my $tentacle_pid = undef;
# PID of udp_server # PID of udp_server
my $udp_server_pid = undef; 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. # Print usage information and exit.
################################################################################ ################################################################################
@ -1385,6 +1394,7 @@ sub sleep_agent {
exit (0); exit (0);
} }
$LoopCounter = ($LoopCounter + 1) % MAX_LOOP_COUNTER;
return $iter_base_time; return $iter_base_time;
} }
@ -1699,6 +1709,14 @@ sub exec_module {
} }
# Check module interval # 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'}) { if (++($module->{'counter'}) < $module->{'intensive_interval'}) {
$ThreadSem->up () if (defined ($ThreadSem) && $Conf{'agent_threads'} > 1); $ThreadSem->up () if (defined ($ThreadSem) && $Conf{'agent_threads'} > 1);
return; return;
@ -2985,7 +3003,6 @@ while (1) {
@BrokerPid = (); @BrokerPid = ();
my @broker_agents = read_config ('broker_agent'); my @broker_agents = read_config ('broker_agent');
foreach my $broker_agent (@broker_agents) { foreach my $broker_agent (@broker_agents) {
# Create broker conf file if it does not exist # Create broker conf file if it does not exist
if (! -e "$ConfDir/${broker_agent}.conf") { if (! -e "$ConfDir/${broker_agent}.conf") {
write_broker_conf($broker_agent); write_broker_conf($broker_agent);
@ -2995,7 +3012,9 @@ while (1) {
# Broker agent # Broker agent
if ($main_agent == 0) { if ($main_agent == 0) {
# Mark broker flag.
$BrokerFlag = 1;
# Set the configuration file # Set the configuration file
$ConfFile = "${broker_agent}.conf"; $ConfFile = "${broker_agent}.conf";

View File

@ -2,8 +2,8 @@
#Pandora FMS Linux Agent #Pandora FMS Linux Agent
# #
%define name pandorafms_agent_unix %define name pandorafms_agent_unix
%define version 7.0NG.738 %define version 7.0NG.739
%define release 190920 %define release 191003
Summary: Pandora FMS Linux agent, PERL version Summary: Pandora FMS Linux agent, PERL version
Name: %{name} Name: %{name}

View File

@ -2,8 +2,8 @@
#Pandora FMS Linux Agent #Pandora FMS Linux Agent
# #
%define name pandorafms_agent_unix %define name pandorafms_agent_unix
%define version 7.0NG.738 %define version 7.0NG.739
%define release 190920 %define release 191003
Summary: Pandora FMS Linux agent, PERL version Summary: Pandora FMS Linux agent, PERL version
Name: %{name} Name: %{name}

View File

@ -9,8 +9,8 @@
# Please see http://www.pandorafms.org. This code is licensed under GPL 2.0 license. # Please see http://www.pandorafms.org. This code is licensed under GPL 2.0 license.
# ********************************************************************** # **********************************************************************
PI_VERSION="7.0NG.738" PI_VERSION="7.0NG.739"
PI_BUILD="190920" PI_BUILD="191003"
OS_NAME=`uname -s` OS_NAME=`uname -s`
FORCE=0 FORCE=0
@ -162,7 +162,15 @@ uninstall () {
rm -Rf $PANDORA_BASE$PANDORA_EXEC_BIN 2> /dev/null rm -Rf $PANDORA_BASE$PANDORA_EXEC_BIN 2> /dev/null
rm -Rf $PANDORA_BASE$PANDORA_REVENT_BIN 2> /dev/null rm -Rf $PANDORA_BASE$PANDORA_REVENT_BIN 2> /dev/null
rm -f $DESTDIR/etc/logrotate.d/pandora_agent rm -f $DESTDIR/etc/logrotate.d/pandora_agent
# Remove systemd service if exists
if [ $(systemctl --v | grep systemd | wc -l) != 0 ]
then
PANDORA_AGENT_SERVICE="/etc/systemd/system/pandora_agent_daemon.service"
rm -f $PANDORA_AGENT_SERVICE
systemctl reset-failed
fi
#Test if exist Pandora Server in this machine #Test if exist Pandora Server in this machine
if [ -d $PANDORA_BASE$PANDORA_TEMP/data_in ] if [ -d $PANDORA_BASE$PANDORA_TEMP/data_in ]
then then
@ -465,6 +473,22 @@ install () {
else else
RCDIRS="/etc/rc2.d /etc/rc3.d" RCDIRS="/etc/rc2.d /etc/rc3.d"
fi fi
# Create systemd service
if [ $(systemctl --v | grep systemd | wc -l) != 0 ]
then
echo "Creating systemd service for pandora_agent_daemon"
PANDORA_AGENT_SERVICE="/etc/systemd/system/pandora_agent_daemon.service"
EXEC_START='ExecStart='$PANDORA_BASE$PANDORA_BIN' '$PANDORA_BASE$PANDORA_CFG
rm -f $PANDORA_AGENT_SERVICE
cp pandora_agent_daemon.service $PANDORA_AGENT_SERVICE
sed -i "s|^ExecStart=.*$|$EXEC_START|g" $PANDORA_AGENT_SERVICE
systemctl daemon-reload
fi
fi fi
[ "$RCDIRS" ] && for RCDIR in $RCDIRS [ "$RCDIRS" ] && for RCDIR in $RCDIRS
do do

View File

@ -1,6 +1,6 @@
# Base config file for Pandora FMS Windows Agent # Base config file for Pandora FMS Windows Agent
# (c) 2006-2017 Artica Soluciones Tecnologicas # (c) 2006-2017 Artica Soluciones Tecnologicas
# Version 7.0NG.738 # Version 7.0NG.739
# This program is Free Software, you can redistribute it and/or modify it # 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 # under the terms of the GNU General Public Licence as published by the Free Software

View File

@ -3,7 +3,7 @@ AllowLanguageSelection
{Yes} {Yes}
AppName AppName
{Pandora FMS Windows Agent v7.0NG.738} {Pandora FMS Windows Agent v7.0NG.739}
ApplicationID ApplicationID
{17E3D2CF-CA02-406B-8A80-9D31C17BD08F} {17E3D2CF-CA02-406B-8A80-9D31C17BD08F}
@ -186,7 +186,7 @@ UpgradeApplicationID
{} {}
Version Version
{190920} {191003}
ViewReadme ViewReadme
{Yes} {Yes}

View File

@ -1422,48 +1422,48 @@ Pandora_Module::evaluatePreconditions () {
buffer[read] = '\0'; buffer[read] = '\0';
output += (char *) buffer; output += (char *) buffer;
} }
try { try {
double_output = Pandora_Strutils::strtodouble (output); double_output = Pandora_Strutils::strtodouble (output);
} catch (Pandora_Strutils::Invalid_Conversion e) { } catch (Pandora_Strutils::Invalid_Conversion e) {
double_output = 0; 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) { GetExitCodeProcess (pi.hProcess, &retval);
break;
} else if(this->getTimeout() < GetTickCount() - tickbase) { if (retval != 0) {
/* STILL_ACTIVE */ if (! TerminateJobObject (job, 0)) {
TerminateProcess(pi.hThread, STILL_ACTIVE); pandoraLog ("evaluatePreconditions: TerminateJobObject failed. (error %d)",
pandoraLog ("evaluatePreconditions: %s timed out (retcode: %d)", this->module_name.c_str (), STILL_ACTIVE); GetLastError ());
break; }
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;
} }
}
GetExitCodeProcess (pi.hProcess, &retval);
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. */ /* Close job, process and thread handles. */
CloseHandle (job); CloseHandle (job);
CloseHandle (pi.hProcess); CloseHandle (pi.hProcess);
CloseHandle (pi.hThread); 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 (new_stdout);
CloseHandle (out_read); CloseHandle (out_read);
@ -1693,4 +1693,18 @@ Pandora_Module::getAsync () {
return this->async; 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;
}

View File

@ -234,6 +234,8 @@ namespace Pandora_Modules {
int getTimeout (); int getTimeout ();
string getSave (); string getSave ();
bool getAsync (); bool getAsync ();
void setExecutions(long executions=0);
long getExecutions();
virtual string getXml (); virtual string getXml ();

View File

@ -30,7 +30,7 @@ using namespace Pandora;
using namespace Pandora_Strutils; using namespace Pandora_Strutils;
#define PATH_SIZE _MAX_PATH+1 #define PATH_SIZE _MAX_PATH+1
#define PANDORA_VERSION ("7.0NG.738(Build 190920)") #define PANDORA_VERSION ("7.0NG.739(Build 191003)")
string pandora_path; string pandora_path;
string pandora_dir; string pandora_dir;

View File

@ -1849,7 +1849,7 @@ Pandora_Windows_Service::sendBufferedXml (string path) {
} }
void void
Pandora_Windows_Service::pandora_run_broker (string config) { Pandora_Windows_Service::pandora_run_broker (string config, long executions) {
Pandora_Agent_Conf *conf = NULL; Pandora_Agent_Conf *conf = NULL;
string server_addr; string server_addr;
unsigned char data_flag = 0; unsigned char data_flag = 0;
@ -1876,7 +1876,10 @@ Pandora_Windows_Service::pandora_run_broker (string config) {
Pandora_Module *module; Pandora_Module *module;
module = this->broker_modules->getCurrentValue (); module = this->broker_modules->getCurrentValue ();
/* Keep executions matching main agent */
module->setExecutions(executions);
/* Check preconditions */ /* Check preconditions */
if (module->evaluatePreconditions () == 0) { if (module->evaluatePreconditions () == 0) {
pandoraDebug ("Preconditions not matched for module %s", module->getName ().c_str ()); 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); check_broker_agents(all_conf);
for (i=0;i<num;i++){ for (i=0;i<num;i++){
pandora_init_broker(all_conf[i]); pandora_init_broker(all_conf[i]);
pandora_run_broker(all_conf[i]); pandora_run_broker(all_conf[i], execution_number);
} }
delete []all_conf; delete []all_conf;

View File

@ -87,7 +87,7 @@ namespace Pandora {
int checkConfig (string file); int checkConfig (string file);
void purgeDiskCollections (); void purgeDiskCollections ();
void pandora_init_broker (string file_conf); 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(); int count_broker_agents();
void check_broker_agents(string *all_conf); void check_broker_agents(string *all_conf);
int launchTentacleProxy(); int launchTentacleProxy();

View File

@ -11,7 +11,7 @@ BEGIN
VALUE "LegalCopyright", "Artica ST" VALUE "LegalCopyright", "Artica ST"
VALUE "OriginalFilename", "PandoraAgent.exe" VALUE "OriginalFilename", "PandoraAgent.exe"
VALUE "ProductName", "Pandora FMS Windows Agent" VALUE "ProductName", "Pandora FMS Windows Agent"
VALUE "ProductVersion", "(7.0NG.738(Build 190920))" VALUE "ProductVersion", "(7.0NG.739(Build 191003))"
VALUE "FileVersion", "1.0.0.0" VALUE "FileVersion", "1.0.0.0"
END END
END END

View File

@ -1,5 +1,5 @@
package: pandorafms-console package: pandorafms-console
Version: 7.0NG.738-190920 Version: 7.0NG.739-191003
Architecture: all Architecture: all
Priority: optional Priority: optional
Section: admin Section: admin

View File

@ -14,7 +14,7 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. # GNU General Public License for more details.
pandora_version="7.0NG.738-190920" pandora_version="7.0NG.739-191003"
package_pear=0 package_pear=0
package_pandora=1 package_pandora=1

View File

@ -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` = 10 && `image` IS NOT NULL && `image` != '' && `image` != 'none') ||
(`type` = 11 && `image` IS NOT NULL && `image` != '' && `image` != 'none' && `show_statistics` = 0)); (`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` ADD COLUMN `uncompressed_module` TINYINT DEFAULT '0';
ALTER TABLE `treport_content_template` ADD COLUMN `uncompressed_module` TINYINT DEFAULT '0'; ALTER TABLE `treport_content_template` ADD COLUMN `uncompressed_module` TINYINT DEFAULT '0';
COMMIT; COMMIT;

View File

@ -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 ('big_operation_step_datos_purge', '100');
INSERT INTO `tconfig` (`token`, `value`) VALUES ('small_operation_step_datos_purge', '1000'); 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 ('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_docs_logo', 'default_docs.png');
INSERT INTO `tconfig` (`token`, `value`) VALUES ('custom_support_logo', 'default_support.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'); 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'; UPDATE tconfig SET value = 'https://licensing.artica.es/pandoraupdate7/server.php' WHERE token='url_update_manager';
DELETE FROM `tconfig` WHERE `token` = 'current_package_enterprise'; 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'); 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'; 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_api_password';
DELETE FROM `tconfig` WHERE `token` LIKE 'integria_inventory'; DELETE FROM `tconfig` WHERE `token` LIKE 'integria_inventory';
DELETE FROM `tconfig` WHERE `token` LIKE 'integria_url'; 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` -- Table `tconfig_os`

View File

@ -29,599 +29,43 @@
// Begin. // Begin.
global $config; global $config;
// Check access. require_once $config['homedir'].'/include/class/CredentialStore.class.php';
check_login();
if (! check_acl($config['id_user'], 0, 'PM')) { $ajaxPage = 'godmode/groups/credential_store';
db_pandora_audit(
'ACL Violation',
'Trying to access event viewer'
);
// Control call flow.
try {
// User access and validation is being processed on class constructor.
$cs = new CredentialStore($ajaxPage);
} catch (Exception $e) {
if (is_ajax()) { 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; return;
} }
// Required files. // AJAX controller.
ui_require_css_file('credential_store');
require_once $config['homedir'].'/include/functions_credential_store.php';
require_once $config['homedir'].'/include/functions_io.php';
if (is_ajax()) { if (is_ajax()) {
$draw = get_parameter('draw', 0); $method = get_parameter('method');
$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);
if ($new_form) { if (method_exists($cs, $method) === true) {
echo print_inputs(); if ($cs->ajaxMethod($method) === true) {
exit; $cs->{$method}();
}
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);
} else { } else {
ajax_msg('result', $identifier, true); $cs->error('Unavailable method.');
} }
} else {
$cs->error('Method not found. ['.$method.']');
} }
if ($update_key) { // Stop any execution.
$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;
}
exit; 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>

View File

@ -295,6 +295,9 @@ if (check_acl($config['id_user'], 0, 'PM')) {
$sub2['godmode/setup/setup&amp;section=ehorus']['text'] = __('eHorus'); $sub2['godmode/setup/setup&amp;section=ehorus']['text'] = __('eHorus');
$sub2['godmode/setup/setup&amp;section=ehorus']['refr'] = 0; $sub2['godmode/setup/setup&amp;section=ehorus']['refr'] = 0;
$sub2['godmode/setup/setup&amp;section=integria']['text'] = __('Integria IMS');
$sub2['godmode/setup/setup&amp;section=integria']['refr'] = 0;
$sub2['godmode/setup/setup&amp;section=notifications']['text'] = __('Notifications'); $sub2['godmode/setup/setup&amp;section=notifications']['text'] = __('Notifications');
$sub2['godmode/setup/setup&amp;section=notifications']['refr'] = 0; $sub2['godmode/setup/setup&amp;section=notifications']['refr'] = 0;

View File

@ -257,11 +257,6 @@ $table_aux = new stdClass();
$table->cellspacing = 0; $table->cellspacing = 0;
$table->align = []; $table->align = [];
$table->head = []; $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[0] = __('Graph name');
$table->head[1] = __('Description'); $table->head[1] = __('Description');
@ -280,6 +275,12 @@ $table_aux = new stdClass();
$table->size[4] = '90px'; $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 = []; $table->data = [];
$result_graphs = array_slice($graphs, $offset, $config['block_size']); $result_graphs = array_slice($graphs, $offset, $config['block_size']);
@ -287,10 +288,6 @@ $table_aux = new stdClass();
foreach ($result_graphs as $graph) { foreach ($result_graphs as $graph) {
$data = []; $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[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); $data[1] = ui_print_truncate_text($graph['description'], 70);
@ -309,6 +306,10 @@ $table_aux = new stdClass();
return false;">'.html_print_image('images/cross.png', true, ['alt' => __('Delete'), 'title' => __('Delete')]).'</a>'; 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); array_push($table->data, $data);
} }

View File

@ -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&section=integria').'">'.html_print_image('images/integria.png', true, ['title' => __('Integria IMS')]).'</a>',
];
$buttons['ehorus'] = [ $buttons['ehorus'] = [
'active' => false, 'active' => false,
'text' => '<a href="'.ui_get_full_url('index.php?sec=gsetup&sec2=godmode/setup/setup&section=ehorus').'">'.html_print_image('images/ehorus/ehorus.png', true, ['title' => __('eHorus')]).'</a>', 'text' => '<a href="'.ui_get_full_url('index.php?sec=gsetup&sec2=godmode/setup/setup&section=ehorus').'">'.html_print_image('images/ehorus/ehorus.png', true, ['title' => __('eHorus')]).'</a>',
@ -167,6 +172,12 @@ switch ($section) {
$help_header = 'setup_ehorus_tab'; $help_header = 'setup_ehorus_tab';
break; break;
case 'integria':
$buttons['integria']['active'] = true;
$subpage = ' &raquo '.__('Integria IMS');
$help_header = 'setup_integria_tab';
break;
case 'notifications': case 'notifications':
$buttons['notifications']['active'] = true; $buttons['notifications']['active'] = true;
$subpage = ' &raquo '.__('Notifications'); $subpage = ' &raquo '.__('Notifications');
@ -228,6 +239,10 @@ switch ($section) {
include_once $config['homedir'].'/godmode/setup/setup_ehorus.php'; include_once $config['homedir'].'/godmode/setup/setup_ehorus.php';
break; break;
case 'integria':
include_once $config['homedir'].'/godmode/setup/setup_integria.php';
break;
case 'notifications': case 'notifications':
include_once $config['homedir'].'/godmode/setup/setup_notifications.php'; include_once $config['homedir'].'/godmode/setup/setup_notifications.php';
break; break;

View File

@ -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;">&nbsp;'.html_print_image('images/spinner.gif', true).'</span>';
$row['control'] .= '<span id="test-integria-success" style="display:none;">&nbsp;'.html_print_image('images/status_sets/default/severity_normal.png', true).'</span>';
$row['control'] .= '<span id="test-integria-failure" style="display:none;">&nbsp;'.html_print_image('images/status_sets/default/severity_critical.png', true).'</span>';
$row['control'] .= '&nbsp;<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>

View File

@ -828,7 +828,7 @@ $values = [
0 => __('No'), 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 = [ $values = [
'Default' => __('Default'), 'Default' => __('Default'),
'Visual console' => __('Visual console'), 'Visual console' => __('Visual console'),

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

View File

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

View File

@ -873,18 +873,20 @@ class ConsoleSupervisor
{ {
global $config; global $config;
$remote_config_dir = io_safe_output($config['remote_config']);
if (enterprise_installed() if (enterprise_installed()
&& isset($config['license_nms']) && isset($config['license_nms'])
&& $config['license_nms'] != 1 && $config['license_nms'] != 1
) { ) {
if (is_readable($config['remote_config']) !== true) { if (is_readable($remote_config_dir) !== true) {
$this->notify( $this->notify(
[ [
'type' => 'NOTIF.PERMISSIONS.REMOTE_CONFIG', 'type' => 'NOTIF.PERMISSIONS.REMOTE_CONFIG',
'title' => __('Remote configuration directory is not readable'), 'title' => __('Remote configuration directory is not readable'),
'message' => __( 'message' => __(
'Remote configuration directory %s is not readable. Please, adjust configuration.', '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&section=general'), 'url' => ui_get_full_url('index.php?sec=general&sec2=godmode/setup/setup&section=general'),
] ]
@ -896,14 +898,14 @@ class ConsoleSupervisor
); );
} }
if (is_writable($config['remote_config'].'/conf') !== true) { if (is_writable($remote_config_dir.'/conf') !== true) {
$this->notify( $this->notify(
[ [
'type' => 'NOTIF.PERMISSIONS.REMOTE_CONFIG.CONF', 'type' => 'NOTIF.PERMISSIONS.REMOTE_CONFIG.CONF',
'title' => __('Remote configuration directory is not writable'), 'title' => __('Remote configuration directory is not writable'),
'message' => __( 'message' => __(
'Remote configuration directory %s is not writable. Please, adjust configuration.', '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&section=general'), 'url' => ui_get_full_url('index.php?sec=general&sec2=godmode/setup/setup&section=general'),
] ]
@ -914,14 +916,14 @@ class ConsoleSupervisor
); );
} }
if (is_writable($config['remote_config'].'/collections') !== true) { if (is_writable($remote_config_dir.'/collections') !== true) {
$this->notify( $this->notify(
[ [
'type' => 'NOTIF.PERMISSIONS.REMOTE_CONFIG.COLLECTIONS', 'type' => 'NOTIF.PERMISSIONS.REMOTE_CONFIG.COLLECTIONS',
'title' => __('Remote collections directory is not writable'), 'title' => __('Remote collections directory is not writable'),
'message' => __( 'message' => __(
'Collections directory %s is not writable. Please, adjust configuration.', '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&section=general'), 'url' => ui_get_full_url('index.php?sec=general&sec2=godmode/setup/setup&section=general'),
] ]
@ -932,14 +934,14 @@ class ConsoleSupervisor
); );
} }
if (is_writable($config['remote_config'].'/md5') !== true) { if (is_writable($remote_config_dir.'/md5') !== true) {
$this->notify( $this->notify(
[ [
'type' => 'NOTIF.PERMISSIONS.REMOTE_CONFIG.MD5', 'type' => 'NOTIF.PERMISSIONS.REMOTE_CONFIG.MD5',
'title' => __('Remote md5 directory is not writable'), 'title' => __('Remote md5 directory is not writable'),
'message' => __( 'message' => __(
'MD5 directory %s is not writable. Please, adjust configuration.', '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&section=general'), 'url' => ui_get_full_url('index.php?sec=general&sec2=godmode/setup/setup&section=general'),
] ]
@ -957,7 +959,7 @@ class ConsoleSupervisor
$MAX_BADXML_FILES_DATA_IN = 150; $MAX_BADXML_FILES_DATA_IN = 150;
$filecount = $this->countFiles( $filecount = $this->countFiles(
$config['remote_config'], $remote_config_dir,
'', '',
$MAX_FILES_DATA_IN $MAX_FILES_DATA_IN
); );
@ -970,7 +972,7 @@ class ConsoleSupervisor
'message' => __( 'message' => __(
'There are more than %d files in %s. Consider checking DataServer performance', 'There are more than %d files in %s. Consider checking DataServer performance',
$MAX_FILES_DATA_IN, $MAX_FILES_DATA_IN,
$config['remote_config'] $remote_config_dir
), ),
'url' => ui_get_full_url('index.php?sec=general&sec2=godmode/setup/setup&section=perf'), 'url' => ui_get_full_url('index.php?sec=general&sec2=godmode/setup/setup&section=perf'),
] ]
@ -980,7 +982,7 @@ class ConsoleSupervisor
} }
$filecount = $this->countFiles( $filecount = $this->countFiles(
$config['remote_config'], $remote_config_dir,
'/^.*BADXML$/', '/^.*BADXML$/',
$MAX_BADXML_FILES_DATA_IN $MAX_BADXML_FILES_DATA_IN
); );
@ -993,7 +995,7 @@ class ConsoleSupervisor
'message' => __( 'message' => __(
'There are more than %d files in %s. Consider checking software agents.', 'There are more than %d files in %s. Consider checking software agents.',
$MAX_BADXML_FILES_DATA_IN, $MAX_BADXML_FILES_DATA_IN,
$config['remote_config'] $remote_config_dir
), ),
'url' => ui_get_full_url('index.php?sec=general&sec2=godmode/setup/setup&section=perf'), 'url' => ui_get_full_url('index.php?sec=general&sec2=godmode/setup/setup&section=perf'),
] ]
@ -1266,7 +1268,8 @@ class ConsoleSupervisor
$PHPSerialize_precision = ini_get('serialize_precision'); $PHPSerialize_precision = ini_get('serialize_precision');
// PhantomJS status. // 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 checks.
$php_version = phpversion(); $php_version = phpversion();
@ -1451,8 +1454,9 @@ class ConsoleSupervisor
'type' => 'NOTIF.PHP.SERIALIZE_PRECISION', 'type' => 'NOTIF.PHP.SERIALIZE_PRECISION',
'title' => sprintf( 'title' => sprintf(
__("Not recommended '%s' value in PHP configuration"), __("Not recommended '%s' value in PHP configuration"),
'serialze_precision' 'serialize_precision'
), 'message' => sprintf( ),
'message' => sprintf(
__('Recommended value is: %s'), __('Recommended value is: %s'),
sprintf('-1') sprintf('-1')
).'<br><br>'.__('Please, change it on your PHP configuration file (php.ini) or contact with administrator'), ).'<br><br>'.__('Please, change it on your PHP configuration file (php.ini) or contact with administrator'),
@ -2061,8 +2065,10 @@ class ConsoleSupervisor
{ {
global $config; global $config;
if (($config['fontpath'] == '') $fontpath = io_safe_output($config['fontpath']);
|| (file_exists($config['fontpath']) === false)
if (($fontpath == '')
|| (file_exists($fontpath) === false)
) { ) {
$this->notify( $this->notify(
[ [

File diff suppressed because it is too large Load Diff

View File

@ -20,8 +20,8 @@
/** /**
* Pandora build version and version * Pandora build version and version
*/ */
$build_version = 'PC190920'; $build_version = 'PC191003';
$pandora_version = 'v7.0NG.738'; $pandora_version = 'v7.0NG.739';
// Do not overwrite default timezone set if defined. // Do not overwrite default timezone set if defined.
$script_tz = @date_default_timezone_get(); $script_tz = @date_default_timezone_get();

View File

@ -3789,11 +3789,20 @@ function series_type_graph_array($data, $show_elements_graph)
} else if (strpos($key, 'percentil') !== false) { } else if (strpos($key, 'percentil') !== false) {
$data_return['series_type'][$key] = 'percentil'; $data_return['series_type'][$key] = 'percentil';
if ($show_elements_graph['percentil']) { if ($show_elements_graph['percentil']) {
$data_return['legend'][$key] = __('Percentil').' '.$config['percentil'].'º '.__('of module').' ';
if ($show_elements_graph['unit']) { 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 { } 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; $data_return['legend'][$key] .= $name_legend;
@ -4086,7 +4095,7 @@ function mask2cidr($mask)
function get_help_info($section_name) function get_help_info($section_name)
{ {
global $config; global $config;
// hd($section_name);
$user_language = get_user_language($id_user); $user_language = get_user_language($id_user);
$es = false; $es = false;
@ -5412,7 +5421,6 @@ function get_help_info($section_name)
break; break;
} }
// hd($result);
return $result; return $result;
} }

View File

@ -1434,6 +1434,92 @@ function config_update_config()
} }
break; 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: default:
// Ignore. // Ignore.
break; break;
@ -1500,7 +1586,7 @@ function config_process_config()
if (!isset($config['remote_config'])) { if (!isset($config['remote_config'])) {
if ($is_windows) { if ($is_windows) {
$default = 'C:\\PandoraFMS\\Pandora_Server\\data_in'; $default = 'C:\PandoraFMS\Pandora_Server\data_in';
} else { } else {
$default = '/var/spool/pandora/data_in'; $default = '/var/spool/pandora/data_in';
} }
@ -1510,7 +1596,7 @@ function config_process_config()
if (!isset($config['phantomjs_bin'])) { if (!isset($config['phantomjs_bin'])) {
if ($is_windows) { if ($is_windows) {
$default = 'C:\\PandoraFMS\\phantomjs'; $default = 'C:\PandoraFMS\Pandora_Server\bin';
} else { } else {
$default = '/usr/bin'; $default = '/usr/bin';
} }
@ -1760,7 +1846,13 @@ function config_process_config()
} }
if (!isset($config['auditdir'])) { 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'])) { if (!isset($config['elasticsearch_ip'])) {
@ -1794,6 +1886,7 @@ function config_process_config()
/* /*
* Parse the ACL IP list for access API * Parse the ACL IP list for access API
*/ */
$temp_list_ACL_IPs_for_API = []; $temp_list_ACL_IPs_for_API = [];
if (isset($config['list_ACL_IPs_for_API'])) { if (isset($config['list_ACL_IPs_for_API'])) {
if (!empty($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; $config['list_ACL_IPs_for_API'] = $temp_list_ACL_IPs_for_API;
$keysConfig = array_keys($config); $keysConfig = array_keys($config);
// This is not set here. The first time, when no /*
// setup is done, update_manager extension manage it * This is not set here. The first time, when no
// the first time make a conenction and disable itself * setup is done, update_manager extension manage it
// Not Managed here ! * the first time make a conenction and disable itself
// if (!isset ($config["autoupdate"])) { * Not Managed here !
// config_update_value ('autoupdate', true);. * if (!isset ($config["autoupdate"])) {
// } * config_update_value ('autoupdate', true);.
* }
*/
include_once $config['homedir'].'/include/auth/mysql.php'; include_once $config['homedir'].'/include/auth/mysql.php';
include_once $config['homedir'].'/include/functions_io.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 // user, and should be in pandora root. By default, Pandora adds
// /attachment to this, so by default is the pandora console home // /attachment to this, so by default is the pandora console home
// dir. // 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'])) { if (!isset($config['attachment_store'])) {
config_update_value( config_update_value(
'attachment_store', 'attachment_store',
io_safe_input($config['homedir']).'/attachment' $attachment_store_path
); );
} else { } else {
// Fixed when the user moves the pandora console to another dir // 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'])) { if (!is_dir($config['attachment_store'])) {
config_update_value( config_update_value(
'attachment_store', 'attachment_store',
$config['homedir'].'/attachment' $attachment_store_path
); );
} }
} }
if (!isset($config['fontpath'])) { 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( config_update_value(
'fontpath', 'fontpath',
$home.'/include/fonts/smallfont.ttf' $fontpath
); );
} }
@ -2077,7 +2186,7 @@ function config_process_config()
if (!isset($config['netflow_path'])) { if (!isset($config['netflow_path'])) {
if ($is_windows) { if ($is_windows) {
$default = 'C:\\PandoraFMS\\Pandora_Server\\data_in\\netflow'; $default = 'C:\PandoraFMS\Pandora_Server\data_in\netflow';
} else { } else {
$default = '/var/spool/pandora/data_in/netflow'; $default = '/var/spool/pandora/data_in/netflow';
} }
@ -2639,6 +2748,10 @@ function config_process_config()
config_update_value('zoom_graph', 1); config_update_value('zoom_graph', 1);
} }
if (!isset($config['percentil'])) {
config_update_value('percentil', 95);
}
if (!isset($config['render_proc_ok'])) { if (!isset($config['render_proc_ok'])) {
config_update_value('render_proc_ok', __('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. // Finally, check if any value was overwritten in a form.
config_update_config(); config_update_config();
} }

View File

@ -24,422 +24,8 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* ============================================================================ * ============================================================================
*
* Moved to CredentialStore.class.php
*/ */
// Begin. // Deprecated.
/**
* 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;
}

View File

@ -2739,6 +2739,10 @@ function events_get_agent(
$date = time_w_fixed_tz($date); $date = time_w_fixed_tz($date);
} }
if (is_metaconsole() && $events_group === false) {
$id_server = true;
}
if (empty($date)) { if (empty($date)) {
$date = get_system_time(); $date = get_system_time();
} }
@ -6636,6 +6640,247 @@ function events_get_secondary_groups_left_join($table)
} }
/**
* 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) function events_get_instructions($event)
{ {
if (!is_array($event)) { if (!is_array($event)) {

File diff suppressed because it is too large Load Diff

View File

@ -302,6 +302,15 @@ function grafico_modulo_sparse_data(
$array_data['sum'.$series_suffix]['agent_alias'] = $data_module_graph['agent_alias']; $array_data['sum'.$series_suffix]['agent_alias'] = $data_module_graph['agent_alias'];
$array_data['sum'.$series_suffix]['unit'] = $data_module_graph['unit']; $array_data['sum'.$series_suffix]['unit'] = $data_module_graph['unit'];
if ($params['percentil']) {
$array_data['percentil'.$series_suffix]['agent_module_id'] = $agent_module_id;
$array_data['percentil'.$series_suffix]['id_module_type'] = $data_module_graph['id_module_type'];
$array_data['percentil'.$series_suffix]['agent_name'] = $data_module_graph['agent_name'];
$array_data['percentil'.$series_suffix]['module_name'] = $data_module_graph['module_name'];
$array_data['percentil'.$series_suffix]['agent_alias'] = $data_module_graph['agent_alias'];
$array_data['percentil'.$series_suffix]['unit'] = $data_module_graph['unit'];
}
// This is for a specific type of report that consists in passing // This is for a specific type of report that consists in passing
// an interval and doing the average sum and avg. // an interval and doing the average sum and avg.
if ($params['force_interval'] != '') { if ($params['force_interval'] != '') {
@ -378,12 +387,6 @@ function grafico_modulo_sparse_data(
$array_data['sum1']['data'] = $acum_array_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 = []; $events = [];
if (isset($array_data['sum'.$series_suffix]['max'])) { if (isset($array_data['sum'.$series_suffix]['max'])) {
$max = $array_data['sum'.$series_suffix]['max']; $max = $array_data['sum'.$series_suffix]['max'];
@ -1471,8 +1474,6 @@ function graphic_combined_module(
$min = $array_data['sum'.$i]['min']; $min = $array_data['sum'.$i]['min'];
$avg = $array_data['sum'.$i]['avg']; $avg = $array_data['sum'.$i]['avg'];
$percentil_value = $array_data['percentil'.$i]['data'][0][1];
if ($config['fixed_graph'] == false) { if ($config['fixed_graph'] == false) {
$water_mark = [ $water_mark = [
'file' => $config['homedir'].'/images/logo_vertical_water.png', 'file' => $config['homedir'].'/images/logo_vertical_water.png',
@ -1521,7 +1522,8 @@ function graphic_combined_module(
$array_data, $array_data,
$params_combined['average'], $params_combined['average'],
$params_combined['summatory'], $params_combined['summatory'],
$params_combined['modules_series'] $params_combined['modules_series'],
$date_array
); );
} }
} }
@ -2222,7 +2224,7 @@ function graphic_combined_module(
* @param boolean $average Average. * @param boolean $average Average.
* @param boolean $summatory Summatory. * @param boolean $summatory Summatory.
* @param boolean $modules_series Series module. * @param boolean $modules_series Series module.
* @param boolean $baseline Baseline data. * @param array $date_array Date data.
* *
* @return array Data. * @return array Data.
*/ */
@ -2231,106 +2233,82 @@ function combined_graph_summatory_average(
$average=false, $average=false,
$summatory=false, $summatory=false,
$modules_series=false, $modules_series=false,
$baseline=false $date_array=[]
) { ) {
if (isset($array_data) && is_array($array_data)) { if (isset($array_data) && is_array($array_data)) {
$reduce_array = [];
foreach ($array_data as $key => $value) { foreach ($array_data as $key => $value) {
if (strpos($key, 'sum') !== false) { if (strpos($key, 'sum') !== false) {
$data_array_reverse[$key] = array_reverse($value['data']); $last = $date_array['start_date'];
if (!$modules_series) { $reduce_array = array_reduce(
unset($array_data[$key]); $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)) { $reduce_array_summatory = [];
$array_sum_reverse = []; $reduce_array_average = [];
$array_avg_reverse = []; $i = 0;
$data_array_prev = false; foreach ($reduce_array as $item) {
$data_array_pop = []; $reduce_array_summatory[$i][0] = $item['t'];
$count = 0; $reduce_array_summatory[$i][1] = $item['value'];
$count_data_array_reverse = count($data_array_reverse['sum0']); $reduce_array_average[$i][0] = $item['t'];
while ($count_data_array_reverse > 0) { $reduce_array_average[$i][1] = ($item['value'] / ($item['n'] + 1));
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]
);
}
}
if (isset($data_array_pop) && is_array($data_array_pop)) { $i++;
$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;
}
$acum_key = $key_pop; if ($summatory && isset($reduce_array_summatory)
$acum_data = $value_pop[0]; && is_array($reduce_array_summatory)
$acum_array = $value_pop; && count($reduce_array_summatory) > 0
$sum_data = $value_pop[1]; ) {
} $array_data['summatory']['data'] = $reduce_array_summatory;
} 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];
}
$count_pop++; if ($average && isset($reduce_array_average)
} && is_array($reduce_array_average)
&& count($reduce_array_average) > 0
if ($summatory) { ) {
$array_sum_reverse[$count][0] = $acum_data; $array_data['average']['data'] = $reduce_array_average;
$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';
}
}
} }
return $array_data; return $array_data;

View File

@ -1475,6 +1475,14 @@ function html_print_input_password(
$attr['class'] = $class; $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); 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; 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;
}
}

View File

@ -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&section=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;
}

View File

@ -507,7 +507,7 @@ function ___($string /*, variable arguments */)
} }
/* /**
* json_encode for multibyte characters. * json_encode for multibyte characters.
* *
* @param string Text string to be encoded. * @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, * Prepare the given password to be stored in the Pandora FMS Database,
* encrypting it if necessary. * encrypting it if necessary.
* *
@ -541,16 +541,22 @@ function io_input_password($password)
global $config; global $config;
enterprise_include_once('include/functions_crypto.php'); 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) { if ($ciphertext === ENTERPRISE_NOT_HOOK) {
return $password; return io_safe_input($password);
} }
return $ciphertext; return $ciphertext;
} }
/* /**
* Process the given password read from the Pandora FMS Database, * Process the given password read from the Pandora FMS Database,
* decrypting it if necessary. * decrypting it if necessary.
* *
@ -563,10 +569,17 @@ function io_output_password($password)
global $config; global $config;
enterprise_include_once('include/functions_crypto.php'); 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) { if ($plaintext === ENTERPRISE_NOT_HOOK) {
return $password; return io_safe_output($password);
} }
return $plaintext; return io_safe_output($plaintext);
} }

View File

@ -104,7 +104,7 @@ class gettext_reader {
* @param boolean enable_cache Enable or disable caching of strings (default on) * @param boolean enable_cache Enable or disable caching of strings (default on)
*/ */
function gettext_reader($Reader, $enable_cache = true) { function gettext_reader($Reader, $enable_cache = true) {
$machine = @shell_exec('uname -m'); $machine = php_uname("m");
$enabled64Bits = false; $enabled64Bits = false;
if (preg_match('/64/', $machine)) { if (preg_match('/64/', $machine)) {

View File

@ -159,10 +159,9 @@
if (custom_graph) { if (custom_graph) {
dataObject = retrieveDataOject(dataObjects,0); dataObject = retrieveDataOject(dataObjects,0);
//dataObjects.forEach(function (element) { dataObjects.forEach(function (element) {
//elements.push(processDataObject(element)); elements.push(processDataObject(element));
//}); });
elements.push(processDataObject(dataObject));
graphData = elements; graphData = elements;
} }
else { else {

View File

@ -1890,6 +1890,16 @@ function load_modal(settings) {
width = settings.onshow.width; width = settings.onshow.width;
} }
settings.target.html("Loading modal...");
settings.target
.dialog({
title: "Loading",
close: false,
width: 200,
buttons: []
})
.show();
$.ajax({ $.ajax({
method: "post", method: "post",
url: settings.url, url: settings.url,
@ -1898,6 +1908,9 @@ function load_modal(settings) {
data: data, data: data,
success: function(data) { success: function(data) {
settings.target.html(data); settings.target.html(data);
if (settings.onload != undefined) {
settings.onload(data);
}
settings.target.dialog({ settings.target.dialog({
resizable: true, resizable: true,
draggable: true, draggable: true,
@ -1927,6 +1940,9 @@ function load_modal(settings) {
click: function() { click: function() {
if (AJAX_RUNNING) return; if (AJAX_RUNNING) return;
AJAX_RUNNING = 1; AJAX_RUNNING = 1;
if (settings.onsubmit.preaction != undefined) {
settings.onsubmit.preaction();
}
var formdata = new FormData(); var formdata = new FormData();
if (settings.extradata) { if (settings.extradata) {
settings.extradata.forEach(function(item) { settings.extradata.forEach(function(item) {
@ -1954,7 +1970,9 @@ function load_modal(settings) {
contentType: false, contentType: false,
data: formdata, data: formdata,
success: function(data) { success: function(data) {
settings.ajax_callback(data); if (settings.ajax_callback != undefined) {
settings.ajax_callback(data);
}
AJAX_RUNNING = 0; AJAX_RUNNING = 0;
} }
}); });

View File

@ -10,3 +10,33 @@
#new_key select { #new_key select {
width: 60%; width: 60%;
} }
ul.wizard li > label:not(.p-switch) {
width: auto;
}
form.top-action-buttons ul.wizard {
display: flex;
flex-direction: row;
}
ul.wizard li {
margin-right: 1em;
}
form.modal ul.wizard li {
display: flex;
flex-direction: row;
width: 90%;
margin: 0 auto;
justify-items: center;
}
form.modal ul.wizard li * {
flex: 1;
}
ul.wizard li.flex-indep {
flex: 1;
margin: 0;
}

View File

@ -0,0 +1,125 @@
/* --- Integria IMS --- */
div.priority {
width: 80px;
color: #fff;
text-align: center;
border-radius: 5px;
padding: 5px;
display: table-cell;
vertical-align: middle;
}
/* Details view */
div.integria_details {
display: grid;
grid-column-gap: 10px;
grid-template-columns: repeat(3, minmax(min-content, auto));
grid-auto-rows: 1fr;
}
div.integria_details div.box-shadow.white_table_graph {
box-shadow: none;
}
div.integria_details div.priority {
display: inline-block;
}
div.integriaims_details_row {
display: grid;
grid-gap: 10px;
text-align: center;
margin-top: 8px;
margin-bottom: 8px;
}
div.integriaims_details_titles {
font-weight: bold;
}
div.integria_details_row_five {
grid-template-columns: repeat(5, 1fr);
}
div.integria_details_row_three {
grid-template-columns: repeat(3, 1fr);
}
div.integria_details_description {
width: 100%;
}
div.integria_details_description textarea {
width: 100%;
background-color: #fbfbfb;
resize: vertical;
}
.integriaims_details_box {
display: grid;
grid-column-gap: 10px;
grid-row-gap: 5px;
align-items: center;
width: 100%;
text-align: center;
}
.integriaims_details_box_five {
grid-template-rows: repeat(3, 1fr);
grid-template-columns: repeat(5, 1fr);
}
.integriaims_details_box_three {
grid-template-rows: repeat(3, 1fr);
grid-template-columns: repeat(3, 1fr);
}
/* ui_toggles */
.integria_details_shadow {
background-color: #fff;
border-bottom: 1px solid #e2e2e2;
border-left: 1px solid #e2e2e2;
border-top-left-radius: 5px;
border-right: 1px solid #e2e2e2;
border-top-right-radius: 5px;
}
.integria_details_shadow .white_table_graph_header {
border-left: none;
border-right: none;
}
.integria_details_content {
border-bottom: none;
border-left: none;
border-right: none;
}
/* Inputs type text shown as a black line */
.integria_incidents_options input[type="text"] {
background-color: transparent;
border: none;
border-radius: 0;
border-bottom: 1px solid #ccc;
font-family: "lato-bolder", "Open Sans", sans-serif;
font-size: 10pt;
padding: 2px 5px;
box-sizing: border-box;
background-repeat: no-repeat;
background-position: left bottom 2px;
margin-bottom: 4px;
}
.integria_incident_options input[readonly] {
color: #848484;
}
.comment_title {
padding: 5px 10px 5px 20px;
background-color: rgba(130, 185, 46, 0.16);
border-radius: 3px;
}
.comment_body {
padding: 15px 20px 15px 20px;
}

View File

@ -27,9 +27,6 @@
* GNU General Public License for more details. * GNU General Public License for more details.
* ============================================================================ * ============================================================================
*/ */
table {
text-align: center;
}
table.header_table { table.header_table {
width: 100%; width: 100%;
@ -72,6 +69,7 @@ table.table_beauty tbody tr td {
table.databox { table.databox {
margin-bottom: 20px; margin-bottom: 20px;
text-align: center;
} }
th.title_table_pdf { th.title_table_pdf {

View File

@ -61,6 +61,7 @@ page.onConsoleMessage = function(msg) {
page.onError = function(msg) { page.onError = function(msg) {
console.log(msg); console.log(msg);
page.close(); page.close();
phantom.exit();
}; };
page.onCallback = function(st) { page.onCallback = function(st) {
@ -74,4 +75,9 @@ page.onCallback = function(st) {
phantom.exit(); phantom.exit();
}; };
page.open(url, "POST", post_data, function(status) {}); page.open(url, "POST", post_data, function(status) {
if (status == "fail") {
console.out("Failed to generate chart.");
phantom.exit();
}
});

View File

@ -128,8 +128,8 @@
</div> </div>
<div style='height: 10px'> <div style='height: 10px'>
<?php <?php
$version = '7.0NG.738'; $version = '7.0NG.739';
$build = '190920'; $build = '191003';
$banner = "v$version Build $build"; $banner = "v$version Build $build";
error_reporting(0); error_reporting(0);

View File

@ -0,0 +1,325 @@
<?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.
// Load global vars
global $config;
check_login();
if (!(check_acl($config['id_user'], 0, 'IW') && check_acl($config['id_user'], 0, 'IR'))) {
// Doesn't have access to this page.
db_pandora_audit('ACL Violation', 'Trying to access IntegriaIMS ticket creation');
include 'general/noaccess.php';
exit;
}
require_once $config['homedir'].'/include/functions_integriaims.php';
$update = (isset($_GET['incident_id']) === true);
// Header tabs.
$onheader = integriaims_tabs('create_tab', $_GET['incident_id']);
if ($update) {
ui_print_page_header(__('Update Integria IMS Ticket'), '', false, '', false, $onheader);
} else {
ui_print_page_header(__('Create Integria IMS Ticket'), '', false, '', false, $onheader);
}
// Check if Integria integration enabled.
if ($config['integria_enabled'] == 0) {
ui_print_error_message(__('Integria integration must be enabled in Pandora setup'));
return;
}
// Check connection to Integria IMS API.
$has_connection = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_login', []);
if ($has_connection === false) {
ui_print_error_message(__('Integria IMS API is not reachable'));
return;
}
// Styles.
ui_require_css_file('integriaims');
// If everything OK, get parameters from Integria IMS API in order to populate combos.
$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);
$event_id = (int) get_parameter('from_event');
$incident_id_edit = (int) get_parameter('incident_id');
$create_incident = (bool) get_parameter('create_incident', 0);
$update_incident = (bool) get_parameter('update_incident', 0);
$incident_group_id = (int) get_parameter('group');
$incident_criticity_id = (int) get_parameter('criticity');
$incident_owner = get_parameter('owner');
$incident_type = (int) get_parameter('type');
$incident_creator = get_parameter('creator');
$incident_status = (int) get_parameter('status');
$incident_title = events_get_field_value_by_event_id($event_id, get_parameter('incident_title'));
$incident_content = events_get_field_value_by_event_id($event_id, get_parameter('incident_content'));
// Separator conversions.
$incident_title = str_replace(',', ':::', $incident_title);
$incident_content = str_replace(',', ':::', $incident_content);
// Perform action.
if ($create_incident === true) {
// Call Integria IMS API method to create an incident.
$result_api_call = integria_api_call($config['integria_hostname'], $incident_creator, $config['integria_pass'], $config['integria_api_pass'], 'create_incident', [$incident_title, $incident_group_id, $incident_criticity_id, $incident_content, '', $incident_type, '', $incident_owner, '0', $incident_status]);
// Necessary to explicitly set true if not false because function returns api call result in case of success instead of true value.
$incident_created_ok = ($result_api_call != false) ? true : false;
ui_print_result_message(
$incident_created_ok,
__('Successfully created in Integria IMS'),
__('Could not be created in Integria IMS')
);
} else if ($update_incident === true) {
// Call Integria IMS API method to update an incident.
$result_api_call = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'update_incident', [$incident_id_edit, $incident_title, $incident_content, '', $incident_group_id, $incident_criticity_id, 0, $incident_status, $incident_owner, 0, $incident_type]);
// Necessary to explicitly set true if not false because function returns api call result in case of success instead of true value.
$incident_updated_ok = ($result_api_call != false) ? true : false;
ui_print_result_message(
$incident_updated_ok,
__('Successfully updated in Integria IMS'),
__('Could not be updated in Integria IMS')
);
}
// If incident id is specified, retrieve incident values from api to populate combos with such values.
if ($update) {
// Call Integria IMS API method to get details of an incident given its id.
$result_api_call = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_incident_details', [$incident_id_edit]);
// API call does not return indexes, therefore future modifications of API function in Integria IMS may lead to inconsistencies when accessing resulting array in this file.
$incident_details_separator = explode(',', $result_api_call);
$incident_details = array_map(
function ($item) {
return str_replace(':::', ',', $item);
},
$incident_details_separator
);
}
// Main table.
$table = new stdClass();
$table->width = '100%';
$table->id = 'add_alert_table';
$table->class = 'databox filters integria_incidents_options';
$table->head = [];
$table->data = [];
$table->size = [];
$table->size = [];
$table->style[0] = 'width: 33%; padding-right: 50px; padding-left: 100px;';
$table->style[1] = 'width: 33%; padding-right: 50px; padding-left: 50px;';
$table->style[2] = 'width: 33%; padding-right: 100px; padding-left: 50px;';
$table->colspan[0][0] = 2;
$table->colspan[3][0] = 3;
$help_macros = isset($_GET['from_event']) ? ui_print_help_icon('response_macros', true) : '';
if (isset($_GET['from_event'])) {
if ($update) {
$input_value_title = $incident_details[3];
$input_value_type = $incident_details[17];
$input_value_status = $incident_details[6];
$input_value_group = $incident_details[8];
$input_value_criticity = $incident_details[7];
$input_value_owner = $incident_details[5];
$input_value_content = $incident_details[4];
} else if (isset($_GET['from_event'])) {
$input_value_title = $config['cr_incident_title'];
$input_value_type = $config['cr_incident_type'];
$input_value_status = $config['cr_incident_status'];
$input_value_group = $config['cr_default_group'];
$input_value_criticity = $config['cr_default_criticity'];
$input_value_owner = $config['cr_default_owner'];
$input_value_content = $config['cr_incident_content'];
} else {
$input_value_title = '';
$input_value_type = '';
$input_value_status = '';
$input_value_group = '';
$input_value_criticity = '';
$input_value_owner = '';
$input_value_content = '';
}
}
$table->data[0][0] = '<div class="label_select"><p class="input_label">'.__('Title').':&nbsp'.$help_macros.'</p>';
$table->data[0][0] .= '<div class="label_select_parent">'.html_print_input_text(
'incident_title',
$input_value_title,
__('Name'),
50,
100,
true,
false,
true,
'',
'w100p'
).'</div>';
$table->data[0][2] = html_print_image('images/integria_logo_gray.png', true, ['style' => 'width: 70%; float: right;'], false);
$table->data[1][0] = '<div class="label_select"><p class="input_label">'.__('Type').': </p>';
$table->data[1][0] .= '<div class="label_select_parent">'.html_print_select(
$integria_types_values,
'type',
$input_value_type,
'',
__('Select'),
0,
true,
false,
true,
'',
false,
'width: 100%;'
).'</div>';
$table->data[2][0] = '<div class="label_select"><p class="input_label">'.__('Status').': </p>';
$table->data[2][0] .= '<div class="label_select_parent">'.html_print_select(
$integria_status_values,
'status',
$input_value_status,
'',
__('Select'),
1,
true,
false,
true,
'',
false,
'width: 100%;'
).'</div>';
$table->data[1][1] = '<div class="label_select"><p class="input_label">'.__('Group').': </p>';
$table->data[1][1] .= '<div class="label_select_parent">'.html_print_select(
$integria_group_values,
'group',
$input_value_group,
'',
'',
0,
true,
false,
true,
'',
false,
'width: 100%;'
).'</div>';
$table->data[2][1] = '<div class="label_select"><p class="input_label">'.__('Creator').': </p>';
$table->data[2][1] .= '<div class="label_select_parent">'.html_print_input_text(
'creator',
$config['integria_user'],
'',
'30',
100,
true,
true,
false,
'',
'w100p'
).ui_print_help_tip(__('This field corresponds to the Integria IMS user specified in Integria IMS setup'), true).'</div>';
$table->data[1][2] = '<div class="label_select"><p class="input_label">'.__('Priority').': </p>';
$table->data[1][2] .= '<div class="label_select_parent">'.html_print_select(
$integria_criticity_values,
'criticity',
$input_value_criticity,
'',
__('Select'),
0,
true,
false,
true,
'',
false,
'width: 100%;'
).'</div>';
$table->data[2][2] = '<div class="label_select"><p class="input_label">'.__('Owner').': </p>';
$table->data[2][2] .= '<div class="label_select_parent">'.html_print_autocomplete_users_from_integria(
'owner',
$input_value_owner,
true
).'</div>';
$table->data[3][0] = '<div class="label_select"><p class="input_label">'.__('Description').':&nbsp'.$help_macros.'</p>';
$table->data[3][0] .= '<div class="label_select_parent">'.html_print_textarea(
'incident_content',
3,
20,
$input_value_content,
'',
true
).'</div>';
// Print forms and stuff.
echo '<form id="create_integria_incident_form" name="create_integria_incident_form" method="POST">';
html_print_table($table);
if (!$update) {
html_print_input_hidden('create_incident', 1);
} else {
html_print_input_hidden('update_incident', 1);
}
echo '</form>';
echo '<div style="width: 100%; text-align:right;">';
if ($update) {
html_print_submit_button(__('Update'), 'accion', false, 'form="create_integria_incident_form" class="sub wand"');
} else {
html_print_submit_button(__('Create'), 'accion', false, 'form="create_integria_incident_form" class="sub wand"');
}
echo '</div>';

View File

@ -0,0 +1,488 @@
<?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.
// Load global vars
global $config;
require_once 'include/functions_integriaims.php';
check_login();
if (!check_acl($config['id_user'], 0, 'IR')) {
// Doesn't have access to this page.
db_pandora_audit('ACL Violation', 'Trying to access IntegriaIMS ticket creation');
include 'general/noaccess.php';
exit;
}
// Check if Integria integration enabled.
if ($config['integria_enabled'] == 0) {
ui_print_error_message(__('Integria integration must be enabled in Pandora setup'));
return;
}
// Check connection to Integria IMS API.
$has_connection = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_login', []);
if ($has_connection === false) {
ui_print_error_message(__('Integria IMS API is not reachable'));
return;
}
// Styles.
ui_require_css_file('integriaims');
// Get id incident.
$incident_id = (int) get_parameter('incident_id');
// API call.
$result_api_call_list = integria_api_call(
$config['integria_hostname'],
$config['integria_user'],
$config['integria_pass'],
$config['integria_api_pass'],
'get_incident_details',
[$incident_id]
);
// Return array of api call 'get_incidents'.
$array_get_incidents = [];
get_array_from_csv_data_all($result_api_call_list, $array_get_incidents);
// Remove index (id)
$array_get_incidents = $array_get_incidents[$incident_id];
// Header tabs.
$onheader = integriaims_tabs(false, $incident_id);
ui_print_page_header($array_get_incidents[3].' - '.__('Details'), '', false, '', false, $onheader);
// Data.
$status = $array_get_incidents[6];
$resolution = $array_get_incidents[12];
$group = $array_get_incidents[8];
$priority = $array_get_incidents[7];
$type = $array_get_incidents[17];
$description = $array_get_incidents[4];
$creator = $array_get_incidents[10];
$owner = $array_get_incidents[5];
$closed_by = $array_get_incidents[23];
$created_at = $array_get_incidents[1];
$updated_at = $array_get_incidents[9];
$closed_at = $array_get_incidents[2];
if ($closed_at == '0000-00-00 00:00:00') {
$closed_at = __('Not yet');
}
if ($closed_by == '') {
$closed_by = __('Not closed yet');
}
// API calls.
$status_text = integriaims_get_details('status', $status);
$group_text = integriaims_get_details('group', $group);
$priority_text = integriaims_get_details('priority', $priority);
$resolution_text = integriaims_get_details('resolution', $resolution);
$type_text = integriaims_get_details('type', $type);
// Incident file management.
$upload_file = get_parameter('upload_file');
$delete_file_id = get_parameter('delete_file');
$download_file_id = get_parameter('download_file');
$download_file_name = get_parameter('download_file_name');
// Files section table.
$table_files_section = new stdClass();
$table_files_section->width = '100%';
$table_files_section->id = 'files_section_table';
$table_files_section->class = 'databox filters';
$table_files_section->head = [];
$table_files_section->data = [];
$table_files_section->size = [];
$table_files_section->colspan[2][0] = 3;
// Files list table.
$table_files = new stdClass();
$table_files->width = '100%';
$table_files->class = 'info_table';
$table_files->head = [];
$table_files->head[0] = __('Filename');
$table_files->head[1] = __('Timestamp');
$table_files->head[2] = __('Description');
$table_files->head[3] = __('User');
$table_files->head[4] = __('Size');
if (check_acl($config['id_user'], 0, 'IW')) {
$table_files->head[5] = __('Delete');
}
$table_files->data = [];
// Upload file.
if ($upload_file && ($_FILES['userfile']['name'] != '')) {
$filedescription = get_parameter('file_description', __('No description available'));
$filename = io_safe_input($_FILES['userfile']['name']);
$filesize = io_safe_input($_FILES['userfile']['size']);
$extension = pathinfo($filename, PATHINFO_EXTENSION);
$invalid_extensions = '/^(bat|exe|cmd|sh|php|php1|php2|php3|php4|php5|pl|cgi|386|dll|com|torrent|js|app|jar|iso|
pif|vb|vbscript|wsf|asp|cer|csr|jsp|drv|sys|ade|adp|bas|chm|cpl|crt|csh|fxp|hlp|hta|inf|ins|isp|jse|htaccess|
htpasswd|ksh|lnk|mdb|mde|mdt|mdw|msc|msi|msp|mst|ops|pcd|prg|reg|scr|sct|shb|shs|url|vbe|vbs|wsc|wsf|wsh)$/i';
if (!preg_match($invalid_extensions, $extension)) {
// The following is if you have clamavlib installed.
// (php5-clamavlib) and enabled in php.ini
// http://www.howtoforge.com/scan_viruses_with_php_clamavlib
if (extension_loaded('clamav')) {
cl_setlimits(5, 1000, 200, 0, 10485760);
$malware = cl_scanfile($_FILES['file']['tmp_name']);
if ($malware) {
$error = 'Malware detected: '.$malware.'<br>ClamAV version: '.clam_get_version();
die($error);
// On malware, we die because it's not good to handle it
}
}
$filecontent = base64_encode(file_get_contents($_FILES['userfile']['tmp_name']));
$result_api_call = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'attach_file', [$incident_id, $filename, $filesize, $filedescription, $filecontent]);
// API method returns '0' string if success.
$file_added = ($result_api_call === '0') ? true : false;
ui_print_result_message(
$file_added,
__('File successfully added'),
__('File could not be added')
);
} else {
ui_print_error_message(__('File has an invalid extension'));
}
}
// Delete file.
if (isset($_GET['delete_file'])) {
$result_api_call = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'delete_file', [$delete_file_id]);
$file_deleted = false;
if ($result_api_call === '0') {
$file_deleted = true;
}
ui_print_result_message(
$file_deleted,
__('File successfully deleted'),
__('File could not be deleted')
);
}
// Download file.
if (isset($_GET['download_file'])) {
$file_base64 = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'download_file', [$download_file_id]);
ob_end_clean();
$decoded = base64_decode($file_base64);
file_put_contents($download_file_name, $decoded);
ob_end_clean();
if (file_exists($download_file_name)) {
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="'.basename($download_file_name).'"');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: '.filesize($download_file_name));
ob_end_clean();
readfile($download_file_name);
unlink($download_file_name);
exit;
}
header('Location: index.php?sec=incident&sec2=operation/incidents/dashboard_detail_integriaims_incident&incident_id='.$incident_id);
}
// Retrieve files belonging to incident and create list table.
$result_api_call = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_incident_files', [$incident_id]);
if ($result_api_call != false && strlen($result_api_call) > 0) {
$files = [];
$csv_array = explode("\n", $result_api_call);
foreach ($csv_array as $csv_line) {
if (!empty($csv_line)) {
$files[] = explode(',', $csv_line);
}
}
}
$i = 0;
foreach ($files as $key => $value) {
$table_files->data[$i][0] = '<a id="link_delete_file" href="'.ui_get_full_url('index.php?sec=incident&sec2=operation/incidents/dashboard_detail_integriaims_incident&incident_id='.$incident_id.'&download_file='.$value[0]).'&download_file_name='.$value[11].'">'.$value[11].'</a>';
$table_files->data[$i][1] = $value[14];
$table_files->data[$i][2] = $value[12];
$table_files->data[$i][3] = $value[8];
$table_files->data[$i][4] = $value[13];
if (check_acl($config['id_user'], 0, 'IW')) {
$table_files->data[$i][5] .= '<a id="link_delete_file" href="'.ui_get_full_url('index.php?sec=incident&sec2=operation/incidents/dashboard_detail_integriaims_incident&incident_id='.$incident_id.'&delete_file='.$value[0]).'"
onClick="javascript:if (!confirm(\''.__('Are you sure?').'\')) return false;">';
$table_files->data[$i][5] .= html_print_image('images/cross.png', true, ['title' => __('Delete')]);
}
$table_files->data[$i][5] .= '</a>';
$i++;
}
$table_files_section->data[0][0] = '<div class="label_select"><p class="input_label">'.__('File name').':</p>';
$table_files_section->data[0][0] .= html_print_input_file('userfile', true);
$table_files_section->data[1][0] = '<div class="label_select"><p class="input_label">'.__('Description').':</p>';
$table_files_section->data[1][0] .= html_print_textarea(
'file_description',
3,
20,
'',
'',
true
);
$table_files_section->data[2][0] .= '<div style="width: 100%; text-align:right;">'.html_print_submit_button(__('Upload'), 'accion', false, 'class="sub wand"', true).'</div>';
$upload_file_form = '<div>';
if (check_acl($config['id_user'], 0, 'IW')) {
$upload_file_form .= '<form method="post" id="file_control" enctype="multipart/form-data">'.'<h4>'.__('Add attachment').'</h4>'.html_print_table($table_files_section, true).html_print_input_hidden('upload_file', 1, true);
}
$upload_file_form .= '<h4>'.__('Attached files').'</h4>'.html_print_table($table_files, true).'</form></div>';
// Incident comments management.
$upload_comment = get_parameter('upload_comment');
$comment_description = get_parameter('comment_description');
// Comments section table.
$table_comments_section = new stdClass();
$table_comments_section->width = '100%';
$table_comments_section->id = 'files_section_table';
$table_comments_section->class = 'databox filters';
$table_comments_section->head = [];
$table_comments_section->data = [];
$table_comments_section->size = [];
// Comments list table.
$table_comments = new stdClass();
$table_comments->width = '100%';
$table_comments->class = 'info_table';
$table_comments->head = [];
$table_comments->head[0] = __('Filename');
$table_comments->head[1] = __('Timestamp');
$table_comments->head[2] = __('Description');
$table_comments->head[3] = __('User');
$table_comments->head[4] = __('Size');
$table_comments->head[5] = __('Delete');
$table_comments->data = [];
$comment_disabled = ($array_get_incidents[6] == 7);
if ($comment_disabled === true) {
$attribute = 'disabled=disabled';
}
$table_comments_section->data[0][0] = '<div class="label_select"><p class="input_label">'.__('Description').':</p>';
$table_comments_section->data[0][0] .= html_print_textarea(
'comment_description',
3,
20,
'',
$attribute,
true
);
$table_comments_section->data[1][1] .= '<div style="width: 100%; text-align:right;">'.html_print_submit_button(__('Add'), 'accion', $comment_disabled, 'class="sub wand"', true).'</div>';
// Upload comment. If ticket is closed, this action cannot be performed.
if ($upload_comment && $array_get_incidents[6] != 7) {
$result_api_call = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'create_workunit', [$incident_id, $comment_description, '0.00', 0, 1, '0']);
// API method returns id of new comment if success.
$comment_added = ($result_api_call >= '0') ? true : false;
ui_print_result_message(
$comment_added,
__('Comment successfully added'),
__('Comment could not be added')
);
}
// Retrieve comments belonging to incident and create comments table.
$result_api_call = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_incident_workunits', [$incident_id]);
if ($result_api_call != false && strlen($result_api_call) > 0) {
$comments = [];
$csv_array = explode("\n", $result_api_call);
foreach ($csv_array as $csv_line) {
if (!empty($csv_line)) {
$comments[] = explode(',', $csv_line);
}
}
}
$comment_table = '';
if (!empty($comments)) {
foreach ($comments as $key => $value) {
$comment_table .= '<div class="comment_title">'.$value[3].'<span>&nbspsaid&nbsp</span>'.$value[1].'<span style="float: right;">'.$value[2].'&nbspHours</span></div>';
$comment_table .= '<div class="comment_body">'.$value[4].'</div>';
}
} else {
$comment_table = __('No comments found');
}
$upload_comment_form = '<div>';
if (check_acl($config['id_user'], 0, 'IW')) {
$upload_comment_form .= '<form method="post" id="comment_form" enctype="multipart/form-data"><h4>'.__('Add comment').'</h4>'.html_print_table($table_comments_section, true).html_print_input_hidden('upload_comment', 1, true).'</form>';
}
$upload_comment_form .= '<h4>'.__('Comments').'</h4>'.$comment_table.'</div>';
// Details box.
$details_box = '<div class="integriaims_details_box integriaims_details_box_five">';
$details_box .= '
<div class="integriaims_details_titles">'.__('Status').'</div>
<div class="integriaims_details_titles">'.__('Resolution').'</div>
<div class="integriaims_details_titles">'.__('Group').'</div>
<div class="integriaims_details_titles">'.__('Priority').'</div>
<div class="integriaims_details_titles">'.__('Type').'</div>';
$details_box .= '
<div>'.html_print_image('images/heart.png', true).'</div>
<div>'.html_print_image('images/builder.png', true).'</div>
<div>'.html_print_image('images/user_green.png', true).'</div>
<div>'.ui_print_integria_incident_priority($priority, $priority_text).'</div>
<div>'.html_print_image('images/incidents.png', true).'</div>';
$details_box .= '
<div>'.$status_text.'</div>
<div>'.$resolution_text.'</div>
<div>'.$group_text.'</div>
<div>'.$priority_text.'</div>
<div>'.$type_text.'</div>';
$details_box .= '</div>';
// People box.
$people_box = '<div class="integriaims_details_box integriaims_details_box_three">';
$people_box .= '
<div>'.html_print_image('images/header_user_green.png', true, ['width' => '21']).'</div>
<div>'.html_print_image('images/header_user_green.png', true, ['width' => '21']).'</div>
<div>'.html_print_image('images/header_user_green.png', true, ['width' => '21']).'</div>';
$people_box .= '
<div class="integriaims_details_titles">'.__('Created by').':</div>
<div class="integriaims_details_titles">'.__('Owned by').':</div>
<div class="integriaims_details_titles">'.__('Closed by').':</div>';
$people_box .= '
<div>'.$creator.'</div>
<div>'.$owner.'</div>
<div>'.$closed_by.'</div>';
$people_box .= '</div>';
// Dates box.
$dates_box = '<div class="integriaims_details_box integriaims_details_box_three">';
$dates_box .= '
<div>'.html_print_image('images/tick.png', true).'</div>
<div>'.html_print_image('images/update.png', true, ['width' => '21']).'</div>
<div>'.html_print_image('images/mul.png', true).'</div>';
$dates_box .= '
<div class="integriaims_details_titles">'.__('Created at').':</div>
<div class="integriaims_details_titles">'.__('Updated at').':</div>
<div class="integriaims_details_titles">'.__('Closed at').':</div>';
$dates_box .= '
<div>'.$created_at.'</div>
<div>'.$updated_at.'</div>
<div>'.$closed_at.'</div>';
$dates_box .= '</div>';
// Show details, people and dates.
echo '<div class="integria_details">';
ui_toggle($details_box, __('Details'), '', 'details_box', false, false, '', 'integria_details_content white-box-content', 'integria_details_shadow box-shadow white_table_graph');
ui_toggle($people_box, __('People'), '', 'people_box', false, false, '', 'integria_details_content white-box-content', 'integria_details_shadow box-shadow white_table_graph');
ui_toggle($dates_box, __('Dates'), '', 'dates_box', false, false, '', 'integria_details_content white-box-content', 'integria_details_shadow box-shadow white_table_graph');
echo '</div>';
// Show description.
$description_box = '<div class="integria_details_description">'.html_print_textarea(
'integria_details_description',
3,
0,
$description,
'disabled="disabled"',
true
).'</div>';
ui_toggle($description_box, __('Description'), '', '', false);
echo '<div class="ui_toggle">';
ui_toggle(
$upload_file_form,
__('Attached files'),
'',
'',
true,
false,
'white_box white_box_opened',
'no-border flex'
);
echo '</div>';
echo '<div class="ui_toggle">';
ui_toggle(
$upload_comment_form,
__('Comments'),
'',
'',
true,
false,
'white_box white_box_opened',
'no-border flex'
);
echo '</div>';
?>
<script type="text/javascript">
$(document).ready (function () {
$('#details_box .white_table_graph_header').click(function(){
$('div#details_box').toggleClass('integria_details_shadow');
});
$('#people_box .white_table_graph_header').click(function(){
$('div#people_box').toggleClass('integria_details_shadow');
});
$('#dates_box .white_table_graph_header').click(function(){
$('div#dates_box').toggleClass('integria_details_shadow');
});
});
</script>

View File

@ -0,0 +1,129 @@
<?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 for version 2.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Load global vars
global $config;
require_once '../../include/config.php';
require_once '../../include/functions.php';
require_once '../../include/functions_integriaims.php';
check_login();
if (! check_acl($config['id_user'], 0, 'IR') && ! check_acl($config['id_user'], 0, 'IW') && ! check_acl($config['id_user'], 0, 'IM')) {
// Doesn't have access to this page.
db_pandora_audit('ACL Violation', 'Trying to access IntegriaIMS ticket creation');
include 'general/noaccess.php';
exit;
}
// API calls.
$status_incident = integriaims_get_details('status');
$group_incident = integriaims_get_details('group');
$priority_incident = integriaims_get_details('priority');
$resolution_incident = integriaims_get_details('resolution');
// Get data to export.
$tickets_filters = json_decode(
base64_decode(
get_parameter('tickets_filters', '')
),
true
);
$tickets_csv_array = get_tickets_integriaims($tickets_filters);
// Build a new array to show only the fields in the table.
$tickets_csv_array_filter = [];
foreach ($tickets_csv_array as $key => $value) {
// Status.
if ($tickets_csv_array[$key][6] == 0) {
$tickets_csv_array[$key][6] = 'None';
} else {
$tickets_csv_array[$key][6] = $status_incident[$tickets_csv_array[$key][6]];
}
// Priority.
$tickets_csv_array[$key][7] = $priority_incident[$tickets_csv_array[$key][7]];
// Group.
$tickets_csv_array[$key][8] = $group_incident[$tickets_csv_array[$key][8]];
// Resolution.
if ($tickets_csv_array[$key][12] == 0) {
$tickets_csv_array[$key][12] = 'None';
} else {
$tickets_csv_array[$key][12] = $resolution_incident[$tickets_csv_array[$key][12]];
}
$tickets_csv_array_filter[$key] = [
'id_incidencia' => $tickets_csv_array[$key][0],
'titulo' => $tickets_csv_array[$key][3],
'id_grupo' => $tickets_csv_array[$key][8],
'estado' => $tickets_csv_array[$key][6],
'resolution' => $tickets_csv_array[$key][12],
'prioridad' => $tickets_csv_array[$key][7],
'actualizacion' => $tickets_csv_array[$key][9],
'inicio' => $tickets_csv_array[$key][1],
'id_creator' => $tickets_csv_array[$key][10],
'owner' => $tickets_csv_array[$key][5],
];
}
// Header for CSV file.
$header = [
__('ID Ticket'),
__('Title'),
__('Group/Company'),
__('Status'),
__('Resolution'),
__('Priority'),
__('Updated'),
__('Started'),
__('Creator'),
__('Owner'),
];
$header_csv = '';
foreach ($header as $key => $value) {
$header_csv .= $value.',';
}
$header_csv = io_safe_output($header_csv).PHP_EOL;
// Join header and content.
$tickets_csv = '';
foreach ($tickets_csv_array_filter as $key => $value) {
$tickets_csv .= implode(',', $tickets_csv_array_filter[$key]).PHP_EOL;
}
$tickets_csv = $header_csv.$tickets_csv;
// Create csv file.
$filename = 'tickets_export-'.date('Ymd').'-'.date('His').'.csv';
ob_clean();
header('Content-Type: text/csv; charset=utf-8');
header('Content-Disposition: attachment; filename='.$filename);
// BOM.
echo pack('C*', 0xEF, 0xBB, 0xBF);
// CSV file.
echo io_safe_output($tickets_csv);

View File

@ -0,0 +1,335 @@
<?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.
// Load global vars
global $config;
require_once 'include/functions_integriaims.php';
check_login();
if (! check_acl($config['id_user'], 0, 'IR')) {
// Doesn't have access to this page.
db_pandora_audit('ACL Violation', 'Trying to access IntegriaIMS ticket creation');
include 'general/noaccess.php';
exit;
}
// Header tabs.
$onheader = integriaims_tabs('list_tab');
ui_print_page_header(__('Integria IMS Tickets'), '', false, '', false, $onheader);
// Check if Integria integration enabled.
if ($config['integria_enabled'] == 0) {
ui_print_error_message(__('Integria integration must be enabled in Pandora setup'));
return;
}
// Check connection to Integria IMS API.
$has_connection = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_login', []);
if ($has_connection === false) {
ui_print_error_message(__('Integria IMS API is not reachable'));
return;
}
// Styles.
ui_require_css_file('integriaims');
// Get parameters for filters.
$incident_text = (string) get_parameter('incident_text', '');
$incident_status = (int) get_parameter('incident_status', 0);
$incident_group = (int) get_parameter('incident_group', 1);
$incident_owner = (string) get_parameter('incident_owner', '');
$incident_creator = (string) get_parameter('incident_creator', '');
$incident_priority = (int) get_parameter('incident_priority', -1);
$incident_resolution = (string) get_parameter('incident_resolution', '');
$created_from = (string) get_parameter('created_from', '');
$created_to = (string) get_parameter('created_to', '');
$offset = (int) get_parameter('offset');
$delete_incident = get_parameter('delete_incident');
if ($delete_incident) {
// Call Integria IMS API method to delete an incident.
$result_api_call_delete = integria_api_call(
$config['integria_hostname'],
$config['integria_user'],
$config['integria_pass'],
$config['integria_api_pass'],
'delete_incident',
[$delete_incident]
);
$incident_deleted_ok = ($result_api_call_delete !== false) ? true : false;
ui_print_result_message(
$incident_deleted_ok,
__('Successfully deleted'),
__('Could not be deleted')
);
}
// Full url with all filters.
$url = ui_get_full_url(
'index.php?sec=incident&sec2=operation/incidents/list_integriaims_incidents&incident_text='.$incident_text.'&incident_status='.$incident_status.'&incident_group='.$incident_group.'&incident_owner='.$incident_owner.'&incident_creator='.$incident_creator.'&incident_priority='.$incident_priority.'&incident_resolution='.$incident_resolution.'&created_from='.$created_from.'&created_to='.$created_to.'&offset='.$offset
);
// ---- FILTERS ----
// API calls to fill the filters.
$status_incident = integriaims_get_details('status');
$group_incident = integriaims_get_details('group');
$priority_incident = integriaims_get_details('priority');
$resolution_incident = integriaims_get_details('resolution');
// TABLE FILTERS.
$table = new StdClass();
$table->width = '100%';
$table->class = 'databox filters';
$table->styleTable = 'margin-bottom:0px';
$table->cellpadding = '0';
$table->cellspacing = '0';
$table->data = [];
$table->data[0][0] = __('Text filter');
$table->data[0][1] = html_print_input_text('incident_text', $incident_text, '', 30, 100, true);
$table->data[0][2] = __('Status');
$table->data[0][3] = html_print_select(
$status_incident,
'incident_status',
$incident_status,
'',
__('All'),
0,
true
);
$table->data[0][4] = __('Group');
$table->data[0][5] = html_print_select(
$group_incident,
'incident_group',
$incident_group,
'',
__('All'),
1,
true
);
$table->data[1][0] = __('Owner');
$table->data[1][1] = html_print_autocomplete_users_from_integria('incident_owner', $incident_owner, true);
$table->data[1][2] = __('Creator');
$table->data[1][3] = html_print_autocomplete_users_from_integria('incident_creator', $incident_creator, true);
$table->data[1][4] = __('Priority');
$table->data[1][5] = html_print_select(
$priority_incident,
'incident_priority',
$incident_priority,
'',
__('All'),
-1,
true
);
$table->data[2][0] = __('Resolution');
$table->data[2][1] = html_print_select(
$resolution_incident,
'incident_resolution',
$incident_resolution,
'',
__('All'),
'',
true
);
// TODO: field type date.
$table->data[2][2] = __('Date');
$table->data[2][3] = html_print_input_text_extended(
'created_from',
$created_from,
'created_from',
'',
12,
50,
false,
'',
'placeholder="'.__('Created from').'"',
true
);
$table->data[2][3] .= html_print_input_text_extended(
'created_to',
$created_to,
'created_to',
'',
12,
50,
false,
'',
'style="margin-left:5px;" placeholder="'.__('Created to').'"',
true
);
// TODO: image of Integria IMS.
$table->data[2][4] = '';
$table->data[2][5] = '';
// Send filters to get_tickets_integriaims().
$tickets_filters = [
'incident_text' => $incident_text,
'incident_status' => $incident_status,
'incident_group' => $incident_group,
'incident_owner' => $incident_owner,
'incident_creator' => $incident_creator,
'incident_priority' => $incident_priority,
'incident_resolution' => $incident_resolution,
'created_from' => $created_from,
'created_to' => $created_to,
];
// Data to export to csv file.
$decode_csv = base64_encode(json_encode($tickets_filters));
// ---- PRINT TABLE FILTERS ----
$integria_incidents_form = '<form method="post" action="'.$url.'" style="padding:0px;">';
$integria_incidents_form .= html_print_table($table, true);
$integria_incidents_form .= '<div style="width:100%; text-align:right;">';
$integria_incidents_form .= '<div style="float:right; margin-left: 5px;">'.html_print_button(
__('Export to CSV'),
'csv_export',
false,
"location.href='operation/incidents/integriaims_export_csv.php?tickets_filters=$decode_csv'",
'class="sub next"',
true
).'</div>';
$integria_incidents_form .= '<div>'.html_print_submit_button(__('Filter'), 'filter_button', false, 'class="sub filter"', true).'</div>';
$integria_incidents_form .= '</div>';
$integria_incidents_form .= '</form>';
ui_toggle($integria_incidents_form, __('Filter'), '', '', false);
/*
* Order api call 'get_incidents'.
*
* resolution = $array_get_incidents[$key][12]
* id_incidencia = $array_get_incidents[$key][0]
* titulo = $array_get_incidents[$key][3]
* id_grupo = $array_get_incidents[$key][8]
* estado = $array_get_incidents[$key][6]
* prioridad = $array_get_incidents[$key][7]
* actualizacion = $array_get_incidents[$key][9]
* id_creator = $array_get_incidents[$key][10]
*
*/
// ---- LIST OF INCIDENTS ----
// Get list of incidents.
$array_get_incidents = get_tickets_integriaims($tickets_filters);
// Prepare pagination.
$incidents_limit = $config['block_size'];
$incidents_paginated = array_slice($array_get_incidents, $offset, $incidents_limit, true);
// TABLE INCIDENTS.
$table = new stdClass();
$table->width = '100%';
$table->class = 'info_table';
$table->head = [];
$table->head[0] = __('ID');
$table->head[1] = __('Ticket');
$table->head[2] = __('Group/Company');
$table->head[3] = __('Status/Resolution');
$table->head[4] = __('Prior');
$table->head[5] = __('Updated/Started');
$table->head[6] = __('Creator');
$table->head[7] = __('Owner');
if (check_acl($config['id_user'], 0, 'IW') || check_acl($config['id_user'], 0, 'IM')) {
$table->head[8] = '';
}
$table->data = [];
$i = 0;
foreach ($incidents_paginated as $key => $value) {
if ($array_get_incidents[$key][6] == 0) {
$status_incident[$array_get_incidents[$key][6]] = __('None');
}
if ($array_get_incidents[$key][12] == 0) {
$resolution_incident[$array_get_incidents[$key][12]] = __('None');
}
$table->data[$i][0] = '#'.$array_get_incidents[$key][0];
$table->data[$i][1] = '<a href="'.ui_get_full_url('index.php?sec=incident&sec2=operation/incidents/dashboard_detail_integriaims_incident&incident_id='.$array_get_incidents[$key][0]).'">';
$table->data[$i][1] .= $array_get_incidents[$key][3];
$table->data[$i][1] .= '</a>';
$table->data[$i][2] = $group_incident[$array_get_incidents[$key][8]];
$table->data[$i][3] = $status_incident[$array_get_incidents[$key][6]].' / '.$resolution_incident[$array_get_incidents[$key][12]];
$table->data[$i][4] = ui_print_integria_incident_priority($array_get_incidents[$key][7], $priority_incident[$array_get_incidents[$key][7]]);
$table->data[$i][5] = $array_get_incidents[$key][9].' / '.$array_get_incidents[$key][1];
$table->data[$i][6] = $array_get_incidents[$key][10];
$table->data[$i][7] = $array_get_incidents[$key][5];
$table->data[$i][8] = '';
$table->cellclass[$i][8] = 'action_buttons';
if (check_acl($config['id_user'], 0, 'IW')) {
$table->data[$i][8] .= '<a href="'.ui_get_full_url('index.php?sec=incident&sec2=operation/incidents/configure_integriaims_incident&incident_id='.$array_get_incidents[$key][0]).'">';
$table->data[$i][8] .= html_print_image('images/config.png', true, ['title' => __('Edit')]);
$table->data[$i][8] .= '</a>';
}
if (check_acl($config['id_user'], 0, 'IM')) {
$table->data[$i][8] .= '<a id="link_delete_incident" href="'.ui_get_full_url('index.php?sec=incident&sec2=operation/incidents/list_integriaims_incidents&delete_incident='.$array_get_incidents[$key][0]).'"
onClick="javascript:if (!confirm(\''.__('Are you sure?').'\')) return false;">';
$table->data[$i][8] .= html_print_image('images/cross.png', true, ['title' => __('Delete')]);
$table->data[$i][8] .= '</a>';
}
$i++;
}
// Show table incidents.
ui_pagination(count($array_get_incidents), $url, $offset);
if (empty($table->data) === true) {
ui_print_info_message(['no_close' => true, 'message' => __('No tickets to show').'.' ]);
} else {
html_print_table($table);
ui_pagination(count($array_get_incidents), $url, $offset, 0, false, 'offset', true, 'pagination-bottom');
}
// Show button to create incident.
if (check_acl($config['id_user'], 0, 'IR')) {
echo '<form method="POST" action="'.ui_get_full_url('index.php?sec=incident&sec2=operation/incidents/configure_integriaims_incident').'">';
echo '<div style="width: 100%; text-align:right;">';
html_print_submit_button(__('Create'), 'create_new_incident', false, 'class="sub next"');
echo '</div>';
echo '</form>';
}
// Datapicker library for show calendar.
ui_require_jquery_file('ui.datepicker-'.get_user_language(), 'include/javascript/i18n/');
?>
<script language="javascript" type="text/javascript">
$(document).ready( function() {
$("#created_from, #created_to").datepicker({
dateFormat: "<?php echo DATE_FORMAT_JS; ?>"
});
});
</script>

View File

@ -479,6 +479,7 @@ if (check_acl($config['id_user'], 0, 'IR')
$sub2 = []; $sub2 = [];
$sub2['operation/incidents/incident']['text'] = __('List of Incidents'); $sub2['operation/incidents/incident']['text'] = __('List of Incidents');
$sub2[$sec2sub]['text'] = __('Statistics'); $sub2[$sec2sub]['text'] = __('Statistics');
$sub2['operation/incidents/list_integriaims_incidents']['text'] = __('Integria IMS Tickets');
$sub[$sec2]['sub2'] = $sub2; $sub[$sec2]['sub2'] = $sub2;
$sec2 = $temp_sec2; $sec2 = $temp_sec2;

View File

@ -124,7 +124,7 @@ if (!defined('METACONSOLE')) {
} }
// Page header for metaconsole // Page header for metaconsole
if ($config['metaconsole'] == 1 and defined('METACONSOLE')) { if (is_metaconsole()) {
// Bread crumbs // Bread crumbs
ui_meta_add_breadcrumb(['link' => 'index.php?sec=reporting&sec2=godmode/reporting/reporting_builder', 'text' => __('Reporting')]); ui_meta_add_breadcrumb(['link' => 'index.php?sec=reporting&sec2=godmode/reporting/reporting_builder', 'text' => __('Reporting')]);

View File

@ -333,7 +333,7 @@ $id_usr = $config['id_user'];
if (!$meta) { if (!$meta) {
$home_screen = '<div class="label_select"><p class="edit_user_labels">'.__('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).'</p>'; $home_screen = '<div class="label_select"><p class="edit_user_labels">'.__('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).'</p>';
$values = [ $values = [
'Default' => __('Default'), 'Default' => __('Default'),
'Visual console' => __('Visual console'), 'Visual console' => __('Visual console'),

View File

@ -2,8 +2,8 @@
# Pandora FMS Console # Pandora FMS Console
# #
%define name pandorafms_console %define name pandorafms_console
%define version 7.0NG.738 %define version 7.0NG.739
%define release 190920 %define release 191003
# User and Group under which Apache is running # User and Group under which Apache is running
%define httpd_name httpd %define httpd_name httpd

View File

@ -2,8 +2,8 @@
# Pandora FMS Console # Pandora FMS Console
# #
%define name pandorafms_console %define name pandorafms_console
%define version 7.0NG.738 %define version 7.0NG.739
%define release 190920 %define release 191003
# User and Group under which Apache is running # User and Group under which Apache is running
%define httpd_name httpd %define httpd_name httpd

View File

@ -2,8 +2,8 @@
# Pandora FMS Console # Pandora FMS Console
# #
%define name pandorafms_console %define name pandorafms_console
%define version 7.0NG.738 %define version 7.0NG.739
%define release 190920 %define release 191003
%define httpd_name httpd %define httpd_name httpd
# User and Group under which Apache is running # User and Group under which Apache is running
%define httpd_name apache2 %define httpd_name apache2

View File

@ -9,7 +9,7 @@
# This code is licensed under GPL 2.0 license. # This code is licensed under GPL 2.0 license.
# ********************************************************************** # **********************************************************************
PI_VERSION="7.0NG.738" PI_VERSION="7.0NG.739"
FORCE=0 FORCE=0
DESTDIR="" DESTDIR=""
LOG_TIMESTAMP=`date +"%Y/%m/%d %H:%M:%S"` LOG_TIMESTAMP=`date +"%Y/%m/%d %H:%M:%S"`

View File

@ -109,14 +109,36 @@ INSERT INTO `tconfig` (`token`, `value`) VALUES
('custom_report_front_logo', 'images/pandora_logo_white.jpg'), ('custom_report_front_logo', 'images/pandora_logo_white.jpg'),
('custom_report_front_header', ''), ('custom_report_front_header', ''),
('custom_report_front_footer', ''), ('custom_report_front_footer', ''),
('MR', 31), ('MR', 32),
('identification_reminder', 1), ('identification_reminder', 1),
('identification_reminder_timestamp', 0), ('identification_reminder_timestamp', 0),
('current_package_enterprise', '738'), ('current_package_enterprise', '739'),
('post_process_custom_values', '{"0.00000038580247":"Seconds&#x20;to&#x20;months","0.00000165343915":"Seconds&#x20;to&#x20;weeks","0.00001157407407":"Seconds&#x20;to&#x20;days","0.01666666666667":"Seconds&#x20;to&#x20;minutes","0.00000000093132":"Bytes&#x20;to&#x20;Gigabytes","0.00000095367432":"Bytes&#x20;to&#x20;Megabytes","0.0009765625":"Bytes&#x20;to&#x20;Kilobytes","0.00000001653439":"Timeticks&#x20;to&#x20;weeks","0.00000011574074":"Timeticks&#x20;to&#x20;days"}'), ('post_process_custom_values', '{"0.00000038580247":"Seconds&#x20;to&#x20;months","0.00000165343915":"Seconds&#x20;to&#x20;weeks","0.00001157407407":"Seconds&#x20;to&#x20;days","0.01666666666667":"Seconds&#x20;to&#x20;minutes","0.00000000093132":"Bytes&#x20;to&#x20;Gigabytes","0.00000095367432":"Bytes&#x20;to&#x20;Megabytes","0.0009765625":"Bytes&#x20;to&#x20;Kilobytes","0.00000001653439":"Timeticks&#x20;to&#x20;weeks","0.00000011574074":"Timeticks&#x20;to&#x20;days"}'),
('custom_docs_logo', 'default_docs.png'), ('custom_docs_logo', 'default_docs.png'),
('custom_support_logo', 'default_support.png'), ('custom_support_logo', 'default_support.png'),
('custom_logo_white_bg_preview', 'pandora_logo_head_white_bg.png'); ('custom_logo_white_bg_preview', 'pandora_logo_head_white_bg.png'),
('integria_enabled', 0),
('integria_user', ''),
('integria_pass', ''),
('integria_hostname', ''),
('integria_api_pass', ''),
('integria_req_timeout', 5),
('default_group', ''),
('default_criticity', ''),
('default_creator', ''),
('default_owner', ''),
('incident_type', ''),
('incident_status', ''),
('incident_title', ''),
('incident_content', ''),
('cr_default_group', ''),
('cr_default_criticity', ''),
('cr_default_creator', ''),
('cr_default_owner', ''),
('cr_incident_type', ''),
('cr_incident_status', ''),
('cr_incident_title', ''),
('cr_incident_content', '');
UNLOCK TABLES; UNLOCK TABLES;
-- --

View File

@ -1,5 +1,5 @@
package: pandorafms-server package: pandorafms-server
Version: 7.0NG.738-190920 Version: 7.0NG.739-191003
Architecture: all Architecture: all
Priority: optional Priority: optional
Section: admin Section: admin

View File

@ -14,7 +14,7 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. # GNU General Public License for more details.
pandora_version="7.0NG.738-190920" pandora_version="7.0NG.739-191003"
package_cpan=0 package_cpan=0
package_pandora=1 package_pandora=1

View File

@ -1,7 +1,7 @@
############################################################################# #############################################################################
# Pandora FMS Server Parameters # Pandora FMS Server Parameters
# Pandora FMS, the Flexible Monitoring System. # Pandora FMS, the Flexible Monitoring System.
# Version 7.0NG.738 # Version 7.0NG.739
# Licensed under GPL license v2, # Licensed under GPL license v2,
# (c) 2003-2017 Artica Soluciones Tecnologicas # (c) 2003-2017 Artica Soluciones Tecnologicas
# http://www.pandorafms.com # http://www.pandorafms.com

View File

@ -44,8 +44,8 @@ our @EXPORT = qw(
); );
# version: Defines actual version of Pandora Server for this module only # version: Defines actual version of Pandora Server for this module only
my $pandora_version = "7.0NG.738"; my $pandora_version = "7.0NG.739";
my $pandora_build = "190920"; my $pandora_build = "191003";
our $VERSION = $pandora_version." ".$pandora_build; our $VERSION = $pandora_version." ".$pandora_build;
# Setup hash # Setup hash
@ -357,7 +357,15 @@ sub pandora_load_config {
# Xprobe2 for recon OS fingerprinting and tcpscan (optional) # Xprobe2 for recon OS fingerprinting and tcpscan (optional)
$pa_config->{"xprobe2"} = "/usr/bin/xprobe2"; $pa_config->{"xprobe2"} = "/usr/bin/xprobe2";
# Winexe allows to exec commands on remote windows systems (optional)
$pa_config->{"winexe"} = "/usr/bin/winexe";
# PsExec allows to exec commands on remote windows systems from windows servers (optional)
$pa_config->{"psexec"} = 'C:\PandoraFMS\Pandora_Server\bin\PsExec.exe';
# plink allows to exec commands on remote linux systems from windows servers (optional)
$pa_config->{"plink"} = 'C:\PandoraFMS\Pandora_Server\bin\plink.exe';
# Snmpget for snmpget system command (optional) # Snmpget for snmpget system command (optional)
$pa_config->{"snmpget"} = "/usr/bin/snmpget"; $pa_config->{"snmpget"} = "/usr/bin/snmpget";
@ -838,6 +846,15 @@ sub pandora_load_config {
elsif ($parametro =~ m/^xprobe2\s(.*)/i) { elsif ($parametro =~ m/^xprobe2\s(.*)/i) {
$pa_config->{'xprobe2'}= clean_blank($1); $pa_config->{'xprobe2'}= clean_blank($1);
} }
elsif ($parametro =~ m/^winexe\s(.*)/i) {
$pa_config->{'winexe'}= clean_blank($1);
}
elsif ($parametro =~ m/^psexec\s(.*)/i) {
$pa_config->{'psexec'}= clean_blank($1);
}
elsif ($parametro =~ m/^plink\s(.*)/i) {
$pa_config->{'plink'}= clean_blank($1);
}
elsif ($parametro =~ m/^snmpget\s(.*)/i) { elsif ($parametro =~ m/^snmpget\s(.*)/i) {
$pa_config->{'snmpget'}= clean_blank($1); $pa_config->{'snmpget'}= clean_blank($1);
} }
@ -1037,7 +1054,7 @@ sub pandora_load_config {
$pa_config->{'console_pass'}= safe_input(clean_blank($1)); $pa_config->{'console_pass'}= safe_input(clean_blank($1));
} }
elsif ($parametro =~ m/^encryption_passphrase\s(.*)/i) { # 6.0 elsif ($parametro =~ m/^encryption_passphrase\s(.*)/i) { # 6.0
$pa_config->{'encryption_passphrase'}= safe_input(clean_blank($1)); $pa_config->{'encryption_passphrase'} = clean_blank($1);
} }
elsif ($parametro =~ m/^unknown_interval\s+([0-9]*)/i) { # > 5.1SP2 elsif ($parametro =~ m/^unknown_interval\s+([0-9]*)/i) { # > 5.1SP2
$pa_config->{'unknown_interval'}= clean_blank($1); $pa_config->{'unknown_interval'}= clean_blank($1);

View File

@ -1137,7 +1137,9 @@ sub pandora_execute_action ($$$$$$$$$;$) {
load_module_macros ($module->{'module_macros'}, \%macros); load_module_macros ($module->{'module_macros'}, \%macros);
} }
# User defined alerts
#logger($pa_config, "Clean name ".$clean_name, 10);
# User defined alert
if ($action->{'internal'} == 0) { if ($action->{'internal'} == 0) {
$macros{_field1_} = subst_alert_macros ($field1, \%macros, $pa_config, $dbh, $agent, $module); $macros{_field1_} = subst_alert_macros ($field1, \%macros, $pa_config, $dbh, $agent, $module);
$macros{_field2_} = subst_alert_macros ($field2, \%macros, $pa_config, $dbh, $agent, $module); $macros{_field2_} = subst_alert_macros ($field2, \%macros, $pa_config, $dbh, $agent, $module);
@ -1442,55 +1444,70 @@ sub pandora_execute_action ($$$$$$$$$;$) {
# Integria IMS Ticket # Integria IMS Ticket
} elsif ($clean_name eq "Integria IMS Ticket") { } elsif ($clean_name eq "Integria IMS Ticket") {
my $config_api_path = pandora_get_tconfig_token ($dbh, 'integria_hostname', '');
my $config_api_pass = pandora_get_tconfig_token ($dbh, 'integria_api_pass', '');
my $config_integria_user = pandora_get_tconfig_token ($dbh, 'integria_user', '');
my $config_integria_user_pass = pandora_get_tconfig_token ($dbh, 'integria_pass', '');
$field1 = subst_alert_macros ($field1, \%macros, $pa_config, $dbh, $agent, $module); $field1 = subst_alert_macros ($field1, \%macros, $pa_config, $dbh, $agent, $module);
$field2 = subst_alert_macros ($field2, \%macros, $pa_config, $dbh, $agent, $module);
$field3 = subst_alert_macros ($field3, \%macros, $pa_config, $dbh, $agent, $module); $field3 = subst_alert_macros ($field3, \%macros, $pa_config, $dbh, $agent, $module);
$field4 = subst_alert_macros ($field4, \%macros, $pa_config, $dbh, $agent, $module);
$field5 = subst_alert_macros ($field5, \%macros, $pa_config, $dbh, $agent, $module); $field5 = subst_alert_macros ($field5, \%macros, $pa_config, $dbh, $agent, $module);
$field6 = subst_alert_macros ($field6, \%macros, $pa_config, $dbh, $agent, $module);
$field7 = subst_alert_macros ($field7, \%macros, $pa_config, $dbh, $agent, $module); $field7 = subst_alert_macros ($field7, \%macros, $pa_config, $dbh, $agent, $module);
$field8 = subst_alert_macros ($field8, \%macros, $pa_config, $dbh, $agent, $module);
$field9 = subst_alert_macros ($field9, \%macros, $pa_config, $dbh, $agent, $module);
$field10 = subst_alert_macros ($field10, \%macros, $pa_config, $dbh, $agent, $module);
# Field 1 (Integria IMS API path) # Field 1 (Integria IMS API path)
my $api_path = $field1; my $api_path = $config_api_path . "/integria/include/api.php";
# Field 2 (Integria IMS API pass) # Field 2 (Integria IMS API pass)
my $api_pass = $field2; my $api_pass = $config_api_pass;
# Field 3 (Integria IMS user) # Field 3 (Integria IMS user)
my $integria_user = $field3; my $integria_user = $config_integria_user;
# Field 4 (Integria IMS user password) # Field 4 (Integria IMS user password)
my $integria_user_pass = $field4; my $integria_user_pass = $config_integria_user_pass;
# Field 5 (Ticket name) # Field 1 (Ticket name)
my $ticket_name = $field5; my $ticket_name = safe_output($field1);
if ($ticket_name eq "") { if ($ticket_name eq "") {
$ticket_name = $pa_config->{'rb_product_name'} . " alert action created by API"; $ticket_name = $pa_config->{'rb_product_name'} . " alert action created by API";
} }
# Field 6 (Ticket group ID) # Field 2 (Ticket group ID)
my $ticket_group_id = $field6; my $ticket_group_id = $field2;
if ($ticket_group_id eq '') { if ($ticket_group_id eq '') {
$ticket_group_id = 0; $ticket_group_id = 0;
} }
# Field 7 (Ticket priority); # Field 3 (Ticket priority);
my $ticket_priority = $field7; my $ticket_priority = $field3;
if ($ticket_priority eq '') { if ($ticket_priority eq '0') {
$ticket_priority = 0; $ticket_priority = 1;
}
# Field 4 (Ticket owner)
my $ticket_owner = $field4;
if ($ticket_owner eq '') {
$ticket_owner = 'admin';
} }
# Field 8 (Ticket email) # Field 5 (Ticket type)
my $ticket_email = $field8; my $ticket_type = $field5;
if ($ticket_type eq '') {
# Field 9 (Ticket owner) $ticket_type = 0;
my $ticket_owner = $field9; }
# Field 10 (Ticket description);
my $ticket_description = $field10;
pandora_create_integria_ticket($pa_config, $api_path, $api_pass, $integria_user, $integria_user_pass, $ticket_name, $ticket_group_id, $ticket_priority, $ticket_email, $ticket_owner, $ticket_description); # Field 6 (Ticket status)
my $ticket_status = $field6;
if ($ticket_status eq '0') {
$ticket_status = 1;
}
# Field 7 (Ticket description);
my $ticket_description = safe_output($field7);
pandora_create_integria_ticket($pa_config, $api_path, $api_pass, $integria_user, $integria_user_pass, $ticket_name, $ticket_group_id, $ticket_priority, $ticket_owner, $ticket_type, $ticket_status, $ticket_description);
# Generate notification # Generate notification
} elsif ($clean_name eq "Generate Notification") { } elsif ($clean_name eq "Generate Notification") {
@ -3155,11 +3172,20 @@ sub pandora_get_config_value ($$) {
########################################################################## ##########################################################################
## Get credential from credential store ## Get credential from credential store
########################################################################## ##########################################################################
sub pandora_get_credential ($$) { sub pandora_get_credential ($$$) {
my ($dbh, $identifier) = @_; my ($pa_config, $dbh, $identifier) = @_;
my $key = get_db_single_row($dbh, 'SELECT * FROM tcredential_store WHERE identifier = ?', $identifier); my $key = get_db_single_row($dbh, 'SELECT * FROM tcredential_store WHERE identifier = ?', $identifier);
$key->{'username'} = pandora_output_password(
$pa_config,
safe_output($key->{'username'})
);
$key->{'password'} = pandora_output_password(
$pa_config,
safe_output($key->{'password'})
);
return $key; return $key;
} }
@ -5840,55 +5866,21 @@ sub pandora_edit_custom_graph ($$$$$$$$$$$) {
} }
sub pandora_create_integria_ticket ($$$$$$$$$$$) { sub pandora_create_integria_ticket ($$$$$$$$$$$) {
my ($pa_config,$api_path,$api_pass,$integria_user,$user_pass,$ticket_name,$group_id,$ticket_priority,$ticket_email,$ticket_owner,$ticket_description) = @_; my ($pa_config,$api_path,$api_pass,$integria_user,$user_pass,$ticket_name,$ticket_group_id,$ticket_priority,$ticket_owner,$ticket_type,$ticket_status,$ticket_description) = @_;
my $data_ticket; my $data_ticket;
my $call_api; my $call_api;
if ($api_path eq "") {
return 0;
}
if ($user_pass eq "") {
return 0;
}
if ($integria_user eq "") {
$integria_user = "admin";
}
if ($ticket_name eq "") {
$ticket_name = "Ticket created by " . $pa_config->{'rb_product_name'};
}
if ($group_id eq "") {
$group_id = 1;
}
if ($ticket_priority eq "") {
$ticket_priority = 1;
}
if ($ticket_owner eq "") {
$ticket_owner = "admin";
}
#~ $data_ticket = $ticket_name .
#~ "|;|" . $group_id .
#~ "|;|" . $ticket_priority .
#~ "|;|" . $ticket_description .
#~ "|;|" . #Id inventory
#~ "|;|" . #Id incident type
#~ "|;|" . $ticket_email .
#~ "|;|" . $ticket_owner .
#~ "|;|" . #Father ticket id
#~ "|;|" . #Status
#~ "|;|" . #Extra info
#~ "|;|"; #Resolution
$data_ticket = $ticket_name . $data_ticket = $ticket_name .
"|;|" . $group_id . "|;|" . $ticket_group_id .
"|;|" . $ticket_priority . "|;|" . $ticket_priority .
"|;|" . $ticket_description . "|;|" . $ticket_description .
"|;|" . "|;|" .
"|;|" . "|;|" . $ticket_type .
"|;|" . $ticket_email . "|;|" .
"|;|" . $ticket_owner . "|;|" . $ticket_owner .
"|;|" . "|;|" .
"|;|" . '1' . "|;|" . $ticket_status .
"|;|" . "|;|" .
"|;|"; "|;|";
@ -5899,9 +5891,9 @@ sub pandora_create_integria_ticket ($$$$$$$$$$$) {
'op=create_incident&' . 'op=create_incident&' .
'params=' . $data_ticket .'&' . 'params=' . $data_ticket .'&' .
'token=|;|'; 'token=|;|';
logger($pa_config, "Integria ticket call:" . $call_api . "", 3);
my $content = get($call_api); my $content = get($call_api);
logger($pa_config, "Integria ticket res:" . $content . "", 3);
if (is_numeric($content) && $content ne "-1") { if (is_numeric($content) && $content ne "-1") {
return $content; return $content;
} }

View File

@ -343,6 +343,9 @@ sub exec_recon_script ($$$) {
sub PandoraFMS::Recon::Base::guess_os($$) { sub PandoraFMS::Recon::Base::guess_os($$) {
my ($self, $device) = @_; my ($self, $device) = @_;
$DEVNULL = '/dev/null' if (!defined($DEVNULL));
$DEVNULL = '/NUL' if ($^O =~ /win/i && !defined($DEVNULL));
# OS detection disabled. Use the device type. # OS detection disabled. Use the device type.
if ($self->{'os_detection'} == 0) { if ($self->{'os_detection'} == 0) {
my $device_type = $self->get_device_type($device); my $device_type = $self->get_device_type($device);
@ -354,17 +357,20 @@ sub PandoraFMS::Recon::Base::guess_os($$) {
} }
# Use xprobe2 if available # Use xprobe2 if available
if (-e $self->{pa_config}->{xprobe2}) { if (-x $self->{'pa_config'}->{'xprobe2'}) {
my $output = `"$self->{pa_config}->{xprobe2}" $device 2>$DEVNULL | grep 'Running OS' | head -1`; my $return = `"$self->{pa_config}->{xprobe2}" $device 2>$DEVNULL`;
if ($? == 0) { if ($? == 0) {
my ($output) = $a =~ /Running OS:(.*)/;
return pandora_get_os($self->{'dbh'}, $output); return pandora_get_os($self->{'dbh'}, $output);
} }
} }
# Use nmap by default # Use nmap by default
if (-e $self->{pa_config}->{nmap}) { if (-x $self->{'pa_config'}->{'nmap'}) {
my $output = `"$self->{pa_config}->{nmap}" -F -O $device 2>$DEVNULL | grep 'Aggressive OS guesses'`; my $return = `"$self->{pa_config}->{nmap}" -F -O $device 2>$DEVNULL`;
return OS_OTHER if ($? != 0); return OS_OTHER if ($? != 0);
my ($output) = $return =~ /Aggressive OS guesses:\s*(.*)/;
return pandora_get_os($self->{'dbh'}, $output); return pandora_get_os($self->{'dbh'}, $output);
} }
@ -377,7 +383,11 @@ sub PandoraFMS::Recon::Base::guess_os($$) {
sub PandoraFMS::Recon::Base::tcp_scan ($$) { sub PandoraFMS::Recon::Base::tcp_scan ($$) {
my ($self, $host) = @_; my ($self, $host) = @_;
my $open_ports = `"$self->{pa_config}->{nmap}" -p$self->{recon_ports} $host | grep open | wc -l`; my $r = `"$self->{pa_config}->{nmap}" -p$self->{recon_ports} $host`;
# Same as ""| grep open | wc -l" but multi-OS;
my $open_ports = () = $r =~ /open/gm;
return $open_ports; return $open_ports;
} }

View File

@ -31,8 +31,8 @@ use base 'Exporter';
our @ISA = qw(Exporter); our @ISA = qw(Exporter);
# version: Defines actual version of Pandora Server for this module only # version: Defines actual version of Pandora Server for this module only
my $pandora_version = "7.0NG.738"; my $pandora_version = "7.0NG.739";
my $pandora_build = "190920"; my $pandora_build = "191003";
our $VERSION = $pandora_version." ".$pandora_build; our $VERSION = $pandora_version." ".$pandora_build;
our %EXPORT_TAGS = ( 'all' => [ qw() ] ); our %EXPORT_TAGS = ( 'all' => [ qw() ] );

View File

@ -36,7 +36,7 @@ use constant {
DISCOVERY_DEPLOY_AGENTS => 9, DISCOVERY_DEPLOY_AGENTS => 9,
}; };
# /dev/null # $DEVNULL
my $DEVNULL = ($^O eq 'MSWin32') ? '/Nul' : '/dev/null'; my $DEVNULL = ($^O eq 'MSWin32') ? '/Nul' : '/dev/null';
# Some useful OIDs. # Some useful OIDs.
@ -852,7 +852,7 @@ sub get_routes($) {
$self->{'routes'} = []; $self->{'routes'} = [];
# Parse route's output. # Parse route's output.
my @output = `route -n 2>/dev/null`; my @output = `route -n 2>$DEVNULL`;
foreach my $line (@output) { foreach my $line (@output) {
chomp($line); chomp($line);
if ($line =~ /^0\.0\.0\.0\s+(\d+\.\d+\.\d+\.\d+).*/) { if ($line =~ /^0\.0\.0\.0\s+(\d+\.\d+\.\d+\.\d+).*/) {
@ -1220,7 +1220,7 @@ sub snmp_responds_v3($$) {
sub local_arp($) { sub local_arp($) {
my ($self) = @_; my ($self) = @_;
my @output = `arp -an 2>/dev/null`; my @output = `arp -an 2>$DEVNULL`;
foreach my $line (@output) { foreach my $line (@output) {
next unless ($line =~ m/\((\S+)\) at ([0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+)/); next unless ($line =~ m/\((\S+)\) at ([0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+)/);
$self->add_mac(parse_mac($2), $1); $self->add_mac(parse_mac($2), $1);
@ -1286,7 +1286,7 @@ sub ping ($$$) {
for (my $i = 0; $i < $retries; $i++) { for (my $i = 0; $i < $retries; $i++) {
# Note: There is no timeout option. # Note: There is no timeout option.
`$ping_command -s -n $host 56 $packets >/dev/null 2>&1`; `$ping_command -s -n $host 56 $packets >$DEVNULL 2>&1`;
return 1 if ($? == 0); return 1 if ($? == 0);
} }
@ -1299,7 +1299,7 @@ sub ping ($$$) {
for (my $i = 0; $i < $retries; $i++) { for (my $i = 0; $i < $retries; $i++) {
# Note: There is no timeout option for ping6. # Note: There is no timeout option for ping6.
`$ping_command -q -n -c $packets $host >/dev/null 2>&1`; `$ping_command -q -n -c $packets $host >$DEVNULL 2>&1`;
return 1 if ($? == 0); return 1 if ($? == 0);
} }
@ -1312,7 +1312,7 @@ sub ping ($$$) {
for (my $i = 0; $i < $retries; $i++) { for (my $i = 0; $i < $retries; $i++) {
# Note: There is no timeout option for ping6. # Note: There is no timeout option for ping6.
`$ping_command -q -n -c $packets $host >/dev/null 2>&1`; `$ping_command -q -n -c $packets $host >$DEVNULL 2>&1`;
if ($? == 0) { if ($? == 0) {
return 1; return 1;
} }
@ -1324,7 +1324,7 @@ sub ping ($$$) {
# Assume Linux by default. # Assume Linux by default.
my $ping_command = $host =~ /\d+:|:\d+/ ? "ping6" : "ping"; my $ping_command = $host =~ /\d+:|:\d+/ ? "ping6" : "ping";
for (my $i = 0; $i < $retries; $i++) { for (my $i = 0; $i < $retries; $i++) {
`$ping_command -q -W $timeout -n -c $packets $host >/dev/null 2>&1`; `$ping_command -q -W $timeout -n -c $packets $host >$DEVNULL 2>&1`;
return 1 if ($? == 0); return 1 if ($? == 0);
} }
@ -1529,99 +1529,101 @@ sub app_scan($) {
$self->{'task_data'} $self->{'task_data'}
); );
if (!$dbObj->is_connected()) { if (defined($dbObj)) {
call('message', 'Cannot connect to target ' . $target, 3); if (!$dbObj->is_connected()) {
$global_percent += $global_step; call('message', 'Cannot connect to target ' . $target, 3);
$self->{'c_network_percent'} = 90; $global_percent += $global_step;
# Update progress $self->{'c_network_percent'} = 90;
$self->call('update_progress', $global_percent + (90 / (scalar @targets))); # Update progress
$self->{'summary'}->{'not_alive'} += 1; $self->call('update_progress', $global_percent + (90 / (scalar @targets)));
push @modules, { $self->{'summary'}->{'not_alive'} += 1;
name => $type . ' connection', push @modules, {
type => 'generic_proc', name => $type . ' connection',
data => 0, type => 'generic_proc',
description => $type . ' availability' data => 0,
}; description => $type . ' availability'
};
} else { } else {
my $dbObjCfg = $dbObj->get_config(); my $dbObjCfg = $dbObj->get_config();
$self->{'summary'}->{'discovered'} += 1; $self->{'summary'}->{'discovered'} += 1;
$self->{'summary'}->{'alive'} += 1; $self->{'summary'}->{'alive'} += 1;
push @modules, { push @modules, {
name => $type . ' connection', name => $type . ' connection',
type => 'generic_proc', type => 'generic_proc',
data => 1, data => 1,
description => $type . ' availability' description => $type . ' availability'
}; };
# Analyze. # Analyze.
$self->{'step'} = STEP_STATISTICS; $self->{'step'} = STEP_STATISTICS;
$self->{'c_network_percent'} = 30; $self->{'c_network_percent'} = 30;
$self->call('update_progress', $global_percent + (30 / (scalar @targets))); $self->call('update_progress', $global_percent + (30 / (scalar @targets)));
$self->{'c_network_name'} = $dbObj->get_host(); $self->{'c_network_name'} = $dbObj->get_host();
# Retrieve connection statistics. # Retrieve connection statistics.
# Retrieve uptime statistics # Retrieve uptime statistics
# Retrieve query stats # Retrieve query stats
# Retrieve connections # Retrieve connections
# Retrieve innodb # Retrieve innodb
# Retrieve cache # Retrieve cache
$self->{'c_network_percent'} = 50; $self->{'c_network_percent'} = 50;
$self->call('update_progress', $global_percent + (50 / (scalar @targets))); $self->call('update_progress', $global_percent + (50 / (scalar @targets)));
push @modules, $dbObj->get_statistics(); push @modules, $dbObj->get_statistics();
# Custom queries. # Custom queries.
$self->{'step'} = STEP_CUSTOM_QUERIES; $self->{'step'} = STEP_CUSTOM_QUERIES;
$self->{'c_network_percent'} = 80; $self->{'c_network_percent'} = 80;
$self->call('update_progress', $global_percent + (80 / (scalar @targets))); $self->call('update_progress', $global_percent + (80 / (scalar @targets)));
push @modules, $dbObj->execute_custom_queries(); push @modules, $dbObj->execute_custom_queries();
if (defined($dbObjCfg->{'scan_databases'}) if (defined($dbObjCfg->{'scan_databases'})
&& $dbObjCfg->{'scan_databases'} == 1) { && "$dbObjCfg->{'scan_databases'}" eq "1") {
# Skip database scan in Oracle tasks # Skip database scan in Oracle tasks
next if $self->{'type'} == DISCOVERY_APP_ORACLE; next if $self->{'type'} == DISCOVERY_APP_ORACLE;
my $__data = $dbObj->scan_databases(); my $__data = $dbObj->scan_databases();
if (ref($__data) eq "ARRAY") { if (ref($__data) eq "ARRAY") {
if (defined($dbObjCfg->{'agent_per_database'}) if (defined($dbObjCfg->{'agent_per_database'})
&& $dbObjCfg->{'agent_per_database'} == 1) { && $dbObjCfg->{'agent_per_database'} == 1) {
# Agent per database detected. # Agent per database detected.
push @data, @{$__data}; push @data, @{$__data};
} else { } else {
# Merge modules into engine agent. # Merge modules into engine agent.
my @_modules = map { my @_modules = map {
map { $_ } @{$_->{'module_data'}} map { $_ } @{$_->{'module_data'}}
} @{$__data}; } @{$__data};
push @modules, @_modules; push @modules, @_modules;
}
} }
} }
} }
# Put engine agent at the beginning of the list.
my $version = $dbObj->get_version();
unshift @data,{
'agent_data' => {
'agent_name' => $dbObj->get_agent_name(),
'os' => $type,
'os_version' => (defined($version) ? $version : 'Discovery'),
'interval' => $self->{'task_data'}->{'interval_sweep'},
'id_group' => $self->{'task_data'}->{'id_group'},
'address' => $dbObj->get_host(),
'description' => '',
},
'module_data' => \@modules,
};
$self->call('create_agents', \@data);
# Destroy item.
undef($dbObj);
} }
# Put engine agent at the beginning of the list.
my $version = $dbObj->get_version();
unshift @data,{
'agent_data' => {
'agent_name' => $dbObj->get_agent_name(),
'os' => $type,
'os_version' => (defined($version) ? $version : 'Discovery'),
'interval' => $self->{'task_data'}->{'interval_sweep'},
'id_group' => $self->{'task_data'}->{'id_group'},
'address' => $dbObj->get_host(),
'description' => '',
},
'module_data' => \@modules,
};
$self->call('create_agents', \@data);
# Destroy item.
undef($dbObj);
$global_percent += $global_step; $global_percent += $global_step;
$self->{'c_network_percent'} = 100; $self->{'c_network_percent'} = 100;
$self->call('update_progress', $global_percent); $self->call('update_progress', $global_percent);
@ -1674,7 +1676,7 @@ sub deploy_scan($) {
########################################################################## ##########################################################################
sub scan($) { sub scan($) {
my ($self) = @_; my ($self) = @_;
my ($progress, $step); my ($progress, $step) = 1, 0;
# 1% # 1%
$self->call('update_progress', 1); $self->call('update_progress', 1);
@ -1697,7 +1699,7 @@ sub scan($) {
} }
# Find devices. # Find devices.
$self->call('message', "[1/5] Scanning the network...", 3); $self->call('message', "[1/4] Scanning the network...", 3);
$self->{'step'} = STEP_SCANNING; $self->{'step'} = STEP_SCANNING;
$self->call('update_progress', $progress); $self->call('update_progress', $progress);
$self->scan_subnet(); $self->scan_subnet();
@ -1713,7 +1715,7 @@ sub scan($) {
$self->call('delete_connections'); $self->call('delete_connections');
# Connectivity from address forwarding tables. # Connectivity from address forwarding tables.
$self->call('message', "[1/4] Finding address forwarding table connectivity...", 3); $self->call('message', "[2/4] Finding address forwarding table connectivity...", 3);
$self->{'step'} = STEP_AFT; $self->{'step'} = STEP_AFT;
($progress, $step) = (50, 20.0 / scalar(@hosts)); # From 50% to 70%. ($progress, $step) = (50, 20.0 / scalar(@hosts)); # From 50% to 70%.
for (my $i = 0; defined($hosts[$i]); $i++) { for (my $i = 0; defined($hosts[$i]); $i++) {
@ -1831,7 +1833,7 @@ sub snmp_get_command {
my ($self, $device, $oid, $community, $vlan) = @_; my ($self, $device, $oid, $community, $vlan) = @_;
$vlan = defined($vlan) ? "\@" . $vlan : ''; $vlan = defined($vlan) ? "\@" . $vlan : '';
my $command = "snmpwalk -M/dev/null -r$self->{'snmp_checks'} -t$self->{'snmp_timeout'} -v$self->{'snmp_version'} -On -Oe "; my $command = "snmpwalk -M$DEVNULL -r$self->{'snmp_checks'} -t$self->{'snmp_timeout'} -v$self->{'snmp_version'} -On -Oe ";
if ($self->{'snmp_version'} eq "3") { if ($self->{'snmp_version'} eq "3") {
if ($self->{'community'}) { # Context if ($self->{'community'}) { # Context
$command .= " -N $self->{'community'} "; $command .= " -N $self->{'community'} ";
@ -1847,7 +1849,7 @@ sub snmp_get_command {
$command .= " -c$community$vlan "; $command .= " -c$community$vlan ";
} }
return "$command $device $oid 2>/dev/null"; return "$command $device $oid 2>$DEVNULL";
} }

View File

@ -624,7 +624,7 @@ sub logger ($$;$) {
$message = safe_output ($message); $message = safe_output ($message);
$level = 1 unless defined ($level); $level = 1 unless defined ($level);
return if ($level > $pa_config->{'verbosity'}); return if (!defined ($pa_config->{'verbosity'}) || $level > $pa_config->{'verbosity'});
if (!defined($pa_config->{'log_file'})) { if (!defined($pa_config->{'log_file'})) {
print strftime ("%Y-%m-%d %H:%M:%S", localtime()) . " [V". $level ."] " . $message . "\n"; print strftime ("%Y-%m-%d %H:%M:%S", localtime()) . " [V". $level ."] " . $message . "\n";
@ -994,7 +994,8 @@ sub load_average {
$load_average = ((split(/\s+/, `/sbin/sysctl -n vm.loadavg`))[1]); $load_average = ((split(/\s+/, `/sbin/sysctl -n vm.loadavg`))[1]);
} elsif ($OSNAME eq "MSWin32") { } elsif ($OSNAME eq "MSWin32") {
# Windows hasn't got load average. # Windows hasn't got load average.
$load_average = undef; $load_average = `powershell "(Get-WmiObject win32_processor | Measure-Object -property LoadPercentage -Average).average"`;
chop($load_average);
} }
# by default LINUX calls # by default LINUX calls
else { else {

View File

@ -2,8 +2,8 @@
# Pandora FMS Server # Pandora FMS Server
# #
%define name pandorafms_server %define name pandorafms_server
%define version 7.0NG.738 %define version 7.0NG.739
%define release 190920 %define release 191003
Summary: Pandora FMS Server Summary: Pandora FMS Server
Name: %{name} Name: %{name}

View File

@ -2,8 +2,8 @@
# Pandora FMS Server # Pandora FMS Server
# #
%define name pandorafms_server %define name pandorafms_server
%define version 7.0NG.738 %define version 7.0NG.739
%define release 190920 %define release 191003
Summary: Pandora FMS Server Summary: Pandora FMS Server
Name: %{name} Name: %{name}

View File

@ -8,8 +8,8 @@
# This code is licensed under GPL 2.0 license. # This code is licensed under GPL 2.0 license.
# ********************************************************************** # **********************************************************************
PI_VERSION="7.0NG.738" PI_VERSION="7.0NG.739"
PI_BUILD="190920" PI_BUILD="191003"
MODE=$1 MODE=$1
if [ $# -gt 1 ]; then if [ $# -gt 1 ]; then

View File

@ -38,6 +38,7 @@ Where options:
Optional parameters: Optional parameters:
[-priority <priority>] : 10 Maintance, 0 Informative, 1 Low, 2 Medium, 3 Serious, 4 Very serious [-priority <priority>] : 10 Maintance, 0 Informative, 1 Low, 2 Medium, 3 Serious, 4 Very serious
[-owner <owner>] : Free text
[-desc <description>] : Free text [-desc <description>] : Free text
[-type <ticket_type>] : Type ID (must exist in Integria IMS) [-type <ticket_type>] : Type ID (must exist in Integria IMS)
[-inventory <inventory_id>] : Inventory ID (must exist in Integria IMS) [-inventory <inventory_id>] : Inventory ID (must exist in Integria IMS)
@ -94,6 +95,7 @@ sub tool_api_main () {
my $ticket_name = ""; my $ticket_name = "";
my $group_id = -1; my $group_id = -1;
my $ticket_priority = 0; my $ticket_priority = 0;
my $ticket_owner = '';
my $ticket_description = ''; my $ticket_description = '';
my $ticket_type = ''; my $ticket_type = '';
my $ticket_inventory = ''; my $ticket_inventory = '';
@ -155,6 +157,9 @@ sub tool_api_main () {
if ($line eq '-priority') { if ($line eq '-priority') {
$ticket_priority = $ARGV[$i + 1]; $ticket_priority = $ARGV[$i + 1];
} }
if ($line eq '-owner') {
$ticket_owner = $ARGV[$i + 1];
}
if ($line eq '-desc') { if ($line eq '-desc') {
$ticket_description = $ARGV[$i + 1]; $ticket_description = $ARGV[$i + 1];
} }
@ -193,6 +198,7 @@ sub tool_api_main () {
$data_ticket = $ticket_name . $data_ticket = $ticket_name .
"|;|" . $group_id . "|;|" . $group_id .
"|;|" . $ticket_priority . "|;|" . $ticket_priority .
"|;|" . $ticket_owner .
"|;|" . $ticket_description . "|;|" . $ticket_description .
"|;|" . $ticket_inventory . "|;|" . $ticket_inventory .
"|;|" . $ticket_type . "|;|" . $ticket_type .

View File

@ -34,7 +34,7 @@ use PandoraFMS::Config;
use PandoraFMS::DB; use PandoraFMS::DB;
# version: define current version # version: define current version
my $version = "7.0NG.738 PS190920"; my $version = "7.0NG.739 PS191003";
# Pandora server configuration # Pandora server configuration
my %conf; my %conf;

View File

@ -36,7 +36,7 @@ use Encode::Locale;
Encode::Locale::decode_argv; Encode::Locale::decode_argv;
# version: define current version # version: define current version
my $version = "7.0NG.738 PS190920"; my $version = "7.0NG.739 PS191003";
# save program name for logging # save program name for logging
my $progname = basename($0); my $progname = basename($0);