Merge branch 'develop' into ent-13188-no-salen-todos-lo-modulos-en-custom-graphs

This commit is contained in:
Pablo Aragon 2024-04-23 13:58:22 +02:00
commit 400bbc2178
78 changed files with 6781 additions and 9673 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

@ -1,5 +1,5 @@
package: pandorafms-agent-unix
Version: 7.0NG.776-240418
Version: 7.0NG.776-240423
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-240418"
pandora_version="7.0NG.776-240423"
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 => '240418';
use constant AGENT_BUILD => '240423';
# 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 240418
%define release 240423
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 240418
%define release 240423
%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 240418
%define release 240423
%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 240418
%define release 240423
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 240418
%define release 240423
Summary: Pandora FMS Linux agent, PERL version
Name: %{name}

View File

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

View File

@ -186,7 +186,7 @@ UpgradeApplicationID
{}
Version
{240418}
{240423}
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 240418")
#define PANDORA_VERSION ("7.0NG.776 Build 240423")
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 240418))"
VALUE "ProductVersion", "(7.0NG.776(Build 240423))"
VALUE "FileVersion", "1.0.0.0"
END
END

View File

@ -1,5 +1,5 @@
package: pandorafms-console
Version: 7.0NG.776-240418
Version: 7.0NG.776-240423
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-240418"
pandora_version="7.0NG.776-240423"
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

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

@ -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,5 +1,11 @@
START TRANSACTION;
-- 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;

View File

@ -2343,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);

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

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

@ -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 = 'PC240418';
$build_version = 'PC240423';
$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));

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

@ -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,7 +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
AND ta.disabled = 0
GROUP BY tasg.id_group
) x GROUP BY g";
$data = db_get_all_rows_sql($sql);

View File

