Merge branch 'develop' into ent-13035-cambiar-comportamiento-del-mecanismo-de-loginhash-meta

This commit is contained in:
Daniel Cebrian 2024-04-26 12:41:08 +02:00
commit 4c485be711
151 changed files with 8464 additions and 10337 deletions

View File

@ -6,37 +6,43 @@ With more than 50,000 customer installations across the five continents, Pandora
Pandora FMS gives you the agility to find and solve problems quickly, scaling them so they can be derived from any source, on-premise, multi cloud or both of them mixed. Now you have that capability across your entire IT stack and analytics to find any problem, even the ones that are hard to find.
Thanks to more than 500 plugins available, you can control and manage any application and technology, from SAP, Oracle, Lotus, Citrix or Jboss to VMware, AWS, SQL Server, Redhat, Websphere, etc.
### Support
For community support you can visit our forums at https://pandorafms.com/community/ and if you need commercial information or/and professional support visit https://pandorafms.com
For community support you can visit our forums at https://pandorafms.com/community/
Pandora FMS has a "commercial" solution, with different features, oriented to companies that do not want to spend time using open source solutions, but closed packaged products, with periodic updates and professional support. Its name is Pandora FMS Enterprise, and you can find more information about it at https://pandorafms.com.
### How to install Pandora FMS
Installing Pandora FMS is a very easy task. Please visit our wiki and follow all the steps described for a quick and proper installation. https://pandorafms.com/manual/en/documentation/02_installation/01_installing
Installing Pandora FMS from sources is a complex task. Please visit our wiki and follow all the steps described for a proper installation. https://pandorafms.com/manual/
### What is Pandora FMS?
Pandora FMS is a monitoring application to watch systems and applications that allows to know the status of any element of the business systems. Pandora FMS watches your hardware, software, your multilayer system and, of course, your OS. Pandora FMS can detect if a network interface is down or the movement of any NASDAQ new technology market value. If you wish, Pandora FMS can send a SMS message when your system or your application fails or when Google stock value drops below 330 US\$. Pandora FMS will fit your systems and requirements, because it has been designed to be open, modular, multiplattform and easy to customize.
Pandora FMS is an open source monitoring application whose origin dates back to 2004. It integrates in the same application the monitoring of different infrastructure elements: networks, applications, servers, web, and other specific data sources such as logs, WMI, Netflow or SNMP traps.
### Other things Pandora FMS can do
It allows you to supervise systems and applications of all types, through remote monitoring or with software agents installed on the equipment to be monitored.
Pandora FMS is a monitoring tool that not only measures if a parameter is right or wrong. Pandora FMS can quantify the state (right or wrong), or store a value (numeric or alphanumeric) for months if necessary. Pandora FMS can measure performances, compare values among different systems and set alarms over thresholds. Pandora FMS works against a Database so it can generate reports, statistics, SLA and meausre anything: OS, applications and hardware systems, such as firewalls, proxies, Databases, web servers, VPN, routers, switches, processes, services, [remote accesses to servers](https://pandorafms.com/server-monitoring/), etc. Everything integrated in an open and distributed architecture. Pandora FMS can be deployed over any OS, with specific agents for each platform. There are agents for Windows (2000, XP, 2003), GNU/Linux, Solaris, HP-UX, BSD, AIX, IPSO and OpenWRT. Pandora FMS not only gathers information through its agents, but it can also monitor any hardware system with TCP/IP connectivity, such as load balancing systems, routers, switches or printers, through SNMP and TCP/ICMP checks.
Pandora FMS monitors your hardware, software, your multilayer system and, of course, your operating system. Pandora FMS can detect if a network interface is down or the movement of the market value of any new NASDAQ technology. If desired, Pandora FMS can send an SMS message when your system or application fails or when the value of Tesla's stock drops below \$180. Pandora FMS will adapt to your systems and requirements, because it has been designed to be open, modular, multiplatform and easy to customize.
Pandora FMS can be deployed over any OS, with specific agents for each platform. There are agents for Windows (2000, XP, 2003), GNU/Linux, Solaris, HP-UX, BSD, AIX, IPSO and OpenWRT. Pandora FMS not only gathers information through its agents, but it can also monitor any hardware system with TCP/IP connectivity, such as load balancing systems, routers, switches or printers, through SNMP and TCP/ICMP checks.
Pandora FMS is a monitoring tool that not only measures if a parameter is right or wrong. Pandora FMS can quantify the state (right or wrong), or store a value (numeric or alphanumeric) for months if necessary. Pandora FMS can measure performances, compare values among different systems and set alarms over thresholds. Pandora FMS works against a MySQL Database so it can generate reports, statistics, SLA and measure anything.
### Main features
- Network monitoring
- WMI monitoring
- Agent monitoring (for all OS)
- Graphical reporting, based on it's own SQL backend
- Server monitoring (using agents for Windows, Linux, Mac, BSD and legacy Unix)
- SSH/WMI remote monitorin.
- Graphical reporting, based on SQL backend
- SLA, and ITIL KPI metrics on reporting
- Status & Performance monitoring
- GIS tracking and viewing
- Inventory management (Local and remote)
- Netflow support
- Centralized log collection.
- User defined visual console screens and Dashboards WYSIWYG
- Very high capacity (Thousands of devices)
- Multiuser, several levels of ACL management.
- Multitenant, several levels of ACL management.
### Screenshots

Binary file not shown.

View File

@ -92,12 +92,10 @@ RUN dnf install -y --setopt=tsflags=nodocs \
php-yaml \
libzstd \
openldap-clients \
http://firefly.artica.es/centos8/chromium-110.0.5481.177-1.el7.x86_64.rpm \
http://firefly.artica.es/centos8/chromium-common-110.0.5481.177-1.el7.x86_64.rpm \
chromium \
http://firefly.artica.es/centos8/perl-Net-Telnet-3.04-1.el8.noarch.rpm \
http://firefly.artica.es/centos7/wmic-1.4-1.el7.x86_64.rpm \
http://firefly.artica.es/centos8/phantomjs-2.1.1-1.el7.x86_64.rpm
http://firefly.artica.es/centos7/wmic-1.4-1.el7.x86_64.rpm
RUN mkdir -p /run/php-fpm/ ; chown -R root:apache /run/php-fpm/
# Not installed perl-Net-Telnet gtk-update-icon-cach ghostscript-fonts

View File

@ -64,7 +64,7 @@ wget $oconsoleurl
wget $oserverurl
if [ "$BASEBUILD" == 1 ] ; then
docker pull centos:8
docker pull rockylinux:8
# Open Base image
echo "building Base el8 image"
cd $DOCKER_PATH/base
@ -77,11 +77,11 @@ else
fi
if [ "$DBBUILD" == 1 ] ; then
docker pull percona:5.7
docker pull percona:8.0
# Percona image
echo "building Percona image"
cd $OPEN/extras/docker/percona
docker build -t $PERCONA_IMAGE:latest -f $OPEN/extras/docker/percona/Dockerfile $OPEN/extras/docker/percona
cd $OPEN/extras/docker/percona/8.0
docker build -t $PERCONA_IMAGE:latest -f $OPEN/extras/docker/percona/8.0/Dockerfile $OPEN/extras/docker/percona/8.0/
echo -e ">>>> \n"
fi

View File

@ -8,6 +8,8 @@ services:
image: pandorafms/pandorafms-percona-base
restart: always
#command: ["mysqld", "--innodb-buffer-pool-size=900M"]
cap_add:
- SYS_NICE # CAP_SYS_NICE
environment:
MYSQL_ROOT_PASSWORD: pandora
MYSQL_DATABASE: pandora

View File

@ -0,0 +1,11 @@
#docker build -t pandorafms/pandorafms-percona-base:80 .
#docker tag pandorafms/pandorafms-percona-base:80 pandorafms/pandorafms-percona-base:latest
#docker push pandorafms/pandorafms-percona-base:80
FROM percona:8.0
ADD pandora.cnf /etc/my.cnf.d/
USER root
RUN chown mysql:mysql /etc/my.cnf.d/pandora.cnf
USER mysql
EXPOSE 3306

View File

@ -0,0 +1,20 @@
# Use root/example as user/password credentials
# este compose incluye la base de datos en otro docker y levanta aplicacion y DB juntos
version: '3.1'
services:
db:
image: pandorafms/pandorafms-percona-base:80
restart: always
command: ["mysqld", "--innodb-buffer-pool-size=1G"]
cap_add:
- SYS_NICE # CAP_SYS_NICE
environment:
MYSQL_ROOT_PASSWORD: pandora
MYSQL_DATABASE: pandora
MYSQL_USER: pandora
MYSQL_PASSWORD: pandora
networks:
- pandora
networks:
pandora:

View File

@ -0,0 +1,39 @@
# copy this file to /etc/my.cnf.d/pandora.cnf directory inside the container to set the onfiguration
[mysqld]
datadir=/var/lib/mysql
user=mysql
character-set-server=utf8mb4
skip-character-set-client-handshake
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Mysql optimizations for Pandora FMS
# Please check the documentation in http://pandorafms.com for better results
max_allowed_packet = 64M
innodb_lock_wait_timeout = 90
innodb_file_per_table
innodb_flush_log_at_trx_commit = 0
innodb_flush_method = O_DIRECT
innodb_log_file_size = 64M
innodb_log_buffer_size = 16M
innodb_io_capacity = 300
thread_cache_size = 8
thread_stack = 256K
max_connections = 100
key_buffer_size=4M
read_buffer_size=128K
read_rnd_buffer_size=128K
sort_buffer_size=128K
join_buffer_size=4M
# legacy compatibility
default_authentication_plugin=mysql_native_password
log_error_suppression_list='MY-013360'
skip-log-bin
sql_mode=""

View File

@ -0,0 +1,6 @@
docker run --name pandora-percona \
-e MYSQL_ROOT_PASSWORD=pandora \
-e MYSQL_DATABASE=pandora \
-e MYSQL_USER=pandora \
-e MYSQL_PASSWORD=pandora \
-d pandora_percona:80

View File

@ -1,33 +0,0 @@
###########################################
### SMTP DATA
###########################################
smtp_user devtest@artica.es
smtp_pass pass1212
smtp_hostname mail.artica.es
###########################################
### POP3 DATA
###########################################
pop3_user devtest@artica.es
pop3_pass pass1212
pop3_hostname mail.artica.es
# Enable or disable SSL. 1 means Enabled, 0 Disabled
pop3_ssl 0
# SSL port
pop3_ssl_port 995
###########################################
### TO SEND INFO
###########################################
# Email receiver where to send the email
receiver_email devtest@artica.es
###########################################
### PATH TO SAVE THE ATTACHED FILE
###########################################
# Desired path where the attached file will be stored
pathtosave /tmp/

View File

@ -1,318 +0,0 @@
#!/usr/bin/perl
##########################################################################
# Pandora FMS Mail Transfer
# This is a tool for transfering Pandora FMS data files by mail (SMTP/POP)
##########################################################################
# Copyright (c) 2011-2023 Pandora FMS
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; version 2
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
##########################################################################
use strict;
use warnings;
use Net::SMTP;
use Mail::POP3Client;
use MIME::Parser;
$| = 1;
# GLOBAL VARIABLES
my $boundary='frontier';
####### FUNCTIONS #######
########################################################################
## SUB check_args
## Checks the command line arguments given at the function call.
########################################################################
sub check_args(){
my $num_args = $#ARGV + 1;
my $action = $ARGV[0];
my $conf_file = $ARGV[1];
my $filename = $ARGV[2];
my $error = "Usage: mail_transfer.pl {send|receive conf_file [FILE]}\n";
my $error_conf_file = "conf_file does not exist or is not readable\n";
my $error_filename = "File to send does not exist or is not readable\n";
if (($num_args < 2) || (($action ne "send") && ($action ne "receive"))) {
die $error;
} elsif ((!(-e $conf_file)) || (!(-r $conf_file))) {
die $error_conf_file;
} elsif (($action eq "send") && ((!(-e $filename)) || (!(-r $filename)))) {
die $error_filename;
}
}
########################################################################
## SUB parse_conf
## Reads the entire conf file and stores all the information given
########################################################################
sub parse_conf ($$) {
my $conf_file = $_[0];
my $conf_hash = $_[1];
open (CONF, $conf_file);
my $line;
while (<CONF>)
{
$line = $_;
# Get the smtp user
if ($line =~ /^smtp_user\s([a-zA-Z0-9\.\_\-\@]+)/) {
$conf_hash -> {smtp_user} = $1;
}
# Get the smtp pass
elsif ($line =~ /^smtp_pass\s(.+)/) {
$conf_hash -> {smtp_pass} = $1;
}
# Get the smtp hostname
elsif ($line =~ /^smtp_hostname\s([a-zA-Z0-9\.\_\-\@]+)/) {
$conf_hash -> {smtp_hostname} = $1;
}
# Get the pop3 user
elsif ($line =~ /^pop3_user\s([a-zA-Z0-9\.\_\-\@]+)/) {
$conf_hash -> {pop3_user} = $1;
}
# Get the pop3 pass
elsif ($line =~ /^pop3_pass\s(.+)/) {
$conf_hash -> {pop3_pass} = $1;
}
# Get the pop3 hostname
elsif ($line =~ /^pop3_hostname\s([a-zA-Z0-9\.\_\-\@]+)/) {
$conf_hash -> {pop3_hostname} = $1;
}
# Get the pop3 ssl flag to know if it's enabled or not
elsif ($line =~ /^pop3_ssl\s(0|1)/) {
$conf_hash -> {pop3_ssl} = $1;
}
# Get the pop3 ssl port
elsif ($line =~ /^pop3_ssl_port\s([0-9]{1,5})/) {
$conf_hash -> {pop3_ssl_port} = $1;
}
# Get the path where to save the attached file
elsif ($line =~ /^pathtosave\s(.+)/) {
$conf_hash -> {pathtosave} = $1;
}
# Get the receiver's email where to send the attached file
elsif ($line =~ /^receiver_email\s([a-zA-Z0-9\.\_\-\@]+)/) {
$conf_hash -> {receiver_email} = $1;
}
}
close CONF;
}
########################################################################
## SUB send_mail
## Sends an attachement file via email using smtp
########################################################################
sub send_mail($) {
my $conf_hash = $_[0];
my $smtp;
my $attachment = $conf_hash -> {filename};
# Get the filename in case the full path was given
# Split the full path with '/', the last item will be the filename
my @file_path = split ('/', $attachment);
# Get the array's last position with '-1' index
my $attach_file = $file_path[-1];
my $host = $conf_hash -> {smtp_hostname};
my $from = $conf_hash -> {smtp_user};
my $password = $conf_hash -> {smtp_pass};
my $to = $conf_hash -> {receiver_email};
open(DATA, $attachment) || die("mail_transfer.pl: ERROR: Could not open the file $attach_file");
my @xml = <DATA>;
close(DATA);
$smtp = Net::SMTP->new($host,
Hello => $host,
Timeout => 30,
Debug => 0,
) || die("mail_trasfer.pl: ERROR: Could not connect to $host");
$smtp->auth($from, $password);
$smtp->mail($from);
$smtp->to($to);
$smtp->data();
$smtp->datasend("To: $to\n");
$smtp->datasend("From: $from\n");
$smtp->datasend("Subject: Pandora mail transfer\n");
$smtp->datasend("MIME-Version: 1.0\n");
$smtp->datasend("Content-Type: application/text; name=" . $attach_file . "\n");
$smtp->datasend("Content-Disposition: attachment; filename=" . $attach_file . "\n");
$smtp->datasend("Content-type: multipart/mixed boundary=" . $boundary . "\n");
$smtp->datasend("\n");
$smtp->datasend("@xml\n");
$smtp->dataend() || print "mail_transfer.pl: ERROR: Data end failed: $!";
$smtp->quit;
}
########################################################################
## SUB receive_mail
## Fetch the last email with 'Pandora mail transfer' as subject and
## download the attached file into the specified folder
########################################################################
sub receive_mail ($) {
my $conf_hash = $_[0];
my $user = $conf_hash -> {pop3_user};
my $password = $conf_hash -> {pop3_pass};
my $host = $conf_hash -> {pop3_hostname};
my $ssl = $conf_hash -> {pop3_ssl};
my $ssl_port = $conf_hash -> {pop3_ssl_port};
my $pathtosave = $conf_hash -> {pathtosave};
my $pop3;
if ($ssl == 1){
$pop3 = new Mail::POP3Client(
USER => $user,
PASSWORD => $password,
HOST => $host,
USESSL => 1,
PORT => $ssl_port,
DEBUG => 0
) or die "mail_transfer.pl: Connection failed\n";
} else {
$pop3 = new Mail::POP3Client(
USER => $user,
PASSWORD => $password,
HOST => $host,
USESSL => 0,
PORT => 110,
DEBUG => 0
) or die "mail_transfer.pl: Connection failed\n";
}
my $tot_msg = $pop3->Count();
if ($tot_msg == 0){
print "No more emails avalaible\n";
return (0); # End program
}
elsif ($tot_msg eq '0E0'){
print "No new emails available\n";
return (0);
}
else{
printf "There are $tot_msg messages \n\n";
}
# the list of valid file extensions. we do extensions, not
# mime-types, because they're easier to understand from
# an end-user perspective (no research is required).
my $valid_exts = "txt xml data";
my %msg_ids; # used to keep track of seen emails.
# create a subdirectory if does not exist
#print "Using directory '$pathtosave' for newly downloaded files.\n";
if (!(-d $pathtosave)) {
mkdir($pathtosave, 0777) or die "mail_transfer.pl: Error creating output directory\n";
}
# get the message to feed to MIME::Parser.
my $msg = $pop3->HeadAndBody($tot_msg);
my $header = $pop3->Head($tot_msg);
if (($header !~ /Subject:\sPandora\smail\stransfer/) || ($header !~ /boundary=$boundary/)) {
print "Deleting message not valid\n";
# delete current email
$pop3->Delete($tot_msg);
# clean up and close the connection.
$pop3->Close;
return -1;
}
# create a MIME::Parser object to
# extract any attachments found within.
my $parser = new MIME::Parser;
$parser->output_dir($pathtosave);
my $entity = $parser->parse_data($msg);
# extract our mime parts and go through each one.
my @parts = $entity->parts;
foreach my $part (@parts) {
# determine the path to the file in question.
my $path = ($part->bodyhandle) ? $part->bodyhandle->path : undef;
# move on if it's not defined,
# else figure out the extension.
next unless $path;
$path =~ /\w+\.([^.]+)$/;
my $ext = $1;
next unless $ext;
# we continue only if our extension is correct.
my $continue; $continue++ if $valid_exts =~ /$ext/i;
# delete the blasted thing.
unless ($valid_exts =~ /$ext/) {
print " Removing unwanted filetype ($ext): $path\n";
unlink $path or print " > Error removing file at $path: $!.";
next; # move on to the next attachment or message.
}
# a valid file type. yummy!
print " Keeping valid file: $path.\n";
}
# delete current email
$pop3->Delete($tot_msg);
# clean up and close the connection.
$pop3->Close;
}
####### MAIN #######
# Check the given command line arguments
check_args();
# Once checked store them
my $action = $ARGV[0];
my $conf_file = $ARGV[1];
my $filename = $ARGV[2];
# If the action is 'send', store the 'file_to_send'
my %conf_hash;
if ($action eq "send") {
$conf_hash {filename} = $filename;
}
# Parse the config file
parse_conf($conf_file, \%conf_hash);
# Call 'send_mail' function in its case
if ($action eq "send") {
send_mail(\%conf_hash);
}
# Or call the 'receive_mail' function.
my $returncode = 1;
if ($action eq "receive") {
while ($returncode != 0) {
$returncode = receive_mail(\%conf_hash);
}
}

View File

@ -1,106 +0,0 @@
Pandora Mail Transfer
======================
1st Edition , 3 May 2011
(c) Pandora FMS 2005-2023
(c) Juan Manuel Ramon <juanma@artica.es>
(c) Javier Lanz <javier.lanz@artica.es>
Description
-----------
Pandora Mail Transfer is a tool for sending and receiving xml files via email.
This script sends through a SMTP server, to the desired address, an email with an attached file.
Is able as well to fetch via POP3 that mail and its attached file.
It's designed to be used with an specific email account, so every time the script is called in “receive” mode, all emails on that account will be deleted. Do not use this script in a personal account because all your emails will be deleted.
This script is designed to send only text files, no binary files.
It's only possible to send .data, .txt, or .xml files.
Requisites
----------
In order to be able to use this application, it's a must having the following Perl's CPAN packages installed in your system:
Mail::POP3Client
MIME::Parser
Authen::SASL
Net::SMTP;
To install these libraries with CPAN, for example Mail::POP3Client:
cpan install Mail::POP3Client
To use the program under Windows, you will need to compile with a compiler like ActiveState PERL. The ActiveState environment allows as well to install CPAN modules easily.
Previous the script execution, it's a must having a configuration file, in which the mail server connection parameters will be defined.
Below it's shown a configuration file example, in which the necessary fields for the proper use of the mail transfer script are detailed.
Sample configuration file
-------------------------
###########################################
### SMTP DATA
###########################################
smtp_user username@domain.com
smtp_pass pass
smtp_hostname mailserver.domain.com
###########################################
### POP3 DATA
###########################################
pop3_user username@domain.com
pop3_pass pass
pop3_hostname mailserver.domain.com
# Enable or disable SSL. 1 means Enabled , 0 Disabled
pop3_ssl 0
# SSL port
pop3_ssl_port 995
###########################################
### TO SEND INFO
###########################################
# Email receiver where to send the email
receiver_email desired.mail@domain.com
###########################################
### PATH TO SAVE THE ATTACHED FILE
###########################################
# Desired path where the attached file will be stored
pathtosave /path/to/save/attached
Pandora mail transfer execution
-------------------------------
The proper way of executing the script should be according to...
./mail_transfer <action> <conf_file> [file_to_send]
Where the meaning of the fields are:
<action> could be 'send' or 'receive'
<conf_file> configuration file, explained above, contains every necessary data for sending and receiving emails.
[file_to_send] desired xml file to send (Only necessary in case of action = 'send')
Execution examples:
./mail_transfer send config_file.conf textfile.txt
./mail_transfer receive config_file.conf
Restrictions
------------
SSL Protocol
In this first version, SSL protocol is only implemented for the mail reception, not for sending.
Another related SSL Protocol restriction is the email erasing once read and downloaded to disk. In case of using SSL, deleting is not possible, on the other hand, if it's not used, the read mail will be properly deleted from the server once download to disk.
Attached file
There is a wee bug not fixed yet about the attached file name. If this one contains special characters such as '(' ')' '\' and more, while downloading from the server, it will be saved to disk with a different file name, probably wrong, although its content will be the right one. Thus, it's recommended not to use special characters in the file name.

View File

@ -1,664 +0,0 @@
#!/usr/bin/perl
# Pandora FMS Agent Plugin for SunONE
# (c) Pandora FMS <info@pandorafms.com> 2011
# v2, 1 Sep 2011
# ------------------------------------------------------------------------
use strict;
use warnings;
use IO::Socket::INET;
# OS and OS version
my $OS = $^O;
# Load on Win32 only
if ($OS eq "MSWin32"){
# Check dependencies
eval 'local $SIG{__DIE__}; use Win32::OLE("in");';
if ($@) {
print "Error loading Win32::Ole library. Cannot continue\n";
exit;
}
use constant wbemFlagReturnImmediately => 0x10;
use constant wbemFlagForwardOnly => 0x20;
}
my %plugin_setup; # This stores plugin parameters
my $archivo_cfg = $ARGV[0];
my $volume_items = 0;
my $log_items = 0;
my $webcheck_items = 0;
my $process_items = 0;
# FLUSH in each IO
$| = 1;
# ----------------------------------------------------------------------------
# This cleans DOS-like line and cleans ^M character. VERY Important when you process .conf edited from DOS
# ----------------------------------------------------------------------------
sub parse_dosline ($){
my $str = $_[0];
$str =~ s/\r//g;
return $str;
}
# ----------------------------------------------------------------------------
# Strips blank likes
# ----------------------------------------------------------------------------
sub trim ($){
my $string = shift;
$string =~ s/^\s+//;
$string =~ s/\s+$//;
return $string;
}
# ----------------------------------------------------------------------------
# clean_blank
#
# This function return a string without blankspaces, given a simple text string
# ----------------------------------------------------------------------------
sub clean_blank($){
my $input = $_[0];
$input =~ s/[\s\r\n]*//g;
return $input;
}
# ----------------------------------------------------------------------------
# print_module
#
# This function return a pandora FMS valid module fiven name, type, value, description
# ----------------------------------------------------------------------------
sub print_module ($$$$){
my $MODULE_NAME = $_[0];
my $MODULE_TYPE = $_[1];
my $MODULE_VALUE = $_[2];
my $MODULE_DESC = $_[3];
# If not a string type, remove all blank spaces!
if ($MODULE_TYPE !~ m/string/){
$MODULE_VALUE = clean_blank($MODULE_VALUE);
}
print "<module>\n";
print "<name>$MODULE_NAME</name>\n";
print "<type>$MODULE_TYPE</type>\n";
print "<data><![CDATA[$MODULE_VALUE]]></data>\n";
print "<description><![CDATA[$MODULE_DESC]]></description>\n";
print "</module>\n";
}
# ----------------------------------------------------------------------------
# load_external_setup
#
# Load external file containing configuration
# ----------------------------------------------------------------------------
sub load_external_setup ($); # Declaration due a recursive call to itself on includes
sub load_external_setup ($){
my $archivo_cfg = $_[0];
my $buffer_line;
my @config_file;
my $parametro = "";
# Collect items from config file and put in an array
if (! open (CFG, "< $archivo_cfg")) {
print "[ERROR] Error opening configuration file $archivo_cfg: $!.\n";
exit 1;
}
while (<CFG>){
$buffer_line = parse_dosline ($_);
# Parse configuration file, this is specially difficult because can contain SQL code, with many things
if ($buffer_line !~ /^\#/){ # begins with anything except # (for commenting)
if ($buffer_line =~ m/(.+)\s(.*)/){
push @config_file, $buffer_line;
}
}
}
close (CFG);
# Some plugin setup default options
$plugin_setup{"logparser"}="/etc/pandora/plugins/grep_log";
$plugin_setup{"timeout"} = 5;
$plugin_setup{"apache_stats"} = "";
foreach (@config_file){
$parametro = $_;
if ($parametro =~ m/^include\s(.*)/i) {
load_external_setup ($1);
}
if ($parametro =~ m/^logparser\s(.*)/i) {
$plugin_setup{"logparser"}=$1;
}
if ($parametro =~ m/^timeout\s(.*)/i) {
$plugin_setup{"timeout"}=clean_blank($1);
}
# Log check
if ($parametro =~ m/^log\s(.*)/i) {
$plugin_setup{"log"}->[$log_items]=$1;
$log_items++;
}
# Volume check
if ($parametro =~ m/^volume\s(.*)/i) {
$plugin_setup{"volume"}->[$volume_items]=$1;
$volume_items++;
}
# Webcheck
if ($parametro =~ m/^webcheck\s(.*)/i) {
$plugin_setup{"webcheck"}->[$webcheck_items]=$1;
$webcheck_items++;
}
# Processcheck
if ($parametro =~ m/^process\s(.*)/i) {
$plugin_setup{"process"}->[$process_items]=$1;
$process_items++;
}
# Apachestats
if ($parametro =~ m/^apache_stats\s(.*)/i) {
$plugin_setup{"apache_stats"}=$1;
}
}
}
# ----------------------------------------------------------------------------
# http_check
#
# This function recives something like 0.0.0.0:80 / 200 OK
# to check a HTTP response, given Host:PORT, URL and Search string
# Return 0 if not, and 1 if found
# ----------------------------------------------------------------------------
sub http_check ($$$$$){
my $name = $_[0];
my $host = $_[1];
my $port = $_[2];
my $query_string = $_[3];
my $search_string = $_[4];
my $tcp_send = "GET $query_string HTTP/1.0\n\n";
my $temp; my $match = 0;
my $sock = new IO::Socket::INET (
PeerAddr => $host,
PeerPort => $port,
Proto => 'tcp',
Timeout=> $plugin_setup{"timeout"},
Blocking=>1 ); # Non block gives non-accurate results. We need to be SURE about this results :(
if (!$sock){
print_module("web_$name", "generic_proc", 0, "HTTP Check on $host for $query_string");
return;
}
# Send data
$sock->autoflush(1);
$tcp_send =~ s/\^M/\r\n/g;
# Replace Carriage return and line feed
print $sock $tcp_send;
my @buffer = <$sock>;
# Search on buffer
foreach (@buffer) {
if ($_ =~ /$search_string/){
$match = 1;
last;
}
}
$sock->close;
print_module ("web_$name", "generic_proc", $match, "HTTP Check on $host for $query_string");
return;
}
# ----------------------------------------------------------------------------
# apache_stats
#
# This function uses mod_status from apache to get information
# Given Instance, Host:PORT, URL (usually should be /server-status)
# ----------------------------------------------------------------------------
sub apache_stats ($$$$){
my $name = $_[0];
my $host = $_[1];
my $port = $_[2];
my $query_string = $_[3];
if ($query_string eq ""){
$query_string = "/";
}
my $tcp_send = "GET $query_string HTTP/1.0\n\n";
my $temp; my $match = 0;
# First at all, check response on apache (200 OK)
http_check ("Apache_Status_$name", $host, $port, $query_string, "200 OK");
my $sock = new IO::Socket::INET (
PeerAddr => $host,
PeerPort => $port,
Proto => 'tcp',
Timeout=> $plugin_setup{"timeout"},
Blocking=>1 ); # Non block gives non-accurate results. We need to be SURE about this results :(
if (!$sock){
return;
}
# Send data
$sock->autoflush(1);
$tcp_send =~ s/\^M/\r\n/g;
# Replace Carriage return and line feed
print $sock $tcp_send;
my @buffer = <$sock>;
# Search on buffer
foreach (@buffer) {
if ($_ =~ /Restart Time: ([aA-zZ]+\,\s[0-9]{2}\-[aA-zZ]{3}\-[0-9]{4}\s[0-9]{2}\:[0-9]{2}\:[0-9]{2}\s[aA-zZ]+)/ ) {
print_module ("apache_restart_time_$name", "generic_data_string", $1, "" );
}
if ($_ =~ /Server uptime: ([aA-zZ 0-9]+)/) {
print_module ("apache_server_uptime_$name", "generic_data_string", $1, "" );
}
if ($_ =~ /Total accesses: ([0-9]+)/ ) {
print_module ("apache_accesses_$name", "generic_data_inc", $1, "" );
}
if ($_ =~ /Total Traffic: ([0-9]+)/ ) {
print_module ("apache_total_traffic_$name", "generic_data_inc", $1, "" );
}
if ($_ =~ /([0-9]+\.[0-9]+)\%\sCPU\sload/ ){
print_module ("apache_CPU_Load_$name", "generic_data", $1, "" );
}
if ($_ =~ /CPU Usage\: u([\.0-9]*)/ ){
print_module ("apache_CPU_User_Load_$name", "generic_data", $1, "" );
}
if ($_ =~ /CPU Usage\: u[\.0-9]* s([\.0-9]*)/ ){
print_module ("apache_CPU_System_Load_$name", "generic_data", $1, "" );
}
if ($_ =~ /([\.0-9]+)\srequests\/sec/){
print_module ("apache_Req/Sec_$name", "generic_data", $1, "" );
}
if ($_ =~ /([0-9]+)\sB\/second/) {
print_module ("apache_B/Sec_$name", "generic_data_inc", $1, "" );
}
if ($_ =~ /([0-9]+)\skB\/request/) {
print_module ("apache_KB/Request_$name", "generic_data_inc", $1, "" );
}
if ($_ =~ /([0-9]+)\srequests\scurrently/) {
print_module ("apache_request_currently_$name", "generic_data", $1, "" );
}
if ($_ =~ /([0-9]+)\sidle\sworkers/) {
print_module ("apache_idle_workers_$name", "generic_data", $1, "" );
}
}
$sock->close;
return;
}
# ----------------------------------------------------------------------------
# alert_log
#
# Do a call to alertlog plugin and output the result
# Receives logfile, and module name
# ----------------------------------------------------------------------------
sub alert_log($$$){
my $alertlog = $_[0];
my $module_name = $_[1];
my $log_expression = $_[2];
my $plugin_call = "";
# Call to logparser
if ($OS eq "MSWin32") {
$plugin_call = $plugin_setup{"logparser"}. " $alertlog $module_name $log_expression";
} else {
$plugin_call = $plugin_setup{"logparser"}. " $alertlog $module_name $log_expression 2> /dev/null";
}
my $output = `$plugin_call`;
if ($output ne ""){
print $output;
} else {
print_module($module_name, "async_string", "", "Alertlog for $alertlog ($log_expression)");
}
}
# ----------------------------------------------------------------------------
# spare_system_disk_win
#
# This function return % free disk on Windows, using WMI call
# ----------------------------------------------------------------------------
sub spare_system_disk_win ($$){
my $name = $_[0];
my $volume = $_[1];
my $computer = "localhost";
my $objWMIService = Win32::OLE->GetObject("winmgmts:\\\\$computer\\root\\CIMV2") or return;
my $colItems = $objWMIService->ExecQuery("SELECT * from CIM_LogicalDisk WHERE Name = '$volume'", "WQL", wbemFlagReturnImmediately | wbemFlagForwardOnly);
foreach my $objItem (in $colItems) {
my $data = ($objItem->{"FreeSpace"} / $objItem->{"Size"}) * 100;
print_module("Volume_$volume" . "_" . "$name", "generic_data", "$data", "Free disk on $volume");
return;
}
}
# ----------------------------------------------------------------------------
# spare_system_disk
#
# Check free space on volume
# Receives volume name and instance
# ----------------------------------------------------------------------------
sub spare_system_disk ($$) {
my $name = $_[0];
my $vol = $_[1];
if ($vol eq ""){
return;
}
# This is a posix call, should be the same on all systems !
my $output = `df -kP | grep "$vol\$" | awk '{ print \$5 }' | tr -d "%"`;
my $disk_space = 100 - $output;
print_module("Volume_$vol" . "_" . "$name", "generic_data", $disk_space, "% of volume free");
}
# ----------------------------------------------------------------------------
# process_status_unix
#
# Generates a pandora module about the running status of a given process
# ----------------------------------------------------------------------------
sub process_status_unix ($$){
my $proc = $_[0];
my $proc_name = $_[1];
if ($proc eq ""){
return;
}
my $data = trim (`ps aux | grep "$proc" | grep -v grep | wc -l`);
print_module("Process_$proc_name", "generic_proc", $data, "Status of process $proc");
}
# ----------------------------------------------------------------------------
# process_status_win
#
# Generates a pandora module about the running status of a given process
# ----------------------------------------------------------------------------
sub process_status_win ($$){
my $proc = $_[0];
my $proc_name = $_[1];
if ($proc eq ""){
return;
}
my $computer = "localhost";
my $objWMIService = Win32::OLE->GetObject("winmgmts:\\\\$computer\\root\\CIMV2") or return;
my $colItems = $objWMIService->ExecQuery("SELECT * FROM Win32_Process WHERE Caption = '$proc'", "WQL", wbemFlagReturnImmediately | wbemFlagForwardOnly);
foreach my $objItem (in $colItems) {
if ($objItem->{"Caption"} eq $proc){
print_module("Process_$proc_name", "generic_proc", 1, "Status of process $proc");
return;
} else {
print_module("Process_$proc_name", "generic_proc", 0, "Status of process $proc");
return;
}
}
# no matches, process is not running
print_module("Process_$proc_name", "generic_proc", 0, "Status of process $proc");
}
# ----------------------------------------------------------------------------
# process_mem_win
#
# Generates a Pandora FMS about memory usage of a given process "pepito.exe"
# only works with EXACT names.
# ----------------------------------------------------------------------------
sub process_mem_win ($$){
my $proc = $_[0];
my $proc_name = $_[1];
if ($proc eq ""){
return;
}
my $computer = "localhost";
my $objWMIService = Win32::OLE->GetObject("winmgmts:\\\\$computer\\root\\CIMV2") or return;
my $colItems = $objWMIService->ExecQuery("SELECT * FROM Win32_Process WHERE Caption = '$proc'", "WQL", wbemFlagReturnImmediately | wbemFlagForwardOnly);
foreach my $objItem (in $colItems) {
if ($objItem->{"Caption"} eq $proc){
print_module("Process_MEM_$proc_name", "generic_data", $objItem->{"WorkingSetSize"}, "Memory in bytes of process $proc");
} else {
return;
}
}
}
# ----------------------------------------------------------------------------
# process_mem_unix
#
# Generates a Pandora FMS about memory usage of a given process
# ----------------------------------------------------------------------------
sub process_mem_unix ($$){
my $vol = $_[0];
my $proc_name = $_[1];
if ($vol eq ""){
return;
}
my $data = `ps aux | grep "$vol" | grep -v grep | awk '{ print \$6 }'`;
my @data2 = split ("\n", $data),
my $tot = 0;
foreach (@data2){
$tot = $tot + $_;
}
print_module("Proc_MEM_$proc_name", "generic_data", $tot, "Memory used (in bytes) for process $vol");
}
# ----------------------------------------------------------------------------
# process_cpu_unix
#
# Generates a Pandora FMS about memory usage of a given process
# ----------------------------------------------------------------------------
sub process_cpu_unix ($$) {
my $vol = $_[0];
my $proc_name = $_[1];
if ($vol eq ""){
return;
}
my $data = `ps aux | grep "$vol" | grep -v grep | awk '{ print \$3 }'`;
my @data2 = split ("\n", $data),
my $tot = 0;
foreach (@data2){
$tot = $tot + $_;
}
print_module("Proc_CPU_$proc_name", "generic_data", $tot, "CPU (%) used for process $vol");
}
#--------------------------------------------------------------------------------
#--------------------------------------------------------------------------------
# MAIN PROGRAM
# -------------------------------------------------------------------------------
#--------------------------------------------------------------------------------
# Parse external configuration file
# Load config file from command line
if ($#ARGV == -1 ){
print "I need at least one parameter: Complete path to external configuration file \n";
exit;
}
# Check for file
if ( ! -f $archivo_cfg ) {
printf "\n [ERROR] Cannot open configuration file at $archivo_cfg. \n\n";
exit 1;
}
load_external_setup ($archivo_cfg);
# Check for logparser, if not ready, skip all log check
if ( ! -f $plugin_setup{"logparser"} ) {
# Create a dummy check module with and advise warning
if ($log_items > 0) {
print_module("Error: Log parser not found", "async_string", 0, "Log parser not found, please check your configuration file and set it");
}
$log_items =0;
}
# Webchecks
if ($webcheck_items > 0){
my $ax;
for ($ax=0; $ax < $webcheck_items; $ax++){
my ($name, $host, $port, $url, $string) = split (";",$plugin_setup{"webcheck"}[$ax]);
http_check ($name, $host, $port, $url, $string);
}
}
# Check individual defined volumes
if ($volume_items > 0){
my $ax;
for ($ax=0; $ax < $volume_items; $ax++){
my ($name, $volume) = split (";",$plugin_setup{"volume"}[$ax]);
if ($OS eq "MSWin32"){
spare_system_disk_win ($name, $volume);
} else {
spare_system_disk ($name, $volume);
}
}
}
# Check individual defined logs
if ($log_items > 0){
my $ax;
for ($ax=0; $ax < $log_items; $ax++){
my ($logfile, $name, $expression) = split (";",$plugin_setup{"log"}[$ax]);
# Verify proper valid values here or skip
if (!defined($logfile)){
next;
}
if (!defined($name)){
next;
}
if (!defined($expression)){
next;
}
alert_log ($logfile, $name, $expression);
}
}
# Check individual defined process
if ($process_items > 0){
my $ax;
for ($ax=0; $ax < $process_items; $ax++){
my ($name, $process) = split (";",$plugin_setup{"process"}[$ax]);
if ($OS eq "MSWin32") {
process_status_win ($process, $name);
process_mem_win ($process, $name);
} else {
process_status_unix ($process, $name);
process_mem_unix ($process, $name);
process_cpu_unix ($process, $name);
}
}
}
# Apache stats
if ($plugin_setup{"apache_stats"} ne "") {
my ($name, $host, $port, $url) = split (";",$plugin_setup{"apache_stats"});
apache_stats ($name, $host, $port, $url);
}

View File

@ -311,4 +311,4 @@ module_plugin pandora_df
#module_type log
#module_regexp /var/log/messages
#module_pattern .*
#module_end
#module_end

View File

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

View File

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

View File

@ -1039,7 +1039,7 @@ my $Sem = undef;
my $ThreadSem = undef;
use constant AGENT_VERSION => '7.0NG.776';
use constant AGENT_BUILD => '240415';
use constant AGENT_BUILD => '240426';
# Agent log default file size maximum and instances
use constant DEFAULT_MAX_LOG_SIZE => 600000;

View File

@ -4,7 +4,7 @@
%global __os_install_post %{nil}
%define name pandorafms_agent_linux
%define version 7.0NG.776
%define release 240415
%define release 240426
Summary: Pandora FMS Linux agent, PERL version
Name: %{name}

View File

@ -5,7 +5,7 @@
%define name pandorafms_agent_linux_bin
%define source_name pandorafms_agent_linux
%define version 7.0NG.776
%define release 240415
%define release 240426
%define debug_package %{nil}
Summary: Pandora FMS Linux agent, binary version

View File

@ -5,7 +5,7 @@
%define name pandorafms_agent_linux_bin
%define source_name pandorafms_agent_linux
%define version 7.0NG.776
%define release 240415
%define release 240426
%define debug_package %{nil}
Summary: Pandora FMS Linux agent, binary version

View File

@ -5,7 +5,7 @@
%define name pandorafms_agent_linux_bin
%define source_name pandorafms_agent_linux
%define version 7.0NG.776
%define release 240415
%define release 240426
Summary: Pandora FMS Linux agent, binary version
Name: %{name}

View File

@ -4,7 +4,7 @@
%global __os_install_post %{nil}
%define name pandorafms_agent_linux
%define version 7.0NG.776
%define release 240415
%define release 240426
Summary: Pandora FMS Linux agent, PERL version
Name: %{name}

View File

@ -10,7 +10,7 @@
# **********************************************************************
PI_VERSION="7.0NG.776"
PI_BUILD="240415"
PI_BUILD="240426"
OS_NAME=`uname -s`
FORCE=0

11
pandora_agents/unix/plugins/autodiscover Normal file → Executable file
View File

@ -22,12 +22,19 @@ try:
from subprocess import PIPE
from subprocess import DEVNULL
from subprocess import getstatusoutput
import signal
except ModuleNotFoundError as err:
print("{} error: {}. Exiting...".format(argv[0], err), file=stderr)
exit(1)
module_list = []
VERSION = "1.2"
VERSION = "1.3"
# Define a function to handle the SIGTERM signal
def sigterm_handler(signum, frame):
print("Received SIGTERM signal. Cleaning up...")
sys.exit(0)
signal.signal(signal.SIGTERM, sigterm_handler)
def win_service(servicelist, option=False, memcpu=False):
@ -74,7 +81,7 @@ def win_service(servicelist, option=False, memcpu=False):
def lnx_service(services_list, memcpu=False):
"""Creates modules for Linux servers"""
modules = []
sysctl = getstatusoutput("command -v systemctl")[0]
sysctl = getstatusoutput("systemd-notify --booted")[0]
servic = getstatusoutput("command -v service")[0]
for srvc in services_list:
status = None

View File

@ -186,7 +186,7 @@ UpgradeApplicationID
{}
Version
{240415}
{240426}
ViewReadme
{Yes}

View File

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

View File

@ -11,7 +11,7 @@ BEGIN
VALUE "LegalCopyright", "Pandora FMS"
VALUE "OriginalFilename", "PandoraAgent.exe"
VALUE "ProductName", "Pandora FMS Windows Agent"
VALUE "ProductVersion", "(7.0NG.776(Build 240415))"
VALUE "ProductVersion", "(7.0NG.776(Build 240426))"
VALUE "FileVersion", "1.0.0.0"
END
END

View File

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

View File

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

View File

@ -2,7 +2,7 @@
"openapi": "3.0.0",
"info": {
"title": "API Pandora FMS",
"description": "<p>This is the new API framework for Pandora FMS.</p>\n<p>The old API is deprecated but still functional, and not all old endpoints are supported in the new API, but new endpoints will be added in each release.</p>\n<p>Using this web interface, you can play around and see how it works each endpoint interactively.</p>\n\nMore useful links:\n\n* <a target='_blank' href='https://pandorafms.com/en/pandora-fms-license-2024_en/'>Pandora FMS Licence </a>\n* <a target='_blank' href='https://support.pandorafms.com'> Pandora FMS Official Support </a>\n* <a target='_blank' href='https://pandorafms.com/en/community/'> Pandora FMS Community </a>\n* <a target='_blank' href='https://pandorafms.com/en/security/vulnerability-disclosure-policy/'> Vulnerability Disclosure Policy </a>\n* <a target='_blank' href='https://pandorafms.com/en/faq/'> Pandora FMS FAQ </a>",
"description": "<p>This is the new API framework for Pandora FMS.</p>\n<p>The old API is deprecated but still functional, and not all old endpoints are supported in the new API, but new endpoints will be added in each release.</p>\n<p>Using this web interface, you can play around and see how it works each endpoint interactively.</p>\n\nMore useful links:\n\n * <a target='_blank' href='https://pandorafms.com/en/pandora-fms-license-2024_en/'>Pandora FMS Licence </a>\n * <a target='_blank' href='https://support.pandorafms.com'> Pandora FMS Official Support </a>\n * <a target='_blank' href='https://pandorafms.com/en/community/'> Pandora FMS Community </a>\n * <a target='_blank' href='https://pandorafms.com/en/security/vulnerability-disclosure-policy/'> Vulnerability Disclosure Policy </a>\n * <a target='_blank' href='https://pandorafms.com/en/faq/'> Pandora FMS FAQ </a>",
"version": "0.0.1"
},
"servers": [
@ -1791,6 +1791,46 @@
]
}
},
"/user/{idUser}/login": {
"get": {
"tags": ["Users"],
"summary": "show user when login process",
"operationId": "1b50ee1984a43d87d69342174571775c",
"parameters": [
{
"$ref": "#/components/parameters/parameterIdUser"
},
{
"$ref": "#/components/parameters/parameterIdUserPass"
}
],
"responses": {
"200": {
"$ref": "#/components/responses/ResponseUser"
},
"400": {
"$ref": "#/components/responses/BadRequest"
},
"401": {
"$ref": "#/components/responses/Unauthorized"
},
"403": {
"$ref": "#/components/responses/Forbidden"
},
"404": {
"$ref": "#/components/responses/NotFound"
},
"500": {
"$ref": "#/components/responses/InternalServerError"
}
},
"security": [
{
"bearerAuth": []
}
]
}
},
"/user/list": {
"post": {
"tags": ["Users"],
@ -4038,6 +4078,16 @@
"default": 1
}
},
"parameterIdUserPass": {
"name": "password",
"in": "query",
"description": "User password",
"required": true,
"schema": {
"type": "string",
"default": null
}
},
"parameterIdUser": {
"name": "idUser",
"in": "path",

View File

@ -50,10 +50,7 @@ function extension_db_status()
}
ui_print_info_message(
__('This extension checks the DB is correct. Because sometimes the old DB from a migration has not some fields in the tables or the data is changed.')
);
ui_print_info_message(
__('At the moment the checks is for MySQL/MariaDB.')
' - '.__('This extension checks the DB is correct. Because sometimes the old DB from a migration has not some fields in the tables or the data is changed.').'<br>'.' - '.__('At the moment the checks is for MySQL/MariaDB.').'<br>'.' - '.__('User must have Select, Drop, Create and References privileges.')
);
echo "<form method='post' class='max_floating_element_size'>";
@ -164,61 +161,109 @@ function extension_db_status_execute_checks($db_user, $db_password, $db_host, $d
$db_name = explode(' ', $db_name);
$db_name = $db_name[0];
if ($config['mysqli'] === true) {
$connection_test = mysqli_connect($db_host, $db_user, $db_password);
} else {
$connection_test = mysql_connect($db_host, $db_user, $db_password);
if (!$db_host) {
ui_print_error_message(__('A host must be provided'));
return;
}
if (!$db_name) {
ui_print_error_message(__('A DB name must be provided'));
return;
}
try {
if ($config['mysqli']) {
$connection_test = mysqli_connect($db_host, $db_user, $db_password);
} else {
$connection_test = mysql_connect($db_host, $db_user, $db_password);
}
} catch (Exception $e) {
$connection_test = false;
}
if (!$connection_test) {
ui_print_error_message(
__('Unsuccessful connected to the DB')
);
} else {
if ($config['mysqli'] === true) {
ui_print_error_message(__('Unsuccessful connected to the DB'));
return;
}
try {
$query = "SELECT IF(EXISTS(SELECT 1 FROM information_schema.SCHEMATA WHERE schema_name = '$db_name'), 'true', 'false') AS result";
if ($config['mysqli']) {
$exist_db = mysqli_fetch_assoc(mysqli_query($connection_test, $query))['result'];
} else {
$exist_db = mysql_fetch_assoc(mysqli_query($connection_test, $query))['result'];
}
} catch (Exception $e) {
ui_print_error_message(__("There was a problem during verification of the existence of the `$db_name` table"));
return;
}
if ($exist_db == 'true') {
ui_print_error_message(__("The testing DB `$db_name` already exists"));
return;
}
if (check_drop_privileges($connection_test) == 0) {
return;
}
try {
if ($config['mysqli']) {
$create_db = mysqli_query($connection_test, "CREATE DATABASE `$db_name`");
} else {
$create_db = mysql_query("CREATE DATABASE `$db_name`");
}
if (!$create_db) {
ui_print_error_message(
__('Unsuccessful created the testing DB')
);
} else {
if ($config['mysqli'] === true) {
mysqli_select_db($connection_test, $db_name);
} else {
mysql_select_db($db_name, $connection_test);
}
$install_tables = extension_db_status_execute_sql_file(
$config['homedir'].'/pandoradb.sql',
$connection_test
);
if (!$install_tables) {
ui_print_error_message(
__('Unsuccessful installed tables into the testing DB')
);
} else {
extension_db_check_tables_differences(
$connection_test,
$connection_system,
$db_name,
$config['dbname']
);
}
if ($config['mysqli'] === true) {
mysqli_select_db($connection_test, $db_name);
mysqli_query($connection_test, "DROP DATABASE IF EXISTS `$db_name`");
} else {
mysql_select_db($db_name, $connection_test);
mysql_query("DROP DATABASE IF EXISTS `$db_name`", $connection_test);
}
}
} catch (Exception $e) {
$connection_test = false;
}
if (!$create_db) {
ui_print_error_message(__('Unsuccessful created the testing DB'));
return;
}
if (check_ref_privileges($connection_test) == 0) {
drop_database($connection_test, $db_name);
ui_print_error_message(__('Unable to <b>create references</b> with the provided user please check its privileges'));
return;
}
if (check_explain_privileges($connection_test) == 0) {
drop_database($connection_test, $db_name);
ui_print_error_message(__('Unable to <b>explain</b> with the provided user please check its privileges'));
return;
}
try {
if ($config['mysqli'] === true) {
mysqli_select_db($connection_test, $db_name);
} else {
mysql_select_db($db_name, $connection_test);
}
} catch (Exception $e) {
drop_database($connection_test, $db_name);
ui_print_error_message(__('There was an error selecting the DB'));
return;
}
$install_tables = extension_db_status_execute_sql_file(
$config['homedir'].'/pandoradb.sql',
$connection_test
);
if (!$install_tables) {
ui_print_error_message(__('Unsuccessful installed tables into the testing DB'));
return;
}
extension_db_check_tables_differences(
$connection_test,
$connection_system,
$db_name,
$config['dbname']
);
drop_database($connection_test, $db_name);
}
@ -296,25 +341,19 @@ function extension_db_check_tables_differences(
if ($config['mysqli'] === true) {
mysqli_select_db($connection_test, $db_name_test);
$result = mysqli_query($connection_test, 'SHOW CREATE TABLE '.$table);
$tables_test = [];
while ($row = mysql_fetch_array($result)) {
ui_print_info_message(
__('You can execute this SQL query for to fix.').'<br />'.'<pre>'.$row[1].'</pre>'
);
}
$create_query = mysqli_fetch_assoc($result)['Create Table'];
mysqli_free_result($result);
ui_print_info_message(
__('You can execute this SQL query for to fix.').'<br />'.'<pre>'.$create_query.'</pre>'
);
} else {
mysql_select_db($db_name_test, $connection_test);
$result = mysql_query('SHOW CREATE TABLE '.$table, $connection_test);
$tables_test = [];
while ($row = mysql_fetch_array($result)) {
ui_print_info_message(
__('You can execute this SQL query for to fix.').'<br />'.'<pre>'.$row[1].'</pre>'
);
}
$create_query = mysqli_fetch_assoc($result)['Create Table'];
mysql_free_result($result);
ui_print_info_message(
__('You can execute this SQL query for to fix.').'<br />'.'<pre>'.$create_query.'</pre>'
);
}
}
}
@ -489,19 +528,16 @@ function extension_db_status_execute_sql_file($url, $connection)
$query .= $sql_line;
if (preg_match("/;[\040]*\$/", $sql_line)) {
if ($config['mysqli'] === true) {
if (!$result = mysqli_query($connection, $query)) {
echo mysqli_error();
// Uncomment for debug
echo "<i><br>$query<br></i>";
return 0;
}
$result = mysqli_query($connection, $query);
} else {
if (!$result = mysql_query($query, $connection)) {
echo mysql_error();
// Uncomment for debug
echo "<i><br>$query<br></i>";
return 0;
}
$result = mysql_query($query, $connection);
}
if (!$result) {
echo mysqli_error($connection);
// Uncomment for debug
echo "<i><br>$query<br></i>";
return 0;
}
$query = '';
@ -516,5 +552,200 @@ function extension_db_status_execute_sql_file($url, $connection)
}
function check_explain_privileges($connection)
{
global $config;
$has_privileges = 1;
$explain_check = 'EXPLAIN tb1';
$create_tb1 = 'CREATE TABLE tb1 (
id INT AUTO_INCREMENT PRIMARY KEY
)';
drop_database($connection, 'pandora_tmp_privilege_check');
try {
if ($config['mysqli']) {
mysqli_query($connection, 'CREATE DATABASE `pandora_tmp_privilege_check`');
} else {
mysql_query('CREATE DATABASE `pandora_tmp_privilege_check`', $connection);
}
} catch (Exception $e) {
ui_print_error_message(__('There was an error creating the DB during reference check'));
return 0;
}
try {
if ($config['mysqli'] === true) {
mysqli_select_db($connection, 'pandora_tmp_privilege_check');
} else {
mysql_select_db('reference_check', $connection);
}
} catch (Exception $e) {
ui_print_error_message(__('There was an error selecting the DB during reference check'));
return 0;
}
try {
if ($config['mysqli'] === true) {
$result = mysqli_query($connection, $create_tb1);
} else {
$result = mysql_query($create_tb1, $connection);
}
if (!$result) {
throw new Exception('Error on explain check: '.$connection->error);
}
if ($config['mysqli'] === true) {
$result = mysqli_query($connection, $explain_check);
} else {
$result = mysql_query($explain_check, $connection);
}
if (!$result) {
throw new Exception('Error on explain check: '.$connection->error);
}
} catch (Exception $e) {
$has_privileges = 0;
} finally {
drop_database($connection, 'pandora_tmp_privilege_check');
return $has_privileges;
}
}
function check_drop_privileges($connection)
{
global $config;
$has_privileges = 1;
try {
if ($config['mysqli']) {
$create_db = mysqli_query($connection, 'CREATE DATABASE IF NOT EXISTS`pandora_tmp_privilege_check`');
} else {
$create_db = mysql_query('CREATE DATABASE IF NOT EXISTS `pandora_tmp_privilege_check`', $connection);
}
} catch (Exception $e) {
$error_message = $e->getMessage();
}
if (!$create_db) {
if (stripos($error_message, 'access denied for user') !== false) {
preg_match("/'.+?'\@'.+?'/", $error_message, $error_user);
$error_user = $error_user[0];
ui_print_error_message(__('Unable to <b>create databases</b> with the provided user please check its privileges'));
return 0;
}
ui_print_error_message(__('There was an error creating the DB during drop check'));
return 0;
}
try {
if ($config['mysqli'] === true) {
mysqli_select_db($connection, 'pandora_tmp_privilege_check');
} else {
mysql_select_db('reference_check', $connection);
}
} catch (Exception $e) {
ui_print_error_message(__('There was an error selecting the DB during drop check'));
return 0;
}
try {
drop_database($connection, 'pandora_tmp_privilege_check');
} catch (Exception $e) {
$has_privileges = 0;
ui_print_error_message(
__('Unable to <b>drop databases</b> with the provided user please check its privileges.').'<br>'.__('Test databases may have been left over due to lack of drop privileges.')
);
} finally {
return $has_privileges;
}
}
function check_ref_privileges($connection)
{
global $config;
$has_privileges = 1;
drop_database($connection, 'pandora_tmp_privilege_check');
$create_tb1 = 'CREATE TABLE tb1 (
id INT AUTO_INCREMENT PRIMARY KEY
)';
$create_tb2 = 'CREATE TABLE tb2 (
id INT AUTO_INCREMENT PRIMARY KEY,
id_tb1 INT,
FOREIGN KEY (id_tb1) REFERENCES tb2(id)
)';
try {
if ($config['mysqli']) {
mysqli_query($connection, 'CREATE DATABASE `pandora_tmp_privilege_check`');
} else {
mysql_query('CREATE DATABASE `pandora_tmp_privilege_check`', $connection);
}
} catch (Exception $e) {
ui_print_error_message(__('There was an error creating the DB during reference check'));
return 0;
}
try {
if ($config['mysqli'] === true) {
mysqli_select_db($connection, 'pandora_tmp_privilege_check');
} else {
mysql_select_db('reference_check', $connection);
}
} catch (Exception $e) {
ui_print_error_message(__('There was an error selecting the DB during reference check'));
return 0;
}
try {
if ($config['mysqli'] === true) {
$result = mysqli_query($connection, $create_tb1);
} else {
$result = mysql_query($create_tb1, $connection);
}
if (!$result) {
throw new Exception('Error on reference check: '.$connection->error);
}
if ($config['mysqli'] === true) {
$result = mysqli_query($connection, $create_tb2);
} else {
$result = mysql_query($create_tb2, $connection);
}
if (!$result) {
throw new Exception('Error on reference check: '.$connection->error);
}
} catch (Exception $e) {
$has_privileges = 0;
} finally {
drop_database($connection, 'pandora_tmp_privilege_check');
return $has_privileges;
}
}
function drop_database($connection, $database)
{
global $config;
if ($config['mysqli'] === true) {
mysqli_query($connection, "DROP DATABASE IF EXISTS `$database`");
} else {
mysql_query("DROP DATABASE IF EXISTS `$database`", $connection);
}
}
extensions_add_godmode_function('extension_db_status');
extensions_add_godmode_menu_option(__('DB Schema check'), 'DM', 'gextensions', null, 'v1r1', 'gdbman');

