Merge remote-tracking branch 'origin/develop' into ent-7074-Command-Center

This commit is contained in:
fbsanchez 2021-06-23 20:08:59 +02:00
commit 2fe6092d37
38 changed files with 2796 additions and 2303 deletions

View File

@ -1,5 +1,5 @@
package: pandorafms-agent-unix
Version: 7.0NG.755-210621
Version: 7.0NG.755-210623
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.755-210621"
pandora_version="7.0NG.755-210623"
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

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

View File

@ -3,7 +3,7 @@
#
%define name pandorafms_agent_unix
%define version 7.0NG.755
%define release 210621
%define release 210623
Summary: Pandora FMS Linux agent, PERL version
Name: %{name}

View File

@ -3,7 +3,7 @@
#
%define name pandorafms_agent_unix
%define version 7.0NG.755
%define release 210621
%define release 210623
Summary: Pandora FMS Linux agent, PERL version
Name: %{name}

View File

@ -10,7 +10,7 @@
# **********************************************************************
PI_VERSION="7.0NG.755"
PI_BUILD="210621"
PI_BUILD="210623"
OS_NAME=`uname -s`
FORCE=0

View File

@ -186,7 +186,7 @@ UpgradeApplicationID
{}
Version
{210621}
{210623}
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.755 Build 210621")
#define PANDORA_VERSION ("7.0NG.755 Build 210623")
string pandora_path;
string pandora_dir;

View File

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

View File

@ -1,5 +1,5 @@
package: pandorafms-console
Version: 7.0NG.755-210621
Version: 7.0NG.755-210623
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.755-210621"
pandora_version="7.0NG.755-210623"
package_pear=0
package_pandora=1

View File

@ -20,7 +20,7 @@
/**
* Pandora build version and version
*/
$build_version = 'PC210621';
$build_version = 'PC210623';
$pandora_version = 'v7.0NG.755';
// Do not overwrite default timezone set if defined.

View File

@ -695,4 +695,5 @@ div.module-graph .gauge_d3_class {
animation: rotate-second 60s infinite linear;
}
/*# sourceMappingURL=vc.main.css.map*/
/*# sourceMappingURL=vc.main.css.map*/

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -129,7 +129,7 @@
<div style='height: 10px'>
<?php
$version = '7.0NG.755';
$build = '210621';
$build = '210623';
$banner = "v$version Build $build";
error_reporting(0);

View File

@ -3,7 +3,7 @@
#
%define name pandorafms_console
%define version 7.0NG.755
%define release 210621
%define release 210623
# 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.755
%define release 210621
%define release 210623
# 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.755
%define release 210621
%define release 210623
%define httpd_name httpd
# User and Group under which Apache is running
%define httpd_name apache2

View File

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

View File