@ -3551,7 +3551,8 @@ function html_print_input_text(
$disabled=false,
$list='',
$placeholder=null,
$pattern=null
$pattern=null,
$id=false
) {
if ($maxlength == 0) {
$maxlength = 255;
@ -3609,7 +3610,7 @@ function html_print_input_text(
return html_print_input_text_extended(
$name,
$value,
'text-'.$name,
(($id === false) ? 'text-'.$name : $id),
$alt,
$size,
$maxlength,
@ -6877,6 +6878,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;
@ -7859,7 +7865,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;
@ -7910,7 +7917,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,
@ -7930,13 +7937,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,
@ -8007,13 +8102,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');
@ -8031,8 +8126,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 {
@ -8058,7 +8153,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({
@ -8068,7 +8163,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')."',
@ -8080,7 +8175,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,
@ -8089,9 +8184,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'];
@ -8102,7 +8197,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,
@ -8111,9 +8206,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'];
@ -8121,10 +8216,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

@ -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);
@ -5772,10 +5779,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 +5798,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 +5814,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 +5840,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);

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

@ -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,7 +1338,6 @@ function listen_event_sound(settings) {
);
}
let sound_listener;
function check_event_sound(settings) {
// Update elements time.
$(".elements-discovered-alerts ul li").each(function() {
@ -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"
@ -1434,7 +1433,7 @@ function check_event_sound(settings) {
});
// -100 delay sound.
sound_listener = setTimeout(
window.sound_listener = setTimeout(
remove_audio,
parseInt($("#tabs-sound-modal #time_sound").val()) * 1000 - 100
);

File diff suppressed because it is too large Load Diff

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

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

View File

@ -814,7 +814,7 @@ form ul.form_flex {
.container-layout {
border-radius: 5px;
border: 3px dashed #fff;
border: 3px dashed var(--border-color);
background: #222;
padding: 10px 0px 10px 0px;
}
@ -1585,7 +1585,7 @@ a.autorefresh_txt,
}
.grid-stack-item-content {
box-shadow: 0px 0px 15px -10px #888;
box-shadow: 0px 0px 7px 1px #8888882b;
border-radius: 0px 0px 0px 0px;
}
@ -2095,6 +2095,14 @@ select option:checked {
filter: invert(1);
}
.grid-stack-item-content {
background-color: var(--secondary-color);
}
#result_order .show_result_interpreter #result_items li.active {
background-color: var(--secondary-color);
}
.black-and-white {
filter: saturate(0);
}

View File

@ -131,7 +131,7 @@
<div style='padding-bottom: 50px'>
<?php
$version = '7.0NG.776';
$build = '240418';
$build = '240423';
$banner = "v$version Build $build";
error_reporting(0);

View File

@ -599,6 +599,33 @@ function alerts_table_controls() {
}
});
$("[id^='div_tip_']").click(function() {
var id = $(this)
.attr("id")
.split("_")[2];
$("#tip_dialog_" + id).dialog({
title: $("#tip_dialog_" + id).data("title"),
modal: true,
maxWidth: 600,
minWidth: 400,
show: {
effect: "fade",
duration: 200
},
hide: {
effect: "fade",
duration: 200
},
closeOnEscape: true,
buttons: {
Close: function() {
$(this).dialog("close");
}
}
});
});
}
$(document).ready ( function () {

View File

@ -434,6 +434,10 @@ ui_include_time_picker(true);
var browserZoomLevel = window.outerWidth / window.innerWidth;
let height = ($('#chart-modal').height() + margin) * browserZoomLevel;
let width = 800 * browserZoomLevel;
if (width === 800) {
width = 1000;
height = 550;
}
window.resizeTo(width, height);
}

View File

@ -43,7 +43,7 @@ if (!reporting_user_can_see_report($id_report)) {
exit;
}
$date_params = get_parameter_date('date', '', 'U');
$date_params = get_parameter_date('date', 'none', 'U');
$date_end = date('Y/m/d', $date_params['date_end']);
$time_end = date('H:i:s', $date_params['date_end']);

View File

@ -6,7 +6,7 @@
%define debug_package %{nil}
%define name pandorafms_console
%define version 7.0NG.776
%define release 240418
%define release 240423
# User and Group under which Apache is running
%define httpd_name httpd

View File

@ -6,7 +6,7 @@
%define debug_package %{nil}
%define name pandorafms_console
%define version 7.0NG.776
%define release 240418
%define release 240423
# User and Group under which Apache is running
%define httpd_name httpd

View File

@ -3,7 +3,7 @@
#
%define name pandorafms_console
%define version 7.0NG.776
%define release 240418
%define release 240423
%define httpd_name httpd
# User and Group under which Apache is running
%define httpd_name apache2

View File

@ -2863,7 +2863,7 @@ SET @short_name = 'pandorafms.vmware';
SET @name = 'VMware';
SET @section = 'app';
SET @description = 'Monitor&#x20;ESXi&#x20;hosts,&#x20;datastores&#x20;and&#x20;VMs&#x20;from&#x20;a&#x20;specific&#x20;datacenter';
SET @version = '1.3';
SET @version = '1.4';
INSERT IGNORE INTO `tdiscovery_apps` (`id_app`, `short_name`, `name`, `section`, `description`, `version`) VALUES ('', @short_name, @name, @section, @description, @version);
SELECT @id_app := `id_app` FROM `tdiscovery_apps` WHERE `short_name` = @short_name;

View File

@ -1,5 +1,5 @@
package: pandorafms-server
Version: 7.0NG.776-240418
Version: 7.0NG.776-240423
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-240418"
pandora_version="7.0NG.776-240423"
package_cpan=0
package_pandora=1

View File

@ -46,7 +46,7 @@ our @EXPORT = qw(
# version: Defines actual version of Pandora Server for this module only
my $pandora_version = "7.0NG.776";
my $pandora_build = "240418";
my $pandora_build = "240423";
our $VERSION = $pandora_version." ".$pandora_build;
# Setup hash

View File

@ -34,7 +34,7 @@ our @ISA = qw(Exporter);
# version: Defines actual version of Pandora Server for this module only
my $pandora_version = "7.0NG.776";
my $pandora_build = "240418";
my $pandora_build = "240423";
our $VERSION = $pandora_version." ".$pandora_build;
our %EXPORT_TAGS = ( 'all' => [ qw() ] );

View File

@ -7,7 +7,7 @@
%define debug_package %{nil}
%define name pandorafms_server
%define version 7.0NG.776
%define release 240418
%define release 240423
Summary: Pandora FMS Server
Name: %{name}

View File

@ -4,7 +4,7 @@
%global __os_install_post %{nil}
%define name pandorafms_server
%define version 7.0NG.776
%define release 240418
%define release 240423
Summary: Pandora FMS Server
Name: %{name}

View File

@ -9,7 +9,7 @@
# **********************************************************************
PI_VERSION="7.0NG.776"
PI_BUILD="240418"
PI_BUILD="240423"
MODE=$1
if [ $# -gt 1 ]; then

View File

@ -38,7 +38,7 @@ use PandoraFMS::Config;
use PandoraFMS::DB;
# version: define current version
my $version = "7.0NG.776 Build 240418";
my $version = "7.0NG.776 Build 240423";
# Pandora server configuration
my %conf;

View File

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