View File

@ -81,30 +81,34 @@ function pandora_realtime_graphs()
$table->style = [];
$table->data = [];
$graph_fields['cpu_load'] = __('%s Server CPU', get_product_name());
$graph_fields['pending_packets'] = __(
'Pending packages from %s Server',
get_product_name()
);
$graph_fields['disk_io_wait'] = __(
'%s Server Disk IO Wait',
get_product_name()
);
$graph_fields['apache_load'] = __(
'%s Server Apache load',
get_product_name()
);
$graph_fields['mysql_load'] = __(
'%s Server MySQL load',
get_product_name()
);
$graph_fields['server_load'] = __(
'%s Server load',
get_product_name()
);
$graph = get_parameter('graph', 'snmp_interface');
if ((bool) check_acl($config['id_user'], 0, 'PM') === true) {
$graph = get_parameter('graph', 'cpu_load');
$graph_fields['cpu_load'] = __('%s Server CPU', get_product_name());
$graph_fields['pending_packets'] = __(
'Pending packages from %s Server',
get_product_name()
);
$graph_fields['disk_io_wait'] = __(
'%s Server Disk IO Wait',
get_product_name()
);
$graph_fields['apache_load'] = __(
'%s Server Apache load',
get_product_name()
);
$graph_fields['mysql_load'] = __(
'%s Server MySQL load',
get_product_name()
);
$graph_fields['server_load'] = __(
'%s Server load',
get_product_name()
);
}
$graph_fields['snmp_interface'] = __('SNMP Interface throughput');
$graph = get_parameter('graph', 'cpu_load');
$refresh = get_parameter('refresh', '1000');
if ($graph != 'snmp_module') {

View File

@ -27,7 +27,7 @@ switch ($graph) {
if ($os == 'windows') {
$data = exec('wmic cpu get loadpercentage|find /I /V "Loadpercentage" | findstr /r "[0-9]" ');
} else {
$data = exec("top -bn 2 -d 0.01 | grep '^Cpu' | tail -n 1 | awk '{ print $2+$4+$6 }'");
$data = exec("top -bn 2 -d 0.01 | grep 'Cpu' | tail -n 1 | awk '{ print $2+$4+$6 }'");
}
break;
@ -55,7 +55,8 @@ switch ($graph) {
if ($os == 'windows') {
$data = exec('(FOR /F "skip=2 tokens=2 delims=\," %P IN (\'typeperf "\\Process(httpd)\\% processor time" -sc 1\') DO @echo %P)|find /V /I "..."');
} else {
$data = exec("ps aux | grep apache2 | grep -v safe | grep -v grep | awk '{ sum+=$3 } END { print sum }'");
$apache = exec('ps aux | grep apache2 | grep -v safe | grep -v grep && echo 1 || echo 0') == 1 ? 'apache2' : 'apache';
$data = exec("ps aux | grep $apache | grep -v safe | grep -v grep | awk '{ sum+=$3 } END { print sum }'");
}
break;
@ -63,7 +64,7 @@ switch ($graph) {
if ($os == 'windows') {
$data = exec('(FOR /F "skip=2 tokens=2 delims=\," %P IN (\'typeperf "\\Process(pandora_server)\\% processor time" -sc 1\') DO @echo %P)|find /V /I "..."');
} else {
$data = exec("ps aux | grep pandora_server | grep -v grep | awk '{ print $3 }'");
$data = exec("ps aux | grep pandora_server | grep -v grep | awk '{ sum+=$3 } END { print sum }'");
}
break;

View File

@ -1749,3 +1749,6 @@ enterprise/include/class/SAP.app.php
enterprise/include/class/VMware.app.php
enterprise/include/class/DatabaseHA.class.php
enterprise/godmode/servers/HA_cluster.php
enterprise/godmode/setup/edit_skin.php
enterprise/godmode/setup/setup_skins.php
enterprise/include/functions_skins.php

View File

@ -1,4 +1,4 @@
pandorafms.vmware=a272ee00a9b5f201bb708bef72bbe276
pandorafms.vmware=3d1785e1baa07db0a40b9e47bb30472c
pandorafms.mysql=33d470c7492214d4b384ed307e81adf4
pandorafms.vmware=1deafce1d55d3574645d8b136104e9ad
pandorafms.mysql=ca7dd8b80a1a03a25eb0fb077818ad63

View File

@ -64,7 +64,7 @@ ALTER TABLE `tmerge_queries` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_09
-- Update version for plugin oracle
UPDATE `tdiscovery_apps` SET `version` = '1.2' WHERE `short_name` = 'pandorafms.oracle';
-- Update version for plugin oracle
UPDATE `tdiscovery_apps` SET `version` = '1.3' WHERE `short_name` = 'pandorafms.vmware';
UPDATE `tdiscovery_apps` SET `version` = '1.4' WHERE `short_name` = 'pandorafms.vmware';
ALTER TABLE `tevent_sound` MODIFY COLUMN `name` text NULL;
ALTER TABLE `tevent_sound` MODIFY COLUMN `sound` text NULL;

View File

@ -1,6 +1,12 @@
START TRANSACTION;
DROP TABLE tskin;
-- Remove column id_usuario_destino from tmensajes --
SET @exist = (SELECT count(*) FROM information_schema.columns WHERE TABLE_NAME='tmensajes' AND COLUMN_NAME='id_usuario_destino' AND table_schema = DATABASE());
SET @sqlstmt = IF (@exist>0, 'ALTER TABLE `tmensajes` DROP COLUMN `id_usuario_destino`', 'SELECT ""');
prepare stmt from @sqlstmt;
execute stmt;
DROP TABLE IF EXISTS tskin;
ALTER TABLE tfavmenu_user CONVERT TO CHARACTER SET UTF8MB4;
ALTER TABLE tfiles_repo CONVERT TO CHARACTER SET UTF8MB4;
@ -7712,6 +7718,8 @@ UPDATE `twelcome_tip` SET url = 'https://pandorafms.com/manual/!current/start?id
DELETE FROM tconfig WHERE `token` = 'legacy_database_ha';
UPDATE tncm_script SET `content` = 'sleep:1&#x0d;&#x0a;capture:export&#92;n&#92;r&#x20;&#x0d;&#x0a;exit&#92;n&#92;r' where `content` = 'sleep:1&#x0d;&#x0a;capture:system&#x20;resource&#x20;print&#92;n&#92;r&#x20;&#x0d;&#x0a;exit&#92;n&#92;r';
-- Add new columns in tdeployment_hosts
ALTER TABLE `tdeployment_hosts` ADD COLUMN `deploy_method` ENUM('SSH', 'HTTP', 'HTTPS') DEFAULT 'SSH';
ALTER TABLE `tdeployment_hosts` ADD COLUMN `deploy_port` INT UNSIGNED NOT NULL DEFAULT 22;
@ -7723,7 +7731,7 @@ UPDATE
SET
`tdeployment_hosts`.`deploy_method` = 'HTTP',
`tdeployment_hosts`.`deploy_port` = 5985,
`tdeployment_hosts`.`temp_folder` = 'C:&#92;Widnows&#92;Temp'
`tdeployment_hosts`.`temp_folder` = 'C:&#92;Windows&#92;Temp'
WHERE
`tdeployment_hosts`.`id_os` = `tconfig_os`.`id_os` AND `tconfig_os`.`name` = 'Windows' AND `tdeployment_hosts`.`deployed` = 0;
@ -7746,6 +7754,11 @@ ALTER TABLE `tdeployment_hosts` DROP COLUMN `arch`;
-- Update all deployment recon tasks port
UPDATE `trecon_task` SET `field4` = 41121 WHERE `type` = 9;
-- Update execution in proxmox discovery plugin
SET @short_name = 'pandorafms.proxmox';
SELECT @id_app := `id_app` FROM `tdiscovery_apps` WHERE `short_name` = @short_name;
UPDATE `tdiscovery_apps_executions` SET `execution` = '&#039;_exec1_&#039;&#x20;--conf&#x20;&#039;_tempfileProxmox_&#039;' WHERE `id_app` = @id_app;
INSERT INTO `tconfig` (`token`, `value`) VALUES ('JWT_signature', 1);
DELETE FROM tconfig WHERE `token` = 'loginhash_pwd';

View File

@ -52,7 +52,7 @@ echo sprintf('<div id="header_table" class="header_table_%s">', $menuTypeClass);
}
// ======= Servers List ===============================================
if ((bool) check_acl($config['id_user'], 0, 'AW') !== false) {
if ((bool) check_acl($config['id_user'], 0, 'PM') !== false) {
$servers = [];
$servers_info = servers_get_info();

View File

@ -386,52 +386,32 @@ if ($access_console_node === true) {
$menu_godmode['galertas']['sub'] = $sub;
}
if ((bool) check_acl($config['id_user'], 0, 'AW') === true || (bool) check_acl($config['id_user'], 0, 'PM') === true) {
if ((bool) check_acl($config['id_user'], 0, 'PM') === true) {
// Servers.
$menu_godmode['gservers']['text'] = __('Servers');
$menu_godmode['gservers']['sec2'] = 'godmode/servers/modificar_server';
$menu_godmode['gservers']['id'] = 'god-servers';
$sub = [];
if ((bool) check_acl($config['id_user'], 0, 'AW') === true) {
$sub['godmode/servers/modificar_server']['text'] = __('Manage servers');
$sub['godmode/servers/modificar_server']['id'] = 'Manage_servers';
}
if ((bool) check_acl($config['id_user'], 0, 'PM') === true
|| is_user_admin($config['id_user']) === true
) {
$sub['godmode/consoles/consoles']['text'] = __('Manage consoles');
$sub['godmode/consoles/consoles']['id'] = 'Manage consoles';
}
$sub['godmode/servers/modificar_server']['text'] = __('Manage servers');
$sub['godmode/servers/modificar_server']['id'] = 'Manage_servers';
$sub['godmode/consoles/consoles']['text'] = __('Manage consoles');
$sub['godmode/consoles/consoles']['id'] = 'Manage consoles';
// This subtabs are only for Pandora Admin.
if ((bool) check_acl($config['id_user'], 0, 'PM') === true) {
enterprise_hook('ha_cluster');
$sub['godmode/servers/plugin']['text'] = __('Plugins');
$sub['godmode/servers/plugin']['id'] = 'Plugins';
$sub['godmode/servers/plugin_registration']['text'] = __('Register Plugin');
$sub['godmode/servers/plugin_registration']['id'] = 'register_plugin';
enterprise_hook('export_target_submenu');
enterprise_hook('manage_satellite_submenu');
}
enterprise_hook('ha_cluster');
$sub['godmode/servers/plugin']['text'] = __('Plugins');
$sub['godmode/servers/plugin']['id'] = 'Plugins';
$sub['godmode/servers/plugin_registration']['text'] = __('Register Plugin');
$sub['godmode/servers/plugin_registration']['id'] = 'register_plugin';
enterprise_hook('export_target_submenu');
enterprise_hook('manage_satellite_submenu');
$menu_godmode['gservers']['sub'] = $sub;
}
if ((bool) check_acl($config['id_user'], 0, 'PM') === true) {
// Setup.
$menu_godmode['gsetup']['text'] = __('Settings');
$menu_godmode['gsetup']['sec2'] = 'general';
$menu_godmode['gsetup']['id'] = 'god-setup';
$sub = [];
// Options Setup.
$sub['general']['text'] = __('System Settings');
$sub['general']['id'] = 'Setup';
@ -457,41 +437,31 @@ if ($access_console_node === true) {
$sub2['godmode/setup/setup&section=vis']['text'] = __('Visual styles');
$sub2['godmode/setup/setup&section=vis']['refr'] = 0;
if ((bool) check_acl($config['id_user'], 0, 'AW') === true) {
if ((bool) $config['activate_netflow'] === true) {
$sub2['godmode/setup/setup&section=net']['text'] = __('Netflow');
$sub2['godmode/setup/setup&section=net']['refr'] = 0;
}
if ((bool) $config['activate_netflow'] === true) {
$sub2['godmode/setup/setup&section=net']['text'] = __('Netflow');
$sub2['godmode/setup/setup&section=net']['refr'] = 0;
}
if ((bool) $config['activate_sflow'] === true) {
$sub2['godmode/setup/setup&section=sflow']['text'] = __('Sflow');
$sub2['godmode/setup/setup&section=sflow']['refr'] = 0;
}
if ((bool) $config['activate_sflow'] === true) {
$sub2['godmode/setup/setup&section=sflow']['text'] = __('Sflow');
$sub2['godmode/setup/setup&section=sflow']['refr'] = 0;
}
$sub2['godmode/setup/setup&section=pandorarc']['text'] = __('Pandora RC');
$sub2['godmode/setup/setup&section=pandorarc']['refr'] = 0;
$sub2['godmode/setup/setup&section=ITSM']['text'] = __('ITSM');
$sub2['godmode/setup/setup&section=ITSM']['refr'] = 0;
enterprise_hook('module_library_submenu');
$sub2['godmode/setup/setup&section=notifications']['text'] = __('Notifications');
$sub2['godmode/setup/setup&section=notifications']['refr'] = 0;
$sub2['godmode/setup/setup&section=quickshell']['text'] = __('QuickShell');
$sub2['godmode/setup/setup&section=quickshell']['refr'] = 0;
$sub2['godmode/setup/setup&section=external_tools']['text'] = __('External Tools');
$sub2['godmode/setup/setup&section=external_tools']['refr'] = 0;
$sub2['godmode/setup/setup&section=welcome_tips']['text'] = __('Welcome Tips');
$sub2['godmode/setup/setup&section=welcome_tips']['refr'] = 0;
$sub2['godmode/setup/setup&section=demo_data']['text'] = __('Demo data');
$sub2['godmode/setup/setup&section=demo_data']['refr'] = 0;
if ((bool) $config['activate_gis'] === true) {
$sub2['godmode/setup/setup&section=gis']['text'] = __('Map conections GIS');
}
@ -503,6 +473,13 @@ if ($access_console_node === true) {
enterprise_hook('translate_string_submenu');
$menu_godmode['gsetup']['sub'] = $sub;
} else if ((bool) check_acl($config['id_user'], 0, 'AW') === true) {
$menu_godmode['gservers']['text'] = __('Servers');
$menu_godmode['gservers']['sec2'] = 'godmode/servers/modificar_server';
$menu_godmode['gservers']['id'] = 'god-servers';
$sub = [];
enterprise_hook('manage_satellite_submenu');
$menu_godmode['gservers']['sub'] = $sub;
}
}

View File

@ -52,6 +52,11 @@ if (! check_acl($config['id_user'], 0, 'RW')
exit;
}
// Get pandora black theme.
if ($config['style'] === 'pandora_black') {
html_print_input_hidden('selected_style_theme', 'pandora_black');
}
$meta = false;
if (($config['metaconsole'] == 1) && (defined('METACONSOLE'))) {
$meta = true;
@ -2338,7 +2343,7 @@ if (is_metaconsole() === true) {
if ($idAgent) {
$sql = 'SELECT id_agente_modulo, nombre
FROM tagente_modulo
WHERE id_agente = "'.$idAgent['id_agent'].'" AND delete_pending = 0';
WHERE id_agente = "'.$idAgent.'" AND delete_pending = 0';
if ($meta) {
$connection = metaconsole_get_connection($server_name);
@ -6190,7 +6195,12 @@ $(document).ready (function () {
});
});
defineTinyMCE('#textarea_render_definition');
var consoleStyle = $("#hidden-selected_style_theme").val();
if (consoleStyle == "pandora_black") {
defineTinyMCEDark('#textarea_render_definition');
} else {
defineTinyMCE('#textarea_render_definition');
}
$("#checkbox-select_by_group").change(function () {
var select_by_group = $('#checkbox-select_by_group').prop('checked');

View File

@ -1328,6 +1328,25 @@ switch ($action) {
],
true
);
} else if (check_acl($config['id_user'], 0, 'RR')) {
$tablePagination = ui_pagination(
$total_reports,
$url,
$offset,
$pagination,
true,
'offset',
$show_count
);
echo html_print_action_buttons(
'',
[
'type' => 'form_action',
'right_content' => $tablePagination,
],
true
);
}
return;
@ -2407,7 +2426,7 @@ switch ($action) {
$values['top_n_value'] = get_parameter('max_items');
$values['server_name'] = get_parameter('combo_server_sql');
if ($sql !== '') {
if ($sql !== '' && $sql !== null) {
// Replaces possible macros to check the validity of the query
$macros_sql = $sql;
$macros_sql = str_replace('_start_date_', '0', $macros_sql);
@ -3357,7 +3376,7 @@ switch ($action) {
$values['server_name'] = get_parameter('combo_server_sql');
if ($sql !== '') {
if ($sql !== '' && $sql !== null) {
// Replaces possible macros to check the validity of the query
$macros_sql = $sql;
$macros_sql = str_replace('_start_date_', '0', $macros_sql);

View File

@ -114,6 +114,7 @@ foreach ($all_images as $image_file) {
$table = new stdClass();
$table->width = '100%';
$table->class = 'databox filter-table-adv';
$table->styleTable = 'min-width: 900px; table-layout:fixed;';
$table->head = [];
$table->head['icon'] = '';
@ -122,8 +123,7 @@ $table->head[1] = __('Image').'<br>'.__('Module').' / '.__('Custom graph');
$table->head[2] = __('Width x Height<br>Max value');
$table->head[3] = __('Position').'<br>'.__('Period');
$table->head[4] = __('Parent').'<br>'.__('Map linked');
$table->head[5] = '';
$table->head[5] .= '&nbsp;&nbsp;&nbsp;'.html_print_checkbox(
$table->head[5] = html_print_checkbox(
'head_multiple_delete',
'',
false,
@ -133,41 +133,66 @@ $table->head[5] .= '&nbsp;&nbsp;&nbsp;'.html_print_checkbox(
);
$table->head[5] .= '&nbsp;&nbsp;&nbsp;<span title="'.__('Action').'">'.__('A.').'</span>';
$table->size = [];
$table->size['icon'] = '1%';
$table->size[0] = '28%';
$table->size[1] = '';
$table->size[2] = '25%';
$table->size[3] = '27%';
$table->size[4] = '7%';
$table->size[5] = '15%';
$table->headstyle = [];
$table->headstyle['icon'] = 'text-align:left; width: 1%;';
$table->headstyle[0] = 'text-align:left; width: 19%;';
$table->headstyle[1] = 'text-align:left; width: 19%;';
$table->headstyle[2] = 'text-align:left; width: 19%;';
$table->headstyle[3] = 'text-align:left; width: 19%;';
$table->headstyle[4] = 'text-align:left; width: 19%;';
$table->headstyle[5] = 'text-align:right; width: 4%;';
$table->align = [];
if (!defined('METACONSOLE')) {
$table->headstyle[0] = 'text-align:left;';
$table->headstyle[1] = 'text-align:left';
$table->headstyle[2] = 'text-align:left';
$table->headstyle[3] = 'text-align:left';
$table->headstyle[4] = 'text-align:left';
$table->headstyle[5] = 'text-align:left';
$table->align[0] = 'left';
$table->align[1] = 'left';
$table->align[2] = 'left';
$table->align[3] = 'left';
$table->align[4] = 'left';
$table->align[5] = 'left';
}
$table->align[0] = 'left';
$table->align[1] = 'left';
$table->align[2] = 'left';
$table->align[3] = 'left';
$table->align[4] = 'left';
$table->align[5] = 'right';
$table->data = [];
// Background
// Background.
$table->data[0]['icon'] = '';
$table->data[0][0] = '<div sclass="invisible">'.__('Background').'</div>';
$table->data[0][1] = '<div sclass="invisible">'.html_print_select($backgrounds_list, 'background', $visualConsole['background'], '', 'None', '', true, false, true, '', false, 'width: 120px;').'</div>';
$table->data[0][2] = '<div sclass="invisible">'.html_print_input_text('width', $visualConsole['width'], '', 3, 5, true).' x '.html_print_input_text('height', $visualConsole['height'], '', 3, 5, true).'</div>';
$table->data[0][3] = $table->data[0][4] = $table->data[0][5] = '';
$table->data[0][0] = '<div>'.__('Background').'</div>';
$table->data[0][1] = '<div>';
$table->data[0][1] .= html_print_select(
$backgrounds_list,
'background',
$visualConsole['background'],
'',
'None',
'',
true,
false,
true,
'',
false,
'width: 100%;'
);
$table->data[0][1] .= '</div>';
$table->data[0][2] = '<div class="row-flex">';
$table->data[0][2] .= html_print_input_text(
'width',
$visualConsole['width'],
'',
3,
5,
true
);
$table->data[0][2] .= '<span class="mrgn_5px">x</span>';
$table->data[0][2] .= html_print_input_text(
'height',
$visualConsole['height'],
'',
3,
5,
true
);
$table->data[0][2] .= '</div>';
$table->data[0][3] = '';
$table->data[0][4] = '';
$table->data[0][5] = '';
$i = 1;
$layoutDatas = db_get_all_rows_field_filter(
@ -186,7 +211,7 @@ $x = 0;
foreach ($layoutDatas as $layoutData) {
$idLayoutData = $layoutData['id'];
// line between rows
// Line between rows.
$table->data[$i][0] = '<hr>';
$table->colspan[$i][0] = '8';
@ -208,7 +233,7 @@ foreach ($layoutDatas as $layoutData) {
true,
[
'title' => __('Percentile Bar'),
'class' => 'invert_filter',
'class' => 'main_menu_icon invert_filter',
]
);
break;
@ -219,7 +244,7 @@ foreach ($layoutDatas as $layoutData) {
true,
[
'title' => __('Percentile Bubble'),
'class' => 'invert_filter',
'class' => 'main_menu_icon invert_filter',
]
);
break;
@ -231,7 +256,7 @@ foreach ($layoutDatas as $layoutData) {
true,
[
'title' => __('Percentile'),
'class' => 'invert_filter',
'class' => 'main_menu_icon invert_filter',
]
);
break;
@ -413,7 +438,7 @@ foreach ($layoutDatas as $layoutData) {
break;
default:
if (enterprise_installed()) {
if (enterprise_installed() === true) {
$table->data[($i + 1)]['icon'] = enterprise_visual_map_print_list_element('icon', $layoutData);
} else {
$table->data[($i + 1)]['icon'] = '';
@ -421,26 +446,27 @@ foreach ($layoutDatas as $layoutData) {
break;
}
// First row
// Label
// Label.
switch ($layoutData['type']) {
case ICON:
case BOX_ITEM:
case NETWORK_LINK:
case LINE_ITEM:
// hasn't the label.
// Hasn't the label.
$table->data[($i + 1)][0] = '';
break;
default:
$table->data[($i + 1)][0] = '<span class="w150px block">'.html_print_input_hidden('label_'.$idLayoutData, $layoutData['label'], true).'<a href="javascript: show_dialog_label_editor('.$idLayoutData.');">'.__('Edit label').'</a>'.'</span>';
$table->data[($i + 1)][0] = '<span class="w150px block">';
$table->data[($i + 1)][0] .= html_print_input_hidden('label_'.$idLayoutData, $layoutData['label'], true);
$table->data[($i + 1)][0] .= '<a href="javascript: show_dialog_label_editor('.$idLayoutData.');">';
$table->data[($i + 1)][0] .= __('Edit label');
$table->data[($i + 1)][0] .= '</a></span>';
break;
}
// Image
// Image.
switch ($layoutData['type']) {
case STATIC_GRAPH:
case ICON:
@ -458,7 +484,7 @@ foreach ($layoutDatas as $layoutData) {
true,
'',
false,
'width: 120px'
'width: 100%'
);
break;
@ -467,47 +493,102 @@ foreach ($layoutDatas as $layoutData) {
break;
}
// Position.
$readonly = false;
if ($layoutData['type'] == NETWORK_LINK || $layoutData['type'] == LINE_ITEM) {
$readonly = true;
}
// Width and height
// Width and height.
switch ($layoutData['type']) {
case NETWORK_LINK:
case LINE_ITEM:
// hasn't the width and height.
$table->data[($i + 1)][2] = '';
break;
case COLOR_CLOUD:
$table->data[($i + 1)][2] = html_print_input_text('width_'.$idLayoutData, $layoutData['width'], '', 2, 5, true).' x '.html_print_input_text('height_'.$idLayoutData, $layoutData['width'], '', 2, 5, true);
$table->data[($i + 1)][2] = '<div class="row-flex">';
$table->data[($i + 1)][2] .= html_print_input_text(
'width_'.$idLayoutData,
$layoutData['width'],
'',
2,
5,
true
);
$table->data[($i + 1)][2] .= '<span class="mrgn_5px">x</span>';
$table->data[($i + 1)][2] .= html_print_input_text(
'height_'.$idLayoutData,
$layoutData['width'],
'',
2,
5,
true
);
$table->data[($i + 1)][2] .= '</div>';
break;
case CIRCULAR_PROGRESS_BAR:
case CIRCULAR_INTERIOR_PROGRESS_BAR:
case PERCENTILE_BUBBLE:
case PERCENTILE_BAR:
$table->data[($i + 1)][2] = html_print_input_text('width_'.$idLayoutData, $layoutData['width'], '', 2, 5, true);
$table->data[($i + 1)][2] = '<div class="row-flex">';
$table->data[($i + 1)][2] .= html_print_input_text(
'width_'.$idLayoutData,
$layoutData['width'],
'',
2,
5,
true
);
$table->data[($i + 1)][2] .= '</div>';
break;
default:
$table->data[($i + 1)][2] = html_print_input_text('width_'.$idLayoutData, $layoutData['width'], '', 2, 5, true).' x '.html_print_input_text('height_'.$idLayoutData, $layoutData['height'], '', 2, 5, true);
$table->data[($i + 1)][2] = '<div class="row-flex">';
$table->data[($i + 1)][2] .= html_print_input_text(
'width_'.$idLayoutData,
$layoutData['width'],
'',
2,
5,
true,
$readonly
);
$table->data[($i + 1)][2] .= '<span class="mrgn_5px">x</span>';
$table->data[($i + 1)][2] .= html_print_input_text(
'height_'.$idLayoutData,
$layoutData['height'],
'',
2,
5,
true,
$readonly
);
$table->data[($i + 1)][2] .= '</div>';
break;
}
// Position
switch ($layoutData['type']) {
case NETWORK_LINK:
case LINE_ITEM:
// hasn't the width and height.
$table->data[($i + 1)][3] = '';
break;
$table->data[($i + 1)][3] = '<div class="row-flex">';
$table->data[($i + 1)][3] .= '<span class="mrgn_5px">(</span>';
$table->data[($i + 1)][3] .= html_print_input_text(
'left_'.$idLayoutData,
$layoutData['pos_x'],
'',
2,
5,
true,
$readonly
);
$table->data[($i + 1)][3] .= '<span class="mrgn_5px">,</span>';
$table->data[($i + 1)][3] .= html_print_input_text(
'top_'.$idLayoutData,
$layoutData['pos_y'],
'',
2,
5,
true,
$readonly
);
$table->data[($i + 1)][3] .= '<span class="mrgn_5px">)</span>';
$table->data[($i + 1)][3] .= '</div>';
default:
$table->data[($i + 1)][3] = '( '.html_print_input_text('left_'.$idLayoutData, $layoutData['pos_x'], '', 2, 5, true).' , '.html_print_input_text('top_'.$idLayoutData, $layoutData['pos_y'], '', 2, 5, true).' )';
break;
}
// Parent
// Parent.
switch ($layoutData['type']) {
case BOX_ITEM:
case NETWORK_LINK:
@ -517,39 +598,57 @@ foreach ($layoutDatas as $layoutData) {
break;
default:
$table->data[($i + 1)][4] = html_print_select(
$table->data[($i + 1)][4] = '<div>'.html_print_select(
$parents,
'parent_'.$idLayoutData,
$layoutData['parent_item'],
'',
__('None'),
0,
true
);
true,
false,
true,
'',
false,
'width: 100%;'
).'</div>';
break;
}
// Delete row button
if (!defined('METACONSOLE')) {
$url_delete = 'index.php?'.'sec=network&'.'sec2=godmode/reporting/visual_console_builder&'.'tab='.$activeTab.'&'.'action=delete&'.'id_visual_console='.$visualConsole['id'].'&'.'id_element='.$idLayoutData;
} else {
$url_delete = 'index.php?'.'operation=edit_visualmap&'.'sec=screen&'.'sec2=screens/screens&'.'action=visualmap&'.'pure='.(int) get_parameter('pure', 0).'&'.'tab=list_elements&'.'action2=delete&'.'id_visual_console='.$visualConsole['id'].'&'.'id_element='.$idLayoutData;
// Delete row button.
$url_delete = 'index.php?sec=network&sec2=godmode/reporting/visual_console_builder';
$url_delete .= '&tab='.$activeTab.'&action=delete';
$url_delete .= '&id_visual_console='.$visualConsole['id'].'&id_element='.$idLayoutData;
if (is_metaconsole() === true) {
$url_delete = 'index.php?operation=edit_visualmap&sec=screen&sec2=screens/screens&action=visualmap';
$url_delete .= '&pure='.(int) get_parameter('pure', 0);
$url_delete .= '&tab=list_elements&action2=delete';
$url_delete .= '&id_visual_console='.$visualConsole['id'].'&id_element='.$idLayoutData;
}
$table->data[($i + 1)][5] = '';
$table->data[($i + 1)][5] = '<div class="row-flex flex-end">';
$table->data[($i + 1)][5] .= html_print_checkbox('multiple_delete_items', $idLayoutData, false, true);
$table->data[($i + 1)][5] .= '<a href="'.$url_delete.'"onclick="javascript: if (!confirm(\''.__('Are you sure?').'\')) return false;">'.html_print_image('images/delete.svg', true, ['class' => 'main_menu_icon invert_filter']).'</a>';
$table->data[($i + 1)][5] .= '<a href="'.$url_delete.'"onclick="javascript: if (!confirm(\''.__('Are you sure?').'\')) return false;">';
$table->data[($i + 1)][5] .= html_print_image(
'images/delete.svg',
true,
['class' => 'main_menu_icon invert_filter']
);
$table->data[($i + 1)][5] .= '</a>';
$table->data[($i + 1)][5] .= html_print_input_hidden('updated_'.$idLayoutData, '0', true);
$table->data[($i + 1)][5] .= html_print_input_hidden('rowtype_'.$idLayoutData, $layoutData['type'], true);
$table->data[($i + 1)][5] .= '</div>';
// Second row
// Second row.
$table->data[($i + 2)]['icon'] = '';
// Agent
// Agent.
switch ($layoutData['type']) {
case GROUP_ITEM:
$own_info = get_user_info($config['id_user']);
if (!$own_info['is_admin'] && !check_acl($config['id_user'], 0, 'PM')) {
if ((bool) $own_info['is_admin'] === false
&& (bool) check_acl($config['id_user'], 0, 'PM') === false
) {
$return_all_group = false;
} else {
$return_all_group = true;
@ -564,7 +663,12 @@ foreach ($layoutDatas as $layoutData) {
'',
'',
0,
true
true,
false,
false,
'',
false,
'width:100%'
);
break;
@ -579,24 +683,25 @@ foreach ($layoutDatas as $layoutData) {
default:
$cell_content_enterprise = false;
if (enterprise_installed()) {
if (enterprise_installed() === true) {
$cell_content_enterprise = enterprise_visual_map_print_list_element('agent', $layoutData);
}
if ($cell_content_enterprise === false) {
$params = [];
$params['return'] = true;
$params['show_helptip'] = true;
$params['show_helptip'] = false;
$params['size'] = 20;
$params['input_name'] = 'agent_'.$idLayoutData;
$params['javascript_is_function_select'] = true;
$params['selectbox_id'] = 'module_'.$idLayoutData;
if (defined('METACONSOLE')) {
if (is_metaconsole() === true) {
$params['javascript_ajax_page'] = '../../ajax.php';
$params['disabled_javascript_on_blur_function'] = true;
$params['print_input_id_server'] = true;
$params['input_id_server_id'] = $params['input_id_server_name'] = 'id_server_id_'.$idLayoutData;
$params['input_id_server_id'] = 'id_server_id_'.$idLayoutData;
$params['input_id_server_name'] = 'id_server_id_'.$idLayoutData;
$params['input_id_server_value'] = $layoutData['id_metaconsole'];
$params['metaconsole_enabled'] = true;
$params['print_hidden_input_idagent'] = true;
@ -616,7 +721,7 @@ foreach ($layoutDatas as $layoutData) {
$params['value'] = db_get_value('alias', 'tagente', 'id_agente', $layoutData['id_agent']);
}
if ($layoutData['id_custom_graph'] != 0) {
if ((int) $layoutData['id_custom_graph'] !== 0) {
$table->data[($i + 2)][0] = __('Custom graph');
} else {
$table->data[($i + 2)][0] = ui_print_agent_autocomplete_input($params);
@ -627,8 +732,7 @@ foreach ($layoutDatas as $layoutData) {
break;
}
// Module
// Module.
switch ($layoutData['type']) {
case ICON:
case LABEL:
@ -642,21 +746,21 @@ foreach ($layoutDatas as $layoutData) {
default:
if ($layoutData['id_layout_linked'] != 0) {
// It is a item that links with other visualmap
// It is a item that links with other visualmap.
$table->data[($i + 2)][1] = '';
break;
}
$cell_content_enterprise = false;
if (enterprise_installed()) {
if (enterprise_installed() === true) {
$cell_content_enterprise = enterprise_visual_map_print_list_element('module', $layoutData);
}
if ($cell_content_enterprise === false) {
if (!defined('METACONSOLE')) {
if (is_metaconsole() === false) {
$modules = agents_get_modules($layoutData['id_agent']);
} else {
if ($layoutData['id_agent'] != 0) {
if ((int) $layoutData['id_agent'] !== 0) {
$server = db_get_row('tmetaconsole_setup', 'id', $layoutData['id_metaconsole']);
if (metaconsole_connect($server) == NOERR) {
$modules = agents_get_modules($layoutData['id_agent']);
@ -668,7 +772,7 @@ foreach ($layoutDatas as $layoutData) {
$modules = io_safe_output($modules);
if ($layoutData['id_custom_graph'] != 0) {
if (is_metaconsole()) {
if (is_metaconsole() === true) {
$graphs = [];
$graphs = metaconsole_get_custom_graphs(true);
$table->data[($i + 2)][1] = html_print_select(
@ -678,7 +782,12 @@ foreach ($layoutDatas as $layoutData) {
'',
__('None'),
0,
true
true,
false,
true,
'',
false,
'width:100%'
);
} else {
$table->data[($i + 2)][1] = html_print_select_from_sql(
@ -688,7 +797,11 @@ foreach ($layoutDatas as $layoutData) {
'',
__('None'),
0,
true
true,
false,
true,
false,
'width:100%'
);
}
} else {
@ -704,7 +817,7 @@ foreach ($layoutDatas as $layoutData) {
true,
'',
false,
'width: 120px'
'width: 100%'
);
}
} else {
@ -713,16 +826,17 @@ foreach ($layoutDatas as $layoutData) {
break;
}
// Empty
// Empty.
$table->data[($i + 2)][2] = '';
// Period
// Period.
switch ($layoutData['type']) {
case MODULE_GRAPH:
case SIMPLE_VALUE_MAX:
case SIMPLE_VALUE_MIN:
case SIMPLE_VALUE_AVG:
$table->data[($i + 2)][3] = html_print_extended_select_for_time(
$table->data[($i + 2)][3] .= '<div class="row-flex">';
$table->data[($i + 2)][3] .= html_print_extended_select_for_time(
'period_'.$idLayoutData,
$layoutData['period'],
'',
@ -731,6 +845,7 @@ foreach ($layoutDatas as $layoutData) {
10,
true
);
$table->data[($i + 2)][3] .= '</div>';
break;
default:
@ -738,7 +853,7 @@ foreach ($layoutDatas as $layoutData) {
break;
}
// Map linked
// Map linked.
switch ($layoutData['type']) {
case NETWORK_LINK:
case LINE_ITEM:
@ -761,9 +876,8 @@ foreach ($layoutDatas as $layoutData) {
true,
false,
true,
'',
false,
'width: 120px'
'width:100%'
);
break;
}

View File

@ -34,7 +34,7 @@ require_once $config['homedir'].'/include/functions_graph.php';
check_login();
if (! check_acl($config['id_user'], 0, 'AW')) {
if (! check_acl($config['id_user'], 0, 'PM') && ((bool) check_acl($config['id_user'], 0, 'AW') === true && $_GET['server_remote'] === null)) {
db_pandora_audit(
AUDIT_LOG_ACL_VIOLATION,
'Trying to access Server Management'
@ -286,19 +286,21 @@ if (isset($_GET['server']) === true) {
$id_server
);
$buttons = '';
$buttons = [];
// Buttons.
$buttons = [
'standard_editor' => [
'active' => false,
'text' => '<a href="index.php?sec=gservers&sec2=godmode/servers/modificar_server&server_remote='.$id_server.'&ext='.$ext.'&tab=standard_editor&pure='.$pure.'">'.html_print_image('images/list.png', true, ['title' => __('Standard editor')]).'</a>',
],
'advanced_editor' => [
'active' => false,
'text' => '<a href="index.php?sec=gservers&sec2=godmode/servers/modificar_server&server_remote='.$id_server.'&ext='.$ext.'&tab=advanced_editor&pure='.$pure.'">'.html_print_image('images/pen.png', true, ['title' => __('Advanced editor')]).'</a>',
],
];
if ((bool) check_acl($config['id_user'], 0, 'PM') === true) {
$buttons = [
'standard_editor' => [
'active' => false,
'text' => '<a href="index.php?sec=gservers&sec2=godmode/servers/modificar_server&server_remote='.$id_server.'&ext='.$ext.'&tab=standard_editor&pure='.$pure.'">'.html_print_image('images/list.png', true, ['title' => __('Standard editor')]).'</a>',
],
'advanced_editor' => [
'active' => false,
'text' => '<a href="index.php?sec=gservers&sec2=godmode/servers/modificar_server&server_remote='.$id_server.'&ext='.$ext.'&tab=advanced_editor&pure='.$pure.'">'.html_print_image('images/pen.png', true, ['title' => __('Advanced editor')]).'</a>',
],
];
}
if ($server_type === SERVER_TYPE_ENTERPRISE_SATELLITE) {
$buttons['agent_editor'] = [

View File

@ -28,7 +28,9 @@
// Begin.
require_once 'include/functions_clippy.php';
require_once 'pending_alerts_list.php';
if ((bool) check_acl($config['id_user'], 0, 'LM') === true) {
include 'pending_alerts_list.php';
}
global $config;

View File

@ -597,7 +597,7 @@ if (enterprise_installed() === true) {
$config['custom_splash_login'],
'',
__('Default'),
'default',
'default.png',
true,
false,
true,
@ -1301,10 +1301,9 @@ $table_chars->data[$row][] = html_print_label_input_block(
'content' => html_print_div(
[
'class' => '',
'content' => __('Area').'&nbsp;'.html_print_radio_button(
'content' => __('Area').'&nbsp;'.html_print_checkbox_switch(
'type_module_charts',
'area',
'',
$config['type_module_charts'] == 'area',
true
),
@ -1313,10 +1312,9 @@ $table_chars->data[$row][] = html_print_label_input_block(
).html_print_div(
[
'class' => '',
'content' => __('Line').'&nbsp;'.html_print_radio_button(
'content' => __('Line').'&nbsp;'.html_print_checkbox_switch(
'type_module_charts',
'line',
'',
$config['type_module_charts'] != 'area',
true
),

View File

@ -786,7 +786,7 @@ if ($create_alert || $update_alert) {
2,
2,
$custom_value,
'class="w100p" required="required"',
'class="w100p"',
true
)
);
@ -806,7 +806,7 @@ if ($create_alert || $update_alert) {
255,
true,
false,
true
false
)
);
echo '</td>';

View File

@ -122,7 +122,7 @@ $table->data[1][1] = html_print_input_text(
50,
255,
true
);
).html_print_input_hidden('today_date', date('Y-m-d'), true);
$table->data[1][2] = __('Expiration Time');
$table->data[1][3] = html_print_input_text(
@ -132,9 +132,9 @@ $table->data[1][3] = html_print_input_text(
50,
255,
true
);
).html_print_input_hidden('today_time', date('H:i:s'), true);
echo '<form class="max_floating_element_size" method="post" action="'.$url_list.'">';
echo '<form class="max_floating_element_size" id="form_token" method="post" action="'.$url_list.'">';
html_print_table($table);
@ -143,7 +143,7 @@ $actionButtons = [];
if (empty($id_token) === true) {
$actionButtons[] = html_print_submit_button(
__('Create'),
'crt',
'next',
false,
['icon' => 'wand'],
true
@ -152,7 +152,7 @@ if (empty($id_token) === true) {
} else {
$actionButtons[] = html_print_submit_button(
__('Update'),
'upd',
'next',
false,
['icon' => 'update'],
true
@ -201,4 +201,41 @@ ui_require_jquery_file('ui.datepicker-'.get_user_language(), 'include/javascript
closeText: '<?php echo __('Close'); ?>'
});
});
function errordate() {
confirmDialog({
title: "<?php echo __('Error'); ?>",
message: "<?php echo __('Expiration date must be later than today.'); ?>",
hideCancelButton: true,
});
}
$('#button-next').on('click', function() {
event.preventDefault();
var date = $('#text-date-expiration').val();
var time = date+' '+$('#text-time-expiration').val();
if (date !== '' && $('#text-time-expiration').val() !== '') {
if (date < $('#hidden-today_date').val() || time < $('#hidden-today_date').val()+' '+$('#hidden-today_time').val()) {
errordate();
} else{
$('#form_token').submit();
}
} else if (date !== '' && time === ' ') {
if (date < $('#hidden-today_date').val()) {
errordate();
} else{
$('#form_token').submit();
}
} else if (date === '' && time !== ' ') {
errordate();
} else if (date !== '' && $('#text-time-expiration').val() === '') {
if (date < $('#hidden-today_date').val()) {
errordate();
} else{
$('#form_token').submit();
}
}else {
$('#form_token').submit();
}
})
</script>

View File

@ -77,10 +77,13 @@ if ($create_token === true || $update_token === true) {
$expirationDate = get_parameter('date-expiration', null);
$expirationTime = get_parameter('time-expiration', null);
$validity = null;
if (empty($expirationDate) === false) {
$validity = $expirationDate;
if (empty($expirationTime) === false) {
$validity .= ' '.$expirationTime;
} else {
$validity .= ' 23:59:59';
}
}

View File

@ -331,7 +331,7 @@ if ($show_update_action_menu) {
false,
'',
false,
false
true
);
$data .= '</td>';
$data .= '</tr>';

View File

@ -1929,13 +1929,13 @@ if (check_login()) {
);
}
// Search module name.
if (empty($search) === false) {
$where .= ' AND tagente_modulo.nombre LIKE "%%'.$search.'%%"';
$where .= ' AND tagente_modulo.nombre LIKE "%%'.io_safe_output($search).'%%"';
}
if (empty($search_agent) === false) {
$where .= ' AND tagente.alias LIKE "%%'.$search_agent.'%%"';
$where .= ' AND tagente.alias LIKE "%%'.io_safe_output($search_agent).'%%"';
}
if (str_contains($status, '6') === true) {

View File

@ -210,6 +210,17 @@ class CalendarManager
if ($op === 'edit' && $action === '') {
$tab = 'list_edit';
$buttons['list_edit'] = [
'active' => false,
'text' => '<a href="'.ui_get_full_url($this->url.'&tab_calendar=list&op=edit').'">'.html_print_image(
'images/edit.svg',
true,
[
'title' => __('Edit calendar'),
'class' => 'main_menu_icon invert_filter',
]
).'</a>',
];
}
$buttons[$tab]['active'] = true;

View File

@ -234,18 +234,18 @@ class ExtensionsDiscovery extends Wizard
url_str = `<a target="_blank" class="link-important" href="${url}">'.__('here').'</a>`;
}
var markup = "<ul class=\'\'>";
var markup = "<ul class=\'\' style=\'padding: 15px 0px 0px 25px;\'>";
if (msgs_json.includes('.NOT_FOUND_MSG.')) {
markup += "<li>&nbsp;&nbsp;&nbsp;'.__('The required files for the application were not found.').'</li>";
markup += \'<li class="lato font_10pt bolder">&nbsp;&nbsp;&nbsp;'.__('The required files for the application were not found.').'</li>\';
}
if (msgs_json.includes('.ENTERPRISE_MSG.')) {
markup += "<li>&nbsp;&nbsp;&nbsp;'.__('This discovery application is for Enterprise customers only.').'</li>";
markup += \'<li class="lato font_10pt bolder">&nbsp;&nbsp;&nbsp;'.__('This discovery application is for Enterprise customers only.').'</li>\';
}
if (msgs_json.includes('.URL_MSG.')) {
markup += \'<li>&nbsp;&nbsp;&nbsp;'.__('You can download this application from').' \'+url_str+\'.</li>\';
markup += \'<li class="lato font_10pt bolder">&nbsp;&nbsp;&nbsp;'.__('You can download this application from').' \'+url_str+\'.</li>\';
}
markup += "</ul>";

View File

@ -553,7 +553,6 @@ class SatelliteCollection extends HTML
},
datatype: "json",
success: function(data) {
console.log(data);
showMsg(data);
},
error: function(e) {
@ -596,7 +595,6 @@ class SatelliteCollection extends HTML
},
datatype: "json",
success: function(data) {
console.log(data);
showMsg(data);
},
error: function(e) {
@ -615,7 +613,7 @@ class SatelliteCollection extends HTML
function showMsg(data) {
var title = "<?php echo __('Success'); ?>";
var dt_satellite_agents = $("#satellite_collections").DataTable();
dt_<?php echo $this->tableId; ?>.draw(false);
dt_satellite_agents.draw(false);
var text = '';
var failed = 0;

View File

@ -554,6 +554,10 @@ class SnmpConsole extends HTML
$filters = get_parameter('filter', []);
// Build ranges.
if (empty($filters['filter_hours_ago']) === true) {
$filters['filter_hours_ago'] = 8;
}
$now_timestamp = time();
$interval_seconds = ($filters['filter_hours_ago'] * 3600);
$ago_timestamp = ($now_timestamp - $interval_seconds);
@ -637,42 +641,25 @@ class SnmpConsole extends HTML
$whereSubquery .= ' AND alerted = '.$filters['filter_alert'];
}
$filters['filter_severity'] = (int) $filters['filter_severity'];
if ($filters['filter_severity'] != -1) {
// There are two special severity values aimed to match two different trap standard severities
// in database: warning/critical and critical/normal.
if ($filters['filter_severity'] != EVENT_CRIT_OR_NORMAL
&& $filters['filter_severity'] != EVENT_CRIT_WARNING_OR_CRITICAL
if ($filters['filter_severity'] !== EVENT_CRIT_OR_NORMAL
&& $filters['filter_severity'] !== EVENT_CRIT_WARNING_OR_CRITICAL
&& $filters['filter_severity'] !== EVENT_CRIT_NOT_NORMAL
) {
// Test if enterprise is installed to search oid in text or oid field in ttrap.
if ($config['enterprise_installed']) {
$whereSubquery .= ' AND (
(alerted = 0 AND severity = '.$filters['filter_severity'].') OR
(alerted = 1 AND priority = '.$filters['filter_severity'].'))';
} else {
$whereSubquery .= ' AND (
(alerted = 0 AND 1 = '.$filters['filter_severity'].') OR
(alerted = 1 AND priority = '.$filters['filter_severity'].'))';
}
$whereSubquery .= ' AND severity = '.$filters['filter_severity'];
} else if ($filters['filter_severity'] === EVENT_CRIT_WARNING_OR_CRITICAL) {
// Test if enterprise is installed to search oid in text or oid field in ttrap.
if ($config['enterprise_installed']) {
$whereSubquery .= ' AND (
(alerted = 0 AND (severity = '.EVENT_CRIT_WARNING.' OR severity = '.EVENT_CRIT_CRITICAL.')) OR
(alerted = 1 AND (priority = '.EVENT_CRIT_WARNING.' OR priority = '.EVENT_CRIT_CRITICAL.')))';
} else {
$whereSubquery .= ' AND (
(alerted = 1 AND (priority = '.EVENT_CRIT_WARNING.' OR priority = '.EVENT_CRIT_CRITICAL.')))';
}
$whereSubquery .= ' AND (severity = '.EVENT_CRIT_WARNING.' OR severity = '.EVENT_CRIT_CRITICAL.' OR severity = '.EVENT_CRIT_WARNING_OR_CRITICAL.')';
} else if ($filters['filter_severity'] === EVENT_CRIT_OR_NORMAL) {
// Test if enterprise is installed to search oid in text or oid field in ttrap.
if ($config['enterprise_installed']) {
$whereSubquery .= ' AND (
(alerted = 0 AND (severity = '.EVENT_CRIT_NORMAL.' OR severity = '.EVENT_CRIT_CRITICAL.')) OR
(alerted = 1 AND (priority = '.EVENT_CRIT_NORMAL.' OR priority = '.EVENT_CRIT_CRITICAL.')))';
} else {
$whereSubquery .= ' AND (
(alerted = 1 AND (priority = '.EVENT_CRIT_NORMAL.' OR priority = '.EVENT_CRIT_CRITICAL.')))';
}
$whereSubquery .= ' AND (severity = '.EVENT_CRIT_NORMAL.' OR severity = '.EVENT_CRIT_CRITICAL.' OR severity = '.EVENT_CRIT_OR_NORMAL.')';
} else if ($filters['filter_severity'] === EVENT_CRIT_NOT_NORMAL) {
// Test if enterprise is installed to search oid in text or oid field in ttrap.
$whereSubquery .= ' AND (severity = '.EVENT_CRIT_WARNING.' OR severity = '.EVENT_CRIT_CRITICAL.' OR severity = '.EVENT_CRIT_NOT_NORMAL.')';
}
}
@ -1142,42 +1129,25 @@ class SnmpConsole extends HTML
$whereSubquery .= ' AND alerted = '.$$alert;
}
if ($severity != -1) {
$severity = (int) $severity;
if ($severity !== -1) {
// There are two special severity values aimed to match two different trap standard severities
// in database: warning/critical and critical/normal.
if ($severity != EVENT_CRIT_OR_NORMAL
&& $severity != EVENT_CRIT_WARNING_OR_CRITICAL
if ($severity !== EVENT_CRIT_OR_NORMAL
&& $severity !== EVENT_CRIT_WARNING_OR_CRITICAL
&& $severity !== EVENT_CRIT_NOT_NORMAL
) {
// Test if enterprise is installed to search oid in text or oid field in ttrap.
if ($config['enterprise_installed']) {
$whereSubquery .= ' AND (
(alerted = 0 AND severity = '.$severity.') OR
(alerted = 1 AND priority = '.$severity.'))';
} else {
$whereSubquery .= ' AND (
(alerted = 0 AND 1 = '.$severity.') OR
(alerted = 1 AND priority = '.$severity.'))';
}
$whereSubquery .= ' AND severity = '.$severity;
} else if ($severity === EVENT_CRIT_WARNING_OR_CRITICAL) {
// Test if enterprise is installed to search oid in text or oid field in ttrap.
if ($config['enterprise_installed']) {
$whereSubquery .= ' AND (
(alerted = 0 AND (severity = '.EVENT_CRIT_WARNING.' OR severity = '.EVENT_CRIT_CRITICAL.')) OR
(alerted = 1 AND (priority = '.EVENT_CRIT_WARNING.' OR priority = '.EVENT_CRIT_CRITICAL.')))';
} else {
$whereSubquery .= ' AND (
(alerted = 1 AND (priority = '.EVENT_CRIT_WARNING.' OR priority = '.EVENT_CRIT_CRITICAL.')))';
}
$whereSubquery .= ' AND (severity = '.EVENT_CRIT_WARNING.' OR severity = '.EVENT_CRIT_CRITICAL.' OR severity = '.EVENT_CRIT_WARNING_OR_CRITICAL.')';
} else if ($severity === EVENT_CRIT_OR_NORMAL) {
// Test if enterprise is installed to search oid in text or oid field in ttrap.
if ($config['enterprise_installed']) {
$whereSubquery .= ' AND (
(alerted = 0 AND (severity = '.EVENT_CRIT_NORMAL.' OR severity = '.EVENT_CRIT_CRITICAL.')) OR
(alerted = 1 AND (priority = '.EVENT_CRIT_NORMAL.' OR priority = '.EVENT_CRIT_CRITICAL.')))';
} else {
$whereSubquery .= ' AND (
(alerted = 1 AND (priority = '.EVENT_CRIT_NORMAL.' OR priority = '.EVENT_CRIT_CRITICAL.')))';
}
$whereSubquery .= ' AND (severity = '.EVENT_CRIT_NORMAL.' OR severity = '.EVENT_CRIT_CRITICAL.' OR severity = '.EVENT_CRIT_OR_NORMAL.')';
} else if ($severity === EVENT_CRIT_NOT_NORMAL) {
// Test if enterprise is installed to search oid in text or oid field in ttrap.
$whereSubquery .= ' AND (severity = '.EVENT_CRIT_WARNING.' OR severity = '.EVENT_CRIT_CRITICAL.' OR severity = '.EVENT_CRIT_NOT_NORMAL.')';
}
}

View File

@ -22,7 +22,7 @@ use DI\ContainerBuilder;
/*
* Pandora build version and version
*/
$build_version = 'PC240415';
$build_version = 'PC240426';
$pandora_version = 'v7.0NG.776';
// Do not overwrite default timezone set if defined.

View File

@ -1006,10 +1006,10 @@ function get_parameter($name, $default='')
function get_parameter_date($name, $default='', $date_format='Y/m/d')
{
// TODO: Configure default value.
$date_end = get_parameter('date_end', 0);
$time_end = get_parameter('time_end');
$datetime_end = strtotime($date_end.' '.$time_end);
$date_none = get_parameter($name, $default);
$custom_date = get_parameter('custom_date', 0);
$range = get_parameter($name, SECONDS_1DAY);
@ -1055,6 +1055,9 @@ function get_parameter_date($name, $default='', $date_format='Y/m/d')
$date_init = $first_of_week;
$period = (strtotime($date_end) - strtotime($first_of_week));
}
} else if ($date_none === 'none') {
// Prioritize the report item period based on the current local date/time.
$date_end = date('Y/m/d H:i:s');
} else {
$date_end = date('Y/m/d H:i:s');
$date_init = date('Y/m/d H:i:s', (strtotime($date_end) - $range));
@ -4419,7 +4422,18 @@ function generator_chart_to_pdf(
$browserFactory = new BrowserFactory($chromium_dir);
// Starts headless chrome.
$browser = $browserFactory->createBrowser(['noSandbox' => true]);
$browser = $browserFactory->createBrowser(
[
'noSandbox' => true,
'customFlags' => [
'--disable-dev-shm-usage',
'--disable-gpu',
'--disable-web-security',
'--font-render-hinting=medium',
],
'ignoreCertificateErrors' => true,
]
);
// Creates a new page.
$page = $browser->createPage();

View File

@ -13175,10 +13175,12 @@ function api_set_create_event($id, $trash1, $other, $returnType)
$values['id_extra'] = '';
}
if ($other['data'][21] != '') {
$values['event_custom_id'] = $other['data'][21];
} else {
$values['event_custom_id'] = '';
if (empty($values['event_custom_id']) === true) {
if ($other['data'][21] != '') {
$values['event_custom_id'] = $other['data'][21];
} else {
$values['event_custom_id'] = '';
}
}
$custom_data = base64_decode($values['custom_data']);

View File

@ -1119,11 +1119,13 @@ function events_get_all(
}
}
if (!$user_is_admin && users_can_manage_group_all('ER') === false) {
$ER_groups = users_get_groups($config['id_user'], 'ER', true);
if (!$user_is_admin && users_can_manage_group_all('EM') === false) {
$EM_groups = users_get_groups($config['id_user'], 'EM', true, true);
$EW_groups = users_get_groups($config['id_user'], 'EW', true, true);
}
if (!$user_is_admin && users_can_manage_group_all('ER') === false) {
$ER_groups = users_get_groups($config['id_user'], 'ER', true);
// Get groups where user have ER grants.
if ((bool) $filter['search_secondary_groups'] === true) {
$sql_filters[] = sprintf(
@ -1155,7 +1157,7 @@ function events_get_all(
}
// Free search.
if (empty($filter['search']) === false && (bool) $filter['regex'] === false) {
if (empty($filter['search']) === false) {
if (isset($config['dbconnection']->server_version) === true
&& $config['dbconnection']->server_version > 50600
) {
@ -1185,23 +1187,39 @@ function events_get_all(
$array_search[] = 'lower(ta.alias)';
}
// Disregard repeated whitespaces when searching.
$collapsed_spaces_search = preg_replace('/(&#x20;)+/', '&#x20;', $filter['search']);
if ((bool) $filter['regex'] === true) {
$sql_search = ' AND (';
foreach ($array_search as $key => $field) {
$sql_search .= sprintf(
'%s %s %s REGEXP "%s" ',
($key === 0) ? '' : $nexo,
$field,
$not_search,
preg_replace('/(?<!\\\\)"/', '', io_safe_output($filter['search'])),
);
$sql_search .= ' ';
}
$sql_search = ' AND (';
foreach ($array_search as $key => $field) {
$sql_search .= sprintf(
'%s LOWER(REGEXP_REPLACE(%s, "(&#x20;)+", "&#x20;")) %s like LOWER("%%%s%%")',
($key === 0) ? '' : $nexo,
$field,
$not_search,
$collapsed_spaces_search
);
$sql_search .= ' ';
$sql_search .= ' )';
} else {
// Disregard repeated whitespaces when searching.
$collapsed_spaces_search = preg_replace('/(&#x20;)+/', '&#x20;', $filter['search']);
$sql_search = ' AND (';
foreach ($array_search as $key => $field) {
$sql_search .= sprintf(
'%s LOWER(REGEXP_REPLACE(%s, "(&#x20;)+", "&#x20;")) %s like LOWER("%%%s%%")',
($key === 0) ? '' : $nexo,
$field,
$not_search,
$collapsed_spaces_search
);
$sql_search .= ' ';
}
$sql_search .= ' )';
}
$sql_search .= ' )';
$sql_filters[] = $sql_search;
}
@ -1674,9 +1692,16 @@ function events_get_all(
}
}
if (!$user_is_admin && users_can_manage_group_all('ER') === false) {
if (str_contains($fields[0], 'te.id_grupo') === false) {
$fields[0] .= ', te.id_grupo';
if (!$user_is_admin && users_can_manage_group_all('EM') === false) {
$exists_id_grupo = false;
foreach ($fields as $field) {
if (str_contains($field, 'te.id_grupo') === true || str_contains($field, 'te.*') === true) {
$exists_id_grupo = true;
}
}
if ($exists_id_grupo === false) {
$fields[] = 'te.id_grupo';
}
}
@ -1791,7 +1816,7 @@ function events_get_all(
return $sql;
}
if (!$user_is_admin && users_can_manage_group_all('ER') === false) {
if (!$user_is_admin && users_can_manage_group_all('EM') === false) {
$can_manage = '0 as user_can_manage';
if (empty($EM_groups) === false) {
$can_manage = sprintf(
@ -5897,17 +5922,30 @@ function events_get_instructions($event, $max_text_length=300)
return $value;
}
$event_name = ui_print_truncate_text(
io_safe_output($event['evento']),
GENERIC_SIZE_TEXT,
false,
true,
false,
'...'
);
$over_event_name = base64_encode($event_name);
$output = '<div id="hidden_event_instructions_'.$event['id_evento'].'"';
$output .= ' class="event_instruction">';
$output .= $value;
$output .= '</div>';
$output .= '<span id="value_event_'.$event['id_evento'].'" class="nowrap">';
$output .= '<span id="value_event_text_'.$event['id_evento'].'"></span>';
$output .= '<a href="javascript:show_instructions('.$event['id_evento'].')">';
$output .= '<a href="javascript:show_instructions('.$event['id_evento'].',\''.$over_event_name.'\')">';
$output .= html_print_image(
'images/default_list.png',
true,
['title' => $over_text]
[
'title' => $over_text,
'class' => 'invert_filter',
]
).'</a></span>';
return $output;

View File

@ -3308,7 +3308,8 @@ function graph_custom_sql_graph(
$only_image=false,
$homeurl='',
$ttl=1,
$max_num_elements=8
$max_num_elements=8,
$layout=false
) {
global $config;
@ -3509,6 +3510,10 @@ function graph_custom_sql_graph(
if ((int) $ttl === 2) {
$options['dataLabel'] = ['display' => 'auto'];
if ($layout !== false && is_array($layout) === true) {
$options['layout'] = $layout;
}
}
$output .= vbar_graph(

View File

@ -1653,42 +1653,46 @@ function groups_monitor_fired_alerts($group_array)
function groups_monitor_alerts_total_counters($group_array, $secondary_group=true)
{
// If there are not groups to query, we jump to nextone
// If there are not groups to query, we jump to nextone.
$default_total = [
'total' => 0,
'fired' => 0,
];
if (empty($group_array)) {
if (empty($group_array) === true) {
return $default_total;
} else if (!is_array($group_array)) {
} else if (is_array($group_array) === false) {
$group_array = [$group_array];
}
$group_clause = implode(',', $group_array);
if ($secondary_group === true) {
$group_clause = "(tasg.id_group IN ($group_clause) OR ta.id_grupo IN ($group_clause))";
$group_clause = '(tagent_secondary_group.id_group IN ('.$group_clause.') OR tagente.id_grupo IN ('.$group_clause.'))';
} else {
$group_clause = "(ta.id_grupo IN ($group_clause))";
$group_clause = '(tagente.id_grupo IN ('.$group_clause.'))';
}
$sql = 'SELECT
COUNT(tatm.id) AS total,
SUM(IF(tatm.times_fired > 0, 1, 0)) AS fired
FROM talert_template_modules tatm
INNER JOIN tagente_modulo tam
ON tatm.id_agent_module = tam.id_agente_modulo
INNER JOIN tagente ta
ON ta.id_agente = tam.id_agente
WHERE ta.id_agente IN (
SELECT ta.id_agente
FROM tagente ta';
$sql_join_secondary_group = '';
if ($secondary_group === true) {
$sql .= ' LEFT JOIN tagent_secondary_group tasg ON ta.id_agente = tasg.id_agent';
$sql_join_secondary_group = 'LEFT JOIN tagent_secondary_group ON tagente.id_agente = tagent_secondary_group.id_agent';
}
$sql .= " WHERE ta.disabled = 0
AND $group_clause
) AND tam.disabled = 0";
$sql = sprintf(
'SELECT
COUNT(talert_template_modules.id) AS total,
SUM(IF(talert_template_modules.times_fired > 0, 1, 0)) AS fired
FROM talert_template_modules
INNER JOIN tagente_modulo
ON talert_template_modules.id_agent_module = tagente_modulo.id_agente_modulo
INNER JOIN tagente
ON tagente.id_agente = tagente_modulo.id_agente
%s
WHERE tagente.disabled = 0
AND tagente_modulo.disabled = 0
AND %s',
$sql_join_secondary_group,
$group_clause
);
$alerts = db_get_row_sql($sql);
@ -2697,7 +2701,7 @@ function tactical_groups_get_stats_alerts($id_groups, $data='')
global $config;
if ($data === '') {
$alerts = groups_monitor_alerts_total_counters($id_groups, false);
$alerts = groups_monitor_alerts_total_counters($id_groups, true);
$data = [
'monitor_alerts' => $alerts['total'],
'monitor_alerts_fired' => $alerts['fired'],

View File

@ -84,6 +84,7 @@ function groupview_get_modules_counters($groups_ids=false)
INNER JOIN $table_sec tasg
ON ta.id_agente = tasg.id_agent
WHERE tasg.id_group IN ($groups_ids)
AND ta.disabled = 0
GROUP BY tasg.id_group
) x GROUP BY g";
$data = db_get_all_rows_sql($sql);

View File

@ -774,6 +774,7 @@ function html_print_select(
$order=false,
$custom_id=null,
$placeholder='',
$select2_container_class=false
) {
$output = "\n";
@ -1190,6 +1191,12 @@ function html_print_select(
$output .= '</script>';
}
if ($select2_container_class !== false) {
$output .= '<script>';
$output .= '$("#'.$id.'").data("select2").$container.addClass("'.$select2_container_class.'")';
$output .= '</script>';
}
if ($return) {
return $output;
}
@ -2498,7 +2505,8 @@ function html_print_extended_select_for_time(
$no_change=false,
$allow_zero=0,
$units=null,
$script_input=''
$script_input='',
$units_select2=false
) {
global $config;
$admin = is_user_admin($config['id_user']);
@ -2588,7 +2596,19 @@ function html_print_extended_select_for_time(
echo '</div>';
echo '<div id="'.$uniq_name.'_manual" class="inline_flex">';
html_print_input_text($uniq_name.'_text', $selected, '', $size, 255, false, $readonly, false, '', $class, $script_input);
html_print_input_text(
$uniq_name.'_text',
$selected,
'',
$size,
255,
false,
$readonly,
false,
'',
$class.(($units_select2 === true) ? ' w100p' : ''),
$script_input
);
html_print_input_hidden($name, $selected, false, $uniq_name);
html_print_select(
@ -2612,7 +2632,7 @@ function html_print_extended_select_for_time(
false,
false,
false,
false
$units_select2
);
echo '&nbsp&nbsp<a href="javascript:">'.html_print_image(
'images/logs@svg.svg',
@ -2625,6 +2645,7 @@ function html_print_extended_select_for_time(
]
).'</a>';
echo '</div>';
echo "<script type='text/javascript'>
$(document).ready (function () {
period_select_init('".$uniq_name."', ".(($allow_zero) ? 1 : 0).");
@ -2645,6 +2666,18 @@ function html_print_extended_select_for_time(
}, 100);
}
</script>";
if ($units_select2 === true) {
echo '
<script>
$(document).ready (function () {
$("#'.$uniq_name.'_units").select2();
$("#'.$uniq_name.'_units").data("select2").$container.addClass("mrgn_lft_10px_imp");
});
</script>
';
}
$returnString = ob_get_clean();
if ($return) {
@ -3528,7 +3561,8 @@ function html_print_input_text(
$disabled=false,
$list='',
$placeholder=null,
$pattern=null
$pattern=null,
$id=false
) {
if ($maxlength == 0) {
$maxlength = 255;
@ -3586,7 +3620,7 @@ function html_print_input_text(
return html_print_input_text_extended(
$name,
$value,
'text-'.$name,
(($id === false) ? 'text-'.$name : $id),
$alt,
$size,
$maxlength,
@ -6327,7 +6361,8 @@ function html_print_input($data, $wrapper='div', $input_only=false)
((isset($data['no_change']) === true) ? $data['no_change'] : ''),
((isset($data['allow_zero']) === true) ? $data['allow_zero'] : ''),
((isset($data['units']) === true) ? $data['units'] : null),
((isset($data['script_input']) === true) ? $data['script_input'] : '')
((isset($data['script_input']) === true) ? $data['script_input'] : ''),
((isset($data['units_select2']) === true) ? $data['units_select2'] : '')
);
break;
@ -6616,7 +6651,12 @@ function html_print_input($data, $wrapper='div', $input_only=false)
false,
true,
true,
true
true,
'',
false,
null,
'',
'select2-multiselect-widget-width select2-multiselect-text-wrap'
);
$output .= '</li>';
@ -6684,7 +6724,12 @@ function html_print_input($data, $wrapper='div', $input_only=false)
false,
true,
true,
true
true,
'',
false,
null,
'',
'select2-multiselect-widget-width select2-multiselect-text-wrap'
);
$output .= '</li>';
@ -6844,6 +6889,11 @@ function html_print_input($data, $wrapper='div', $input_only=false)
(isset($data['time_end']) === true) ? $data['time_end'] : '',
(isset($data['date_text']) === true) ? $data['date_text'] : SECONDS_1DAY,
(isset($data['class']) === true) ? $data['class'] : 'w100p',
(isset($data['date_format_php']) === true) ? $data['date_format_php'] : 'Y/m/d',
(isset($data['time_format_php']) === true) ? $data['time_format_php'] : 'H:i:s',
(isset($data['date_format_js']) === true) ? $data['date_format_js'] : 'yy/mm/dd',
(isset($data['time_format_js']) === true) ? $data['time_format_js'] : 'HH/mm/ss',
(isset($data['id']) === true) ? $data['id'] : '',
);
break;
@ -7826,7 +7876,8 @@ function html_print_select_date_range(
$date_format_php='Y/m/d',
$time_format_php='H:i:s',
$date_format_js='yy/mm/dd',
$time_format_js='HH:mm:ss'
$time_format_js='HH:mm:ss',
$id='',
) {
global $config;
@ -7877,7 +7928,7 @@ function html_print_select_date_range(
$fields['chose_range'] = __('Chose start/end date period');
$fields['none'] = __('None');
$output = html_print_input_hidden('custom_date', $custom_date, true);
$output = html_print_input_hidden('custom_date', $custom_date, true, false, false, 'hidden-custom_date'.$id);
$output .= '<div id="'.$name.'_default" class="wauto inline_flex" '.$display_default.'>';
$output .= html_print_select(
$fields,
@ -7897,13 +7948,101 @@ function html_print_select_date_range(
$table->data = [];
$table->class = 'table-adv-filter';
$table->data[0][0] = '<div><div><div><span class="font-title-font">'.__('From').':</span></div>';
$table->data[0][0] .= html_print_input_text('date_init', $date_init, '', 12, 10, true).' ';
$table->data[0][0] .= html_print_input_text('time_init', $time_init, '', 10, 7, true).' ';
$table->data[0][0] .= html_print_input_text(
'date_init',
$date_init,
'',
12,
10,
true,
false,
false,
'',
'',
'',
'off',
false,
'',
'',
'',
false,
'',
null,
null,
(empty($id) === false) ? 'text-date_init'.$id : false,
).' ';
$table->data[0][0] .= html_print_input_text(
'time_init',
$time_init,
'',
10,
7,
true,
false,
false,
'',
'',
'',
'off',
false,
'',
'',
'',
false,
'',
null,
null,
(empty($id) === false) ? 'text-time_init'.$id : false,
).' ';
$table->data[0][0] .= '</div>';
$table->data[0][0] .= '<div><div><span class="font-title-font">'.__('to').':</span></div>';
$table->data[0][0] .= html_print_input_text('date_end', $date_end, '', 12, 10, true).' ';
$table->data[0][0] .= html_print_input_text(
'date_end',
$date_end,
'',
12,
10,
true,
false,
false,
'',
'',
'',
'off',
false,
'',
'',
'',
false,
'',
null,
null,
(empty($id) === false) ? 'text-date_end'.$id : false,
).' ';
$table->data[0][0] .= '<div id="'.$name.'_manual" class="w100p inline_line">';
$table->data[0][0] .= html_print_input_text('time_end', $time_end, '', 10, 7, true).' ';
$table->data[0][0] .= html_print_input_text(
'time_end',
$time_end,
'',
10,
7,
true,
false,
false,
'',
'',
'',
'off',
false,
'',
'',
'',
false,
'',
null,
null,
(empty($id) === false) ? 'text-time_end'.$id : false,
).' ';
$table->data[0][0] .= ' <a href="javascript:">'.html_print_image(
'images/logs@svg.svg',
true,
@ -7974,13 +8113,13 @@ function html_print_select_date_range(
$('#".$name."_range').show();
$('#".$name."_default').hide();
$('#".$name."_extend').hide();
$('#hidden-custom_date').val('1');
$('#hidden-custom_date".$id."').val('1');
$('.filter_label_position_before').addClass('filter_label_position_after');
} else if ($(this).val() === 'custom') {
$('#".$name."_range').hide();
$('#".$name."_default').hide();
$('#".$name."_extend').show();
$('#hidden-custom_date').val('2');
$('#hidden-custom_date".$id."').val('2');
$('.filter_label_position_before').removeClass('filter_label_position_after');
} else {
$('.filter_label_position_before').removeClass('filter_label_position_after');
@ -7998,8 +8137,8 @@ function html_print_select_date_range(
$('#".$name."_range').show();
$('#".$name."_default').hide();
$('#".$name."_extend').hide();
position_top_init = $('#text-date_init').offset().top + $('#text-date_init').outerHeight();
position_top_end = $('#text-date_end').offset().top + $('#text-date_end').outerHeight();
position_top_init = $('[id^=text-date_init".$id."]').offset().top + $('[id^=text-date_init".$id."]').outerHeight();
position_top_end = $('[id^=text-date_end".$id."]').offset().top + $('[id^=text-date_end".$id."]').outerHeight();
if(def_state_range){
$('#".$name."_range').show();
} else {
@ -8025,7 +8164,7 @@ function html_print_select_date_range(
$('#".$name."_range').hide();
$('#".$name."_extend').hide();
$('#".$name."').val('".SECONDS_1DAY."').trigger('change');
$('#hidden-custom_date').val('0');
$('#hidden-custom_date".$id."').val('0');
}
$('#text-date').datepicker({
@ -8035,7 +8174,7 @@ function html_print_select_date_range(
showAnim: 'slideDown'
});
$('[id^=text-time_init]').timepicker({
$('[id^=text-time_init".$id."]').timepicker({
showSecond: true,
timeFormat: '".$time_format_js."',
timeOnlyTitle: '".__('Choose time')."',
@ -8047,7 +8186,7 @@ function html_print_select_date_range(
closeText: '".__('Close')."'
});
$('[id^=text-date_init]').datepicker ({
$('[id^=text-date_init".$id."]').datepicker ({
dateFormat: '".$date_format_js."',
changeMonth: true,
changeYear: true,
@ -8056,9 +8195,9 @@ function html_print_select_date_range(
beforeShowDay: function (date) {
show_datepicker = 'date_init';
var date_now = date.getTime();
var date_ini_split = $('[id^=text-date_init]').val().split('/');
var date_ini_split = $('[id^=text-date_init".$id."]').val().split('/');
var date_ini = new Date(date_ini_split[1]+'/'+date_ini_split[2]+'/'+date_ini_split[0]).getTime();
var date_end_split = $('[id^=text-date_end]').val().split('/');
var date_end_split = $('[id^=text-date_end".$id."]').val().split('/');
var date_end = new Date(date_end_split[1]+'/'+date_end_split[2]+'/'+date_end_split[0]).getTime();
if (date_now > date_ini && date_now < date_end) {
return [true, 'ui-date-range-in', 'prueba'];
@ -8069,7 +8208,7 @@ function html_print_select_date_range(
}
});
$('[id^=text-date_end]').datepicker ({
$('[id^=text-date_end".$id."]').datepicker ({
dateFormat: '".$date_format_js."',
changeMonth: true,
changeYear: true,
@ -8078,9 +8217,9 @@ function html_print_select_date_range(
beforeShowDay: function (date) {
show_datepicker = 'date_end';
var date_now = date.getTime();
var date_ini_split = $('[id^=text-date_init]').val().split('/');
var date_ini_split = $('[id^=text-date_init".$id."]').val().split('/');
var date_ini = new Date(date_ini_split[1]+'/'+date_ini_split[2]+'/'+date_ini_split[0]).getTime();
var date_end_split = $('[id^=text-date_end]').val().split('/');
var date_end_split = $('[id^=text-date_end".$id."]').val().split('/');
var date_end = new Date(date_end_split[1]+'/'+date_end_split[2]+'/'+date_end_split[0]).getTime();
if (date_now > date_ini && date_now < date_end) {
return [true, 'ui-date-range-in', 'prueba'];
@ -8088,10 +8227,10 @@ function html_print_select_date_range(
return [true, 'ui-datepicker-current-day', ''];
}
return [true, '', ''];
}
},
});
$('[id^=text-time_end]').timepicker({
$('[id^=text-time_end".$id."]').timepicker({
showSecond: true,
timeFormat: '".$time_format_js."',
timeOnlyTitle: '".__('Choose time')."',

View File

@ -1052,6 +1052,154 @@ function get_data_basic_info_sql($params, $count=false)
}
function get_inventory_basic_info_sql($params, $count=false)
{
$table = 'tagente';
if (is_metaconsole() === true) {
$table = 'tmetaconsole_agent';
}
$where = 'WHERE 1=1 ';
if ($params['id_agent'] > 0) {
$where .= sprintf(' AND %s.id_agente = %d', $table, $params['id_agent']);
}
if ($params['status'] >= 0) {
$where .= sprintf(' AND %s.disabled = %d', $table, $params['status']);
}
if ($params['id_group'] > 0) {
$where .= sprintf(' AND id_grupo = %d', $params['id_group']);
} else {
global $config;
$user_groups = implode(',', array_keys(users_get_groups($config['id_user'])));
// Avoid errors if there are no groups.
if (empty($user_groups) === true) {
$user_groups = '"0"';
}
$where .= sprintf(' AND id_grupo IN (%s)', $user_groups);
}
if ($params['search'] > 0) {
$where .= sprintf(
' AND ( REPLACE(alias, "&#x20;", " ") LIKE "%%%s%%" )',
$params['search']
);
}
if ($params['utimestamp'] > 0) {
$where .= sprintf(
' AND UNIX_TIMESTAMP(ultimo_contacto) BETWEEN %d AND %d',
($params['utimestamp'] - $params['period']),
$params['utimestamp']
);
}
if ($params['order'] > 0) {
$str_split = explode(' ', $params['order']);
switch ($str_split[0]) {
case 'alias':
$params['order'] = 'alias '.$str_split[1];
break;
case 'ip':
$params['order'] = 'direccion '.$str_split[1];
break;
case 'secondoaryIp':
$params['order'] = 'fixed_ip '.$str_split[1];
break;
case 'group':
$params['order'] = 'id_grupo '.$str_split[1];
break;
case 'description':
$params['order'] = 'comentarios '.$str_split[1];
break;
case 'os':
$params['order'] = 'id_os '.$str_split[1];
break;
case 'interval':
$params['order'] = 'intervalo '.$str_split[1];
break;
case 'lastContact':
$params['order'] = 'ultimo_contacto '.$str_split[1];
break;
default:
$params['order'] = 'alias '.$str_split[1];
break;
}
}
$limit_condition = '';
$order_condition = '';
$groupby = '';
if (is_metaconsole() === true) {
$fields = 'tmetaconsole_agent.*';
} else {
$fields = 'tagente.*';
}
if ($count !== true) {
$limit_condition = sprintf(
'LIMIT %d, %d',
$params['start'],
$params['length']
);
$order_condition = sprintf('ORDER BY %s', $params['order']);
} else {
$fields = 'COUNT(*)';
}
$groupby = 'GROUP BY '.$table.'.id_agente';
$sql = sprintf(
'SELECT %s
FROM %s
%s
%s
%s
%s
%s',
$fields,
$table,
$innerjoin,
$where,
$groupby,
$order_condition,
$limit_condition
);
$sql_count = sprintf(
'SELECT COUNT(*)
FROM (%s) AS sub_sql',
$sql
);
if ($count !== true) {
$result = db_get_all_rows_sql($sql);
if ($result === false) {
$result = [];
}
} else {
$result = db_get_sql($sql_count);
if ($result === false) {
$result = 0;
}
}
return $result;
}
function inventory_get_dates($module_inventory_name, $inventory_agent, $inventory_id_group)
{
$sql = 'SELECT tagente_datos_inventory.utimestamp,

View File

@ -169,6 +169,10 @@ function menu_print_menu(&$menu)
$sec2 = 'godmode/users/profile_list';
} else if ($sec2 === 'godmode/users/configure_token') {
$sec2 = 'godmode/users/token_list';
} else if ($sec2 === 'godmode/servers/modificar_server' && check_acl($config['id_user'], 0, 'AW') && (bool) check_acl($config['id_user'], 0, 'PM') === false) {
$sec2 = 'enterprise/godmode/servers/list_satellite';
} else if ($sec2 === 'enterprise/godmode/snmpconsole/snmp_trap_editor_form') {
$sec2 = 'enterprise/godmode/snmpconsole/snmp_trap_editor';
} else {
$sec2 = (string) get_parameter('sec2');
}

View File

@ -1389,6 +1389,7 @@ function netflow_draw_item(
$show_summary=true,
$show_table=true
) {
global $config;
$aggregate = $filter['aggregate'];
$interval = ($end_date - $start_date);
if (is_metaconsole() === true) {
@ -1568,13 +1569,20 @@ function netflow_draw_item(
$data_top_n
);
// Theme.
$theme = $config['style'];
$text_color = ($theme !== 'pandora_black') ? '#333' : '#fff';
$graph_output = pie_graph(
$pie_data,
[
'width' => 200,
'height' => 200,
'ttl' => ($output === 'PDF') ? 2 : 1,
'dataLabel' => ['display' => 'auto'],
'dataLabel' => [
'display' => 'auto',
'color' => $text_color,
],
'layout' => [
'padding' => [
'top' => 15,

View File

@ -205,14 +205,21 @@ function reporting_make_reporting_data(
$contents = io_safe_output($report['contents']);
} else {
$report = io_safe_output(db_get_row('treport', 'id_report', $id_report));
$contents = io_safe_output(
db_get_all_rows_field_filter(
'treport_content',
'id_report',
$id_report,
db_escape_key_identifier('order')
)
$contents = db_get_all_rows_field_filter(
'treport_content',
'id_report',
$id_report,
db_escape_key_identifier('order')
);
foreach ($contents as $key_content => $content) {
foreach ($content as $key_item => $item) {
if ($key_item !== 'macros_definition') {
$contents[$key_content][$key_item] = io_safe_output($item);
}
}
}
}
$datetime = strtotime($date.' '.$time);
@ -2729,7 +2736,8 @@ function reporting_event_report_module(
$ttl,
$id_server,
$metaconsole_dbtable,
$filter_event_filter_exclude
$filter_event_filter_exclude,
$content['id_agent_module']
);
if (empty($data)) {
@ -5772,10 +5780,17 @@ function reporting_custom_render($report, $content, $type='dinamic', $pdf=0)
if (isset($content['macros_definition']) === true
&& empty($content['macros_definition']) === false
) {
$macros = json_decode(
io_safe_output($content['macros_definition']),
true
);
$macros = json_decode($content['macros_definition'], true);
if ($macros === null && json_last_error() !== JSON_ERROR_NONE) {
$return['data'] = ui_print_error_message(
__('Error decoded json macros definition'),
'',
true
);
return reporting_check_structure_content($return);
}
if (empty($macros) === false && is_array($macros) === true) {
foreach ($macros as $key_macro => $data_macro) {
switch ($data_macro['type']) {
@ -5784,7 +5799,7 @@ function reporting_custom_render($report, $content, $type='dinamic', $pdf=0)
$patterns[] = addslashes(
'/_'.$data_macro['name'].'_/'
);
$substitutions[] = $data_macro['value'];
$substitutions[] = io_safe_output($data_macro['value']);
break;
case 1:
@ -5800,7 +5815,7 @@ function reporting_custom_render($report, $content, $type='dinamic', $pdf=0)
$error_reporting = error_reporting();
error_reporting(0);
$value_query = db_get_value_sql(
trim($data_macro['value'], ';')
trim(io_safe_output($data_macro['value']), ';')
);
if ($value_query === false) {
@ -5826,7 +5841,7 @@ function reporting_custom_render($report, $content, $type='dinamic', $pdf=0)
$error_reporting = error_reporting();
error_reporting(0);
$data_query = db_get_all_rows_sql(
trim($data_macro['value'], ';')
trim(io_safe_output($data_macro['value']), ';')
);
error_reporting($error_reporting);
@ -6672,6 +6687,7 @@ function reporting_sql_graph(
$type_sql_graph
) {
global $config;
$layout = false;
switch ($type_sql_graph) {
case 'sql_graph_hbar':
@ -6680,6 +6696,7 @@ function reporting_sql_graph(
break;
case 'sql_graph_vbar':
$layout = ['padding' => ['top' => '40']];
$return['type'] = 'sql_graph_vbar';
break;
@ -6754,7 +6771,8 @@ function reporting_sql_graph(
$only_image,
ui_get_full_url(false, false, false, false),
$ttl,
$content['top_n_value']
$content['top_n_value'],
$layout
);
break;
@ -11711,7 +11729,8 @@ function reporting_get_module_detailed_event(
$ttl=1,
$id_server=false,
$metaconsole_dbtable=false,
$filter_event_filter_exclude=false
$filter_event_filter_exclude=false,
$id_agent=false
) {
global $config;
@ -11734,7 +11753,7 @@ function reporting_get_module_detailed_event(
foreach ($id_modules as $id_module) {
$event['data'] = events_get_agent(
false,
$id_agent,
(int) $period,
(int) $date,
$history,

View File

@ -112,8 +112,8 @@ function reporting_html_header(
}
$data[] = $title.$sizhfin;
$data[] = $sizh.$subtitle.$sizhfin;
$data[] = "<div class='right'>".$sizh.$date_text.$sizhfin.'</div>';
$data[] = $sizh.__('Group').': '.$subtitle.$sizhfin;
$data[] = '<div class="flex-content-right flex-items-center">'.$sizh.__('Data time').': '.$sizhfin."<div class='right mrgn_lft_15px'>".$sizh.$date_text.$sizhfin.'</div></div>';
}
array_push($table->data, $data);
@ -194,6 +194,9 @@ function reporting_html_print_report($report, $mini=false, $report_info=1, $cust
$table->head = [];
$table->colspan = [];
$table->rowstyle = ['background-color: #686868'];
$table->size[0] = '33%';
$table->size[1] = '33%';
$table->size[2] = '33%';
if (isset($item['label']) && $item['label'] != '') {
$id_agent = $item['id_agent'];
@ -3606,7 +3609,7 @@ function reporting_html_group_report($table, $item, $pdf=0)
}
$graph_width = 280;
$graph_height = 250;
$graph_height = 300;
$out = '<table width="100%" class="info_table">';
$out .= '<tbody>';
@ -3688,9 +3691,9 @@ function reporting_html_group_report($table, $item, $pdf=0)
$out .= '<div id="events_per_agent_pie" style="height: '.$graph_height.'px">';
if ((int) $ttl === 2) {
$out .= '<img src="data:image/png;base64,';
$out .= '<img width="350" src="data:image/png;base64,';
} else {
$out .= '<div id="status_pie" style="margin: auto; width: '.$graph_width.'px;">';
$out .= '<div id="status_pie" style="margin: auto;">';
}
$out .= pie_graph($data, $options);
@ -3730,9 +3733,9 @@ function reporting_html_group_report($table, $item, $pdf=0)
$out .= '<div id="group_os_pie" style="height: '.$graph_height.'px">';
if ((int) $ttl === 2) {
$out .= '<img src="data:image/png;base64,';
$out .= '<img width="350" src="data:image/png;base64,';
} else {
$out .= '<div id="status_pie" style="margin: auto; width: '.$graph_width.'px;">';
$out .= '<div id="status_pie" style="margin: auto;">';
}
$out .= pie_graph($data, $options);

View File

@ -301,8 +301,7 @@ function ui_print_message($message, $class='', $attributes='', $return=false, $t
if (empty($message['no_close']) === false) {
// Workaround.
$no_close_bool = false;
// $no_close_bool = (bool) $message['no_close'];
$no_close_bool = (bool) $message['no_close'];
}
if (empty($message['force_style']) === false) {
@ -436,7 +435,7 @@ function ui_print_message($message, $class='', $attributes='', $return=false, $t
$_SESSION['info_box_count']++;
}
$position = (20 + ((int) $_SESSION['info_box_count'] * 100));
$position = (20 + (int) $_SESSION['info_box_count'] + 120);
$output = html_print_div(
[
@ -3540,7 +3539,7 @@ function ui_print_status_sets(
}
if (empty($title) === false) {
$options['title'] = (empty($extra_info) === true) ? $title : $title.'&#10'.$extra_info;
// $options['title'] = (empty($extra_info) === true) ? $title : $title.'&#10'.$extra_info;
$options['data-title'] = (empty($extra_info) === true) ? $title : $title.'<br>'.$extra_info;
$options['data-use_title_for_force_title'] = 1;
if (isset($options['class']) === true) {

View File

@ -4177,126 +4177,132 @@ function visual_map_create_internal_name_item(
$idData=''
) {
$text = '';
switch ($type) {
case 'box_item':
case BOX_ITEM:
$text = __('Box');
break;
if (empty($label)) {
switch ($type) {
case 'box_item':
case BOX_ITEM:
$text = __('Box');
break;
case 'module_graph':
case MODULE_GRAPH:
$text = __('Module graph');
break;
case 'module_graph':
case MODULE_GRAPH:
$text = __('Module graph');
break;
case 'clock':
case CLOCK:
$text = __('Clock');
break;
case 'clock':
case CLOCK:
$text = __('Clock');
break;
case 'bars_graph':
case BARS_GRAPH:
$text = __('Bars graph');
break;
case 'bars_graph':
case BARS_GRAPH:
$text = __('Bars graph');
break;
case 'auto_sla_graph':
case AUTO_SLA_GRAPH:
$text = __('Event history graph');
break;
case 'auto_sla_graph':
case AUTO_SLA_GRAPH:
$text = __('Event history graph');
break;
case 'percentile_bar':
case PERCENTILE_BAR:
$text = __('Percentile bar');
break;
case 'percentile_bar':
case PERCENTILE_BAR:
$text = __('Percentile bar');
break;
case 'circular_progress_bar':
case CIRCULAR_PROGRESS_BAR:
$text = __('Circular progress bar');
break;
case 'circular_progress_bar':
case CIRCULAR_PROGRESS_BAR:
$text = __('Circular progress bar');
break;
case 'interior_circular_progress_bar':
case CIRCULAR_INTERIOR_PROGRESS_BAR:
$text = __('Circular progress bar (interior)');
break;
case 'interior_circular_progress_bar':
case CIRCULAR_INTERIOR_PROGRESS_BAR:
$text = __('Circular progress bar (interior)');
break;
case 'static_graph':
case STATIC_GRAPH:
$text = __('Static Image').' - '.$image;
break;
case 'static_graph':
case STATIC_GRAPH:
$text = __('Static Image').' - '.$image;
break;
case 'simple_value':
case SIMPLE_VALUE:
$text = __('Simple Value');
break;
case 'simple_value':
case SIMPLE_VALUE:
$text = __('Simple Value');
break;
case 'label':
case LABEL:
$text = __('Label');
break;
case 'label':
case LABEL:
$text = __('Label');
break;
case GROUP_ITEM:
case 'group_item':
$text = __('Group').' - ';
break;
case GROUP_ITEM:
case 'group_item':
$text = __('Group').' - ';
break;
case COLOR_CLOUD:
case 'color_cloud':
$text = __('Color cloud').' - ';
break;
case COLOR_CLOUD:
case 'color_cloud':
$text = __('Color cloud').' - ';
break;
case 'icon':
case ICON:
$text = __('Icon').' - '.$image;
break;
case 'icon':
case ICON:
$text = __('Icon').' - '.$image;
break;
}
case BASIC_CHART:
$text = __('Basic chart').' - '.$image;
break;
if (!empty($agent)) {
$text .= ' ('.ui_print_truncate_text($agent, 'agent_small', false);
case ODOMETER:
$text = __('Odometer').' - '.$image;
break;
$moduleName = io_safe_output(db_get_value('nombre', 'tagente_modulo', 'id_agente_modulo', $id_module));
if (!empty($moduleName)) {
$text .= ' - '.ui_print_truncate_text($moduleName, 'module_small', false);
}
$text .= ')';
}
$text .= ' ('.$idData.')';
} else {
$text = $label;
default:
$text = __('Not assigned');
break;
}
if (!empty($agent)) {
$text .= ' ('.ui_print_truncate_text($agent, 'agent_small', false);
$moduleName = io_safe_output(db_get_value('nombre', 'tagente_modulo', 'id_agente_modulo', $id_module));
if (!empty($moduleName)) {
$text .= ' - '.ui_print_truncate_text($moduleName, 'module_small', false);
}
$text .= ')';
}
$text .= ' ('.$idData.')';
return io_safe_output($text);
}
function visual_map_get_items_parents($idVisual)
{
// Avoid the sort by 'label' in the query cause oracle cannot sort by columns with CLOB type
$items = db_get_all_rows_filter('tlayout_data', ['id_layout' => $idVisual]);
if ($items == false) {
$items = [];
} else {
// Sort by label
sort_by_column($items, 'label');
}
$return = [];
foreach ($items as $item) {
if ($item['type'] == LINE_ITEM) {
continue;
}
$agent = null;
if ($item['id_agent'] != 0) {
$agent = io_safe_output(agents_get_alias($item['id_agent']));
}
$return[$item['id']] = visual_map_create_internal_name_item(
$item['label'],
$text = visual_map_create_internal_name_item(
($item['type'] != COLOR_CLOUD) ? $item['label'] : null,
$item['type'],
$item['image'],
$agent,
$item['id_agente_modulo'],
$item['id']
);
$return[$item['id']] = $text;
}
return $return;

View File

@ -43,7 +43,7 @@
function create_module_latency_goliat($id_agent, $module_name, $id_group, $url_search, $string_search='')
{
if ($string_search !== '') {
$str_search = 'check_string '.$string_search.'';
$str_search = "check_string $string_search";
}
include_once 'include/functions_modules.php';
@ -65,11 +65,7 @@ function create_module_latency_goliat($id_agent, $module_name, $id_group, $url_s
'id_export' => '0',
'plugin_user' => '',
'plugin_pass' => '0',
'plugin_parameter' => 'task_begin
get '.$url_search.'
resource 1
'.$str_search.'
task_end',
'plugin_parameter' => io_safe_input("task_begin\nget $url_search\nresource 1\n$str_search\ntask_end\n"),
'id_plugin' => '0',
'post_process' => '0',
'prediction_module' => '0',
@ -137,7 +133,7 @@ task_end',
function create_module_status_goliat($id_agent, $module_name, $id_group, $url_search, $string_search='')
{
if ($string_search !== '') {
$str_search = 'check_string '.$string_search.' ';
$str_search = "check_string $string_search";
}
include_once 'include/functions_modules.php';
@ -157,13 +153,9 @@ function create_module_status_goliat($id_agent, $module_name, $id_group, $url_se
'tcp_rcv' => '',
'tcp_send' => '',
'id_export' => '0',
'plugin_user' => '',
'plugin_pass' => '0',
'plugin_parameter' => 'task_begin
get '.$url_search.'
resource 1
'.$str_search.'
task_end',
'plugin_user' => io_safe_input('Pandora FMS / Webcheck'),
'plugin_pass' => '1',
'plugin_parameter' => io_safe_input("task_begin\nget $url_search\nresource 1\n$str_search\ntask_end\n"),
'id_plugin' => '0',
'post_process' => '0',
'prediction_module' => '0',

View File

@ -92,7 +92,7 @@ if (empty($file) === true || empty($hash) === true || $hash !== md5($file_raw.$c
break;
case $main_collections:
$downloadable_file = $_SERVER['DOCUMENT_ROOT'].'/pandora_console/attachment/collection/'.$file;
$downloadable_file = io_safe_output($config['attachment_store']).'/collection/'.$file;
break;
case 'godmode/setup/file_manager':

View File

@ -547,6 +547,7 @@ function line_graph(
function get_build_setup_charts($type, $options, $data)
{
global $config;
$user_info = get_user_info($config['id_user']);
$factory = new Factory();
@ -1294,6 +1295,10 @@ function get_build_setup_charts($type, $options, $data)
}
}
if (isset($user_info['id_skin']) === true) {
$chart->options()->setTheme($user_info['id_skin']);
}
// Add Datasets.
$setData = $chart->createDataSet();
switch ($type) {

View File

@ -1490,7 +1490,12 @@ function defineTinyMCEDark(selector) {
{ text: "C#", value: "csharp" },
{ text: "C++", value: "cpp" }
],
toolbar: defaultToolbar
toolbar: defaultToolbar,
content_style: `
body {
color: #fff;
}
`
});
}
@ -2561,19 +2566,13 @@ function menuActionButtonResizing() {
function check_period_warning(time, title, message) {
var period = time.value;
var times = 0;
if (period >= 2592000 && period < 7776000) {
WarningPeriodicityModal(title, message);
} else if (period >= 7776000 && period < 15552000) {
do {
WarningPeriodicityModal(title, message);
times = times + 1;
} while (times < 2);
WarningPeriodicityModal(title, message);
} else if (period >= 15552000) {
do {
WarningPeriodicityModal(title, message);
times = times + 1;
} while (times < 3);
WarningPeriodicityModal(title, message);
}
}

View File

@ -24,12 +24,6 @@ function show_option_dialog(settings) {
method: "updateDashboard",
dataType: "json"
},
oncancel: {
reload: true
},
onclose: {
reload: true
},
ajax_callback: update_dashboard
});
}
@ -483,10 +477,6 @@ function initialiceLayout(data) {
function configurationWidget(cellId, widgetId, size) {
var reload = 0;
var overlay = false;
if (widgetId == 46) {
reload = 1;
overlay = true;
}
title = $("#hidden-widget_name_" + cellId).val();
load_modal({
target: $("#modal-config-widget"),

View File

@ -1338,14 +1338,13 @@ function listen_event_sound(settings) {
);
}
let sound_listener;
function check_event_sound(settings) {
// Update elements time.
$(".elements-discovered-alerts ul li").each(function() {
let element_time = $(this)
.children(".li-hidden")
.val();
let obj_time = new Date(element_time);
let obj_time = new Date(element_time * 1000);
let current_dt = new Date();
let timestamp = current_dt.getTime() - obj_time.getTime();
timestamp = timestamp / 1000;
@ -1382,7 +1381,7 @@ function check_event_sound(settings) {
},
function(data) {
if (data != false) {
clearTimeout(sound_listener);
clearTimeout(window.sound_listener);
// Hide empty.
$("#tabs-sound-modal .empty-discovered-alerts").addClass(
"invisible_important"
@ -1427,14 +1426,14 @@ function check_event_sound(settings) {
li.insertAdjacentHTML(
"beforeend",
'<input type="hidden" value="' +
element.event_timestamp +
element.utimestamp +
'" class="li-hidden"/>'
);
$("#tabs-sound-modal .elements-discovered-alerts ul").prepend(li);
});
// -100 delay sound.
sound_listener = setTimeout(
window.sound_listener = setTimeout(
remove_audio,
parseInt($("#tabs-sound-modal #time_sound").val()) * 1000 - 100
);

View File

@ -625,6 +625,10 @@ var TreeController = {
$("#fixed-bottom-box-head-title").html(
$("#fixedBottomHeadTitle").html()
);
$("#fixed-bottom-box-head-title")
.closest(".fixed-bottom-box")
.addClass("tree-view-bottom-modal");
},
error: function(xhr, textStatus, errorThrown) {
callback(errorThrown);
@ -1543,7 +1547,7 @@ var TreeController = {
} else if (controller.tree.length == 0) {
controller.recipient.empty();
controller.recipient.html(
"<div>" + controller.emptyMessage + "</div>"
"<div class='recipent'>" + controller.emptyMessage + "</div>"
);
return;
}

File diff suppressed because it is too large Load Diff

View File

@ -363,6 +363,27 @@ class Manager implements PublicLogin
}
/**
* Generates a hash to authenticate in public dashboards with user form url.
*
* @param string|null $other_secret To authenticate some parts
* of public dashboards (like visual consoles or wux widgets)
* another hash is needed. Other secret avoid
* to reuse the main hash to view other components.
*
* @return string Returns a hash with the authenticaction.
*/
public static function generatePublicHashUser(?string $other_secret='', $id_user=''):string
{
global $config;
$str = $config['dbpass'];
$str .= ($id_user ?? $config['id_user']);
$str .= $other_secret;
return hash('sha256', $str);
}
/**
* Validates a hash to authenticate in public dashboards.
*
@ -411,6 +432,33 @@ class Manager implements PublicLogin
$config['public_dashboard'] = true;
$config['force_instant_logout'] = true;
return true;
} else {
$dashboards = self::getDashboards();
$dashboards = array_reduce(
$dashboards,
function ($carry, $item) {
$carry[$item['id']] = $item['name'];
return $carry;
},
[]
);
foreach ($dashboards as $key => $layout) {
$hash_compare = self::generatePublicHash($key);
if (hash_equals($hash, $hash_compare)) {
// "Log" user in.
if (session_status() !== PHP_SESSION_ACTIVE) {
session_start();
}
$_SESSION['id_usuario'] = get_parameter('id_user');
session_write_close();
$config['public_dashboard'] = true;
$config['force_instant_logout'] = true;
return true;
}
}
}
// Remove id user from config array if authentication has failed.
@ -994,6 +1042,38 @@ class Manager implements PublicLogin
ui_require_css_file('modal');
ui_require_css_file('form');
$hash_aux = get_parameter('hash');
if (empty($dashboardId)) {
$dashboards = $this->getDashboards();
$dashboards = array_reduce(
$dashboards,
function ($carry, $item) {
$carry[$item['id']] = $item['name'];
return $carry;
},
[]
);
foreach ($dashboards as $key => $layout) {
$hash_compare = self::generatePublicHash($key);
if (hash_equals($hash_aux, $hash_compare)) {
$this->dashboardId = $key;
break;
}
}
if (empty($this->dashboardId) === true) {
$id_user_url = get_parameter('id_user', $config['id_user']);
foreach ($dashboards as $key => $layout) {
$hash_compare = self::generatePublicHashUser($key, $id_user_url);
if (hash_equals($hash_aux, $hash_compare)) {
$this->dashboardId = $key;
break;
}
}
}
}
if ($this->dashboardId === 0
|| $this->deleteDashboard === true
|| $this->copyDashboard === true
@ -1164,11 +1244,10 @@ class Manager implements PublicLogin
[
'dashboards' => $dashboards,
'ajaxController' => $this->ajaxController,
'dashboardId' => $this->dashboardId,
'refr' => $this->refr,
'url' => $this->url,
'dashboardName' => $this->dashboardFields['name'],
'hash' => self::generatePublicHash(),
'hash' => self::generatePublicHash($this->dashboardId),
'publicLink' => $this->publicLink,
'dashboardGroup' => $this->dashboardFields['id_group'],
'dashboardUser' => $this->dashboardFields['id_user'],
@ -1210,7 +1289,7 @@ class Manager implements PublicLogin
'updateDashboard' => $this->updateDashboard,
'cellIdCreate' => \get_parameter('cellIdCreate', 0),
'class' => (($config['public_dashboard'] === true) ? quotemeta(__CLASS__) : ''),
'hash' => (($config['public_dashboard'] === true) ? self::generatePublicHash() : ''),
'hash' => (($config['public_dashboard'] === true) ? self::generatePublicHash($this->dashboardId) : ''),
]
);
} else {

View File

@ -423,6 +423,7 @@ class BasicChart extends Widget
'style_icon' => 'flex-grow: 0',
'script' => 'check_period_warning(this, \''.__('Warning').'\', \''.__('Displaying items with extended historical data can have an impact on system performance. We do not recommend that you use intervals longer than 30 days, especially if you combine several of them in a report, dashboard or visual console.').'\')',
'script_input' => 'check_period_warning_manual(\'period\', \''.__('Warning').'\', \''.__('Displaying items with extended historical data can have an impact on system performance. We do not recommend that you use intervals longer than 30 days, especially if you combine several of them in a report, dashboard or visual console.').'\')',
'units_select2' => true,
],
];

View File

@ -306,6 +306,7 @@ class BlockHistogram extends Widget
'style_icon' => 'flex-grow: 0',
'script' => 'check_period_warning(this, \''.__('Warning').'\', \''.__('Displaying items with extended historical data can have an impact on system performance. We do not recommend that you use intervals longer than 30 days, especially if you combine several of them in a report, dashboard or visual console.').'\')',
'script_input' => 'check_period_warning_manual(\'period\', \''.__('Warning').'\', \''.__('Displaying items with extended historical data can have an impact on system performance. We do not recommend that you use intervals longer than 30 days, especially if you combine several of them in a report, dashboard or visual console.').'\')',
'units_select2' => true,
],
];

View File

@ -317,6 +317,7 @@ class DataMatrix extends Widget
'style_icon' => 'flex-grow: 0',
'script' => 'check_period_warning(this, \''.__('Warning').'\', \''.__('Displaying items with extended historical data can have an impact on system performance. We do not recommend that you use intervals longer than 30 days, especially if you combine several of them in a report, dashboard or visual console.').'\')',
'script_input' => 'check_period_warning_manual(\'period\', \''.__('Warning').'\', \''.__('Displaying items with extended historical data can have an impact on system performance. We do not recommend that you use intervals longer than 30 days, especially if you combine several of them in a report, dashboard or visual console.').'\')',
'units_select2' => true,
],
];
@ -335,6 +336,7 @@ class DataMatrix extends Widget
'style_icon' => 'flex-grow: 0',
'script' => 'check_period_warning(this, \''.__('Warning').'\', \''.__('Displaying items with extended historical data can have an impact on system performance. We do not recommend that you use intervals longer than 30 days, especially if you combine several of them in a report, dashboard or visual console.').'\')',
'script_input' => 'check_period_warning_manual(\'slice\', \''.__('Warning').'\', \''.__('Displaying items with extended historical data can have an impact on system performance. We do not recommend that you use intervals longer than 30 days, especially if you combine several of them in a report, dashboard or visual console.').'\')',
'units_select2' => true,
],
];

View File

@ -394,6 +394,7 @@ class CustomGraphWidget extends Widget
'style_icon' => 'flex-grow: 0',
'script' => 'check_period_warning(this, \''.__('Warning').'\', \''.__('Displaying items with extended historical data can have an impact on system performance. We do not recommend that you use intervals longer than 30 days, especially if you combine several of them in a report, dashboard or visual console.').'\')',
'script_input' => 'check_period_warning_manual(\'period\', \''.__('Warning').'\', \''.__('Displaying items with extended historical data can have an impact on system performance. We do not recommend that you use intervals longer than 30 days, especially if you combine several of them in a report, dashboard or visual console.').'\')',
'units_select2' => true,
],
];

View File

@ -373,6 +373,7 @@ class GraphModuleHistogramWidget extends Widget
'style_icon' => 'flex-grow: 0',
'script' => 'check_period_warning(this, \''.__('Warning').'\', \''.__('Displaying items with extended historical data can have an impact on system performance. We do not recommend that you use intervals longer than 30 days, especially if you combine several of them in a report, dashboard or visual console.').'\')',
'script_input' => 'check_period_warning_manual(\'period\', \''.__('Warning').'\', \''.__('Displaying items with extended historical data can have an impact on system performance. We do not recommend that you use intervals longer than 30 days, especially if you combine several of them in a report, dashboard or visual console.').'\')',
'units_select2' => true,
],
];

View File

@ -207,6 +207,7 @@ class Netflow extends Widget
'style_icon' => 'flex-grow: 0',
'script' => 'check_period_warning(this, \''.__('Warning').'\', \''.__('Displaying items with extended historical data can have an impact on system performance. We do not recommend that you use intervals longer than 30 days, especially if you combine several of them in a report, dashboard or visual console.').'\')',
'script_input' => 'check_period_warning_manual(\'period\', \''.__('Warning').'\', \''.__('Displaying items with extended historical data can have an impact on system performance. We do not recommend that you use intervals longer than 30 days, especially if you combine several of them in a report, dashboard or visual console.').'\')',
'units_select2' => true,
],
];
$chart_types = netflow_get_chart_types();
@ -366,8 +367,8 @@ class Netflow extends Widget
'',
'HTML',
0,
($size['width'] - 50),
($size['height'] - 20),
($size['width'] + 120),
($size['height'] + 120),
),
],
true
@ -462,7 +463,7 @@ class Netflow extends Widget
public function getSizeModalConfiguration(): array
{
$size = [
'width' => 400,
'width' => 600,
'height' => 530,
];

View File

@ -270,8 +270,8 @@ class SecurityHardening extends Widget
'id' => 'row_date',
'class' => 'row_input',
'arguments' => [
'id' => 'range',
'name' => 'range',
'id' => '_range_vulnerability',
'name' => 'range_vulnerability',
'type' => 'date_range',
'selected' => 'chose_range',
'date_init' => date('Y/m/d', $values['date_init']),
@ -301,7 +301,7 @@ class SecurityHardening extends Widget
$values['limit'] = \get_parameter('limit', 10);
$values['category'] = \get_parameter('category', 6);
$values['ignore_skipped'] = \get_parameter_switch('ignore_skipped', 0);
$date = $this->getDateParameter();
$date = \get_parameter_date('range_vulnerability', '', 'U');
$values['date_init'] = $date['date_init'];
$values['date_end'] = $date['date_end'];
return $values;
@ -366,75 +366,6 @@ class SecurityHardening extends Widget
}
/**
* Returns the date in an object obtained by parameter.
*
* @return object Object with date_init, date_end and period.
*/
private function getDateParameter()
{
$date_end = get_parameter('date_end', 0);
$time_end = get_parameter('time_end');
$datetime_end = strtotime($date_end.' '.$time_end);
$custom_date = get_parameter('custom_date', 0);
$range = get_parameter('range', SECONDS_1DAY);
$date_text = get_parameter('range_text', SECONDS_1DAY);
$date_init_less = (strtotime(date('Y/m/d')) - SECONDS_1DAY);
$date_init = get_parameter('date_init', date(DATE_FORMAT, $date_init_less));
$time_init = get_parameter('time_init', date(TIME_FORMAT, $date_init_less));
$datetime_init = strtotime($date_init.' '.$time_init);
if ($custom_date === '1') {
if ($datetime_init >= $datetime_end) {
$datetime_init = $date_init_less;
}
$date_init = date('Y/m/d H:i:s', $datetime_init);
$date_end = date('Y/m/d H:i:s', $datetime_end);
$period = ($datetime_end - $datetime_init);
} else if ($custom_date === '2') {
$date_units = get_parameter('range_units');
$date_end = date('Y/m/d H:i:s');
$date_init = date('Y/m/d H:i:s', (strtotime($date_end) - ((int) $date_text * (int) $date_units)));
$period = (strtotime($date_end) - strtotime($date_init));
} else if (in_array($range, ['this_week', 'this_month', 'past_week', 'past_month'])) {
if ($range === 'this_week') {
$monday = date('Y/m/d', strtotime('last monday'));
$sunday = date('Y/m/d', strtotime($monday.' +6 days'));
$period = (strtotime($sunday) - strtotime($monday));
$date_init = $monday;
$date_end = $sunday;
} else if ($range === 'this_month') {
$date_end = date('Y/m/d', strtotime('last day of this month'));
$first_of_month = date('Y/m/d', strtotime('first day of this month'));
$date_init = $first_of_month;
$period = (strtotime($date_end) - strtotime($first_of_month));
} else if ($range === 'past_month') {
$date_end = date('Y/m/d', strtotime('last day of previous month'));
$first_of_month = date('Y/m/d', strtotime('first day of previous month'));
$date_init = $first_of_month;
$period = (strtotime($date_end) - strtotime($first_of_month));
} else if ($range === 'past_week') {
$date_end = date('Y/m/d', strtotime('sunday', strtotime('last week')));
$first_of_week = date('Y/m/d', strtotime('monday', strtotime('last week')));
$date_init = $first_of_week;
$period = (strtotime($date_end) - strtotime($first_of_week));
}
} else {
$date_end = date('Y/m/d H:i:s');
$date_init = date('Y/m/d H:i:s', (strtotime($date_end) - $range));
$period = (strtotime($date_end) - strtotime($date_init));
}
return [
'date_init' => strtotime($date_init),
'date_end' => strtotime($date_end),
'period' => $period,
];
}
/**
* Check user's acl using group.
*
@ -692,6 +623,7 @@ class SecurityHardening extends Widget
*/
private function vulnerabilitiesByCategory($group, $category, $ignore_skipped=true)
{
global $config;
$labels = [
__('Passed'),
__('Failed'),
@ -749,7 +681,7 @@ class SecurityHardening extends Widget
$total = (count($vulnerabilities['pass']) + count($vulnerabilities['fail']));
if ($ignore_skipped === false) {
if ($ignore_skipped === false && isset($vulnerabilities['skipped']) === true) {
$data[] = count($vulnerabilities['skipped']);
$total += count($vulnerabilities['skipped']);
$labels[] = __('Skipped');
@ -763,18 +695,19 @@ class SecurityHardening extends Widget
'display' => true,
'position' => 'right',
'align' => 'center',
'fonts' => [ 'size' => '12' ],
],
'elements' => [
'center' => [
'text' => $total,
'color' => '#2c3e50',
'color' => ($config['style'] === 'pandora_black') ? '#ffffff' : '#2c3e50',
],
],
'labels' => $labels,
'colors' => [
'#82b92e',
'#e63c52',
'#E4E4E4',
($config['style'] === 'pandora_black') ? '#666' : '#E4E4E4',
],
]
);

View File

@ -449,6 +449,7 @@ class SingleGraphWidget extends Widget
'style_icon' => 'flex-grow: 0',
'script' => 'check_period_warning(this, \''.__('Warning').'\', \''.__('Displaying items with extended historical data can have an impact on system performance. We do not recommend that you use intervals longer than 30 days, especially if you combine several of them in a report, dashboard or visual console.').'\')',
'script_input' => 'check_period_warning_manual(\'period\', \''.__('Warning').'\', \''.__('Displaying items with extended historical data can have an impact on system performance. We do not recommend that you use intervals longer than 30 days, especially if you combine several of them in a report, dashboard or visual console.').'\')',
'units_select2' => true,
],
];
@ -527,99 +528,101 @@ class SingleGraphWidget extends Widget
'id' => 'div_projection_period',
'style' => $display_projection,
'arguments' => [
'name' => 'period_projection',
'type' => 'interval',
'value' => $values['period_projection'],
'script' => 'check_period_warning(this, \''.__('Warning').'\', \''.__('Displaying items with extended historical data can have an impact on system performance. We do not recommend that you use intervals longer than 30 days, especially if you combine several of them in a report, dashboard or visual console.').'\')',
'script_input' => 'check_period_warning_manual(\'period\', \''.__('Warning').'\', \''.__('Displaying items with extended historical data can have an impact on system performance. We do not recommend that you use intervals longer than 30 days, especially if you combine several of them in a report, dashboard or visual console.').'\')',
],
];
$inputs['inputs']['row2'][] = [
'label' => __('Maximum'),
'id' => 'div_period_maximum',
'style' => $display_periodicity_chart,
'arguments' => [
'name' => 'period_maximum',
'id' => 'period_maximum',
'type' => 'switch',
'value' => $values['period_maximum'],
],
];
$inputs['inputs']['row2'][] = [
'label' => __('Minimum'),
'id' => 'div_period_minimum',
'style' => $display_periodicity_chart,
'arguments' => [
'name' => 'period_minimum',
'id' => 'period_minimum',
'type' => 'switch',
'value' => $values['period_minimum'],
],
];
$inputs['inputs']['row2'][] = [
'label' => __('Average'),
'id' => 'div_period_average',
'style' => $display_periodicity_chart,
'arguments' => [
'name' => 'period_average',
'id' => 'period_average',
'type' => 'switch',
'value' => $values['period_average'],
],
];
$inputs['inputs']['row2'][] = [
'label' => __('Summatory'),
'id' => 'div_period_summatory',
'style' => $display_periodicity_chart,
'arguments' => [
'name' => 'period_summatory',
'id' => 'period_summatory',
'type' => 'switch',
'value' => $values['period_summatory'],
],
];
$inputs['inputs']['row2'][] = [
'label' => __('Slice period'),
'id' => 'div_period_slice_chart',
'style' => $display_periodicity_chart,
'arguments' => [
'name' => 'period_slice_chart',
'name' => 'period_projection',
'type' => 'interval',
'value' => (string) $values['period_slice_chart'],
'custom_fields' => [
SECONDS_1HOUR => __('1 hour'),
SECONDS_1DAY => __('1 day'),
SECONDS_1WEEK => __('1 week'),
SECONDS_1MONTH => __('1 month'),
'value' => $values['period_projection'],
'script' => 'check_period_warning(this, \''.__('Warning').'\', \''.__('Displaying items with extended historical data can have an impact on system performance. We do not recommend that you use intervals longer than 30 days, especially if you combine several of them in a report, dashboard or visual console.').'\')',
'script_input' => 'check_period_warning_manual(\'period\', \''.__('Warning').'\', \''.__('Displaying items with extended historical data can have an impact on system performance. We do not recommend that you use intervals longer than 30 days, especially if you combine several of them in a report, dashboard or visual console.').'\')',
'units_select2' => true,
],
];
$inputs['inputs']['row2'][] = [
'label' => __('Maximum'),
'id' => 'div_period_maximum',
'style' => $display_periodicity_chart,
'arguments' => [
'name' => 'period_maximum',
'id' => 'period_maximum',
'type' => 'switch',
'value' => $values['period_maximum'],
],
],
];
];
$options_period_mode = [
CUSTOM_GRAPH_AREA => __('Area'),
CUSTOM_GRAPH_LINE => __('Line'),
CUSTOM_GRAPH_VBARS => __('Vertical bars'),
];
$inputs['inputs']['row2'][] = [
'label' => __('Minimum'),
'id' => 'div_period_minimum',
'style' => $display_periodicity_chart,
'arguments' => [
'name' => 'period_minimum',
'id' => 'period_minimum',
'type' => 'switch',
'value' => $values['period_minimum'],
],
];
$inputs['inputs']['row2'][] = [
'label' => __('Type chart'),
'id' => 'div_period_mode',
'style' => $display_periodicity_chart,
'arguments' => [
'type' => 'select',
'fields' => $options_period_mode,
'name' => 'period_mode',
'selected' => $values['period_mode'],
'return' => true,
],
];
$inputs['inputs']['row2'][] = [
'label' => __('Average'),
'id' => 'div_period_average',
'style' => $display_periodicity_chart,
'arguments' => [
'name' => 'period_average',
'id' => 'period_average',
'type' => 'switch',
'value' => $values['period_average'],
],
];
return $inputs;
$inputs['inputs']['row2'][] = [
'label' => __('Summatory'),
'id' => 'div_period_summatory',
'style' => $display_periodicity_chart,
'arguments' => [
'name' => 'period_summatory',
'id' => 'period_summatory',
'type' => 'switch',
'value' => $values['period_summatory'],
],
];
$inputs['inputs']['row2'][] = [
'label' => __('Slice period'),
'id' => 'div_period_slice_chart',
'style' => $display_periodicity_chart,
'arguments' => [
'name' => 'period_slice_chart',
'type' => 'interval',
'value' => (string) $values['period_slice_chart'],
'custom_fields' => [
SECONDS_1HOUR => __('1 hour'),
SECONDS_1DAY => __('1 day'),
SECONDS_1WEEK => __('1 week'),
SECONDS_1MONTH => __('1 month'),
],
'units_select2' => true,
],
];
$options_period_mode = [
CUSTOM_GRAPH_AREA => __('Area'),
CUSTOM_GRAPH_LINE => __('Line'),
CUSTOM_GRAPH_VBARS => __('Vertical bars'),
];
$inputs['inputs']['row2'][] = [
'label' => __('Type chart'),
'id' => 'div_period_mode',
'style' => $display_periodicity_chart,
'arguments' => [
'type' => 'select',
'fields' => $options_period_mode,
'name' => 'period_mode',
'selected' => $values['period_mode'],
'return' => true,
],
];
return $inputs;
}

View File

@ -383,6 +383,7 @@ class SLAPercentWidget extends Widget
'style_icon' => 'flex-grow: 0',
'script' => 'check_period_warning(this, \''.__('Warning').'\', \''.__('Displaying items with extended historical data can have an impact on system performance. We do not recommend that you use intervals longer than 30 days, especially if you combine several of them in a report, dashboard or visual console.').'\')',
'script_input' => 'check_period_warning_manual(\'period\', \''.__('Warning').'\', \''.__('Displaying items with extended historical data can have an impact on system performance. We do not recommend that you use intervals longer than 30 days, especially if you combine several of them in a report, dashboard or visual console.').'\')',
'units_select2' => true,
],
];

View File

@ -262,6 +262,7 @@ class TopNWidget extends Widget
'style_icon' => 'flex-grow: 0',
'script' => 'check_period_warning(this, \''.__('Warning').'\', \''.__('Displaying items with extended historical data can have an impact on system performance. We do not recommend that you use intervals longer than 30 days, especially if you combine several of them in a report, dashboard or visual console.').'\')',
'script_input' => 'check_period_warning_manual(\'period\', \''.__('Warning').'\', \''.__('Displaying items with extended historical data can have an impact on system performance. We do not recommend that you use intervals longer than 30 days, especially if you combine several of them in a report, dashboard or visual console.').'\')',
'units_select2' => true,
],
];

View File

@ -684,7 +684,7 @@ class TreeViewWidget extends Widget
'dateFormat' => DATE_FORMAT_JS,
'userLanguage' => get_user_language(),
'translate' => [
'emptyMessage' => __('No data found'),
'emptyMessage' => ui_print_info_message(['no_close' => true, 'message' => __('No data found.')], '', true),
'foundMessage' => $foundMessage,
'total' => [
'agents' => __('Total agents'),

View File

@ -26,12 +26,12 @@ final class CreateTokenController extends Controller
* path="/token",
* summary="Creates a new tokens",
* @OA\RequestBody(ref="#/components/requestBodies/requestBodyToken"),
* @OA\Response(response=200, ref="#/components/responses/ResponseToken"),
* @OA\Response(response=400, ref="#/components/responses/BadRequest"),
* @OA\Response(response=401, ref="#/components/responses/Unauthorized"),
* @OA\Response(response=403, ref="#/components/responses/Forbidden"),
* @OA\Response(response=404, ref="#/components/responses/NotFound"),
* @OA\Response(response=500, ref="#/components/responses/InternalServerError")
* @OA\Response(response=200, ref="#/components/responses/ResponseToken"),
* @OA\Response(response=400, ref="#/components/responses/BadRequest"),
* @OA\Response(response=401, ref="#/components/responses/Unauthorized"),
* @OA\Response(response=403, ref="#/components/responses/Forbidden"),
* @OA\Response(response=404, ref="#/components/responses/NotFound"),
* @OA\Response(response=500, ref="#/components/responses/InternalServerError")
* )
*/
public function __invoke(Request $request, Response $response): Response

View File

@ -0,0 +1,19 @@
<?php
namespace PandoraFMS\Modules\Users\Actions;
use PandoraFMS\Modules\Users\Entities\User;
use PandoraFMS\Modules\Users\Services\GetUserLoginService;
final class GetUserLoginAction
{
public function __construct(
private GetUserLoginService $getUserLoginService
) {
}
public function __invoke(string $idUser, string $pass): User
{
return $this->getUserLoginService->__invoke($idUser, $pass);
}
}

View File

@ -0,0 +1,59 @@
<?php
namespace PandoraFMS\Modules\Users\Controllers;
use PandoraFMS\Modules\Shared\Controllers\Controller;
use PandoraFMS\Modules\Shared\Services\ValidateAclSystem;
use PandoraFMS\Modules\Users\Actions\GetUserLoginAction;
use PandoraFMS\Modules\Users\Entities\UserFilter;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
final class GetUserLoginController extends Controller
{
public function __construct(
private GetUserLoginAction $getUserLoginAction,
private ValidateAclSystem $acl
) {
}
/**
* @OA\Get(
* security={{ "bearerAuth": {}}},
* path="/user/{idUser}/login",
* tags={"Users"},
* summary="show user when login process",
* @OA\Parameter(ref="#/components/parameters/parameterIdUser"),
* @OA\Parameter(ref="#/components/parameters/parameterIdUserPass"),
* @OA\Response(response=200, ref="#/components/responses/ResponseUser"),
* @OA\Response(response=400, ref="#/components/responses/BadRequest"),
* @OA\Response(response=401, ref="#/components/responses/Unauthorized"),
* @OA\Response(response=403, ref="#/components/responses/Forbidden"),
* @OA\Response(response=404, ref="#/components/responses/NotFound"),
* @OA\Response(response=500, ref="#/components/responses/InternalServerError")
* ),
* @OA\Parameter(
* parameter="parameterIdUserPass",
* name="password",
* in="query",
* description="User password",
* required=true,
* @OA\Schema(
* type="string",
* default=null
* )
* )
*/
public function __invoke(Request $request, Response $response): Response
{
$idUser = $this->getParam($request, 'idUser');
$userFilter = $this->fromRequest($request, UserFilter::class);
$pass = $userFilter->getEntityFilter()->getPassword();
$this->acl->validate(0, 'UM', ' tried to manage user');
$result = $this->getUserLoginAction->__invoke($idUser, $pass);
return $this->getResponse($response, $result);
}
}

View File

@ -0,0 +1,27 @@
<?php
namespace PandoraFMS\Modules\Users\Services;
use PandoraFMS\Modules\Shared\Exceptions\NotFoundException;
use PandoraFMS\Modules\Users\Entities\User;
use PandoraFMS\Modules\Users\Repositories\UserRepository;
final class GetUserLoginService
{
public function __construct(
private UserRepository $userRepository,
private GetUserService $getUserService
) {
}
public function __invoke(string $idUser, string $pass): User
{
$result = \process_user_login($idUser, $pass);
if ($result === false) {
throw new NotFoundException(__('Not found User'));
}
return $this->getUserService->__invoke($idUser);
}
}

View File

@ -20,9 +20,7 @@ final class GetUserService
{
$userFilter = new UserFilter();
/*
@var User $entityFilter
*/
/** @var User $entityFilter*/
$entityFilter = $userFilter->getEntityFilter();
$entityFilter->setIdUser($idUser);

View File

@ -3,6 +3,7 @@
use PandoraFMS\Modules\Users\Controllers\CreateUserController;
use PandoraFMS\Modules\Users\Controllers\DeleteUserController;
use PandoraFMS\Modules\Users\Controllers\GetUserController;
use PandoraFMS\Modules\Users\Controllers\GetUserLoginController;
use PandoraFMS\Modules\Users\Controllers\ListUserController;
use PandoraFMS\Modules\Users\Controllers\UpdateUserController;
use PandoraFMS\Modules\Users\UserProfiles\Controllers\CreateUserProfileController;
@ -17,6 +18,7 @@ return function (App $app) {
$app->post('/user', CreateUserController::class);
$app->put('/user/{idUser}', UpdateUserController::class);
$app->delete('/user/{idUser}', DeleteUserController::class);
$app->get('/user/{idUser}/login', GetUserLoginController::class);
$app->map(['GET', 'POST'], '/user/{idUser}/profiles', ListUserProfileController::class);
$app->get('/user/{idUser}/profile/{idProfile}', GetUserProfileController::class);

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