Merge remote-tracking branch 'origin/develop' into ent-9423-respuestas-de-evento-en-metaconsola-usan-configuracion-de-nodo
This commit is contained in:
commit
755432b381
|
@ -1,5 +1,5 @@
|
|||
package: pandorafms-agent-unix
|
||||
Version: 7.0NG.764-220927
|
||||
Version: 7.0NG.764-220928
|
||||
Architecture: all
|
||||
Priority: optional
|
||||
Section: admin
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
pandora_version="7.0NG.764-220927"
|
||||
pandora_version="7.0NG.764-220928"
|
||||
|
||||
echo "Test if you has the tools for to make the packages."
|
||||
whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null
|
||||
|
|
|
@ -165,9 +165,15 @@ remote_config 0
|
|||
# should consider changing the temporal directory, since /tmp is world writable.
|
||||
xml_buffer 1
|
||||
|
||||
# Minimum available bytes in the temporal directory to enable the XML buffer
|
||||
# Minimum available megabytes in the temporal directory to enable the XML buffer
|
||||
temporal_min_size 1024
|
||||
|
||||
# Maximum size (in megabytes) allowed for the XML buffer.
|
||||
temporal_max_size 1024
|
||||
|
||||
# Maximum number of files allowed for the XML buffer.
|
||||
temporal_max_files 1024
|
||||
|
||||
# Agent mode: Learn (default), No-learn, Autodisable
|
||||
# agent_mode autodisable
|
||||
|
||||
|
|
|
@ -1015,7 +1015,7 @@ my $Sem = undef;
|
|||
my $ThreadSem = undef;
|
||||
|
||||
use constant AGENT_VERSION => '7.0NG.764';
|
||||
use constant AGENT_BUILD => '220927';
|
||||
use constant AGENT_BUILD => '220928';
|
||||
|
||||
# Agent log default file size maximum and instances
|
||||
use constant DEFAULT_MAX_LOG_SIZE => 600000;
|
||||
|
@ -1145,7 +1145,9 @@ my %DefaultConf = (
|
|||
'secondary_server_opts' => '',
|
||||
'secondary_temporal' => '/var/spool/pandora',
|
||||
'autotime' => 0,
|
||||
'temporal_min_size' => 1,
|
||||
'temporal_min_size' => 1024,
|
||||
'temporal_max_files' => 1024,
|
||||
'temporal_max_size' => 1024,
|
||||
'timezone_offset' => 0,
|
||||
'pandora_exec' => 'pandora_agent_exec',
|
||||
'agent_threads' => 1,
|
||||
|
@ -2110,13 +2112,13 @@ sub send_xml_file ($) {
|
|||
swap_servers();
|
||||
|
||||
# Secondary buffer.
|
||||
if ($rc_sec != 0 && $Conf{'xml_buffer'} == 1 && temporal_freedisk () > $Conf{'temporal_min_size'}) {
|
||||
if ($rc_sec != 0 && write_to_buffer($Conf{'secondary_temporal'}) == 1) {
|
||||
copy($file, $Conf{'secondary_temporal'}) || die("Error copying file $file to " . $Conf{'secondary_temporal'} . ": $!");
|
||||
}
|
||||
}
|
||||
|
||||
# Primary buffer.
|
||||
if ($rc == 0 || $Conf{'xml_buffer'} == 0 || temporal_freedisk () <= $Conf{'temporal_min_size'}) {
|
||||
if ($rc == 0 || write_to_buffer($Conf{'temporal'}) == 0) {
|
||||
if ($Conf{'debug'} eq '1') {
|
||||
rename($file, $file . "sent");
|
||||
} else {
|
||||
|
@ -3761,20 +3763,45 @@ sub kill_signal_handler (){
|
|||
}
|
||||
|
||||
################################################################################
|
||||
# Get the free disk space in the temporal directory (in bytes).
|
||||
# Get the free disk space in the temporal directory (in megabytes).
|
||||
################################################################################
|
||||
sub temporal_freedisk () {
|
||||
sub temporal_freedisk {
|
||||
my ($temporal) = @_;
|
||||
|
||||
# Call df
|
||||
return 0 unless defined (DF_CMDS->{$OS});
|
||||
my $cmd = DF_CMDS->{$OS} . ' ' . $Conf{'temporal'} . ' | awk \'NR > 1 {print $4}\'';
|
||||
my $cmd = DF_CMDS->{$OS} . ' ' . $temporal . ' | awk \'NR > 1 {print $4}\'';
|
||||
my $temporal_freedisk = `$cmd`;
|
||||
|
||||
# Check for errors
|
||||
return 0 unless ($? eq 0);
|
||||
|
||||
# Convert to bytes
|
||||
return 1024 * int ($temporal_freedisk);
|
||||
# Convert from KB to MB.
|
||||
return $temporal_freedisk / 1024;
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# Return the number of data files in the temporal directory and their total
|
||||
# size (in megabytes).
|
||||
################################################################################
|
||||
sub temporal_stats {
|
||||
my ($temporal) = @_;
|
||||
|
||||
my $file_count = 0;
|
||||
my $file_size = 0;
|
||||
opendir(my $dir, $temporal) or die($!);
|
||||
while (my $f = readdir($dir)) {
|
||||
if ($f =~ m/.data$/ || $f =~ m/.datasent$/) {
|
||||
$file_count += 1;
|
||||
$file_size += (stat $temporal . '/' . $f)[7];
|
||||
}
|
||||
}
|
||||
closedir($dir);
|
||||
|
||||
# Convert from B to MB.
|
||||
$file_size /= 1048576;
|
||||
|
||||
return ($file_count, $file_size);
|
||||
}
|
||||
|
||||
################################################################################
|
||||
|
@ -3960,6 +3987,27 @@ sub get_ehkey {
|
|||
return '';
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# Return 1 if XML files should be written to the buffer. 0 otherwise.
|
||||
################################################################################
|
||||
sub write_to_buffer {
|
||||
my ($temporal) = @_;
|
||||
|
||||
# The XML buffer is disabled.
|
||||
return 0 if ($Conf{'xml_buffer'} == 0);
|
||||
|
||||
# Check available disk space.
|
||||
return 0 if ($Conf{'temporal_min_size'} != 0 && temporal_freedisk($temporal) < $Conf{'temporal_min_size'});
|
||||
|
||||
# Check buffer file count and size limits.
|
||||
my ($file_count, $file_size) = temporal_stats($temporal);
|
||||
return 0 if ($Conf{'temporal_max_files'} != 0 && $file_count > $Conf{'temporal_max_files'});
|
||||
return 0 if ($Conf{'temporal_max_size'} != 0 && $file_size > $Conf{'temporal_max_size'});
|
||||
|
||||
# It's OK to write to the buffer.
|
||||
return 1;
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# Main.
|
||||
################################################################################
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#
|
||||
%define name pandorafms_agent_unix
|
||||
%define version 7.0NG.764
|
||||
%define release 220927
|
||||
%define release 220928
|
||||
|
||||
Summary: Pandora FMS Linux agent, PERL version
|
||||
Name: %{name}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#
|
||||
%define name pandorafms_agent_unix
|
||||
%define version 7.0NG.764
|
||||
%define release 220927
|
||||
%define release 220928
|
||||
|
||||
Summary: Pandora FMS Linux agent, PERL version
|
||||
Name: %{name}
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
# **********************************************************************
|
||||
|
||||
PI_VERSION="7.0NG.764"
|
||||
PI_BUILD="220927"
|
||||
PI_BUILD="220928"
|
||||
OS_NAME=`uname -s`
|
||||
|
||||
FORCE=0
|
||||
|
|
|
@ -55,9 +55,15 @@ address auto
|
|||
# or setting a fixed IP address, like for example:
|
||||
#address 192.168.36.73
|
||||
|
||||
# This limits operation if temporal dir has not enough free disk.
|
||||
# This limits operation if temporal dir has not enough free disk (in megabytes).
|
||||
#temporal_min_size 1024
|
||||
|
||||
# Maximum size (in megabytes) allowed for the XML buffer.
|
||||
temporal_max_size 1024
|
||||
|
||||
# Maximum number of files allowed for the XML buffer.
|
||||
temporal_max_files 1024
|
||||
|
||||
# Delay start execution X second before start to monitoring nothing
|
||||
#startup_delay 30
|
||||
|
||||
|
|
|
@ -186,7 +186,7 @@ UpgradeApplicationID
|
|||
{}
|
||||
|
||||
Version
|
||||
{220927}
|
||||
{220928}
|
||||
|
||||
ViewReadme
|
||||
{Yes}
|
||||
|
|
|
@ -30,7 +30,7 @@ using namespace Pandora;
|
|||
using namespace Pandora_Strutils;
|
||||
|
||||
#define PATH_SIZE _MAX_PATH+1
|
||||
#define PANDORA_VERSION ("7.0NG.764 Build 220927")
|
||||
#define PANDORA_VERSION ("7.0NG.764 Build 220928")
|
||||
|
||||
string pandora_path;
|
||||
string pandora_dir;
|
||||
|
|
|
@ -1696,7 +1696,7 @@ Pandora_Windows_Service::checkConfig (string file) {
|
|||
|
||||
int
|
||||
Pandora_Windows_Service::sendXml (Pandora_Module_List *modules, string extra /* = ""*/) {
|
||||
int rc = 0, rc_sec = 0, xml_buffer;
|
||||
int rc = 0, rc_sec = 0, xml_buffer;
|
||||
string data_xml;
|
||||
string xml_filename, random_integer;
|
||||
string tmp_filename, tmp_filepath;
|
||||
|
@ -1705,12 +1705,10 @@ Pandora_Windows_Service::sendXml (Pandora_Module_List *modules, string extra /*
|
|||
string ehorus_conf, eh_key;
|
||||
static HANDLE mutex = 0;
|
||||
ULARGE_INTEGER free_bytes;
|
||||
double min_free_bytes = 0;
|
||||
Pandora_Agent_Conf *conf = NULL;
|
||||
FILE *conf_fh = NULL;
|
||||
|
||||
conf = this->getConf ();
|
||||
min_free_bytes = 1024 * atoi (conf->getValue ("temporal_min_size").c_str ());
|
||||
xml_buffer = atoi (conf->getValue ("xml_buffer").c_str ());
|
||||
|
||||
if (mutex == 0) {
|
||||
|
@ -1814,14 +1812,14 @@ Pandora_Windows_Service::sendXml (Pandora_Module_List *modules, string extra /*
|
|||
rc_sec = this->copyToSecondary (tmp_filename, false);
|
||||
|
||||
/* Secondary buffer. */
|
||||
if (rc_sec != 0 && xml_buffer == 1 && (GetDiskFreeSpaceEx (conf->getValue ("secondary_temporal").c_str (), &free_bytes, NULL, NULL) != 0 && free_bytes.QuadPart >= min_free_bytes)) {
|
||||
if (rc_sec != 0 && this->writeToBuffer(conf->getValue ("secondary_temporal").c_str ())) {
|
||||
secondary_filepath = conf->getValue ("secondary_temporal") + "\\" + tmp_filename;
|
||||
CopyFile (tmp_filepath.c_str(), secondary_filepath.c_str(), false);
|
||||
}
|
||||
}
|
||||
|
||||
/* Primary buffer. Delete the file if successfully copied, buffer disabled or not enough space available. */
|
||||
if (rc == 0 || xml_buffer == 0 || (GetDiskFreeSpaceEx (tmp_filepath.c_str (), &free_bytes, NULL, NULL) != 0 && free_bytes.QuadPart < min_free_bytes)) {
|
||||
if (rc == 0 || !writeToBuffer(conf->getValue ("temporal").c_str ())) {
|
||||
/* Rename the file if debug mode is enabled*/
|
||||
if (getPandoraDebug ()) {
|
||||
string tmp_filepath_sent = tmp_filepath;
|
||||
|
@ -2218,3 +2216,60 @@ Pandora_Windows_Service::generateAgentName () {
|
|||
sha256(data.str().c_str(), digest);
|
||||
return std::string(digest);
|
||||
}
|
||||
|
||||
bool
|
||||
Pandora_Windows_Service::writeToBuffer (string temporal) {
|
||||
int xml_buffer;
|
||||
long int temporal_max_files;
|
||||
double temporal_min_size, temporal_max_size;
|
||||
string dir, file_name;
|
||||
ULARGE_INTEGER free_bytes;
|
||||
Pandora_Agent_Conf *conf = NULL;
|
||||
|
||||
conf = this->getConf ();
|
||||
|
||||
dir = temporal;
|
||||
if (dir[dir.length () - 1] != '\\') {
|
||||
dir += "\\";
|
||||
}
|
||||
file_name = dir + "*.data";
|
||||
|
||||
// Is the XML buffer disabled?
|
||||
xml_buffer = atoi (conf->getValue ("xml_buffer").c_str ());
|
||||
if (xml_buffer == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check available disk space.
|
||||
temporal_min_size = atoi (conf->getValue ("temporal_min_size").c_str ());
|
||||
if (GetDiskFreeSpaceEx (dir.c_str (), &free_bytes, NULL, NULL) && (free_bytes.QuadPart / 1048576) < temporal_min_size) { // Convert free_bytes.QuadPart from B to MB.
|
||||
pandoraLog ("[writeToBuffer] Disk full.");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check buffer file count and size limits.
|
||||
temporal_max_size = atoi (conf->getValue ("temporal_max_size").c_str ());
|
||||
temporal_max_files = atol (conf->getValue ("temporal_max_files").c_str ());
|
||||
if (temporal_max_size != 0 || temporal_max_files != 0) {
|
||||
long int file_count = 0;
|
||||
ULONGLONG file_size = 0;
|
||||
HANDLE hFind;
|
||||
WIN32_FIND_DATA FindFileData;
|
||||
if ((hFind = FindFirstFile(file_name.c_str(), &FindFileData)) != INVALID_HANDLE_VALUE) {
|
||||
do {
|
||||
file_count += 1;
|
||||
file_size += (FindFileData.nFileSizeHigh * (MAXDWORD + 1)) + FindFileData.nFileSizeLow;
|
||||
} while (FindNextFile(hFind, &FindFileData));
|
||||
FindClose(hFind);
|
||||
}
|
||||
|
||||
file_size /= 1048576; // Convert from B to MB.
|
||||
if ((temporal_max_size != 0 && file_size > temporal_max_size) ||
|
||||
(temporal_max_files != 0 && file_count > temporal_max_files)) {
|
||||
pandoraLog ("[writeToBuffer] Too many files or buffer full.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -124,6 +124,7 @@ namespace Pandora {
|
|||
long getInterval ();
|
||||
long getIntensiveInterval ();
|
||||
string generateAgentName ();
|
||||
bool writeToBuffer (string temporal);
|
||||
|
||||
};
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ BEGIN
|
|||
VALUE "LegalCopyright", "Artica ST"
|
||||
VALUE "OriginalFilename", "PandoraAgent.exe"
|
||||
VALUE "ProductName", "Pandora FMS Windows Agent"
|
||||
VALUE "ProductVersion", "(7.0NG.764(Build 220927))"
|
||||
VALUE "ProductVersion", "(7.0NG.764(Build 220928))"
|
||||
VALUE "FileVersion", "1.0.0.0"
|
||||
END
|
||||
END
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
package: pandorafms-console
|
||||
Version: 7.0NG.764-220927
|
||||
Version: 7.0NG.764-220928
|
||||
Architecture: all
|
||||
Priority: optional
|
||||
Section: admin
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
pandora_version="7.0NG.764-220927"
|
||||
pandora_version="7.0NG.764-220928"
|
||||
|
||||
package_pear=0
|
||||
package_pandora=1
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,5 @@
|
|||
START TRANSACTION;
|
||||
|
||||
|
||||
|
||||
COMMIT;
|
|
@ -15,6 +15,7 @@
|
|||
global $config;
|
||||
|
||||
require_once $config['homedir'].'/include/functions_alerts.php';
|
||||
require_once $config['homedir'].'/include/functions_reports.php';
|
||||
enterprise_include_once('meta/include/functions_alerts_meta.php');
|
||||
|
||||
check_login();
|
||||
|
@ -284,13 +285,13 @@ if (is_ajax()) {
|
|||
$ffield .= '<div name="field'.$i.'_value_container">'.html_print_switch(
|
||||
[
|
||||
'name' => 'field'.$i.'_value[]',
|
||||
'value' => '',
|
||||
'value' => ''
|
||||
]
|
||||
).'</div>';
|
||||
$rfield .= '<div name="field'.$i.'_recovery_value_container">'.html_print_switch(
|
||||
[
|
||||
'name' => 'field'.$i.'_recovery_value[]',
|
||||
'value' => '',
|
||||
'value' => ''
|
||||
]
|
||||
).'</div>';
|
||||
|
||||
|
@ -349,9 +350,94 @@ if (is_ajax()) {
|
|||
);
|
||||
} else {
|
||||
$fields_value_select = [];
|
||||
$fv = explode(';', $field_value);
|
||||
$force_print_select = false;
|
||||
|
||||
if (count($fv) > 1) {
|
||||
// Exception for dynamically filled select boxes.
|
||||
if (preg_match('/^_reports_$/i', $field_value)) {
|
||||
// Filter normal and metaconsole reports.
|
||||
if (is_metaconsole() === true) {
|
||||
$filter['metaconsole'] = 1;
|
||||
} else {
|
||||
$filter['metaconsole'] = 0;
|
||||
}
|
||||
|
||||
$own_info = get_user_info($config['id_user']);
|
||||
if ($own_info['is_admin'] || check_acl($config['id_user'], 0, 'RM') || check_acl($config['id_user'], 0, 'RR')) {
|
||||
$return_all_group = true;
|
||||
} else {
|
||||
$return_all_group = false;
|
||||
}
|
||||
|
||||
if (is_user_admin($config['id_user']) === false) {
|
||||
$filter[] = sprintf(
|
||||
'private = 0 OR (private = 1 AND id_user = "%s")',
|
||||
$config['id_user']
|
||||
);
|
||||
}
|
||||
|
||||
$reports = reports_get_reports(
|
||||
$filter,
|
||||
[
|
||||
'name',
|
||||
'id_report'
|
||||
],
|
||||
$return_all_group,
|
||||
'RR'
|
||||
);
|
||||
|
||||
$fv = array_map(
|
||||
function ($report) {
|
||||
return $report['id_report'].','.$report['name'];
|
||||
},
|
||||
$reports
|
||||
);
|
||||
|
||||
$force_print_select = true;
|
||||
} else if (preg_match('/^_report_templates_$/i', $field_value)) {
|
||||
// Filter normal and metaconsole reports.
|
||||
if (is_metaconsole() === true) {
|
||||
$filter['metaconsole'] = 1;
|
||||
} else {
|
||||
$filter['metaconsole'] = 0;
|
||||
}
|
||||
|
||||
$own_info = get_user_info($config['id_user']);
|
||||
if ($own_info['is_admin'] || check_acl($config['id_user'], 0, 'RM') || check_acl($config['id_user'], 0, 'RR')) {
|
||||
$return_all_group = true;
|
||||
} else {
|
||||
$return_all_group = false;
|
||||
}
|
||||
|
||||
if (is_user_admin($config['id_user']) === false) {
|
||||
$filter[] = sprintf(
|
||||
'private = 0 OR (private = 1 AND id_user = "%s")',
|
||||
$config['id_user']
|
||||
);
|
||||
}
|
||||
|
||||
$templates = reports_get_report_templates(
|
||||
$filter,
|
||||
[
|
||||
'name',
|
||||
'id_report'
|
||||
],
|
||||
$return_all_group,
|
||||
'RR'
|
||||
);
|
||||
|
||||
$fv = array_map(
|
||||
function ($template) {
|
||||
return $template['id_report'].','.$template['name'];
|
||||
},
|
||||
$templates
|
||||
);
|
||||
|
||||
$force_print_select = true;
|
||||
} else {
|
||||
$fv = explode(';', $field_value);
|
||||
}
|
||||
|
||||
if (count($fv) > 1 || $force_print_select === true) {
|
||||
if (!empty($fv)) {
|
||||
foreach ($fv as $fv_option) {
|
||||
$fv_option = explode(',', $fv_option);
|
||||
|
|
|
@ -647,7 +647,12 @@ if ($get_agent_alerts_datatable === true) {
|
|||
$order = get_datatable_order(true);
|
||||
$url = get_parameter('url', '#');
|
||||
|
||||
$free_search_alert = $filter_alert['free_search_alert'];
|
||||
if (empty($filter_alert['free_search']) === false) {
|
||||
$free_search_alert = $filter_alert['free_search'];
|
||||
} else {
|
||||
$free_search_alert = $filter_alert['free_search_alert'];
|
||||
}
|
||||
|
||||
$idGroup = $filter_alert['ag_group'];
|
||||
$tag_filter = $filter_alert['tag_filter'];
|
||||
$action_filter = $filter_alert['action'];
|
||||
|
@ -676,7 +681,7 @@ if ($get_agent_alerts_datatable === true) {
|
|||
$selectLastFiredDown = false;
|
||||
|
||||
switch ($sortField) {
|
||||
case 'module':
|
||||
case 'agent_module_name':
|
||||
switch ($sort) {
|
||||
case 'asc':
|
||||
$selectModuleasc = $selected;
|
||||
|
@ -696,7 +701,7 @@ if ($get_agent_alerts_datatable === true) {
|
|||
}
|
||||
break;
|
||||
|
||||
case 'template':
|
||||
case 'template_name':
|
||||
switch ($sort) {
|
||||
case 'asc':
|
||||
$selectTemplateasc = $selected;
|
||||
|
@ -736,7 +741,7 @@ if ($get_agent_alerts_datatable === true) {
|
|||
}
|
||||
break;
|
||||
|
||||
case 'agent':
|
||||
case 'agent_name':
|
||||
switch ($sort) {
|
||||
case 'asc':
|
||||
$selectLastFiredasc = $selected;
|
||||
|
@ -857,7 +862,7 @@ if ($get_agent_alerts_datatable === true) {
|
|||
if (is_metaconsole() === true) {
|
||||
include_once $config['homedir'].'/enterprise/meta/include/functions_alerts_meta.php';
|
||||
if ($idAgent != 0) {
|
||||
$alerts['alerts_simple'] = alerts_meta_get_alerts($agents, $filter_alert, $options_simple, $whereAlertSimple, false, false, $idGroup, false, $strict_user, $tag_filter, $action_filter);
|
||||
$alerts['alerts_simple'] = alerts_meta_get_alerts($agents, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, false, $strict_user, $tag_filter, $action_filter);
|
||||
|
||||
$countAlertsSimple = alerts_meta_get_alerts($agents, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, true, $strict_user, $tag_filter, $action_filter);
|
||||
} else {
|
||||
|
@ -865,7 +870,7 @@ if ($get_agent_alerts_datatable === true) {
|
|||
users_get_groups($config['id_user'], 'AR', false)
|
||||
);
|
||||
|
||||
$alerts['alerts_simple'] = alerts_meta_get_group_alerts($id_groups, $filter_alert, $options_simple, $whereAlertSimple, false, false, $idGroup, false, $strict_user, $tag_filter, $action_filter);
|
||||
$alerts['alerts_simple'] = alerts_meta_get_group_alerts($id_groups, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, false, $strict_user, $tag_filter, $action_filter);
|
||||
|
||||
$countAlertsSimple = alerts_meta_get_group_alerts($id_groups, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, true, $strict_user, $tag_filter, $action_filter);
|
||||
}
|
||||
|
@ -885,12 +890,60 @@ if ($get_agent_alerts_datatable === true) {
|
|||
}
|
||||
}
|
||||
|
||||
// Order and pagination metacosole.
|
||||
if (is_metaconsole() === true) {
|
||||
|
||||
|
||||
/**
|
||||
* Auxiliar Ordenation function
|
||||
*
|
||||
* @param string $sort Direction of sort.
|
||||
* @param string $sortField Field for perform the sorting.
|
||||
*/
|
||||
function arrayOutputSorting($sort, $sortField)
|
||||
{
|
||||
return function ($a, $b) use ($sort, $sortField) {
|
||||
if ($sort === 'asc') {
|
||||
if (is_string($a[$sortField]) === true) {
|
||||
return strnatcasecmp($a[$sortField], $b[$sortField]);
|
||||
} else {
|
||||
return ($a[$sortField] - $b[$sortField]);
|
||||
}
|
||||
} else {
|
||||
if (is_string($a[$sortField]) === true) {
|
||||
return strnatcasecmp($b[$sortField], $a[$sortField]);
|
||||
} else {
|
||||
return ($a[$sortField] + $b[$sortField]);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
// Status order.
|
||||
if ($sortField === 'status') {
|
||||
foreach ($alerts['alerts_simple'] as $i => $alert) {
|
||||
if ($alert['times_fired'] > 0) {
|
||||
$alerts['alerts_simple'][$i]['status'] = '3';
|
||||
} else if ($alert['disabled'] > 0) {
|
||||
$alerts['alerts_simple'][$i]['status'] = '1';
|
||||
} else {
|
||||
$alerts['alerts_simple'][$i]['status'] = '2';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
usort($alerts['alerts_simple'], arrayOutputSorting($sort, $sortField));
|
||||
$alerts['alerts_simple'] = array_slice($alerts['alerts_simple'], $start, $length);
|
||||
}
|
||||
|
||||
$data = [];
|
||||
if ($alerts['alerts_simple']) {
|
||||
foreach ($alerts['alerts_simple'] as $alert) {
|
||||
$data[] = ui_format_alert_row($alert, true, $url, 'font-size: 7pt;');
|
||||
}
|
||||
|
||||
|
||||
$data = array_reduce(
|
||||
$data,
|
||||
function ($carry, $row) {
|
||||
|
@ -902,11 +955,11 @@ if ($get_agent_alerts_datatable === true) {
|
|||
$tmp->policy = $row[0];
|
||||
$tmp->standby = $row[1];
|
||||
$tmp->force = $row[2];
|
||||
$tmp->agent = $row[3];
|
||||
$tmp->module = $row[4];
|
||||
$tmp->template = $row[5];
|
||||
$tmp->agent_name = $row[3];
|
||||
$tmp->agent_module_name = $row[4];
|
||||
$tmp->template_name = $row[5];
|
||||
$tmp->action = $row[6];
|
||||
$tmp->lastFired = $row[7];
|
||||
$tmp->last_fired = $row[7];
|
||||
$tmp->status = $row[8];
|
||||
$tmp->validate = $row[9];
|
||||
|
||||
|
@ -916,6 +969,7 @@ if ($get_agent_alerts_datatable === true) {
|
|||
);
|
||||
}
|
||||
|
||||
|
||||
// Datatables format: RecordsTotal && recordsfiltered.
|
||||
echo json_encode(
|
||||
[
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
/**
|
||||
* Pandora build version and version
|
||||
*/
|
||||
$build_version = 'PC220927';
|
||||
$build_version = 'PC220928';
|
||||
$pandora_version = 'v7.0NG.764';
|
||||
|
||||
// Do not overwrite default timezone set if defined.
|
||||
|
|
|
@ -46,12 +46,18 @@ require_once $config['homedir'].'/include/functions_planned_downtimes.php';
|
|||
require_once $config['homedir'].'/include/functions_db.php';
|
||||
require_once $config['homedir'].'/include/functions_event_responses.php';
|
||||
require_once $config['homedir'].'/include/functions_tactical.php';
|
||||
require_once $config['homedir'].'/include/functions_reporting.php';
|
||||
require_once $config['homedir'].'/include/functions_reporting_xml.php';
|
||||
require_once $config['homedir'].'/include/functions_reports.php';
|
||||
enterprise_include_once('include/functions_local_components.php');
|
||||
enterprise_include_once('include/functions_events.php');
|
||||
enterprise_include_once('include/functions_agents.php');
|
||||
enterprise_include_once('include/functions_modules.php');
|
||||
enterprise_include_once('include/functions_clusters.php');
|
||||
enterprise_include_once('include/functions_alerts.php');
|
||||
enterprise_include_once('include/functions_reporting_pdf.php');
|
||||
enterprise_include_once('include/functions_reporting_csv.php');
|
||||
enterprise_include_once('include/functions_cron.php');
|
||||
|
||||
// Clases.
|
||||
use PandoraFMS\Agent;
|
||||
|
@ -17542,3 +17548,302 @@ function api_set_enable_disable_discovery_task($id_task, $thrash2, $other)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Make report (PDF, CSV or XML) and send it via e-mail (this method is intended to be used by server's execution
|
||||
* of alert actions that involve sending reports by e-mail).
|
||||
* @param [string] $server_id id server (Node)
|
||||
* @param [string] $console_event_id console Id node event in tevent
|
||||
* @param [string] $trash2 don't use
|
||||
* @param [string] $returnType
|
||||
*
|
||||
* --Internal use--
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function api_set_send_report($thrash1, $thrash2, $other, $returnType)
|
||||
{
|
||||
global $config;
|
||||
|
||||
$id_item = (int) $other['data'][0];
|
||||
$report_type = $other['data'][1];
|
||||
$email = $other['data'][2];
|
||||
$subject_email = $other['data'][3];
|
||||
$body_email = $other['data'][4];
|
||||
$make_report_from_template = (bool) $other['data'][5];
|
||||
$template_regex_agents = $other['data'][6];
|
||||
|
||||
// Filter normal and metaconsole reports.
|
||||
if (is_metaconsole() === true) {
|
||||
$filter['metaconsole'] = 1;
|
||||
} else {
|
||||
$filter['metaconsole'] = 0;
|
||||
}
|
||||
|
||||
$own_info = get_user_info($config['id_user']);
|
||||
if ($own_info['is_admin'] || check_acl($config['id_user'], 0, 'RM') || check_acl($config['id_user'], 0, 'RR')) {
|
||||
$return_all_group = true;
|
||||
} else {
|
||||
$return_all_group = false;
|
||||
}
|
||||
|
||||
if (is_user_admin($config['id_user']) === false) {
|
||||
$filter[] = sprintf(
|
||||
'private = 0 OR (private = 1 AND id_user = "%s")',
|
||||
$config['id_user']
|
||||
);
|
||||
}
|
||||
|
||||
$date_today = date($config['date_format']);
|
||||
$date_today = preg_split('/[\s,]+/', io_safe_output($date_today));
|
||||
$date_today = __($date_today[0]).' '.$date_today[1].' '.$date_today[2].' '.$date_today[3].' '.$date_today[4];
|
||||
|
||||
|
||||
if ($make_report_from_template === true) {
|
||||
$filter['id_report'] = $id_item;
|
||||
|
||||
$template = reports_get_report_templates(
|
||||
$filter,
|
||||
[
|
||||
'description'
|
||||
],
|
||||
$return_all_group,
|
||||
'RR'
|
||||
)[0];
|
||||
|
||||
$description = $template['description'];
|
||||
|
||||
// Report macros post-process.
|
||||
$body_email = str_replace([
|
||||
'_report_description_',
|
||||
'_report_generated_date_',
|
||||
'_report_date_'
|
||||
],
|
||||
[
|
||||
$description,
|
||||
$date_today,
|
||||
$date_today
|
||||
],
|
||||
$body_email
|
||||
);
|
||||
|
||||
$report_type = strtoupper($report_type);
|
||||
$body_email = io_safe_output(io_safe_output($body_email));
|
||||
|
||||
cron_task_generate_report_by_template(
|
||||
$id_item,
|
||||
'',
|
||||
$template_regex_agents,
|
||||
false,
|
||||
'',
|
||||
$email,
|
||||
$subject_email,
|
||||
$body_email,
|
||||
$report_type,
|
||||
''
|
||||
);
|
||||
} else {
|
||||
$report = reports_get_report($id_item);
|
||||
|
||||
if ($report === false) {
|
||||
// User has no grant to access this report.
|
||||
return;
|
||||
}
|
||||
|
||||
// Report macros post-process.
|
||||
$body_email = str_replace([
|
||||
'_report_description_',
|
||||
'_report_generated_date_',
|
||||
'_report_date_'
|
||||
],
|
||||
[
|
||||
$report['description'],
|
||||
$date_today,
|
||||
$date_today
|
||||
],
|
||||
$body_email
|
||||
);
|
||||
|
||||
$body_email = io_safe_output(io_safe_output($body_email));
|
||||
|
||||
// Set the languaje of user.
|
||||
global $l10n;
|
||||
|
||||
if (isset($l10n) === false) {
|
||||
$l10n = null;
|
||||
$user_language = get_user_language($config['id_user']);
|
||||
if (file_exists(
|
||||
$config['homedir'].'/include/languages/'.$user_language.'.mo'
|
||||
) === true
|
||||
) {
|
||||
$obj = new CachedFileReader(
|
||||
$config['homedir'].'/include/languages/'.$user_language.'.mo'
|
||||
);
|
||||
$l10n = new gettext_reader($obj);
|
||||
$l10n->load_tables();
|
||||
}
|
||||
}
|
||||
|
||||
// Attachments.
|
||||
$attachments = [];
|
||||
// Set the datetime for the report.
|
||||
$report['datetime'] = time();
|
||||
|
||||
$date = date('Y-m-j');
|
||||
$time = date('h:iA');
|
||||
|
||||
$tmpfile = false;
|
||||
|
||||
switch ($report_type) {
|
||||
case 'pdf':
|
||||
$tmpfile = $config['homedir'].'/attachment/'.date('Ymd-His').'.pdf';
|
||||
|
||||
$report = reporting_make_reporting_data(
|
||||
null,
|
||||
$id_item,
|
||||
$date,
|
||||
$time,
|
||||
null,
|
||||
'static',
|
||||
null,
|
||||
null,
|
||||
true
|
||||
);
|
||||
pdf_get_report($report, $tmpfile);
|
||||
|
||||
$attachments[0] = [
|
||||
'file' => $tmpfile,
|
||||
'content_type' => 'application/pdf',
|
||||
];
|
||||
break;
|
||||
|
||||
case 'csv':
|
||||
$report = reporting_make_reporting_data(
|
||||
null,
|
||||
$id_item,
|
||||
$date,
|
||||
$time,
|
||||
null,
|
||||
'data'
|
||||
);
|
||||
|
||||
$name = explode(' - ', $report['name']);
|
||||
$tmpfile = $config['homedir'].'/attachment/'.$name[0].'.csv';
|
||||
|
||||
// Remove unused fields.
|
||||
unset($report['header']);
|
||||
unset($report['first_page']);
|
||||
unset($report['footer']);
|
||||
unset($report['custom_font']);
|
||||
unset($report['id_template']);
|
||||
unset($report['id_group_edit']);
|
||||
unset($report['metaconsole']);
|
||||
unset($report['private']);
|
||||
unset($report['custom_logo']);
|
||||
|
||||
ob_start();
|
||||
csv_get_report($report, true);
|
||||
$output = ob_get_clean();
|
||||
|
||||
file_put_contents($tmpfile, $output);
|
||||
ob_end_clean();
|
||||
|
||||
$attachments[0] = [
|
||||
'file' => $tmpfile,
|
||||
'content_type' => 'text/csv',
|
||||
];
|
||||
break;
|
||||
|
||||
case 'json':
|
||||
$report = reporting_make_reporting_data(
|
||||
null,
|
||||
$id_item,
|
||||
$date,
|
||||
$time,
|
||||
null,
|
||||
'data'
|
||||
);
|
||||
|
||||
// Remove unused fields.
|
||||
unset($report['header']);
|
||||
unset($report['first_page']);
|
||||
unset($report['footer']);
|
||||
unset($report['custom_font']);
|
||||
unset($report['id_template']);
|
||||
unset($report['id_group_edit']);
|
||||
unset($report['metaconsole']);
|
||||
unset($report['private']);
|
||||
unset($report['custom_logo']);
|
||||
|
||||
$name = explode(' - ', $report['name']);
|
||||
$tmpfile = $config['homedir'].'/attachment/'.$name[0].'.json';
|
||||
|
||||
file_put_contents($tmpfile, json_encode($report, JSON_PRETTY_PRINT));
|
||||
|
||||
$attachments[0] = [
|
||||
'file' => $tmpfile,
|
||||
'content_type' => 'text/json',
|
||||
];
|
||||
break;
|
||||
|
||||
case 'xml':
|
||||
$report = reporting_make_reporting_data(
|
||||
null,
|
||||
$id_item,
|
||||
$date,
|
||||
$time,
|
||||
null,
|
||||
'data'
|
||||
);
|
||||
|
||||
$name = explode(' - ', $report['name']);
|
||||
$tmpfile = $config['homedir'].'/attachment/'.$name[0].'.xml';
|
||||
|
||||
// Remove unused fields.
|
||||
unset($report['header']);
|
||||
unset($report['first_page']);
|
||||
unset($report['footer']);
|
||||
unset($report['custom_font']);
|
||||
unset($report['id_template']);
|
||||
unset($report['id_group_edit']);
|
||||
unset($report['metaconsole']);
|
||||
unset($report['private']);
|
||||
unset($report['custom_logo']);
|
||||
|
||||
ob_start();
|
||||
reporting_xml_get_report($report, true);
|
||||
$output = ob_get_clean();
|
||||
|
||||
file_put_contents($tmpfile, $output);
|
||||
ob_end_clean();
|
||||
|
||||
$attachments[0] = [
|
||||
'file' => $tmpfile,
|
||||
'content_type' => 'text/xml',
|
||||
];
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
reporting_email_template(
|
||||
$subject_email,
|
||||
$body_email,
|
||||
'',
|
||||
$report['name'],
|
||||
$email,
|
||||
$attachments
|
||||
);
|
||||
|
||||
unlink($other['data'][0]);
|
||||
|
||||
$data = [
|
||||
'type' => 'string',
|
||||
'data' => '1',
|
||||
];
|
||||
|
||||
returnData($returnType, $data, ';');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2078,7 +2078,7 @@ function events_change_owner(
|
|||
events_comment(
|
||||
$id_event,
|
||||
'',
|
||||
'Change owner to '.$new_owner
|
||||
'Change owner to '.get_user_fullname($new_owner).' ('.$new_owner.')'
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -3284,18 +3284,9 @@ function events_page_responses($event)
|
|||
|
||||
foreach ($users as $u) {
|
||||
$owners[$u['id_user']] = $u['id_user'];
|
||||
}
|
||||
|
||||
if (empty($event['owner_user']) === true) {
|
||||
$owner_name = __('None');
|
||||
} else {
|
||||
$owner_name = db_get_value(
|
||||
'id_user',
|
||||
'tusuario',
|
||||
'id_user',
|
||||
$event['owner_user']
|
||||
);
|
||||
$owners[$event['owner_user']] = $owner_name;
|
||||
if (empty($u['fullname']) === false) {
|
||||
$owners[$u['id_user']] = $u['fullname'].' ('.$u['id_user'].')';
|
||||
}
|
||||
}
|
||||
|
||||
$data[1] = html_print_select(
|
||||
|
@ -4921,7 +4912,7 @@ function events_page_comments($event, $ajax=false, $groupedComments=[])
|
|||
'<b>%s %s %s%s</b>',
|
||||
$c['action'],
|
||||
__('by'),
|
||||
$c['id_user'],
|
||||
get_user_fullname($c['id_user']).' ('.$c['id_user'].')',
|
||||
$eventIdExplanation
|
||||
);
|
||||
|
||||
|
|
|
@ -86,7 +86,8 @@ function groupview_get_modules_counters($groups_ids=false)
|
|||
WHERE tasg.id_group IN ($groups_ids)
|
||||
GROUP BY tasg.id_group
|
||||
) x GROUP BY g";
|
||||
return db_get_all_rows_sql($sql);
|
||||
$data = db_get_all_rows_sql($sql);
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -11537,7 +11537,7 @@ function reporting_get_group_stats_resume($id_group=0, $access='AR', $ignore_per
|
|||
$data['status'] = 'critical';
|
||||
} else if ($data['monitor_warning'] > 0) {
|
||||
$data['status'] = 'warning';
|
||||
} else if (($data['monitor_unknown'] > 0) || ($data['agents_unknown'] > 0)) {
|
||||
} else if (($data['monitor_unknown'] > 0) || ($data['agent_unknown'] > 0)) {
|
||||
$data['status'] = 'unknown';
|
||||
} else if ($data['monitor_ok'] > 0) {
|
||||
$data['status'] = 'ok';
|
||||
|
|
|
@ -1408,3 +1408,77 @@ function custom_fields_macros_report($macro, $key_macro)
|
|||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of the reports the user can view.
|
||||
*
|
||||
* A user can view a report by two ways:
|
||||
* - The user created the report (id_user field in treport)
|
||||
* - The report is not private and the user has reading privileges on
|
||||
* the group associated to the report
|
||||
*
|
||||
* @param array Extra filter to retrieve reports. All reports are returned by
|
||||
* default
|
||||
* @param array Fields to be fetched on every report.
|
||||
*
|
||||
* @return array An array with all the reports the user can view.
|
||||
*/
|
||||
function reports_get_report_templates(
|
||||
$filter=false,
|
||||
$fields=false,
|
||||
$returnAllGroup=true,
|
||||
$privileges='RR',
|
||||
$group=false,
|
||||
$strict_user=false
|
||||
) {
|
||||
global $config;
|
||||
|
||||
if (is_array($filter) === false) {
|
||||
$filter = [];
|
||||
}
|
||||
|
||||
if (is_array($fields) === false) {
|
||||
$fields[] = 'id_group';
|
||||
$fields[] = 'id_user';
|
||||
}
|
||||
|
||||
$templates = [];
|
||||
$all_templates = @db_get_all_rows_filter('treport_template', $filter, $fields);
|
||||
|
||||
if (empty($all_templates) === true) {
|
||||
$all_templates = [];
|
||||
}
|
||||
|
||||
if ($group) {
|
||||
$groups = $group;
|
||||
} else {
|
||||
$groups = users_get_groups($config['id_user'], $privileges, $returnAllGroup);
|
||||
if ($strict_user) {
|
||||
$groups = users_get_strict_mode_groups($config['id_user'], $returnAllGroup);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($all_templates as $template) {
|
||||
// If the template is not in all group.
|
||||
if ($template['id_group'] != 0) {
|
||||
if (!in_array($template['id_group'], array_keys($groups))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($config['id_user'] != $template['id_user']
|
||||
&& !check_acl($config['id_user'], $template['id_group'], $privileges)
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
if ($returnAllGroup === false) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
array_push($templates, $template);
|
||||
}
|
||||
|
||||
return $templates;
|
||||
}
|
||||
|
||||
|
|
|
@ -1075,7 +1075,7 @@ function ui_format_alert_row(
|
|||
}
|
||||
}
|
||||
|
||||
if (is_metaconsole() === true) {
|
||||
if (is_metaconsole() === true && (int) $server_id !== 0) {
|
||||
$server = db_get_row('tmetaconsole_setup', 'id', $alert['server_data']['id']);
|
||||
|
||||
if (metaconsole_connect($server) == NOERR) {
|
||||
|
|
|
@ -3788,6 +3788,7 @@ function visual_map_get_user_layouts(
|
|||
unset($filter['can_manage_group_all']);
|
||||
}
|
||||
|
||||
$where = '';
|
||||
if ($check_user_groups === true && !empty($groups)) {
|
||||
if (empty($where)) {
|
||||
$where = '';
|
||||
|
@ -4080,7 +4081,7 @@ function visual_map_get_layout_status($layout_id, $status_data=[], $depth=0)
|
|||
// When the status calculation type is 'default', only one critical
|
||||
// element is required to set the layout status as critical, so we can
|
||||
// return the critical status right now.
|
||||
if ($status_data['linked_layout_status_type'] === 'default'
|
||||
if ((isset($status_data['linked_layout_status_type']) === true && $status_data['linked_layout_status_type'] === 'default')
|
||||
&& ($status == VISUAL_MAP_STATUS_CRITICAL_BAD
|
||||
|| $status == VISUAL_MAP_STATUS_CRITICAL_ALERT)
|
||||
) {
|
||||
|
@ -4104,71 +4105,73 @@ function visual_map_get_layout_status($layout_id, $status_data=[], $depth=0)
|
|||
metaconsole_restore_db();
|
||||
}
|
||||
|
||||
// Status calculation.
|
||||
switch ($status_data['linked_layout_status_type']) {
|
||||
default:
|
||||
case 'default':
|
||||
$num_items_critical_alert = $num_elements_by_status[VISUAL_MAP_STATUS_CRITICAL_ALERT];
|
||||
$num_items_critical = $num_elements_by_status[VISUAL_MAP_STATUS_CRITICAL_BAD];
|
||||
$num_items_warning_alert = $num_elements_by_status[VISUAL_MAP_STATUS_WARNING_ALERT];
|
||||
$num_items_warning = $num_elements_by_status[VISUAL_MAP_STATUS_WARNING];
|
||||
$num_items_unknown = $num_elements_by_status[VISUAL_MAP_STATUS_UNKNOWN];
|
||||
if (isset($status_data['linked_layout_status_type']) === true) {
|
||||
// Status calculation.
|
||||
switch ($status_data['linked_layout_status_type']) {
|
||||
default:
|
||||
case 'default':
|
||||
$num_items_critical_alert = $num_elements_by_status[VISUAL_MAP_STATUS_CRITICAL_ALERT];
|
||||
$num_items_critical = $num_elements_by_status[VISUAL_MAP_STATUS_CRITICAL_BAD];
|
||||
$num_items_warning_alert = $num_elements_by_status[VISUAL_MAP_STATUS_WARNING_ALERT];
|
||||
$num_items_warning = $num_elements_by_status[VISUAL_MAP_STATUS_WARNING];
|
||||
$num_items_unknown = $num_elements_by_status[VISUAL_MAP_STATUS_UNKNOWN];
|
||||
|
||||
if ($num_items_critical_alert > 0) {
|
||||
return VISUAL_MAP_STATUS_CRITICAL_ALERT;
|
||||
} else if ($num_items_critical > 0) {
|
||||
return VISUAL_MAP_STATUS_CRITICAL_BAD;
|
||||
} else if ($num_items_warning_alert > 0) {
|
||||
return VISUAL_MAP_STATUS_WARNING_ALERT;
|
||||
} else if ($num_items_warning > 0) {
|
||||
return VISUAL_MAP_STATUS_WARNING;
|
||||
} else if ($num_items_unknown > 0) {
|
||||
return VISUAL_MAP_STATUS_UNKNOWN;
|
||||
} else {
|
||||
return VISUAL_MAP_STATUS_NORMAL;
|
||||
}
|
||||
break;
|
||||
case 'weight':
|
||||
$weight = $status_data['id_layout_linked_weight'];
|
||||
$num_items = count($valid_layout_items);
|
||||
$num_items_critical_alert = $num_elements_by_status[VISUAL_MAP_STATUS_CRITICAL_ALERT];
|
||||
$num_items_critical = $num_elements_by_status[VISUAL_MAP_STATUS_CRITICAL_BAD];
|
||||
$num_items_warning_alert = $num_elements_by_status[VISUAL_MAP_STATUS_WARNING_ALERT];
|
||||
$num_items_warning = $num_elements_by_status[VISUAL_MAP_STATUS_WARNING];
|
||||
$num_items_unknown = $num_elements_by_status[VISUAL_MAP_STATUS_UNKNOWN];
|
||||
if ($num_items_critical_alert > 0) {
|
||||
return VISUAL_MAP_STATUS_CRITICAL_ALERT;
|
||||
} else if ($num_items_critical > 0) {
|
||||
return VISUAL_MAP_STATUS_CRITICAL_BAD;
|
||||
} else if ($num_items_warning_alert > 0) {
|
||||
return VISUAL_MAP_STATUS_WARNING_ALERT;
|
||||
} else if ($num_items_warning > 0) {
|
||||
return VISUAL_MAP_STATUS_WARNING;
|
||||
} else if ($num_items_unknown > 0) {
|
||||
return VISUAL_MAP_STATUS_UNKNOWN;
|
||||
} else {
|
||||
return VISUAL_MAP_STATUS_NORMAL;
|
||||
}
|
||||
break;
|
||||
case 'weight':
|
||||
$weight = $status_data['id_layout_linked_weight'];
|
||||
$num_items = count($valid_layout_items);
|
||||
$num_items_critical_alert = $num_elements_by_status[VISUAL_MAP_STATUS_CRITICAL_ALERT];
|
||||
$num_items_critical = $num_elements_by_status[VISUAL_MAP_STATUS_CRITICAL_BAD];
|
||||
$num_items_warning_alert = $num_elements_by_status[VISUAL_MAP_STATUS_WARNING_ALERT];
|
||||
$num_items_warning = $num_elements_by_status[VISUAL_MAP_STATUS_WARNING];
|
||||
$num_items_unknown = $num_elements_by_status[VISUAL_MAP_STATUS_UNKNOWN];
|
||||
|
||||
if (($num_items_critical > 0 || $num_items_critical_alert > 0)
|
||||
&& ((($num_items_critical_alert + $num_items_critical) * 100) / $num_items) >= $weight
|
||||
) {
|
||||
return ($num_items_critical_alert > 0) ? VISUAL_MAP_STATUS_CRITICAL_ALERT : VISUAL_MAP_STATUS_CRITICAL_BAD;
|
||||
} else if (($num_items_warning > 0 || $num_items_warning_alert > 0)
|
||||
&& (($num_items_warning_alert + $num_items_warning * 100) / $num_items) >= $weight
|
||||
) {
|
||||
return ($num_items_warning_alert > 0) ? VISUAL_MAP_STATUS_WARNING_ALERT : VISUAL_MAP_STATUS_WARNING;
|
||||
} else if ($num_items_unknown > 0
|
||||
&& (($num_items_unknown * 100) / $num_items) >= $weight
|
||||
) {
|
||||
return VISUAL_MAP_STATUS_UNKNOWN;
|
||||
} else {
|
||||
return VISUAL_MAP_STATUS_NORMAL;
|
||||
}
|
||||
break;
|
||||
if (($num_items_critical > 0 || $num_items_critical_alert > 0)
|
||||
&& ((($num_items_critical_alert + $num_items_critical) * 100) / $num_items) >= $weight
|
||||
) {
|
||||
return ($num_items_critical_alert > 0) ? VISUAL_MAP_STATUS_CRITICAL_ALERT : VISUAL_MAP_STATUS_CRITICAL_BAD;
|
||||
} else if (($num_items_warning > 0 || $num_items_warning_alert > 0)
|
||||
&& (($num_items_warning_alert + $num_items_warning * 100) / $num_items) >= $weight
|
||||
) {
|
||||
return ($num_items_warning_alert > 0) ? VISUAL_MAP_STATUS_WARNING_ALERT : VISUAL_MAP_STATUS_WARNING;
|
||||
} else if ($num_items_unknown > 0
|
||||
&& (($num_items_unknown * 100) / $num_items) >= $weight
|
||||
) {
|
||||
return VISUAL_MAP_STATUS_UNKNOWN;
|
||||
} else {
|
||||
return VISUAL_MAP_STATUS_NORMAL;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'service':
|
||||
$num_items_critical = ($num_elements_by_status[VISUAL_MAP_STATUS_CRITICAL_BAD] + $num_elements_by_status[VISUAL_MAP_STATUS_CRITICAL_ALERT]);
|
||||
$critical_percentage = (($num_items_critical * 100) / count($valid_layout_items));
|
||||
case 'service':
|
||||
$num_items_critical = ($num_elements_by_status[VISUAL_MAP_STATUS_CRITICAL_BAD] + $num_elements_by_status[VISUAL_MAP_STATUS_CRITICAL_ALERT]);
|
||||
$critical_percentage = (($num_items_critical * 100) / count($valid_layout_items));
|
||||
|
||||
$num_items_warning = ($num_elements_by_status[VISUAL_MAP_STATUS_WARNING] + $num_elements_by_status[VISUAL_MAP_STATUS_WARNING_ALERT]);
|
||||
$warning_percentage = (($num_items_warning * 100) / count($valid_layout_items));
|
||||
$num_items_warning = ($num_elements_by_status[VISUAL_MAP_STATUS_WARNING] + $num_elements_by_status[VISUAL_MAP_STATUS_WARNING_ALERT]);
|
||||
$warning_percentage = (($num_items_warning * 100) / count($valid_layout_items));
|
||||
|
||||
if ($critical_percentage >= $status_data['linked_layout_status_as_service_critical'] && $critical_percentage !== 0) {
|
||||
return VISUAL_MAP_STATUS_CRITICAL_BAD;
|
||||
} else if ($warning_percentage >= $status_data['linked_layout_status_as_service_warning'] && $warning_percentage !== 0) {
|
||||
return VISUAL_MAP_STATUS_WARNING;
|
||||
} else {
|
||||
return VISUAL_MAP_STATUS_NORMAL;
|
||||
}
|
||||
break;
|
||||
if ($critical_percentage >= $status_data['linked_layout_status_as_service_critical'] && $critical_percentage !== 0) {
|
||||
return VISUAL_MAP_STATUS_CRITICAL_BAD;
|
||||
} else if ($warning_percentage >= $status_data['linked_layout_status_as_service_warning'] && $warning_percentage !== 0) {
|
||||
return VISUAL_MAP_STATUS_WARNING;
|
||||
} else {
|
||||
return VISUAL_MAP_STATUS_NORMAL;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -526,8 +526,7 @@ function print_clock_analogic_1(
|
|||
$color,
|
||||
$title=true
|
||||
) {
|
||||
global $config;
|
||||
$output .= '<style type="text/css">
|
||||
$output = '<style type="text/css">
|
||||
#rim {
|
||||
fill: none;
|
||||
stroke: #999;
|
||||
|
|
|
@ -336,9 +336,12 @@ function event_change_status(event_ids, server_id) {
|
|||
}
|
||||
|
||||
if (data.status == "status_ok") {
|
||||
if (typeof dt_events !== "undefined") {
|
||||
dt_events.draw(false);
|
||||
}
|
||||
// if (typeof dt_events !== "undefined") {
|
||||
// dt_events.draw(false);
|
||||
// }
|
||||
$("#table_events")
|
||||
.DataTable()
|
||||
.draw(false);
|
||||
$("#notification_status_success").show();
|
||||
if (new_status == 1) {
|
||||
$("#extended_event_general_page table td.general_acknowleded").text(
|
||||
|
@ -396,9 +399,12 @@ function event_change_owner(event_id, server_id) {
|
|||
}
|
||||
|
||||
if (data == "owner_ok") {
|
||||
if (typeof dt_events !== "undefined") {
|
||||
dt_events.draw(false);
|
||||
}
|
||||
// if (typeof dt_events !== "undefined") {
|
||||
// dt_events.draw(false);
|
||||
// }
|
||||
$("#table_events")
|
||||
.DataTable()
|
||||
.draw(false);
|
||||
$("#notification_owner_success").show();
|
||||
if (new_owner == -1) {
|
||||
$("#extended_event_general_page table td.general_owner").html(
|
||||
|
|
|
@ -387,17 +387,17 @@ class BlockHistogram extends Widget
|
|||
$output = '';
|
||||
|
||||
if (is_metaconsole() === true) {
|
||||
$modules_nodes = array_reduce(
|
||||
$this->values['moduleBlockHistogram'],
|
||||
function ($carry, $item) {
|
||||
$explode = explode('|', $item);
|
||||
$carry[$explode[0]][] = $explode[1];
|
||||
return $carry;
|
||||
},
|
||||
[]
|
||||
);
|
||||
$modules_nodes = array_reduce(
|
||||
$this->values['moduleBlockHistogram'],
|
||||
function ($carry, $item) {
|
||||
$explode = explode('|', $item);
|
||||
$carry[$explode[0]][] = $explode[1];
|
||||
return $carry;
|
||||
},
|
||||
[]
|
||||
);
|
||||
|
||||
$modules = [];
|
||||
$modules = [];
|
||||
foreach ($modules_nodes as $n => $mod) {
|
||||
try {
|
||||
$node = new Node((int) $n);
|
||||
|
@ -475,7 +475,8 @@ class BlockHistogram extends Widget
|
|||
private function getInfoModules(array $modules): array
|
||||
{
|
||||
$where = sprintf(
|
||||
'tagente_modulo.id_agente_modulo IN (%s)',
|
||||
'tagente_modulo.id_agente_modulo IN (%s)
|
||||
AND tagente_modulo.delete_pending = 0',
|
||||
implode(',', $modules)
|
||||
);
|
||||
|
||||
|
|
|
@ -426,7 +426,8 @@ class ColorModuleTabs extends Widget
|
|||
private function getInfoModules(array $modules): array
|
||||
{
|
||||
$where = sprintf(
|
||||
'tagente_modulo.id_agente_modulo IN (%s)',
|
||||
'tagente_modulo.id_agente_modulo IN (%s)
|
||||
AND tagente_modulo.delete_pending = 0',
|
||||
implode(',', $modules)
|
||||
);
|
||||
|
||||
|
|
|
@ -170,6 +170,17 @@ class AlertsFiredWidget extends Widget
|
|||
$this->configurationRequired = false;
|
||||
if (isset($this->values['groupId']) === false) {
|
||||
$this->configurationRequired = true;
|
||||
} else {
|
||||
$check_exist = \db_get_value(
|
||||
'id_grupo',
|
||||
'tgrupo',
|
||||
'id_grupo',
|
||||
$this->values['groupId']
|
||||
);
|
||||
|
||||
if ($check_exist === false) {
|
||||
$this->loadError = true;
|
||||
}
|
||||
}
|
||||
|
||||
$this->overflow_scrollbars = false;
|
||||
|
|
|
@ -28,6 +28,8 @@
|
|||
|
||||
namespace PandoraFMS\Dashboard;
|
||||
|
||||
use PandoraFMS\Enterprise\Metaconsole\Node;
|
||||
|
||||
/**
|
||||
* Custom graph Widgets
|
||||
*/
|
||||
|
@ -178,6 +180,41 @@ class CustomGraphWidget extends Widget
|
|||
$this->configurationRequired = false;
|
||||
if (empty($this->values['id_graph']) === true) {
|
||||
$this->configurationRequired = true;
|
||||
} else {
|
||||
try {
|
||||
if (is_metaconsole() === true
|
||||
&& $this->values['node'] > 0
|
||||
) {
|
||||
$node = new Node($this->values['node']);
|
||||
$node->connect();
|
||||
}
|
||||
|
||||
$check_exist = \db_get_value(
|
||||
'name',
|
||||
'tgraph',
|
||||
'id_graph',
|
||||
$this->values['id_graph']
|
||||
);
|
||||
} catch (\Exception $e) {
|
||||
// Unexistent agent.
|
||||
if (is_metaconsole() === true
|
||||
&& $this->values['node'] > 0
|
||||
) {
|
||||
$node->disconnect();
|
||||
}
|
||||
|
||||
$check_exist = false;
|
||||
} finally {
|
||||
if (is_metaconsole() === true
|
||||
&& $this->values['node'] > 0
|
||||
) {
|
||||
$node->disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
if ($check_exist === false) {
|
||||
$this->loadError = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -553,6 +553,18 @@ class EventsListWidget extends Widget
|
|||
);
|
||||
$filter['module_search'] = $name[0]['nombre'];
|
||||
}
|
||||
} else if (empty($this->values['customFilter']) === false
|
||||
&& (int) $this->values['customFilter'] !== -1
|
||||
) {
|
||||
$output = '<div class="container-center">';
|
||||
$output .= \ui_print_error_message(
|
||||
__('Widget cannot be loaded').'. '.__('Please, event filter has been removed.'),
|
||||
'',
|
||||
true
|
||||
);
|
||||
$output .= '</div>';
|
||||
echo $output;
|
||||
return;
|
||||
} else {
|
||||
// Filtering.
|
||||
$filter['event_view_hr'] = $this->values['maxHours'];
|
||||
|
|
|
@ -28,6 +28,8 @@
|
|||
|
||||
namespace PandoraFMS\Dashboard;
|
||||
|
||||
use PandoraFMS\Enterprise\Metaconsole\Node;
|
||||
|
||||
global $config;
|
||||
|
||||
/**
|
||||
|
@ -183,6 +185,44 @@ class GraphModuleHistogramWidget extends Widget
|
|||
$this->configurationRequired = false;
|
||||
if (empty($this->values['moduleId']) === true) {
|
||||
$this->configurationRequired = true;
|
||||
} else {
|
||||
try {
|
||||
if (is_metaconsole() === true
|
||||
&& $this->values['metaconsoleId'] > 0
|
||||
) {
|
||||
$node = new Node($this->values['metaconsoleId']);
|
||||
$node->connect();
|
||||
}
|
||||
|
||||
$check_exist = db_get_sql(
|
||||
sprintf(
|
||||
'SELECT id_agente_modulo
|
||||
FROM tagente_modulo
|
||||
WHERE id_agente_modulo = %s
|
||||
AND delete_pending = 0',
|
||||
$this->values['moduleId']
|
||||
)
|
||||
);
|
||||
} catch (\Exception $e) {
|
||||
// Unexistent agent.
|
||||
if (is_metaconsole() === true
|
||||
&& $this->values['metaconsoleId'] > 0
|
||||
) {
|
||||
$node->disconnect();
|
||||
}
|
||||
|
||||
$check_exist = false;
|
||||
} finally {
|
||||
if (is_metaconsole() === true
|
||||
&& $this->values['metaconsoleId'] > 0
|
||||
) {
|
||||
$node->disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
if ($check_exist === false) {
|
||||
$this->loadError = true;
|
||||
}
|
||||
}
|
||||
|
||||
$this->overflow_scrollbars = false;
|
||||
|
@ -304,7 +344,6 @@ class GraphModuleHistogramWidget extends Widget
|
|||
'label' => __('Module'),
|
||||
'arguments' => [
|
||||
'type' => 'autocomplete_module',
|
||||
'fields' => $fields,
|
||||
'name' => 'moduleId',
|
||||
'selected' => $values['moduleId'],
|
||||
'return' => true,
|
||||
|
@ -312,7 +351,9 @@ class GraphModuleHistogramWidget extends Widget
|
|||
'agent_id' => $values['agentId'],
|
||||
'metaconsole_id' => $values['metaconsoleId'],
|
||||
'style' => 'width: inherit;',
|
||||
'filter_modules' => users_access_to_agent($values['agentId']) === false ? [$values['moduleId']] : [],
|
||||
'filter_modules' => (users_access_to_agent($values['agentId']) === false) ? [$values['moduleId']] : [],
|
||||
'nothing' => __('None'),
|
||||
'nothing_value' => 0,
|
||||
],
|
||||
];
|
||||
|
||||
|
|
|
@ -166,6 +166,17 @@ class GroupsStatusWidget extends Widget
|
|||
$this->configurationRequired = false;
|
||||
if (empty($this->values['groupId']) === true) {
|
||||
$this->configurationRequired = true;
|
||||
} else {
|
||||
$check_exist = \db_get_value(
|
||||
'id_grupo',
|
||||
'tgrupo',
|
||||
'id_grupo',
|
||||
$this->values['groupId']
|
||||
);
|
||||
|
||||
if ($check_exist === false) {
|
||||
$this->loadError = true;
|
||||
}
|
||||
}
|
||||
|
||||
$this->overflow_scrollbars = false;
|
||||
|
@ -520,7 +531,7 @@ class GroupsStatusWidget extends Widget
|
|||
{
|
||||
$size = [
|
||||
'width' => 400,
|
||||
'height' => 270,
|
||||
'height' => 330,
|
||||
];
|
||||
|
||||
return $size;
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
namespace PandoraFMS\Dashboard;
|
||||
// Load Visual Console.
|
||||
use Models\VisualConsole\Container as VisualConsole;
|
||||
use PandoraFMS\Enterprise\Metaconsole\Node;
|
||||
use PandoraFMS\User;
|
||||
/**
|
||||
* Maps by users Widgets.
|
||||
|
@ -183,12 +184,36 @@ class MapsMadeByUser extends Widget
|
|||
if (empty($this->values['vcId']) === true) {
|
||||
$this->configurationRequired = true;
|
||||
} else {
|
||||
$check_exist = db_get_value(
|
||||
'id',
|
||||
'tlayout',
|
||||
'id',
|
||||
$this->values['vcId']
|
||||
);
|
||||
try {
|
||||
if (is_metaconsole() === true
|
||||
&& $this->values['node'] > 0
|
||||
) {
|
||||
$node = new Node($this->values['node']);
|
||||
$node->connect();
|
||||
}
|
||||
|
||||
$check_exist = db_get_value(
|
||||
'id',
|
||||
'tlayout',
|
||||
'id',
|
||||
$this->values['vcId']
|
||||
);
|
||||
} catch (\Exception $e) {
|
||||
// Unexistent agent.
|
||||
if (is_metaconsole() === true
|
||||
&& $this->values['node'] > 0
|
||||
) {
|
||||
$node->disconnect();
|
||||
}
|
||||
|
||||
$check_exist = false;
|
||||
} finally {
|
||||
if (is_metaconsole() === true
|
||||
&& $this->values['node'] > 0
|
||||
) {
|
||||
$node->disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
if ($check_exist === false) {
|
||||
$this->loadError = true;
|
||||
|
@ -334,12 +359,14 @@ class MapsMadeByUser extends Widget
|
|||
$inputs[] = [
|
||||
'label' => __('Visual console'),
|
||||
'arguments' => [
|
||||
'id' => 'vcId',
|
||||
'type' => 'select',
|
||||
'fields' => $fields,
|
||||
'name' => 'vcId',
|
||||
'selected' => $values['vcId'],
|
||||
'return' => true,
|
||||
'id' => 'vcId',
|
||||
'type' => 'select',
|
||||
'fields' => $fields,
|
||||
'name' => 'vcId',
|
||||
'selected' => $values['vcId'],
|
||||
'return' => true,
|
||||
'nothing' => __('None'),
|
||||
'nothing_value' => 0,
|
||||
],
|
||||
];
|
||||
|
||||
|
|
|
@ -320,6 +320,17 @@ class MapsStatusWidget extends Widget
|
|||
$output = '';
|
||||
if (isset($maps) === true && empty($maps) === false) {
|
||||
foreach ($maps as $id_layout) {
|
||||
$check_exist = db_get_value(
|
||||
'id',
|
||||
'tlayout',
|
||||
'id',
|
||||
$id_layout
|
||||
);
|
||||
|
||||
if ($check_exist === false) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$data = [];
|
||||
|
||||
$url = $config['homeurl'];
|
||||
|
@ -366,12 +377,22 @@ class MapsStatusWidget extends Widget
|
|||
array_push($table->data, $data);
|
||||
}
|
||||
|
||||
// 31 px for each map.
|
||||
$minHeight = (count($maps) * 31);
|
||||
$style = 'min-width:200px; min-height:'.$minHeight.'px';
|
||||
$output = '<div class="container-center" style="'.$style.'">';
|
||||
$output .= html_print_table($table, true);
|
||||
$output .= '</div>';
|
||||
if (empty($table->data) === false) {
|
||||
// 31 px for each map.
|
||||
$minHeight = (count($maps) * 31);
|
||||
$style = 'min-width:200px; min-height:'.$minHeight.'px';
|
||||
$output = '<div class="container-center" style="'.$style.'">';
|
||||
$output .= html_print_table($table, true);
|
||||
$output .= '</div>';
|
||||
} else {
|
||||
$output .= '<div class="container-center">';
|
||||
$output .= \ui_print_error_message(
|
||||
__('Widget cannot be loaded').'. '.__('Please, configure the widget again to recover it'),
|
||||
'',
|
||||
true
|
||||
);
|
||||
$output .= '</div>';
|
||||
}
|
||||
}
|
||||
|
||||
return $output;
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
|
||||
namespace PandoraFMS\Dashboard;
|
||||
use PandoraFMS\Dashboard;
|
||||
use PandoraFMS\Enterprise\Metaconsole\Node;
|
||||
|
||||
global $config;
|
||||
|
||||
|
@ -186,6 +187,44 @@ class ModuleIconWidget extends Widget
|
|||
$this->configurationRequired = false;
|
||||
if (empty($this->values['moduleId']) === true) {
|
||||
$this->configurationRequired = true;
|
||||
} else {
|
||||
try {
|
||||
if (is_metaconsole() === true
|
||||
&& $this->values['metaconsoleId'] > 0
|
||||
) {
|
||||
$node = new Node($this->values['metaconsoleId']);
|
||||
$node->connect();
|
||||
}
|
||||
|
||||
$check_exist = db_get_sql(
|
||||
sprintf(
|
||||
'SELECT id_agente_modulo
|
||||
FROM tagente_modulo
|
||||
WHERE id_agente_modulo = %s
|
||||
AND delete_pending = 0',
|
||||
$this->values['moduleId']
|
||||
)
|
||||
);
|
||||
} catch (\Exception $e) {
|
||||
// Unexistent agent.
|
||||
if (is_metaconsole() === true
|
||||
&& $this->values['metaconsoleId'] > 0
|
||||
) {
|
||||
$node->disconnect();
|
||||
}
|
||||
|
||||
$check_exist = false;
|
||||
} finally {
|
||||
if (is_metaconsole() === true
|
||||
&& $this->values['metaconsoleId'] > 0
|
||||
) {
|
||||
$node->disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
if ($check_exist === false) {
|
||||
$this->loadError = true;
|
||||
}
|
||||
}
|
||||
|
||||
$this->overflow_scrollbars = false;
|
||||
|
@ -334,7 +373,6 @@ class ModuleIconWidget extends Widget
|
|||
'label' => __('Module'),
|
||||
'arguments' => [
|
||||
'type' => 'autocomplete_module',
|
||||
'fields' => $fields,
|
||||
'name' => 'moduleId',
|
||||
'selected' => $values['moduleId'],
|
||||
'return' => true,
|
||||
|
@ -343,6 +381,8 @@ class ModuleIconWidget extends Widget
|
|||
'metaconsole_id' => $values['metaconsoleId'],
|
||||
'style' => 'width: inherit;',
|
||||
'filter_modules' => users_access_to_agent($values['agentId']) === false ? [$values['moduleId']] : [],
|
||||
'nothing' => __('None'),
|
||||
'nothing_value' => 0,
|
||||
],
|
||||
];
|
||||
|
||||
|
|
|
@ -28,6 +28,8 @@
|
|||
|
||||
namespace PandoraFMS\Dashboard;
|
||||
|
||||
use PandoraFMS\Enterprise\Metaconsole\Node;
|
||||
|
||||
global $config;
|
||||
|
||||
/**
|
||||
|
@ -181,6 +183,44 @@ class ModuleStatusWidget extends Widget
|
|||
$this->configurationRequired = false;
|
||||
if (empty($this->values['moduleId']) === true) {
|
||||
$this->configurationRequired = true;
|
||||
} else {
|
||||
try {
|
||||
if (is_metaconsole() === true
|
||||
&& $this->values['metaconsoleId'] > 0
|
||||
) {
|
||||
$node = new Node($this->values['metaconsoleId']);
|
||||
$node->connect();
|
||||
}
|
||||
|
||||
$check_exist = db_get_sql(
|
||||
sprintf(
|
||||
'SELECT id_agente_modulo
|
||||
FROM tagente_modulo
|
||||
WHERE id_agente_modulo = %s
|
||||
AND delete_pending = 0',
|
||||
$this->values['moduleId']
|
||||
)
|
||||
);
|
||||
} catch (\Exception $e) {
|
||||
// Unexistent agent.
|
||||
if (is_metaconsole() === true
|
||||
&& $this->values['metaconsoleId'] > 0
|
||||
) {
|
||||
$node->disconnect();
|
||||
}
|
||||
|
||||
$check_exist = false;
|
||||
} finally {
|
||||
if (is_metaconsole() === true
|
||||
&& $this->values['metaconsoleId'] > 0
|
||||
) {
|
||||
$node->disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
if ($check_exist === false) {
|
||||
$this->loadError = true;
|
||||
}
|
||||
}
|
||||
|
||||
$this->overflow_scrollbars = false;
|
||||
|
@ -324,7 +364,6 @@ class ModuleStatusWidget extends Widget
|
|||
'label' => __('Module'),
|
||||
'arguments' => [
|
||||
'type' => 'autocomplete_module',
|
||||
'fields' => $fields,
|
||||
'name' => 'moduleId',
|
||||
'selected' => $values['moduleId'],
|
||||
'return' => true,
|
||||
|
@ -332,7 +371,9 @@ class ModuleStatusWidget extends Widget
|
|||
'agent_id' => $values['agentId'],
|
||||
'metaconsole_id' => $values['metaconsoleId'],
|
||||
'style' => 'width: inherit;',
|
||||
'filter_modules' => users_access_to_agent($values['agentId']) === false ? [$values['moduleId']] : [],
|
||||
'filter_modules' => (users_access_to_agent($values['agentId']) === false) ? [$values['moduleId']] : [],
|
||||
'nothing' => __('None'),
|
||||
'nothing_value' => 0,
|
||||
],
|
||||
];
|
||||
|
||||
|
@ -454,15 +495,8 @@ class ModuleStatusWidget extends Widget
|
|||
*/
|
||||
public function load()
|
||||
{
|
||||
global $config;
|
||||
|
||||
$output .= '';
|
||||
|
||||
$id_agent = $this->values['agentId'];
|
||||
$id_group = agents_get_agent_group($id_agent);
|
||||
|
||||
$output = '';
|
||||
$id_module = $this->values['moduleId'];
|
||||
|
||||
$icon = $this->values['imageSrc'];
|
||||
$label = $this->values['label'];
|
||||
$sizeLabel = (isset($this->values['sizeLabel']) === true) ? $this->values['sizeLabel'] : 30;
|
||||
|
|
|
@ -28,6 +28,8 @@
|
|||
|
||||
namespace PandoraFMS\Dashboard;
|
||||
|
||||
use PandoraFMS\Enterprise\Metaconsole\Node;
|
||||
|
||||
global $config;
|
||||
|
||||
|
||||
|
@ -183,6 +185,44 @@ class ModuleTableValueWidget extends Widget
|
|||
$this->configurationRequired = false;
|
||||
if (empty($this->values['moduleId']) === true) {
|
||||
$this->configurationRequired = true;
|
||||
} else {
|
||||
try {
|
||||
if (is_metaconsole() === true
|
||||
&& $this->values['metaconsoleId'] > 0
|
||||
) {
|
||||
$node = new Node($this->values['metaconsoleId']);
|
||||
$node->connect();
|
||||
}
|
||||
|
||||
$check_exist = db_get_sql(
|
||||
sprintf(
|
||||
'SELECT id_agente_modulo
|
||||
FROM tagente_modulo
|
||||
WHERE id_agente_modulo = %s
|
||||
AND delete_pending = 0',
|
||||
$this->values['moduleId']
|
||||
)
|
||||
);
|
||||
} catch (\Exception $e) {
|
||||
// Unexistent agent.
|
||||
if (is_metaconsole() === true
|
||||
&& $this->values['metaconsoleId'] > 0
|
||||
) {
|
||||
$node->disconnect();
|
||||
}
|
||||
|
||||
$check_exist = false;
|
||||
} finally {
|
||||
if (is_metaconsole() === true
|
||||
&& $this->values['metaconsoleId'] > 0
|
||||
) {
|
||||
$node->disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
if ($check_exist === false) {
|
||||
$this->loadError = true;
|
||||
}
|
||||
}
|
||||
|
||||
$this->overflow_scrollbars = false;
|
||||
|
@ -293,6 +333,8 @@ class ModuleTableValueWidget extends Widget
|
|||
'filter_modules' => users_access_to_agent(
|
||||
($values['agentId']) === false
|
||||
) ? [$values['moduleId']] : [],
|
||||
'nothing' => __('None'),
|
||||
'nothing_value' => 0,
|
||||
],
|
||||
];
|
||||
|
||||
|
|
|
@ -28,6 +28,8 @@
|
|||
|
||||
namespace PandoraFMS\Dashboard;
|
||||
|
||||
use PandoraFMS\Enterprise\Metaconsole\Node;
|
||||
|
||||
global $config;
|
||||
|
||||
require_once $config['homedir'].'/include/functions_agents.php';
|
||||
|
@ -181,6 +183,44 @@ class ModuleValueWidget extends Widget
|
|||
$this->configurationRequired = false;
|
||||
if (empty($this->values['moduleId']) === true) {
|
||||
$this->configurationRequired = true;
|
||||
} else {
|
||||
try {
|
||||
if (is_metaconsole() === true
|
||||
&& $this->values['metaconsoleId'] > 0
|
||||
) {
|
||||
$node = new Node($this->values['metaconsoleId']);
|
||||
$node->connect();
|
||||
}
|
||||
|
||||
$check_exist = db_get_sql(
|
||||
sprintf(
|
||||
'SELECT id_agente_modulo
|
||||
FROM tagente_modulo
|
||||
WHERE id_agente_modulo = %s
|
||||
AND delete_pending = 0',
|
||||
$this->values['moduleId']
|
||||
)
|
||||
);
|
||||
} catch (\Exception $e) {
|
||||
// Unexistent agent.
|
||||
if (is_metaconsole() === true
|
||||
&& $this->values['metaconsoleId'] > 0
|
||||
) {
|
||||
$node->disconnect();
|
||||
}
|
||||
|
||||
$check_exist = false;
|
||||
} finally {
|
||||
if (is_metaconsole() === true
|
||||
&& $this->values['metaconsoleId'] > 0
|
||||
) {
|
||||
$node->disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
if ($check_exist === false) {
|
||||
$this->loadError = true;
|
||||
}
|
||||
}
|
||||
|
||||
$this->overflow_scrollbars = false;
|
||||
|
@ -308,7 +348,6 @@ class ModuleValueWidget extends Widget
|
|||
'label' => __('Module'),
|
||||
'arguments' => [
|
||||
'type' => 'autocomplete_module',
|
||||
'fields' => $fields,
|
||||
'name' => 'moduleId',
|
||||
'selected' => $values['moduleId'],
|
||||
'return' => true,
|
||||
|
@ -316,7 +355,9 @@ class ModuleValueWidget extends Widget
|
|||
'agent_id' => $values['agentId'],
|
||||
'metaconsole_id' => $values['metaconsoleId'],
|
||||
'style' => 'width: inherit;',
|
||||
'filter_modules' => users_access_to_agent($values['agentId']) === false ? [$values['moduleId']] : [],
|
||||
'filter_modules' => (users_access_to_agent($values['agentId']) === false) ? [$values['moduleId']] : [],
|
||||
'nothing' => __('None'),
|
||||
'nothing_value' => 0,
|
||||
],
|
||||
];
|
||||
|
||||
|
@ -380,9 +421,6 @@ class ModuleValueWidget extends Widget
|
|||
|
||||
$output = '';
|
||||
|
||||
$id_agent = $this->values['agentId'];
|
||||
$id_group = agents_get_agent_group($id_agent);
|
||||
|
||||
$id_module = $this->values['moduleId'];
|
||||
|
||||
$data_module = \modules_get_last_value($id_module);
|
||||
|
|
|
@ -236,7 +236,7 @@ class MonitorHealthWidget extends Widget
|
|||
|
||||
$all_data = tactical_status_modules_agents(
|
||||
$config['id_user'],
|
||||
$user_strict,
|
||||
false,
|
||||
'AR'
|
||||
);
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
namespace PandoraFMS\Dashboard;
|
||||
|
||||
use PandoraFMS\Dashboard\Manager;
|
||||
use PandoraFMS\Enterprise\Metaconsole\Node;
|
||||
|
||||
/**
|
||||
* Network map Widgets.
|
||||
|
@ -180,6 +181,42 @@ class NetworkMapWidget extends Widget
|
|||
$this->configurationRequired = false;
|
||||
if (empty($this->values['networkmapId']) === true) {
|
||||
$this->configurationRequired = true;
|
||||
} else {
|
||||
try {
|
||||
if (is_metaconsole() === true
|
||||
&& $this->values['node'] > 0
|
||||
) {
|
||||
$node = new Node($this->values['node']);
|
||||
$node->connect();
|
||||
}
|
||||
|
||||
// Reports.
|
||||
$check_exist = db_get_value(
|
||||
'id',
|
||||
'tmap',
|
||||
'id',
|
||||
$this->values['networkmapId']
|
||||
);
|
||||
} catch (\Exception $e) {
|
||||
// Unexistent agent.
|
||||
if (is_metaconsole() === true
|
||||
&& $this->values['node'] > 0
|
||||
) {
|
||||
$node->disconnect();
|
||||
}
|
||||
|
||||
$check_exist = false;
|
||||
} finally {
|
||||
if (is_metaconsole() === true
|
||||
&& $this->values['node'] > 0
|
||||
) {
|
||||
$node->disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
if ($check_exist === false) {
|
||||
$this->loadError = true;
|
||||
}
|
||||
}
|
||||
|
||||
$this->overflow_scrollbars = false;
|
||||
|
@ -312,8 +349,6 @@ class NetworkMapWidget extends Widget
|
|||
$values['networkmapId']
|
||||
);
|
||||
|
||||
$fields[$selected] = $selected_networkmap;
|
||||
|
||||
if ((bool) is_metaconsole() === true) {
|
||||
metaconsole_restore_db();
|
||||
}
|
||||
|
@ -322,11 +357,13 @@ class NetworkMapWidget extends Widget
|
|||
$inputs[] = [
|
||||
'label' => __('Map'),
|
||||
'arguments' => [
|
||||
'type' => 'select',
|
||||
'fields' => $fields,
|
||||
'name' => 'networkmapId',
|
||||
'selected' => $selected,
|
||||
'return' => true,
|
||||
'type' => 'select',
|
||||
'fields' => $fields,
|
||||
'name' => 'networkmapId',
|
||||
'selected' => $selected,
|
||||
'return' => true,
|
||||
'nothing' => __('None'),
|
||||
'nothing_value' => 0,
|
||||
],
|
||||
];
|
||||
|
||||
|
|
|
@ -28,6 +28,8 @@
|
|||
|
||||
namespace PandoraFMS\Dashboard;
|
||||
|
||||
use PandoraFMS\Enterprise\Metaconsole\Node;
|
||||
|
||||
global $config;
|
||||
require_once $config['homedir'].'/include/Image/image_functions.php';
|
||||
require_once $config['homedir'].'/include/functions_reporting_html.php';
|
||||
|
@ -173,12 +175,37 @@ class ReportsWidget extends Widget
|
|||
if (empty($this->values['reportId']) === true) {
|
||||
$this->configurationRequired = true;
|
||||
} else {
|
||||
$check_exist = db_get_value(
|
||||
'id_report',
|
||||
'treport',
|
||||
'id_report',
|
||||
$this->values['reportId']
|
||||
);
|
||||
try {
|
||||
if (is_metaconsole() === true
|
||||
&& $this->values['node'] > 0
|
||||
) {
|
||||
$node = new Node($this->values['node']);
|
||||
$node->connect();
|
||||
}
|
||||
|
||||
// Reports.
|
||||
$check_exist = db_get_value(
|
||||
'id_report',
|
||||
'treport',
|
||||
'id_report',
|
||||
$this->values['reportId']
|
||||
);
|
||||
} catch (\Exception $e) {
|
||||
// Unexistent agent.
|
||||
if (is_metaconsole() === true
|
||||
&& $this->values['node'] > 0
|
||||
) {
|
||||
$node->disconnect();
|
||||
}
|
||||
|
||||
$check_exist = false;
|
||||
} finally {
|
||||
if (is_metaconsole() === true
|
||||
&& $this->values['node'] > 0
|
||||
) {
|
||||
$node->disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
if ($check_exist === false) {
|
||||
$this->loadError = true;
|
||||
|
@ -227,15 +254,39 @@ class ReportsWidget extends Widget
|
|||
$return_all_group = true;
|
||||
}
|
||||
|
||||
// Reports.
|
||||
$reports = \reports_get_reports(
|
||||
false,
|
||||
[
|
||||
'id_report',
|
||||
'name',
|
||||
],
|
||||
$return_all_group
|
||||
);
|
||||
try {
|
||||
if (is_metaconsole() === true
|
||||
&& $this->values['node'] > 0
|
||||
) {
|
||||
$node = new Node($this->values['node']);
|
||||
$node->connect();
|
||||
}
|
||||
|
||||
// Reports.
|
||||
$reports = \reports_get_reports(
|
||||
false,
|
||||
[
|
||||
'id_report',
|
||||
'name',
|
||||
],
|
||||
$return_all_group
|
||||
);
|
||||
} catch (\Exception $e) {
|
||||
// Unexistent agent.
|
||||
if (is_metaconsole() === true
|
||||
&& $this->values['node'] > 0
|
||||
) {
|
||||
$node->disconnect();
|
||||
}
|
||||
|
||||
$reports = [];
|
||||
} finally {
|
||||
if (is_metaconsole() === true
|
||||
&& $this->values['node'] > 0
|
||||
) {
|
||||
$node->disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
// If currently selected report is not included in fields array
|
||||
// (it belongs to a group over which user has no permissions), then add
|
||||
|
@ -363,7 +414,7 @@ class ReportsWidget extends Widget
|
|||
$output .= 'Click to view: <a href="?sec=reporting&sec2=operation/reporting/reporting_viewer&id='.$this->values['reportId'].'">'.__('Report').'</a>';
|
||||
$output .= '</div>';
|
||||
} else {
|
||||
$this->load_error = true;
|
||||
$this->loadError = true;
|
||||
}
|
||||
|
||||
return $output;
|
||||
|
|
|
@ -200,6 +200,17 @@ class ServiceMapWidget extends Widget
|
|||
$this->configurationRequired = false;
|
||||
if (empty($this->values['serviceId']) === true) {
|
||||
$this->configurationRequired = true;
|
||||
} else {
|
||||
$check_exist = db_get_value(
|
||||
'id',
|
||||
'tservice',
|
||||
'id',
|
||||
$this->values['serviceId']
|
||||
);
|
||||
|
||||
if ($check_exist === false) {
|
||||
$this->loadError = true;
|
||||
}
|
||||
}
|
||||
|
||||
$this->overflow_scrollbars = false;
|
||||
|
|
|
@ -194,11 +194,9 @@ class ServiceViewWidget extends Widget
|
|||
$this->name = 'service_view';
|
||||
}
|
||||
|
||||
// // This forces at least a first configuration.
|
||||
// $this->configurationRequired = false;
|
||||
// if (empty($this->values['serviceId']) === true) {
|
||||
// $this->configurationRequired = true;
|
||||
// }
|
||||
// This forces at least a first configuration.
|
||||
$this->configurationRequired = false;
|
||||
|
||||
$this->overflow_scrollbars = false;
|
||||
}
|
||||
|
||||
|
|
|
@ -28,6 +28,8 @@
|
|||
|
||||
namespace PandoraFMS\Dashboard;
|
||||
|
||||
use PandoraFMS\Enterprise\Metaconsole\Node;
|
||||
|
||||
global $config;
|
||||
|
||||
/**
|
||||
|
@ -178,6 +180,44 @@ class SingleGraphWidget extends Widget
|
|||
$this->configurationRequired = false;
|
||||
if (empty($this->values['moduleId']) === true) {
|
||||
$this->configurationRequired = true;
|
||||
} else {
|
||||
try {
|
||||
if (is_metaconsole() === true
|
||||
&& $this->values['metaconsoleId'] > 0
|
||||
) {
|
||||
$node = new Node($this->values['metaconsoleId']);
|
||||
$node->connect();
|
||||
}
|
||||
|
||||
$check_exist = db_get_sql(
|
||||
sprintf(
|
||||
'SELECT id_agente_modulo
|
||||
FROM tagente_modulo
|
||||
WHERE id_agente_modulo = %s
|
||||
AND delete_pending = 0',
|
||||
$this->values['moduleId']
|
||||
)
|
||||
);
|
||||
} catch (\Exception $e) {
|
||||
// Unexistent agent.
|
||||
if (is_metaconsole() === true
|
||||
&& $this->values['metaconsoleId'] > 0
|
||||
) {
|
||||
$node->disconnect();
|
||||
}
|
||||
|
||||
$check_exist = false;
|
||||
} finally {
|
||||
if (is_metaconsole() === true
|
||||
&& $this->values['metaconsoleId'] > 0
|
||||
) {
|
||||
$node->disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
if ($check_exist === false) {
|
||||
$this->loadError = true;
|
||||
}
|
||||
}
|
||||
|
||||
$this->overflow_scrollbars = false;
|
||||
|
@ -286,6 +326,8 @@ class SingleGraphWidget extends Widget
|
|||
'agent_id' => $values['agentId'],
|
||||
'metaconsole_id' => $values['metaconsoleId'],
|
||||
'style' => 'width: inherit;',
|
||||
'nothing' => __('None'),
|
||||
'nothing_value' => 0,
|
||||
],
|
||||
];
|
||||
|
||||
|
|
|
@ -28,6 +28,8 @@
|
|||
|
||||
namespace PandoraFMS\Dashboard;
|
||||
|
||||
use PandoraFMS\Enterprise\Metaconsole\Node;
|
||||
|
||||
global $config;
|
||||
|
||||
require_once $config['homedir'].'/include/functions_agents.php';
|
||||
|
@ -182,6 +184,44 @@ class SLAPercentWidget extends Widget
|
|||
$this->configurationRequired = false;
|
||||
if (empty($this->values['moduleId']) === true) {
|
||||
$this->configurationRequired = true;
|
||||
} else {
|
||||
try {
|
||||
if (is_metaconsole() === true
|
||||
&& $this->values['metaconsoleId'] > 0
|
||||
) {
|
||||
$node = new Node($this->values['metaconsoleId']);
|
||||
$node->connect();
|
||||
}
|
||||
|
||||
$check_exist = db_get_sql(
|
||||
sprintf(
|
||||
'SELECT id_agente_modulo
|
||||
FROM tagente_modulo
|
||||
WHERE id_agente_modulo = %s
|
||||
AND delete_pending = 0',
|
||||
$this->values['moduleId']
|
||||
)
|
||||
);
|
||||
} catch (\Exception $e) {
|
||||
// Unexistent agent.
|
||||
if (is_metaconsole() === true
|
||||
&& $this->values['metaconsoleId'] > 0
|
||||
) {
|
||||
$node->disconnect();
|
||||
}
|
||||
|
||||
$check_exist = false;
|
||||
} finally {
|
||||
if (is_metaconsole() === true
|
||||
&& $this->values['metaconsoleId'] > 0
|
||||
) {
|
||||
$node->disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
if ($check_exist === false) {
|
||||
$this->loadError = true;
|
||||
}
|
||||
}
|
||||
|
||||
$this->overflow_scrollbars = false;
|
||||
|
@ -315,7 +355,6 @@ class SLAPercentWidget extends Widget
|
|||
'label' => __('Module'),
|
||||
'arguments' => [
|
||||
'type' => 'autocomplete_module',
|
||||
'fields' => $fields,
|
||||
'name' => 'moduleId',
|
||||
'selected' => $values['moduleId'],
|
||||
'return' => true,
|
||||
|
@ -323,6 +362,8 @@ class SLAPercentWidget extends Widget
|
|||
'agent_id' => $values['agentId'],
|
||||
'metaconsole_id' => $values['metaconsoleId'],
|
||||
'style' => 'width: inherit;',
|
||||
'nothing' => __('None'),
|
||||
'nothing_value' => 0,
|
||||
],
|
||||
];
|
||||
|
||||
|
|
|
@ -459,18 +459,19 @@ class SystemGroupStatusWidget extends Widget
|
|||
}
|
||||
|
||||
$module_counters = groupview_get_modules_counters($selected_groups);
|
||||
$result_groups = [];
|
||||
if (empty($module_counters) === false) {
|
||||
foreach ($module_counters as $key => $item) {
|
||||
$module_counters[$key]['name'] = groups_get_name($item['g']);
|
||||
}
|
||||
|
||||
foreach ($module_counters as $key => $item) {
|
||||
$module_counters[$key]['name'] = groups_get_name($item['g']);
|
||||
}
|
||||
$keys = array_column($module_counters, 'g');
|
||||
$values = array_values($module_counters);
|
||||
$result_groups = array_combine($keys, $values);
|
||||
|
||||
$keys = array_column($module_counters, 'g');
|
||||
$values = array_values($module_counters);
|
||||
|
||||
$result_groups = array_combine($keys, $values);
|
||||
|
||||
if (empty($all_counters) === false) {
|
||||
$result_groups[0] = $all_counters;
|
||||
if (empty($all_counters) === false) {
|
||||
$result_groups[0] = $all_counters;
|
||||
}
|
||||
}
|
||||
|
||||
$this->values['groupId'] = $selected_groups;
|
||||
|
|
|
@ -501,7 +501,10 @@ class TreeViewWidget extends Widget
|
|||
}
|
||||
|
||||
$id_cell = $this->cellId;
|
||||
$all_nodes = $this->values['openAllGroups'];
|
||||
$all_nodes = false;
|
||||
if (isset($this->values['openAllGroups']) === true) {
|
||||
$all_nodes = $this->values['openAllGroups'];
|
||||
}
|
||||
|
||||
$tab = 'group';
|
||||
if (empty($this->values['typeTree']) === false) {
|
||||
|
@ -587,7 +590,7 @@ class TreeViewWidget extends Widget
|
|||
|
||||
$output .= \html_print_input_hidden(
|
||||
'publi_dash_tree_view_hash',
|
||||
$hash,
|
||||
'',
|
||||
true
|
||||
);
|
||||
$output .= \html_print_input_hidden(
|
||||
|
|
|
@ -1150,7 +1150,7 @@ class Item extends CachedModel
|
|||
'sec2' => 'screens/screens',
|
||||
'action' => 'visualmap',
|
||||
'id_visualmap' => $vcId,
|
||||
'pure' => (int) $config['pure'],
|
||||
'pure' => (int) (isset($config['pure']) === true) ? $config['pure'] : 0,
|
||||
]
|
||||
);
|
||||
} else if (empty($linkedLayoutNodeId) === true
|
||||
|
@ -1175,7 +1175,7 @@ class Item extends CachedModel
|
|||
'sec' => 'network',
|
||||
'sec2' => 'operation/visual_console/view',
|
||||
'id' => $vcId,
|
||||
'pure' => (int) $config['pure'],
|
||||
'pure' => (int) (isset($config['pure']) === true) ? $config['pure'] : 0,
|
||||
]
|
||||
);
|
||||
} else if (\is_metaconsole() === true
|
||||
|
@ -1313,7 +1313,7 @@ class Item extends CachedModel
|
|||
'operation/agentes/status_monitor',
|
||||
['id_module' => $moduleId],
|
||||
// No autologin from the public view.
|
||||
!$config['public_view'],
|
||||
!((isset($config['public_view']) === true) ? $config['public_view'] : false),
|
||||
$mobile_navigation,
|
||||
[
|
||||
'id' => $moduleId,
|
||||
|
|
|
@ -236,6 +236,7 @@ li#div-textarea label {
|
|||
}
|
||||
|
||||
.container-center > .parent_graph p {
|
||||
margin-top: 0px;
|
||||
margin-bottom: 3px;
|
||||
}
|
||||
|
||||
|
|
|
@ -220,7 +220,7 @@ table.table_modal_alternate tr td {
|
|||
}
|
||||
|
||||
table.table_modal_alternate tr td:first-child {
|
||||
width: 35%;
|
||||
width: 50%;
|
||||
font-weight: 600;
|
||||
padding-left: 20px;
|
||||
}
|
||||
|
|
|
@ -129,7 +129,7 @@
|
|||
<div style='height: 10px'>
|
||||
<?php
|
||||
$version = '7.0NG.764';
|
||||
$build = '220927';
|
||||
$build = '220928';
|
||||
$banner = "v$version Build $build";
|
||||
|
||||
error_reporting(0);
|
||||
|
|
|
@ -294,7 +294,7 @@ if ($free_search != '') {
|
|||
|
||||
$columns = array_merge(
|
||||
$columns,
|
||||
['agent']
|
||||
['agent_name']
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -309,10 +309,10 @@ if ($free_search != '') {
|
|||
|
||||
$columns = array_merge(
|
||||
$columns,
|
||||
['module'],
|
||||
['template'],
|
||||
['agent_module_name'],
|
||||
['template_name'],
|
||||
['action'],
|
||||
['lastFired'],
|
||||
['last_fired'],
|
||||
['status']
|
||||
);
|
||||
|
||||
|
@ -359,7 +359,7 @@ if ($free_search != '') {
|
|||
],
|
||||
'drawCallback' => 'alerts_table_controls()',
|
||||
'order' => [
|
||||
'field' => 'module',
|
||||
'field' => 'agent_module_name',
|
||||
'direction' => 'asc',
|
||||
],
|
||||
'zeroRecords' => __('No alerts found'),
|
||||
|
@ -400,7 +400,7 @@ if ($free_search != '') {
|
|||
],
|
||||
'drawCallback' => 'alerts_table_controls()',
|
||||
'order' => [
|
||||
'field' => 'module',
|
||||
'field' => 'agent_module_name',
|
||||
'direction' => 'asc',
|
||||
],
|
||||
'zeroRecords' => __('No alerts found'),
|
||||
|
|
|
@ -741,6 +741,8 @@ if (is_ajax() === true) {
|
|||
// Owner.
|
||||
if (empty($tmp->owner_user) === true) {
|
||||
$tmp->owner_user = __('System');
|
||||
} else {
|
||||
$tmp->owner_user = get_user_fullname($tmp->owner_user).' ('.$tmp->owner_user.')';
|
||||
}
|
||||
|
||||
// Group name.
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#
|
||||
%define name pandorafms_console
|
||||
%define version 7.0NG.764
|
||||
%define release 220927
|
||||
%define release 220928
|
||||
|
||||
# User and Group under which Apache is running
|
||||
%define httpd_name httpd
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#
|
||||
%define name pandorafms_console
|
||||
%define version 7.0NG.764
|
||||
%define release 220927
|
||||
%define release 220928
|
||||
|
||||
# User and Group under which Apache is running
|
||||
%define httpd_name httpd
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#
|
||||
%define name pandorafms_console
|
||||
%define version 7.0NG.764
|
||||
%define release 220927
|
||||
%define release 220928
|
||||
%define httpd_name httpd
|
||||
# User and Group under which Apache is running
|
||||
%define httpd_name apache2
|
||||
|
|
|
@ -2513,6 +2513,7 @@ CREATE TABLE IF NOT EXISTS `tpolicies` (
|
|||
`id_group` INT UNSIGNED DEFAULT 0,
|
||||
`status` INT UNSIGNED NOT NULL DEFAULT 0,
|
||||
`force_apply` TINYINT DEFAULT 0,
|
||||
`apply_to_secondary_groups` TINYINT NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4;
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,5 +1,5 @@
|
|||
package: pandorafms-server
|
||||
Version: 7.0NG.764-220927
|
||||
Version: 7.0NG.764-220928
|
||||
Architecture: all
|
||||
Priority: optional
|
||||
Section: admin
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
pandora_version="7.0NG.764-220927"
|
||||
pandora_version="7.0NG.764-220928"
|
||||
|
||||
package_cpan=0
|
||||
package_pandora=1
|
||||
|
|
|
@ -46,7 +46,7 @@ our @EXPORT = qw(
|
|||
|
||||
# version: Defines actual version of Pandora Server for this module only
|
||||
my $pandora_version = "7.0NG.764";
|
||||
my $pandora_build = "220927";
|
||||
my $pandora_build = "220928";
|
||||
our $VERSION = $pandora_version." ".$pandora_build;
|
||||
|
||||
# Setup hash
|
||||
|
|
|
@ -1647,6 +1647,70 @@ sub pandora_execute_action ($$$$$$$$$;$$) {
|
|||
pandora_sendmail ($pa_config, $field1, $field2, $field3, $content_type);
|
||||
}
|
||||
|
||||
# Email report
|
||||
} elsif ($clean_name eq "Send report by e-mail") {
|
||||
# Text
|
||||
$field4 = subst_alert_macros ($field4, \%macros, $pa_config, $dbh, $agent, $module, $alert);
|
||||
|
||||
# API connection
|
||||
my $ua = new LWP::UserAgent;
|
||||
eval {
|
||||
$ua->ssl_opts( 'verify_hostname' => 0 );
|
||||
$ua->ssl_opts( 'SSL_verify_mode' => 0x00 );
|
||||
};
|
||||
if ( $@ ) {
|
||||
logger($pa_config, "Failed to limit ssl security on console link: " . $@, 10);
|
||||
}
|
||||
|
||||
my $url ||= $pa_config->{"console_api_url"};
|
||||
|
||||
my $params = {};
|
||||
$params->{"apipass"} = $pa_config->{"console_api_pass"};
|
||||
$params->{"user"} ||= $pa_config->{"console_user"};
|
||||
$params->{"pass"} ||= $pa_config->{"console_pass"};
|
||||
$params->{"op"} = "set";
|
||||
$params->{"op2"} = "send_report";
|
||||
$params->{"other_mode"} = "url_encode_separator_|;|";
|
||||
|
||||
$field4 = safe_input($field4);
|
||||
$field4 =~ s/&/&/g;
|
||||
|
||||
$params->{"other"} = $field1.'|;|'.$field5.'|;|'.$field2.'|;|'.$field3.'|;|'.$field4.'|;|0';
|
||||
|
||||
$ua->post($url, $params);
|
||||
|
||||
# Email report (from template)
|
||||
} elsif ($clean_name eq "Send report by e-mail (from template)") {
|
||||
# Text
|
||||
$field5 = subst_alert_macros ($field5, \%macros, $pa_config, $dbh, $agent, $module, $alert);
|
||||
|
||||
# API connection
|
||||
my $ua = new LWP::UserAgent;
|
||||
eval {
|
||||
$ua->ssl_opts( 'verify_hostname' => 0 );
|
||||
$ua->ssl_opts( 'SSL_verify_mode' => 0x00 );
|
||||
};
|
||||
if ( $@ ) {
|
||||
logger($pa_config, "Failed to limit ssl security on console link: " . $@, 10);
|
||||
}
|
||||
|
||||
my $url ||= $pa_config->{"console_api_url"};
|
||||
|
||||
my $params = {};
|
||||
$params->{"apipass"} = $pa_config->{"console_api_pass"};
|
||||
$params->{"user"} ||= $pa_config->{"console_user"};
|
||||
$params->{"pass"} ||= $pa_config->{"console_pass"};
|
||||
$params->{"op"} = "set";
|
||||
$params->{"op2"} = "send_report";
|
||||
$params->{"other_mode"} = "url_encode_separator_|;|";
|
||||
|
||||
$field5 = safe_input($field5);
|
||||
$field5 =~ s/&/&/g;
|
||||
|
||||
$params->{"other"} = $field1.'|;|'.$field6.'|;|'.$field3.'|;|'.$field4.'|;|'.$field5.'|;|1|;|'.$field2;
|
||||
|
||||
$ua->post($url, $params);
|
||||
|
||||
# Pandora FMS Event
|
||||
} elsif ($clean_name eq "Monitoring Event") {
|
||||
$field1 = subst_alert_macros ($field1, \%macros, $pa_config, $dbh, $agent, $module, $alert);
|
||||
|
@ -6830,7 +6894,7 @@ sub pandora_create_integria_ticket ($$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$) {
|
|||
'params=' . $data_ticket .'&' .
|
||||
'token=|;|';
|
||||
|
||||
my $content = get($call_api);
|
||||
my $content = get($call_api);
|
||||
|
||||
if (is_numeric($content) && $content ne "-1") {
|
||||
return $content;
|
||||
|
|
|
@ -336,6 +336,9 @@ sub curl {
|
|||
|
||||
my $cmd = "curl $curl_opts " . safe_param($url);
|
||||
my $response = `"$exec" $timeout $cmd 2>/dev/null`;
|
||||
if ($? == -1) {
|
||||
die("Error calling curl. Not enough memory?\n");
|
||||
}
|
||||
|
||||
# Curl command stored for live debugging feature.
|
||||
set_update_agentmodule ($dbh, $moduleId, { 'debug_content' => $cmd }) if defined($dbh);
|
||||
|
|
|
@ -110,6 +110,9 @@ sub g_http_task {
|
|||
my $get_content_advanced = "";
|
||||
|
||||
my $ua = new LWP::UserAgent;
|
||||
if (!defined($ua)) {
|
||||
die("LWP::UserAgent->new() failed. Not enough memory?");
|
||||
}
|
||||
$task_requests [$thread_id] = 0 ;
|
||||
$task_sessions [$thread_id] = 0 ;
|
||||
$task_reqsec[$thread_id] = 0;
|
||||
|
@ -388,6 +391,9 @@ sub g_get_page {
|
|||
my $debug = $_[3];
|
||||
|
||||
my $req = HTTP::Request->new(GET => $url);
|
||||
if (!defined($req)) {
|
||||
die("HTTP::Request->new() failed. Not enough memory?");
|
||||
}
|
||||
$req->header('Accept' => 'text/html');
|
||||
while (my ($header, $value) = each %{$headers}) {
|
||||
$req->header($header => $value);
|
||||
|
@ -418,6 +424,9 @@ sub g_head_page {
|
|||
my $debug = $_[3];
|
||||
|
||||
my $req = HTTP::Request->new(HEAD => $url);
|
||||
if (!defined($req)) {
|
||||
die("HTTP::Request->new() failed. Not enough memory?");
|
||||
}
|
||||
$req->header('Accept' => 'text/html');
|
||||
while (my ($header, $value) = each %{$headers}) {
|
||||
$req->header($header => $value);
|
||||
|
|
|
@ -34,7 +34,7 @@ our @ISA = qw(Exporter);
|
|||
|
||||
# version: Defines actual version of Pandora Server for this module only
|
||||
my $pandora_version = "7.0NG.764";
|
||||
my $pandora_build = "220927";
|
||||
my $pandora_build = "220928";
|
||||
our $VERSION = $pandora_version." ".$pandora_build;
|
||||
|
||||
our %EXPORT_TAGS = ( 'all' => [ qw() ] );
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#
|
||||
%define name pandorafms_server
|
||||
%define version 7.0NG.764
|
||||
%define release 220927
|
||||
%define release 220928
|
||||
|
||||
Summary: Pandora FMS Server
|
||||
Name: %{name}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#
|
||||
%define name pandorafms_server
|
||||
%define version 7.0NG.764
|
||||
%define release 220927
|
||||
%define release 220928
|
||||
|
||||
Summary: Pandora FMS Server
|
||||
Name: %{name}
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
# **********************************************************************
|
||||
|
||||
PI_VERSION="7.0NG.764"
|
||||
PI_BUILD="220927"
|
||||
PI_BUILD="220928"
|
||||
|
||||
MODE=$1
|
||||
if [ $# -gt 1 ]; then
|
||||
|
|
|
@ -35,11 +35,14 @@ use PandoraFMS::Config;
|
|||
use PandoraFMS::DB;
|
||||
|
||||
# version: define current version
|
||||
my $version = "7.0NG.764 Build 220927";
|
||||
my $version = "7.0NG.764 Build 220928";
|
||||
|
||||
# Pandora server configuration
|
||||
my %conf;
|
||||
|
||||
# History DB configuration
|
||||
my $h_conf;
|
||||
|
||||
# Long operations are divided in XX steps for performance
|
||||
my $BIG_OPERATION_STEP = 100; # 100 is default
|
||||
|
||||
|
@ -73,8 +76,8 @@ sub log_message ($$;$) {
|
|||
########################################################################
|
||||
# Delete old data from the database.
|
||||
########################################################################
|
||||
sub pandora_purgedb ($$) {
|
||||
my ($conf, $dbh) = @_;
|
||||
sub pandora_purgedb ($$$) {
|
||||
my ($conf, $dbh, $h_conf) = @_;
|
||||
|
||||
# 1) Obtain last value for date limit
|
||||
# 2) Delete all elements below date limit
|
||||
|
@ -141,13 +144,13 @@ sub pandora_purgedb ($$) {
|
|||
|
||||
# Delete sessions data
|
||||
pandora_delete_old_session_data (\%conf, $dbh, $ulimit_timestamp);
|
||||
|
||||
# Delete old inventory data
|
||||
}
|
||||
else {
|
||||
log_message ('PURGE', 'days_purge is set to 0. Old data will not be deleted.');
|
||||
}
|
||||
|
||||
pandora_delete_old_tplanned_downtime(\%conf, $dbh, $h_conf);
|
||||
|
||||
# String data deletion
|
||||
if (!defined($conf->{'_string_purge'})){
|
||||
$conf->{'_string_purge'} = 7;
|
||||
|
@ -1024,6 +1027,33 @@ sub pandora_delete_old_export_data {
|
|||
};
|
||||
}
|
||||
|
||||
##############################################################################
|
||||
# Delete old data from tplanned_downtime.
|
||||
##############################################################################
|
||||
sub pandora_delete_old_tplanned_downtime {
|
||||
my ($conf, $dbh, $h_conf) = @_;
|
||||
|
||||
# Use the configuration from the history DB if available, which should be
|
||||
# less restrictive.
|
||||
my $days_purge = $conf->{'_days_purge'};
|
||||
if (defined($h_conf) &&
|
||||
defined($h_conf->{'_days_purge'}) &&
|
||||
$h_conf->{'_days_purge'} > 0) {
|
||||
$days_purge = $h_conf->{'_days_purge'};
|
||||
}
|
||||
|
||||
# _days_purge was not configured.
|
||||
return unless $days_purge > 0;
|
||||
|
||||
my $ulimit_timestamp = time() - (86400 * $days_purge);
|
||||
|
||||
log_message ('PURGE', "Deleting data older than $days_purge days from tplanned_downtime.");
|
||||
|
||||
db_do($dbh, "DELETE FROM tplanned_downtime
|
||||
WHERE type_execution = 'once'
|
||||
AND date_to < ?", $ulimit_timestamp);
|
||||
}
|
||||
|
||||
##############################################################################
|
||||
# Delete old session data.
|
||||
##############################################################################
|
||||
|
@ -1114,13 +1144,13 @@ sub pandoradb_history ($$) {
|
|||
###############################################################################
|
||||
# Main
|
||||
###############################################################################
|
||||
sub pandoradb_main ($$$;$) {
|
||||
my ($conf, $dbh, $history_dbh) = @_;
|
||||
sub pandoradb_main {
|
||||
my ($conf, $dbh, $h_conf, $history_dbh) = @_;
|
||||
|
||||
log_message ('', "Starting at ". strftime ("%Y-%m-%d %H:%M:%S", localtime()) . "\n");
|
||||
|
||||
# Purge
|
||||
pandora_purgedb ($conf, $dbh);
|
||||
pandora_purgedb ($conf, $dbh, $h_conf);
|
||||
|
||||
# Consistency check
|
||||
pandora_checkdb_consistency ($conf, $dbh);
|
||||
|
@ -1223,6 +1253,7 @@ if (defined($conf{'_history_db_enabled'}) && $conf{'_history_db_enabled'} eq '1'
|
|||
eval {
|
||||
$conf{'encryption_key'} = enterprise_hook('pandora_get_encryption_key', [\%conf, $conf{'encryption_passphrase'}]);
|
||||
$history_dbh = db_connect ($conf{'dbengine'}, $conf{'_history_db_name'}, $conf{'_history_db_host'}, $conf{'_history_db_port'}, $conf{'_history_db_user'}, pandora_output_password(\%conf, $conf{'_history_db_pass'}));
|
||||
$h_conf = pandoradb_load_history_conf($history_dbh);
|
||||
};
|
||||
if ($@) {
|
||||
if (is_offline(\%conf)) {
|
||||
|
@ -1271,12 +1302,11 @@ if ($lock == 0) {
|
|||
}
|
||||
|
||||
# Main
|
||||
pandoradb_main(\%conf, $dbh, $history_dbh);
|
||||
pandoradb_main(\%conf, $dbh, $h_conf, $history_dbh);
|
||||
|
||||
# history_dbh is unset in pandoradb_main if not in use.
|
||||
if (defined($history_dbh)) {
|
||||
log_message('', " [>] DB Tool running on historical database.\n");
|
||||
my $h_conf = pandoradb_load_history_conf($history_dbh);
|
||||
|
||||
# Keep base settings.
|
||||
$h_conf->{'_onlypurge'} = $conf{'_onlypurge'};
|
||||
|
|
|
@ -36,7 +36,7 @@ use Encode::Locale;
|
|||
Encode::Locale::decode_argv;
|
||||
|
||||
# version: define current version
|
||||
my $version = "7.0NG.764 Build 220927";
|
||||
my $version = "7.0NG.764 Build 220928";
|
||||
|
||||
# save program name for logging
|
||||
my $progname = basename($0);
|
||||
|
|
Loading…
Reference in New Issue