@ -90,6 +90,12 @@ snmpconsole 0
snmpconsole_threads 1
# If set to 1, traps from the same source will never be processed in parallel. 0 by default.
#snmpconsole_lock 0
# Time between consecutive reads of the SNMP log file in seconds. Defaults to server_threshold.
#snmpconsole_threshold 5
# Attempt to translate variable bindings when processing SNMP traps. 1 enabled, 0 disabled. 0 by default. (ENTERPRISE ONLY).
translate_variable_bindings 0

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.755";
my $pandora_build = "210621";
my $pandora_build = "210623";
our $VERSION = $pandora_version." ".$pandora_build;
# Setup hash
@ -333,6 +333,8 @@ sub pandora_load_config {
$pa_config->{"dynamic_warning"} = 25; # 7.0
$pa_config->{"dynamic_constant"} = 10; # 7.0
$pa_config->{"mssql_driver"} = undef; # 745
$pa_config->{"snmpconsole_lock"} = 0; # 755.
$pa_config->{"snmpconsole_period"} = 0; # 755.
# Internal MTA for alerts, each server need its own config.
$pa_config->{"mta_address"} = ''; # Introduced on 2.0
@ -676,6 +678,12 @@ sub pandora_load_config {
elsif ($parametro =~ m/^snmpconsole_threads\s+(\d+)/i) {
$pa_config->{'snmpconsole_threads'}= clean_blank($1);
}
elsif ($parametro =~ m/^snmpconsole_lock\s+([0-1])/i) {
$pa_config->{'snmpconsole_lock'}= clean_blank($1);
}
elsif ($parametro =~ m/^snmpconsole_threshold\s+(\d+(?:\.\d+){0,1})/i) {
$pa_config->{'snmpconsole_threshold'}= clean_blank($1);
}
elsif ($parametro =~ m/^translate_variable_bindings\s+([0-1])/i) {
$pa_config->{'translate_variable_bindings'}= clean_blank($1);
}

View File

@ -3961,9 +3961,7 @@ sub pandora_evaluate_snmp_alerts ($$$$$$$$$) {
for ($count = 1; defined ($custom_values[$count-1]); $count++) {
my $macro_name = '_snmp_f' . $count . '_';
my $order_field = $alert->{'order_'.$count};
#~ my $order_field = $order_field - 1;
if ($custom_values[($order_field-1)] =~ m/= \S+: (.*)/) {
if ($custom_values[$count] =~ m/= \S+: (.*)/) {
my $value = $1;
# Strip leading and trailing double quotes
@ -3971,6 +3969,9 @@ sub pandora_evaluate_snmp_alerts ($$$$$$$$$) {
$value =~ s/"$//;
$macros{$macro_name} = $value;
} else {
# Empty variable.
$macros{$macro_name} = '';
}
}
$count--;

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.755";
my $pandora_build = "210621";
my $pandora_build = "210623";
our $VERSION = $pandora_version." ".$pandora_build;
our %EXPORT_TAGS = ( 'all' => [ qw() ] );

View File

@ -23,6 +23,7 @@ use warnings;
use threads;
use threads::shared;
use Thread::Semaphore;
use Time::HiRes qw(usleep);
# Default lib dir for RPM and DEB packages
use lib '/usr/lib/perl5';
@ -163,7 +164,7 @@ sub data_producer ($$$$$) {
$self->setQueueSize (scalar @{$task_queue});
threads->yield;
sleep ($pa_config->{'server_threshold'});
usleep (int(1e6 * $self->getPeriod()));
}
};

View File

@ -45,16 +45,20 @@ our @ISA = qw(PandoraFMS::ProducerConsumerServer);
my @TaskQueue :shared;
my %PendingTasks :shared;
my $Sem :shared;
my %Sources :shared;
my $SourceSem :shared;
my $TaskSem :shared;
# Trap statistics by agent
my %AGENTS = ();
# Sources silenced by storm protection.
my %SILENCEDSOURCES = ();
# Index and buffer management for trap log files
my $SNMPTRAPD = { 'log_file' => '', 'fd' => undef, 'idx_file' => '', 'last_line' => 0, 'last_size' => 0, 'read_ahead_line' => '', 'read_ahead_pos' => 0 };
my $DATASERVER = { 'log_file' => '', 'fd' => undef, 'idx_file' => '', 'last_line' => 0, 'last_size' => 0, 'read_ahead_line' => '', 'read_ahead_pos' => 0 };
my $SNMPTRAPD = { 'log_file' => '', 'fd' => undef, 'idx_file' => '', 'last_line' => 0, 'last_size' => 0, 'read_ahead_line' => '', 'read_ahead_pos' => 0 };
my $DATASERVER = { 'log_file' => '', 'fd' => undef, 'idx_file' => '', 'last_line' => 0, 'last_size' => 0, 'read_ahead_line' => '', 'read_ahead_pos' => 0 };
my $BUFFER = { 'log_file' => undef, 'fd' => [], 'idx_file' => undef, 'last_line' => 0, 'last_size' => 0, 'read_ahead_line' => undef, 'read_ahead_pos' => 0 };
########################################################################################
# SNMP Server class constructor.
@ -96,6 +100,7 @@ sub new ($$$) {
%PendingTasks = ();
$Sem = Thread::Semaphore->new;
$TaskSem = Thread::Semaphore->new (0);
$SourceSem = Thread::Semaphore->new (1);
# Call the constructor of the parent class
my $self = $class->SUPER::new($config, SNMPCONSOLE, \&PandoraFMS::SNMPServer::data_producer, \&PandoraFMS::SNMPServer::data_consumer, $dbh);
@ -119,6 +124,11 @@ sub run ($) {
# Set the initial date for storm protection.
$pa_config->{"__storm_ref__"} = time();
# Set a server-specific period.
if ($pa_config->{'snmpconsole_threshold'} > 0) {
$self->setPeriod($pa_config->{'snmpconsole_threshold'});
}
$self->setNumThreads ($pa_config->{'snmpconsole_threads'});
$self->SUPER::run (\@TaskQueue, \%PendingTasks, $Sem, $TaskSem);
}
@ -130,7 +140,9 @@ sub data_producer ($) {
my $self = shift;
my ($pa_config, $dbh) = ($self->getConfig (), $self->getDBH ());
my %tasks_by_source;
my @tasks;
my @buffer;
# Reset storm protection counters
my $curr_time = time ();
@ -139,7 +151,12 @@ sub data_producer ($) {
%AGENTS = ();
}
for my $fs (($SNMPTRAPD, $DATASERVER)) {
# Make a local copy of locked sources.
$SourceSem->down ();
my $local_sources = {%Sources};
$SourceSem->up ();
for my $fs (($BUFFER, $SNMPTRAPD, $DATASERVER)) {
next unless defined($fs->{'fd'});
reset_if_truncated($pa_config, $fs);
while (my $line_with_pos = read_snmplogfile($fs)) {
@ -151,10 +168,11 @@ sub data_producer ($) {
chomp ($line);
# Update index file
open(my $idxfd, '>' . $fs->{'idx_file'});
print $idxfd $fs->{'last_line'} . ' ' . $fs->{'last_size'};
close $idxfd;
set_file_permissions($pa_config, $fs->{'idx_file'}, "0666");
if (defined($fs->{'idx_file'})) {
open(my $idxfd, '>' . $fs->{'idx_file'});
print $idxfd $fs->{'last_line'} . ' ' . $fs->{'last_size'};
close $idxfd;
}
# Skip lines other than SNMP Trap logs
next unless ($line =~ m/^SNMPv[12]\[\*\*\]/);
@ -189,10 +207,18 @@ sub data_producer ($) {
next;
}
push (@tasks, $line);
# Either buffer or process the trap.
if (source_lock($pa_config, $source, $local_sources) == 0) {
push(@buffer, $line);
} else {
push (@tasks, $line);
}
}
}
# Save the buffer for the next run.
$BUFFER->{'fd'} = \@buffer;
return @tasks;
}
@ -201,8 +227,18 @@ sub data_producer ($) {
###############################################################################
sub data_consumer ($$) {
my ($self, $task) = @_;
my ($pa_config, $server_id, $dbh) = ($self->getConfig(), $self->getServerID(), $self->getDBH());
pandora_snmptrapd ($self->getConfig (), $task, $self->getServerID (), $self->getDBH ());
pandora_snmptrapd ($pa_config, $task, $server_id, $dbh);
# Unlock.
if ($pa_config->{'snmpconsole_lock'} == 1) {
my ($ver, $date, $time, $source, $null) = split(/\[\*\*\]/, $task, 5);
if ($ver eq "SNMPv2" || $pa_config->{'snmp_pdu_address'} eq '1' ) {
$source =~ s/(?:(?:TCP|UDP):\s*)?\[?([^] ]+)\]?(?::-?\d+)?(?:\s*->.*)?$/$1/;
}
source_unlock($pa_config, $source);
}
}
##########################################################################
@ -458,6 +494,15 @@ sub read_snmplogfile($) {
my $line;
my $pos;
# Reading from a temporary buffer.
if (ref($fs->{'fd'}) eq 'ARRAY') {
if ($#{$fs->{'fd'}} < 0) {
return undef;
}
return [0, shift(@{$fs->{'fd'}})];
}
if(defined($fs->{'read_ahead_line'})) {
# Restore saved line
$line = $fs->{'read_ahead_line'};
@ -537,6 +582,10 @@ sub init_log_file($$$) {
sub reset_if_truncated($$) {
my ($pa_config, $fs) = @_;
if (!defined($fs->{'log_file'})) {
return;
}
my $log_size = (stat ($fs->{'log_file'}))[7];
# New SNMP log file found
@ -548,6 +597,45 @@ sub reset_if_truncated($$) {
}
}
##########################################################################
# Get a lock on the given source. Return 1 on success, 0 otherwise.
##########################################################################
sub source_lock($$$) {
my ($pa_config, $source, $local_sources) = @_;
# Locking is disabled.
if ($pa_config->{'snmpconsole_lock'} == 0) {
return 1;
}
if (defined($local_sources->{$source})) {
return 0;
}
$local_sources->{$source} = 1;
$SourceSem->down ();
$Sources{$source} = 1;
$SourceSem->up ();
return 1;
}
##########################################################################
# Remove the lock on the given source.
##########################################################################
sub source_unlock {
my ($pa_config, $source) = @_;
# Locking is disabled.
if ($pa_config->{'snmpconsole_lock'} == 0) {
return;
}
$SourceSem->down ();
delete ($Sources{$source});
$SourceSem->up ();
}
###############################################################################
# Clean-up when the server is destroyed.
###############################################################################

View File

@ -46,12 +46,16 @@ sub new ($$$;$) {
_num_threads => 1,
_threads => [],
_queue_size => 0,
_errstr => ''
_errstr => '',
_period => 0
};
# Share variables that may be set from different threads
share ($self->{'_queue_size'});
share ($self->{'_errstr'});
# Set the default period.
$self->{'_period'} = $self->{'_pa_config'}->{'server_threshold'};
bless $self, $class;
return $self;
@ -190,6 +194,24 @@ sub getErrStr ($) {
return $self->{'_errstr'};
}
########################################################################################
# Get period.
########################################################################################
sub getPeriod ($) {
my $self = shift;
return $self->{'_period'};
}
########################################################################################
# Set period.
########################################################################################
sub setPeriod ($$) {
my ($self, $period) = @_;
$self->{'_period'} = $period;
}
########################################################################################
# Set event storm protection.
########################################################################################

View File

@ -3,7 +3,7 @@
#
%define name pandorafms_server
%define version 7.0NG.755
%define release 210621
%define release 210623
Summary: Pandora FMS Server
Name: %{name}

View File

@ -3,7 +3,7 @@
#
%define name pandorafms_server
%define version 7.0NG.755
%define release 210621
%define release 210623
Summary: Pandora FMS Server
Name: %{name}

View File

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

View File

@ -35,7 +35,7 @@ use PandoraFMS::Config;
use PandoraFMS::DB;
# version: define current version
my $version = "7.0NG.755 Build 210621";
my $version = "7.0NG.755 Build 210623";
# 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.755 Build 210621";
my $version = "7.0NG.755 Build 210623";
# save program name for logging
my $progname = basename($0);

File diff suppressed because it is too large Load Diff

View File

@ -25,28 +25,28 @@
"homepage": "https://github.com/pandorafms/pandorafms#readme",
"dependencies": {
"@fortawesome/free-solid-svg-icons": "^5.10.0",
"@types/d3-shape": "^1.3.1",
"@types/jest": "^24.0.11",
"@typescript-eslint/eslint-plugin": "^1.6.0",
"@typescript-eslint/parser": "^1.6.0",
"@types/d3-shape": "^1.3.5",
"@types/jest": "^24.9.1",
"@typescript-eslint/eslint-plugin": "^1.13.0",
"@typescript-eslint/parser": "^1.13.0",
"awesome-typescript-loader": "^5.2.1",
"clean-webpack-plugin": "^2.0.1",
"clean-webpack-plugin": "^2.0.2",
"css-loader": "^2.1.1",
"d3-shape": "^1.3.5",
"d3-shape": "^1.3.7",
"eslint": "^5.16.0",
"eslint-config-prettier": "^4.1.0",
"eslint-plugin-prettier": "^3.0.1",
"eslint-config-prettier": "^4.3.0",
"eslint-plugin-prettier": "^3.4.0",
"file-loader": "^3.0.1",
"jest": "^24.7.1",
"jest": "^24.9.0",
"mini-css-extract-plugin": "^0.5.0",
"postcss-loader": "^3.0.0",
"prettier": "^1.16.1",
"ts-jest": "^24.0.2",
"typescript": "^3.4.3",
"prettier": "^1.19.1",
"ts-jest": "^24.3.0",
"typescript": "^3.9.9",
"url-loader": "^1.1.2",
"webpack": "^4.29.6",
"webpack-cli": "^3.3.0",
"webpack-dev-server": "^3.3.1"
"webpack": "^4.46.0",
"webpack-cli": "^3.3.12",
"webpack-dev-server": "^3.11.2"
},
"browserslist": [
"> 1%",

View File

@ -613,13 +613,13 @@ abstract class VisualConsoleItem<Props extends ItemProps> {
case "down":
if (this.props.width > 0) {
table.style.width = `${this.props.width}px`;
table.style.height = null;
table.style.height = "";
}
break;
case "left":
case "right":
if (this.props.height > 0) {
table.style.width = null;
table.style.width = "";
table.style.height = `${this.props.height}px`;
}
break;
@ -963,13 +963,13 @@ abstract class VisualConsoleItem<Props extends ItemProps> {
case "down":
if (this.props.width > 0) {
table.style.width = `${this.props.width}px`;
table.style.height = null;
table.style.height = "";
}
break;
case "left":
case "right":
if (this.props.height > 0) {
table.style.width = null;
table.style.width = "";
table.style.height = `${this.props.height}px`;
}
break;
@ -1025,8 +1025,8 @@ abstract class VisualConsoleItem<Props extends ItemProps> {
this.props.type != ItemType.LINE_ITEM &&
this.props.type != ItemType.NETWORK_LINK
) {
this.childElementRef.style.width = width > 0 ? `${width}px` : null;
this.childElementRef.style.height = height > 0 ? `${height}px` : null;
this.childElementRef.style.width = width > 0 ? `${width}px` : "";
this.childElementRef.style.height = height > 0 ? `${height}px` : "";
}
if (this.props.label && this.props.label.length > 0) {
@ -1038,11 +1038,11 @@ abstract class VisualConsoleItem<Props extends ItemProps> {
switch (this.props.labelPosition) {
case "up":
case "down":
table.style.width = width > 0 ? `${width}px` : null;
table.style.width = width > 0 ? `${width}px` : "";
break;
case "left":
case "right":
table.style.height = height > 0 ? `${height}px` : null;
table.style.height = height > 0 ? `${height}px` : "";
break;
}
}