Merge remote-tracking branch 'origin/develop' into ent-9086-eliminacion-de-la-replicacion-de-eventos-duplicado

This commit is contained in:
Daniel Barbero Martin 2022-06-23 12:51:35 +02:00
commit 5328cf21c6
77 changed files with 609 additions and 213 deletions
pandora_agents
pandora_console
pandora_server

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

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

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

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

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

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

@ -1,6 +1,6 @@
# Base config file for Pandora FMS Windows Agent
# (c) 2006-2021 Artica Soluciones Tecnologicas
# Version 7.0NG.762
# Version 7.0NG.763
# This program is Free Software, you can redistribute it and/or modify it
# under the terms of the GNU General Public Licence as published by the Free Software
# Foundation; either version 2 of the Licence or any later version

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

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

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

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

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

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

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

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

@ -1,5 +1,5 @@
package: pandorafms-agent-unix
Version: 7.0NG.762-220623
Version: 7.0NG.763
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.762-220623"
pandora_version="7.0NG.763"
echo "Test if you has the tools for to make the packages."
whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null

@ -31,7 +31,7 @@ fi
if [ "$#" -ge 2 ]; then
VERSION="$2"
else
VERSION="7.0NG.762"
VERSION="7.0NG.763"
fi
# Path for the generated DMG file

@ -19,11 +19,11 @@
<choice id="com.pandorafms.pandorafms_src" visible="false">
<pkg-ref id="com.pandorafms.pandorafms_src"/>
</choice>
<pkg-ref id="com.pandorafms.pandorafms_src" version="7.0NG.762" onConclusion="none">pandorafms_src.pdk</pkg-ref>
<pkg-ref id="com.pandorafms.pandorafms_src" version="7.0NG.763" onConclusion="none">pandorafms_src.pdk</pkg-ref>
<choice id="com.pandorafms.pandorafms_uninstall" visible="true" customLocation="/Applications">
<pkg-ref id="com.pandorafms.pandorafms_uninstall"/>
</choice>
<pkg-ref id="com.pandorafms.pandorafms_uninstall" version="7.0NG.762" onConclusion="none">pandorafms_uninstall.pdk</pkg-ref>
<pkg-ref id="com.pandorafms.pandorafms_uninstall" version="7.0NG.763" onConclusion="none">pandorafms_uninstall.pdk</pkg-ref>
<!-- <installation-check script="check()" />
<script>
<![CDATA[

@ -5,9 +5,9 @@
<key>CFBundleIconFile</key> <string>pandorafms.icns</string>
<key>CFBundleIdentifier</key> <string>com.pandorafms.pandorafms_uninstall</string>
<key>CFBundleVersion</key> <string>7.0NG.762</string>
<key>CFBundleGetInfoString</key> <string>7.0NG.762 Pandora FMS Agent uninstaller for MacOS by Artica ST on Aug 2020</string>
<key>CFBundleShortVersionString</key> <string>7.0NG.762</string>
<key>CFBundleVersion</key> <string>7.0NG.763</string>
<key>CFBundleGetInfoString</key> <string>7.0NG.763 Pandora FMS Agent uninstaller for MacOS by Artica ST on Aug 2020</string>
<key>CFBundleShortVersionString</key> <string>7.0NG.763</string>
<key>NSPrincipalClass</key><string>NSApplication</string>
<key>NSMainNibFile</key><string>MainMenu</string>

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

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

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

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

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

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

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

@ -1014,7 +1014,7 @@ my $Sem = undef;
# Semaphore used to control the number of threads
my $ThreadSem = undef;
use constant AGENT_VERSION => '7.0NG.762';
use constant AGENT_VERSION => '7.0NG.763';
use constant AGENT_BUILD => '220623';
# Agent log default file size maximum and instances

@ -2,8 +2,8 @@
#Pandora FMS Linux Agent
#
%define name pandorafms_agent_unix
%define version 7.0NG.762
%define release 220623
%define version 7.0NG.763
%define release 1
Summary: Pandora FMS Linux agent, PERL version
Name: %{name}

@ -2,8 +2,8 @@
#Pandora FMS Linux Agent
#
%define name pandorafms_agent_unix
%define version 7.0NG.762
%define release 220623
%define version 7.0NG.763
%define release 1
Summary: Pandora FMS Linux agent, PERL version
Name: %{name}

@ -9,7 +9,7 @@
# Please see http://www.pandorafms.org. This code is licensed under GPL 2.0 license.
# **********************************************************************
PI_VERSION="7.0NG.762"
PI_VERSION="7.0NG.763"
PI_BUILD="220623"
OS_NAME=`uname -s`

@ -1,6 +1,6 @@
# Base config file for Pandora FMS Windows Agent
# (c) 2006-2021 Artica Soluciones Tecnologicas
# Version 7.0NG.762
# Version 7.0NG.763
# This program is Free Software, you can redistribute it and/or modify it
# under the terms of the GNU General Public Licence as published by the Free Software
# Foundation; either version 2 of the Licence or any later version

@ -3,7 +3,7 @@ AllowLanguageSelection
{Yes}
AppName
{Pandora FMS Windows Agent v7.0NG.762}
{Pandora FMS Windows Agent v7.0NG.763}
ApplicationID
{17E3D2CF-CA02-406B-8A80-9D31C17BD08F}
@ -2387,7 +2387,7 @@ Windows,BuildSeparateArchives
{No}
Windows,Executable
{<%AppName%>-<%Version%>-Setup<%Ext%>}
{<%AppName%>-Setup<%Ext%>}
Windows,FileDescription
{<%AppName%> <%Version%> Setup}

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

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

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

@ -41,6 +41,15 @@ ALTER TABLE `tservice` ADD COLUMN `rca` TEXT;
ALTER TABLE `tdashboard` MODIFY `name` TEXT NOT NULL DEFAULT '';
ALTER TABLE `tevent_alert` ADD COLUMN `field1_recovery` TEXT AFTER `recovery_notify`;
ALTER TABLE `tevent_alert` ADD COLUMN `field4_recovery` TEXT AFTER `field3_recovery`;
ALTER TABLE `tevent_alert` ADD COLUMN `field5_recovery` TEXT AFTER `field4_recovery`;
ALTER TABLE `tevent_alert` ADD COLUMN `field6_recovery` TEXT AFTER `field5_recovery`;
ALTER TABLE `tevent_alert` ADD COLUMN `field7_recovery` TEXT AFTER `field6_recovery`;
ALTER TABLE `tevent_alert` ADD COLUMN `field8_recovery` TEXT AFTER `field7_recovery`;
ALTER TABLE `tevent_alert` ADD COLUMN `field9_recovery` TEXT AFTER `field8_recovery`;
ALTER TABLE `tevent_alert` ADD COLUMN `field10_recovery` TEXT AFTER `field9_recovery`;
ALTER TABLE `tagente` ADD COLUMN `satellite_server` INT NOT NULL default 0;
ALTER TABLE `tmetaconsole_agent` ADD COLUMN `satellite_server` INT NOT NULL default 0;

@ -288,7 +288,7 @@ foreach ($sessions as $session) {
array_push($table->data, $data);
}
$activity .= html_print_table($table, true);
$activity = html_print_table($table, true);
unset($table);
ui_toggle(

@ -663,6 +663,16 @@ $tip = ui_print_help_tip(
true
);
$table_other->data[$i][0] = __('WMI binary');
$table_other->data[$i++][1] = html_print_input_text(
'wmiBinary',
$config['wmiBinary'],
'',
50,
50,
true
);
if (enterprise_installed() === true) {
$table_other->data[$i][0] = __('PhantomJS cache cleanup ').$tip;
$table_other->data[$i++][1] = html_print_input(

@ -11,7 +11,7 @@
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Load global vars
// Load global vars.
global $config;
check_login();
@ -181,7 +181,8 @@ $backgrounds_list = array_merge($backgrounds_list_jpg, $backgrounds_list_png);
$backgrounds_list = array_merge($backgrounds_list, $backgrounds_list_gif);
asort($backgrounds_list);
if (!enterprise_installed()) {
$open = false;
if (enterprise_installed() === false) {
$open = true;
}
@ -953,7 +954,7 @@ $options_full_escale[2] = __('On Boolean graphs');
$table_chars->data[$row][1] = html_print_select(
$options_full_escale,
'full_scale_option',
$config['full_scale_option'],
(isset($config['full_scale_option']) === true) ? $config['full_scale_option'] : 0,
'',
'',
0,
@ -973,7 +974,7 @@ $options_soft_graphs[1] = __('Show MAX/AVG/MIN by default');
$table_chars->data[$row][1] = html_print_select(
$options_soft_graphs,
'type_mode_graph',
$config['type_mode_graph'],
(isset($config['type_mode_graph']) === true) ? $config['type_mode_graph'] : 0,
'',
'',
0,
@ -1053,13 +1054,31 @@ $table_vc->data[$row][1] = html_print_extended_select_for_time(
$row++;
$table_vc->data[$row][0] = __('Default interval for refresh on Visual Console');
$table_vc->data[$row][1] = html_print_select($values, 'vc_refr', (int) $config['vc_refr'], '', 'N/A', 0, true, false, false);
$table_vc->data[$row][1] = html_print_select(
$values,
'vc_refr',
(int) $config['vc_refr'],
'',
'N/A',
0,
true,
false,
false
);
$row++;
$vc_favourite_view_array[0] = __('Classic view');
$vc_favourite_view_array[1] = __('View of favorites');
$table_vc->data[$row][0] = __('Type of view of visual consoles');
$table_vc->data[$row][1] = html_print_select($vc_favourite_view_array, 'vc_favourite_view', $config['vc_favourite_view'], '', '', 0, true);
$table_vc->data[$row][1] = html_print_select(
$vc_favourite_view_array,
'vc_favourite_view',
$config['vc_favourite_view'],
'',
'',
0,
true
);
$row++;
$table_vc->data[$row][0] = __('Number of favorite visual consoles to show in the menu');
@ -1067,7 +1086,23 @@ $table_vc->data[$row][1] = "<input type ='number' value=".$config['vc_menu_items
$row++;
$table_vc->data[$row][0] = __('Default line thickness for the Visual Console');
$table_vc->data[$row][1] = html_print_input_text('vc_line_thickness', (int) $config['vc_line_thickness'], '', 5, 5, true);
$table_vc->data[$row][1] = html_print_input_text(
'vc_line_thickness',
(int) $config['vc_line_thickness'],
'',
5,
5,
true
);
$table_vc->data[$row][0] = __('Mobile view not allow visual console orientation');
$table_vc->data[$row][1] = html_print_checkbox_switch(
'mobile_view_orientation_vc',
1,
(bool) $config['mobile_view_orientation_vc'],
true
);
$row++;
// ----------------------------------------------------------------------
@ -1133,7 +1168,17 @@ $interval_description = [
'tiny' => 'Short',
];
$table_report->data[$row][0] = __('Interval description');
$table_report->data[$row][1] = html_print_select($interval_description, 'interval_description', $config['interval_description'], '', '', '', true, false, false);
$table_report->data[$row][1] = html_print_select(
$interval_description,
'interval_description',
(isset($config['interval_description']) === true) ? $config['interval_description'] : 'large',
'',
'',
'',
true,
false,
false
);
$row++;

@ -278,6 +278,13 @@ class AgentWizard extends HTML
*/
private $extraArguments = '';
/**
* Binary of wmic.
*
* @var string
*/
private $wmiBinary = '';
/**
* Constructor
@ -291,7 +298,7 @@ class AgentWizard extends HTML
// Check access.
check_login();
if (!check_acl($config['id_user'], 0, 'AR')) {
if ((bool) check_acl($config['id_user'], 0, 'AR') === false) {
db_pandora_audit(
AUDIT_LOG_ACL_VIOLATION,
'Trying to access event viewer'
@ -311,6 +318,7 @@ class AgentWizard extends HTML
$this->idAgent = get_parameter('id_agente', '');
$this->idPolicy = get_parameter('id', '');
$this->targetIp = get_parameter('targetIp', '');
$this->wmiBinary = $config['wmiBinary'];
if (empty($this->idAgent) === false) {
$array_aux = db_get_all_rows_sql(
@ -1044,7 +1052,7 @@ class AgentWizard extends HTML
$oidExplore = '.1.3.6.1.2.1.1.2.0';
}
// Explore general or interfaces
// Explore general or interfaces.
$receivedOid = $this->snmpWalkValues(
$oidExplore,
false,
@ -1080,7 +1088,7 @@ class AgentWizard extends HTML
// Capture the parameters.
// Call WMI Explorer function.
$this->wmiCommand = wmi_compose_query(
'wmic',
$this->wmiBinary,
$this->usernameWMI,
$this->passwordWMI,
$this->targetIp,
@ -1090,19 +1098,26 @@ class AgentWizard extends HTML
// the host is Windows (and allow WMI).
$commandQuery = $this->wmiCommand;
$commandQuery .= ' "SELECT Caption FROM Win32_ComputerSystem"';
// Execute the wmic command.
// Declare the vars.
$result = [];
exec($commandQuery, $result);
$execCorrect = true;
$returnVar = 0;
$tmpError = '';
// Look for the response if we have ERROR messages.
foreach ($result as $info) {
if (preg_match('/ERROR:/', $info) !== 0) {
$execCorrect = false;
$tmpError = strrchr($info, 'ERROR:');
break;
$execCorrect = true;
// Execute the command.
exec($commandQuery, $result, $returnVar);
// Only is valid if return code is 0.
if ($returnVar === 0) {
// Look for the response if we have ERROR messages.
foreach ($result as $info) {
if (preg_match('/ERROR:/', $info) !== 0) {
$execCorrect = false;
$tmpError = strrchr($info, 'ERROR:');
break;
}
}
} else {
$tmpError = sprintf('Return Code %s', $returnVar);
$execCorrect = false;
}
// FOUND ERRORS: TIMEOUT.
@ -2806,7 +2821,7 @@ class AgentWizard extends HTML
// Unpack the query filters.
$queryFilters = json_decode($module['query_filters'], true);
// Name of query filter field.
$fieldValueName = $fieldSet[$queryFilters['field']];
$fieldValueName = (empty($fieldSet[$queryFilters['field']]) === false) ? $fieldSet[$queryFilters['field']] : '1';
// Evaluate type of scan and execution.
if ($module['scan_type'] == SCAN_TYPE_FIXED) {
@ -2841,13 +2856,13 @@ class AgentWizard extends HTML
// If name of the module have a macro.
$moduleBlocks[$k]['name'] = $this->macroFilter(
$module['name'],
io_safe_output($module['name']),
$columnsList,
$rowList
);
// Description can have macros too.
$moduleBlocks[$k]['description'] = $this->macroFilter(
$module['description'],
io_safe_output($module['description']),
$columnsList,
$rowList
);
@ -2859,7 +2874,7 @@ class AgentWizard extends HTML
);
foreach ($columnsList as $columnKey => $columnValue) {
$macros['macros']['_'.$columnValue.'_'] = $rowList[$columnKey];
$macros['macros']['_'.trim($columnValue).'_'] = $rowList[trim($columnKey)];
}
$moduleBlocks[$k]['macros'] = json_encode($macros);
@ -2892,6 +2907,7 @@ class AgentWizard extends HTML
$dataCombined = array_combine($columnsList, $rowList);
// Change the macros for values.
foreach ($dataCombined as $macroKey => $macroValue) {
$macroKey = trim($macroKey);
if (preg_match('/_'.$macroKey.'_/', $valueOperation) !== 0) {
$valueOperation = preg_replace(
'/_'.$macroKey.'_/',
@ -2937,19 +2953,19 @@ class AgentWizard extends HTML
$rowList = explode('|', $rowContent);
// If name of the module have a macro.
$newModule['name'] = $this->macroFilter(
$module['name'],
io_safe_output($module['name']),
$columnsList,
$rowList
);
// Description can have macros too.
$newModule['description'] = $this->macroFilter(
$module['description'],
io_safe_output($module['description']),
$columnsList,
$rowList
);
$newModule['query_filters'] = $this->macroFilter(
$module['query_filters'],
io_safe_output($module['query_filters']),
$columnsList,
$rowList
);
@ -2995,6 +3011,7 @@ class AgentWizard extends HTML
);
// Change the macros for values.
foreach ($dataCombined as $macroKey => $macroValue) {
$macroKey = trim($macroKey);
if (preg_match('/_'.$macroKey.'_/', $valueOperation) !== 0) {
$valueOperation = preg_replace(
'/_'.$macroKey.'_/',
@ -3022,39 +3039,48 @@ class AgentWizard extends HTML
}
}
// Create the final table with all of data received.
foreach ($moduleBlocks as $module) {
// Prepare the blocks. If its new, create a new index.
if (key_exists($module['group'], $blockTables) === false) {
$blockTables[$module['group']] = [
'name' => $module['group_name'],
'data' => [],
];
// If we not retrieve information (P.E. connection refused).
if (empty($moduleBlocks) === true) {
$this->message['type'][] = 'warning';
$this->message['message'][] = __(
'No information could be retrieved.'
);
$this->showMessage();
} else {
// Create the final table with all of data received.
foreach ($moduleBlocks as $module) {
// Prepare the blocks. If its new, create a new index.
if (key_exists($module['group'], $blockTables) === false) {
$blockTables[$module['group']] = [
'name' => $module['group_name'],
'data' => [],
];
}
// Add the module info in the block.
$blockTables[$module['group']]['data'][] = $module;
if (isset($blockTables[$module['group']]['activeModules']) === false
&& (int) $module['module_enabled'] === 1
) {
$blockTables[$module['group']]['activeModules'] = 2;
} else if (isset($blockTables[$module['group']]['activeModules']) === true
&& (int) $module['module_enabled'] === 0
) {
$blockTables[$module['group']]['activeModules'] = 1;
}
}
// Add the module info in the block.
$blockTables[$module['group']]['data'][] = $module;
if (isset($blockTables[$module['group']]['activeModules']) === false
&& (int) $module['module_enabled'] === 1
) {
$blockTables[$module['group']]['activeModules'] = 2;
} else if (isset($blockTables[$module['group']]['activeModules']) === true
&& (int) $module['module_enabled'] === 0
) {
$blockTables[$module['group']]['activeModules'] = 1;
}
// General Default monitoring.
html_print_div(
[
'class' => 'wizard wizard-result',
'style' => 'margin-top: 20px;',
'content' => $this->toggleTableModules($blockTables),
]
);
// Add Create Modules form.
$this->createModulesForm();
}
// General Default monitoring.
html_print_div(
[
'class' => 'wizard wizard-result',
'style' => 'margin-top: 20px;',
'content' => $this->toggleTableModules($blockTables),
]
);
// Add Create Modules form.
$this->createModulesForm();
}
@ -5542,13 +5568,13 @@ class AgentWizard extends HTML
string $unit='',
?int $type=0
) {
$output = '';
try {
// Avoid non-numeric or arithmetic chars for security reasons.
if (preg_match('/(([^0-9\s\+\-\*\/\(\).,])+)/', $operation) === 1) {
throw new Exception(sprintf(__("The operation '%s' is not permitted. Review for remote components."), $operation));
} else {
// Get the result of the operation and set it.
$output = '';
eval('$output = '.$operation.';');
// If this module has unit, attach to current value.
$output = $this->replacementUnit(
@ -5723,7 +5749,7 @@ class AgentWizard extends HTML
$(this).removeClass('hidden');
return;
}
if (this.id.match(regex)) {
$(this).removeClass('hidden');
} else {
@ -5735,7 +5761,7 @@ class AgentWizard extends HTML
$(this).addClass('hidden');
}
}
if (filter_up == true) {
if ($(this).attr('operstatus') != 1) {
$(this).addClass('hidden');

@ -851,6 +851,8 @@ class HTML
foreach ($inputs as $input) {
if (is_array(($input['arguments'] ?? null)) === true
&& isset($input['arguments']) === true
&& isset($input['arguments']['type']) === true
&& $input['arguments']['type'] === 'submit'
) {
$output_submit .= self::printBlock($input, true);

@ -309,7 +309,7 @@ class WelcomeWindow extends Wizard
{
global $config;
return $config['welcome_id_agent'];
return (isset($config['welcome_id_agent']) === true) ? $config['welcome_id_agent'] : '';
}

@ -21,7 +21,7 @@
* Pandora build version and version
*/
$build_version = 'PC220623';
$pandora_version = 'v7.0NG.762';
$pandora_version = 'v7.0NG.763';
// Do not overwrite default timezone set if defined.
$script_tz = @date_default_timezone_get();

@ -902,6 +902,10 @@ function config_update_config()
$error_update[] = __('SNMP walk binary path (fallback for v1)');
}
if (config_update_value('wmiBinary', get_parameter('wmiBinary'), true) === false) {
$error_update[] = __('Default WMI Binary');
}
$pjs = get_parameter('phantomjs_cache_interval');
switch ($pjs) {
case $config['phantomjs_cache_interval']:
@ -1157,6 +1161,10 @@ function config_update_config()
$error_update[] = __('Default line thickness for the Visual Console');
}
if (config_update_value('mobile_view_orientation_vc', (int) get_parameter('mobile_view_orientation_vc'), true) === false) {
$error_update[] = __('Mobile view not allow visual console orientation');
}
if (config_update_value('ser_menu_items', (int) get_parameter('ser_menu_items', 10), true) === false) {
$error_update[] = __('Default line menu items for the Services');
}
@ -2065,6 +2073,10 @@ function config_process_config()
config_update_value('snmpwalk_fallback', 'snmpwalk');
}
if (isset($config['wmiBinary']) === false) {
config_update_value('wmiBinary', 'pandorawmic');
}
if (!isset($config['event_purge'])) {
config_update_value('event_purge', 15);
}
@ -3019,6 +3031,10 @@ function config_process_config()
config_update_value('vc_line_thickness', 2);
}
if (isset($config['mobile_view_orientation_vc']) === false) {
config_update_value('mobile_view_orientation_vc', 0);
}
if (!isset($config['agent_size_text_small'])) {
config_update_value('agent_size_text_small', 18);
}

@ -4924,7 +4924,7 @@ function html_print_input($data, $wrapper='div', $input_only=false)
case 'image':
$output .= html_print_input_image(
$data['name'],
((isset($data['name']) === true) ? $data['name'] : ''),
$data['src'],
$data['value'],
((isset($data['style']) === true) ? $data['style'] : ''),

@ -34,15 +34,22 @@
*
* @param boolean $id_user
* @param boolean $user_strict
* @param [type] $acltags
* @param array $acltags
* @param boolean $returnAllGroup
* @param string $mode
* @param array $agent_filter
* @param array $module_filter
* @return void
*/
function tactical_get_data($id_user=false, $user_strict=false, $acltags, $returnAllGroup=false, $mode='group', $agent_filter=[], $module_filter=[])
{
function tactical_get_data(
$id_user=false,
$user_strict=false,
$acltags=[],
$returnAllGroup=false,
$mode='group',
$agent_filter=[],
$module_filter=[]
) {
global $config;
if ($id_user == false) {
$id_user = $config['id_user'];
@ -504,10 +511,12 @@ function tactical_status_modules_agents($id_user=false, $user_strict=false, $acc
function tactical_monitor_alerts($strict_user=false)
{
global $config;
$groups = users_get_groups($config['id_user'], 'AR', false);
$id_groups = array_keys($groups);
if (empty($id_groups)) {
$where_clause = '';
if (empty($id_groups) === true) {
$where_clause .= ' AND (1 = 0) ';
} else {
$where_clause .= sprintf(

@ -82,7 +82,7 @@ function visual_map_print_user_line_handles($layoutData)
function visual_map_print_item(
$mode='read',
$layoutData,
$layoutData=[],
$proportion=null,
$show_links=true,
$isExternalLink=false,
@ -2554,13 +2554,13 @@ function visual_map_process_wizard_add(
$range,
$width=0,
$height=0,
$period,
$process_value,
$percentileitem_width,
$max_value,
$type_percentile,
$value_show,
$type
$period='',
$process_value='',
$percentileitem_width='',
$max_value=0,
$type_percentile='',
$value_show='',
$type=''
) {
if (empty($id_agents)) {
print_error_message(__('No agents selected'));
@ -3956,7 +3956,15 @@ function visual_map_get_layout_status($layout_id, $status_data=[], $depth=0)
sort_by_column($valid_layout_items, 'id_metaconsole');
}
$num_elements_by_status = [];
$num_elements_by_status = [
VISUAL_MAP_STATUS_CRITICAL_BAD => 0,
VISUAL_MAP_STATUS_CRITICAL_ALERT => 0,
VISUAL_MAP_STATUS_NORMAL => 0,
VISUAL_MAP_STATUS_WARNING => 0,
VISUAL_MAP_STATUS_UNKNOWN => 0,
VISUAL_MAP_STATUS_WARNING_ALERT => 0,
];
$meta_connected_to = null;
foreach ($valid_layout_items as $layout_item_data) {
@ -3993,7 +4001,7 @@ function visual_map_get_layout_status($layout_id, $status_data=[], $depth=0)
$ent_element_status = enterprise_hook(
'enterprise_visual_map_get_status_element',
[$layoutData]
[$layout_item_data]
);
if ($ent_element_status === ENTERPRISE_NOT_HOOK) {
$ent_element_status = false;
@ -4558,7 +4566,7 @@ function css_label_styles_visual_console($uniq, $ratio=1)
$output .= '.c-'.$uniq.' a {color: #3f3f3f } ';
$output .= '.c-'.$uniq.' .label p strong span {display: inline-block !important; line-height: normal !important} ';
$output .= '.c-'.$uniq.' *:not(.parent_graph p table tr td span) { font-size: '.(8 * $ratio).'pt; line-height:'.(8 * ($ratio)).'pt; }';
$output .= '.c-'.$uniq.' .visual-console-item-label table tr td { padding: 0; margin: 0; }';
$output .= '.c-'.$uniq.' .visual-console-item-label table tr td { padding: 0; margin: 0; white-space: pre-wrap; }';
$output .= '.c-'.$uniq.' .visual_font_size_4pt, .c-'.$uniq.' .visual_font_size_4pt * { font-size: '.(4 * $ratio).'pt !important; line-height:'.(4 * ($ratio)).'pt !important; }';
$output .= '.c-'.$uniq.' .visual_font_size_6pt, .c-'.$uniq.' .visual_font_size_6pt * { font-size: '.(6 * $ratio).'pt !important; line-height:'.(6 * ($ratio)).'pt !important; }';
$output .= '.c-'.$uniq.' .visual_font_size_8pt, .c-'.$uniq.' .visual_font_size_8pt * { font-size: '.(8 * $ratio).'pt !important; line-height:'.(8 * ($ratio)).'pt !important; }';

@ -32,13 +32,13 @@ function wmi_compose_query($wmi_client, $user, $password, $host, $namespace='')
{
$wmi_command = '';
if (!empty($password)) {
$wmi_command = $wmi_client.' -U "'.$user.'"%"'.$password.'"';
if (empty($password) === false) {
$wmi_command = $wmi_client.' -U \''.$user.'\'%\''.$password.'\'';
} else {
$wmi_command = $wmi_client.' -U "'.$user.'"';
}
if (!empty($namespace)) {
if (empty($namespace) === false) {
$namespace = str_replace('&quot;', "'", $namespace);
$wmi_command .= ' --namespace="'.$namespace.'"';
}

@ -1223,6 +1223,8 @@ function dashboardLoadVC(settings) {
var ratio_visualconsole = props.height / props.width;
var ratio_w = size.width / props.width;
var ratio_h = size.height / props.height;
var acum_height = props.height;
var acum_width = props.width;
props.width = size.width;
props.height = size.width * ratio_visualconsole;
@ -1235,6 +1237,11 @@ function dashboardLoadVC(settings) {
props.height = size.height;
props.width = size.height / ratio_visualconsole;
}
} else {
ratio = ratio_w;
var height = (acum_height * size.width) / acum_width;
props.height = height;
props.width = height / ratio_visualconsole;
}
} else {
if (props.height > size.height) {
@ -1290,22 +1297,30 @@ function dashboardLoadVC(settings) {
var regex_hash = /(hash=)[^&]+(&?)/gi;
var replacement_hash = "$1" + props.hash + "$2";
/*
var regex_width = /(width=)[^&]+(&?)/gi;
var replacement_width = "$1" + size.width + "$2";
var regex_height = /(height=)[^&]+(&?)/gi;
var replacement_height =
"$1" + (size.height + headerMobileFix) + "$2";
*/
// Change the URL (if the browser has support).
if ("history" in window) {
var href = window.location.href.replace(regex, replacement);
href = href.replace(regex_hash, replacement_hash);
href = href.replace(regex_width, replacement_width);
href = href.replace(regex_height, replacement_height);
//href = href.replace(regex_width, replacement_width);
//href = href.replace(regex_height, replacement_height);
window.history.replaceState({}, document.title, href);
}
if (props.height > props.width) {
$(".container-center").css("overflow", "auto");
} else {
$(".container-center").css("overflow", "inherit");
}
container.classList.remove("cv-overflow");
// View title.
@ -1351,40 +1366,42 @@ function dashboardLoadVC(settings) {
: "dashboard"
);
$(window).on("orientationchange", function() {
$(container).width($(window).height());
$(container).height($(window).width() - headerMobileFix);
//Remove spinner change VC.
container.classList.remove("is-updating");
container.classList.remove("cv-overflow");
if (settings.mobile_view_orientation_vc === true) {
$(window).on("orientationchange", function() {
$(container).width($(window).height());
$(container).height($(window).width() - headerMobileFix);
//Remove spinner change VC.
container.classList.remove("is-updating");
container.classList.remove("cv-overflow");
var div = container.querySelector(".div-visual-console-spinner");
var div = container.querySelector(".div-visual-console-spinner");
if (div !== null) {
var parent = div.parentElement;
if (parent !== null) {
parent.removeChild(div);
if (div !== null) {
var parent = div.parentElement;
if (parent !== null) {
parent.removeChild(div);
}
}
}
container.classList.add("is-updating");
container.classList.add("cv-overflow");
const divParent = document.createElement("div");
divParent.className = "div-visual-console-spinner";
container.classList.add("is-updating");
container.classList.add("cv-overflow");
const divParent = document.createElement("div");
divParent.className = "div-visual-console-spinner";
const divSpinner = document.createElement("div");
divSpinner.className = "visual-console-spinner";
const divSpinner = document.createElement("div");
divSpinner.className = "visual-console-spinner";
divParent.appendChild(divSpinner);
container.appendChild(divParent);
divParent.appendChild(divSpinner);
container.appendChild(divParent);
var dimensions = {
width: $(window).height(),
height: $(window).width() - 40
};
var dimensions = {
width: $(window).height(),
height: $(window).width() - 40
};
visualConsoleManager.changeDimensionsVc(dimensions, interval);
});
visualConsoleManager.changeDimensionsVc(dimensions, interval);
});
}
}
// eslint-disable-next-line no-unused-vars

@ -438,16 +438,22 @@ class MapsMadeByUser extends Widget
$settings = \json_encode(
[
'props' => $visualConsoleData,
'items' => $visualConsoleItems,
'baseUrl' => ui_get_full_url('/', false, false, false),
'ratio' => $ratio,
'size' => $size,
'cellId' => $this->cellId,
'hash' => User::generatePublicHash(),
'id_user' => $config['id_user'],
'page' => 'include/ajax/visual_console.ajax',
'uniq' => $uniq,
'props' => $visualConsoleData,
'items' => $visualConsoleItems,
'baseUrl' => ui_get_full_url(
'/',
false,
false,
false
),
'ratio' => $ratio,
'size' => $size,
'cellId' => $this->cellId,
'hash' => User::generatePublicHash(),
'id_user' => $config['id_user'],
'page' => 'include/ajax/visual_console.ajax',
'uniq' => $uniq,
'mobile_view_orientation_vc' => false,
]
);
@ -507,7 +513,6 @@ class MapsMadeByUser extends Widget
},
dataType: 'JSON',
success: function(data) {
console.log(data);
$('#vcId').empty();
Object.entries(data).forEach(e => {
key = e[0];

@ -223,17 +223,33 @@ abstract class Model
*/
public function adjustToViewport($size, $mode='')
{
global $config;
$ratio_visualconsole = $this->getRatio();
$ratio_w = ($size['width'] / $this->data['width']);
$ratio_h = ($size['height'] / $this->data['height']);
$acum_height = $this->data['height'];
$acum_width = $this->data['width'];
$this->data['width'] = $size['width'];
$this->data['height'] = ($size['width'] * $ratio_visualconsole);
$ratio = $ratio_w;
if ($mode === 'mobile') {
if ($this->data['height'] < $this->data['width']) {
if ($this->data['height'] > $size['height']) {
if ((bool) $config['mobile_view_orientation_vc'] === true) {
if ($this->data['height'] < $this->data['width']) {
if ($this->data['height'] > $size['height']) {
$ratio = $ratio_h;
$this->data['height'] = $size['height'];
$this->data['width'] = ($size['height'] / $ratio_visualconsole);
}
} else {
$ratio = $ratio_w;
$height = (($acum_height * ($size['width'])) / $acum_width);
$this->data['height'] = $height;
$this->data['width'] = ($height / $ratio_visualconsole);
}
} else {
if ($this->data['height'] > $this->data['width']) {
$ratio = $ratio_h;
$this->data['height'] = $size['height'];
$this->data['width'] = ($size['height'] / $ratio_visualconsole);

@ -174,6 +174,14 @@ final class StaticGraph extends Item
throw new \InvalidArgumentException('missing module Id');
}
if (isset($data['agentDisabled']) === false) {
$data['agentDisabled'] = false;
}
if (isset($data['moduleDisabled']) === false) {
$data['moduleDisabled'] = false;
}
if ((bool) $data['agentDisabled'] === false
&& (bool) $data['moduleDisabled'] === false
) {

@ -94,6 +94,7 @@ form#advanced_filters_alert textarea {
flex: 1 1 auto;
height: 5em;
min-height: 5em;
width: 2em;
}
form#advanced_filters_alert ul li label img {

@ -128,7 +128,7 @@
</div>
<div style='height: 10px'>
<?php
$version = '7.0NG.762';
$version = '7.0NG.763';
$build = '220623';
$banner = "v$version Build $build";

@ -1396,7 +1396,7 @@ div.ui-mobile-viewport {
overflow: visible;
overflow-x: hidden;
padding: 1em;
min-height: calc(100vh - 60px);
/*min-height: calc(100vh - 60px);*/
}
.ui-corner-all > .ui-toolbar-header:first-child,
.ui-corner-all > .ui-content:first-child,

@ -1003,6 +1003,22 @@ class Ui
$(document).ready(function () {
dashboardLoadVC(settings);
if(settings.mobile_view_orientation_vc === false) {
$("#main_page > .ui-content").css("display", "block");
$(".container-center").css("padding", "50% 0");
$(".container-center").css("height", "100vh");
$(".visual-console-container-dashboard").css("display", "block");
$(".visual-console-container-dashboard").css("transform-origin", "left top");
$(".visual-console-container-dashboard").css("transform", "rotate(-90deg) translate(-100%)");
$(".visual-console-container-dashboard").css("margin-top", "-50%");
$(".visual-console-container-dashboard").css("white-space", "nowrap");
if(settings.props.height > settings.props.width) {
$(".container-center").css("overflow", "auto");
}
}
});
</script>'
);

@ -216,6 +216,7 @@ class Visualmap
*/
private function show_visualmap()
{
global $config;
$ui = Ui::getInstance();
$system = System::getInstance();
@ -279,6 +280,13 @@ class Visualmap
'height' => $this->height,
];
if ((bool) $config['mobile_view_orientation_vc'] === true) {
$size = [
'width' => $this->height,
'height' => $this->width,
];
}
$ratio_t = $visualConsole->adjustToViewport($size, 'mobile');
$visualConsoleData = $visualConsole->toArray();
@ -340,16 +348,17 @@ class Visualmap
$settings = \json_encode(
[
'props' => $visualConsoleData,
'items' => $visualConsoleItems,
'baseUrl' => ui_get_full_url('/', false, false, false),
'page' => 'include/ajax/visual_console.ajax',
'ratio' => $ratio_t,
'size' => $size,
'cellId' => $uniq,
'uniq' => $uniq,
'mobile' => true,
'vcId' => $visualConsoleId,
'props' => $visualConsoleData,
'items' => $visualConsoleItems,
'baseUrl' => ui_get_full_url('/', false, false, false),
'page' => 'include/ajax/visual_console.ajax',
'ratio' => $ratio_t,
'size' => $size,
'cellId' => $uniq,
'uniq' => $uniq,
'mobile' => true,
'vcId' => $visualConsoleId,
'mobile_view_orientation_vc' => (bool) !$config['mobile_view_orientation_vc'],
]
);

@ -2,8 +2,8 @@
# Pandora FMS Console
#
%define name pandorafms_console
%define version 7.0NG.762
%define release 220623
%define version 7.0NG.763
%define release 1
# User and Group under which Apache is running
%define httpd_name httpd

@ -2,8 +2,8 @@
# Pandora FMS Console
#
%define name pandorafms_console
%define version 7.0NG.762
%define release 220623
%define version 7.0NG.763
%define release 1
# User and Group under which Apache is running
%define httpd_name httpd

@ -2,8 +2,8 @@
# Pandora FMS Console
#
%define name pandorafms_console
%define version 7.0NG.762
%define release 220623
%define version 7.0NG.763
%define release 1
%define httpd_name httpd
# User and Group under which Apache is running
%define httpd_name apache2

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

@ -3018,8 +3018,16 @@ CREATE TABLE IF NOT EXISTS `tevent_alert` (
`saturday` TINYINT DEFAULT 1,
`sunday` TINYINT DEFAULT 1,
`recovery_notify` TINYINT DEFAULT 0,
`field2_recovery` TEXT ,
`field1_recovery` TEXT,
`field2_recovery` TEXT,
`field3_recovery` TEXT,
`field4_recovery` TEXT,
`field5_recovery` TEXT,
`field6_recovery` TEXT,
`field7_recovery` TEXT,
`field8_recovery` TEXT,
`field9_recovery` TEXT,
`field10_recovery` TEXT,
`id_group` MEDIUMINT UNSIGNED NULL DEFAULT 0,
`internal_counter` INT DEFAULT 0,
`last_fired` BIGINT NOT NULL DEFAULT 0,

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

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

@ -45,7 +45,7 @@ our @EXPORT = qw(
);
# version: Defines actual version of Pandora Server for this module only
my $pandora_version = "7.0NG.762";
my $pandora_version = "7.0NG.763";
my $pandora_build = "220623";
our $VERSION = $pandora_version." ".$pandora_build;

@ -505,7 +505,7 @@ B<Returns>:
##########################################################################
sub pandora_evaluate_alert ($$$$$$$;$$$$) {
my ($pa_config, $agent, $data, $last_status, $alert, $utimestamp, $dbh,
$last_data_value, $correlatedItems, $event, $log) = @_;
$last_data_value, $correlated_items, $event, $log) = @_;
if (defined ($agent)) {
logger ($pa_config, "Evaluating alert '" . safe_output($alert->{'name'}) . "' for agent '" . safe_output ($agent->{'nombre'}) . "'.", 10);
@ -603,13 +603,16 @@ sub pandora_evaluate_alert ($$$$$$$;$$$$) {
# Cease on valid data
$status = 3;
# Unlike module alerts, correlated alerts recover when they cease!
$status = 4 if ($alert->{'recovery_notify'} == 1 && !defined($alert->{'id_template_module'}));
# Always reset
($alert->{'internal_counter'}, $alert->{'times_fired'}) = (0, 0);
}
# Recover takes precedence over cease
$status = 4 if ($alert->{'recovery_notify'} == 1);
$status = 4 if ($alert->{'recovery_notify'} == 1 && defined ($alert->{'id_template_module'}));
}
elsif ($utimestamp > $limit_utimestamp && $alert->{'internal_counter'} > 0) {
@ -690,7 +693,7 @@ sub pandora_evaluate_alert ($$$$$$$;$$$$) {
$pa_config,
$dbh,
$alert,
$correlatedItems,
$correlated_items,
$event,
$log
]

@ -536,9 +536,54 @@ sub PandoraFMS::Recon::Base::test_module($$) {
# Column
$test->{'tcp_port'}
);
} elsif ($test->{'id_modulo'} == 4) {
# SNMP Bandwith plugin modules.
# Check if plugin is running.
if ($module->{'macros'} ne '') {
# Get Bandwidth plugin.
my $plugin = get_db_single_row(
$self->{'dbh'},
'SELECT * FROM tplugin WHERE name = "Network&#x20;bandwidth&#x20;SNMP"',
);
return 0 unless defined($plugin);
my $parameters = safe_output($plugin->{'parameters'});
my $plugin_exec = $plugin->{'plugin_exec'};
# Decode macros.
my $macros = p_decode_json($self->{'config'}, safe_output($test->{'macros'}));
my %macros = %{$macros};
if(ref($macros) eq "HASH") {
foreach my $macro_id (keys(%macros))
{
my $macro_field = safe_output($macros{$macro_id}{'macro'});
my $macro_desc = safe_output($macros{$macro_id}{'desc'});
my $macro_value = (defined($macros{$macro_id}{'hide'}) && $macros{$macro_id}{'hide'} eq '1') ?
pandora_output_password($self->{'config'}, safe_output($macros{$macro_id}{'value'})) :
safe_output($macros{$macro_id}{'value'});
# build parameters to invoke plugin
$parameters =~ s/\'$macros{$macro_id}{'macro'}\'/$macro_value/g;
}
}
my $command = safe_output($plugin_exec);
# Execute the plugin.
my $output = `$command 2>$DEVNULL`;
# Do not save the output if there was an error.
if ($? != 0) {
return 0;
} else {
$value = 1;
}
}
} elsif(is_enabled($test->{'id_plugin'})) {
# XXX TODO: Test plugins. How to identify arguments? and values?
# Disabled until we can ensure result.
return 0;
}
@ -702,7 +747,7 @@ sub PandoraFMS::Recon::Base::create_interface_modules($$) {
'id_modulo' => 2,
'name' => $if_name."_ifOperStatus",
'descripcion' => safe_input(
$if_desc
'The current operational state of the interface: up(1), down(2), testing(3), unknown(4), dormant(5), notPresent(6), lowerLayerDown(7)',
),
'ip_target' => $device,
'tcp_send' => $self->{'task_data'}{'snmp_version'},
@ -713,7 +758,9 @@ sub PandoraFMS::Recon::Base::create_interface_modules($$) {
'plugin_user' => $self->{'task_data'}{'snmp_auth_user'},
'plugin_pass' => $self->{'task_data'}{'snmp_auth_pass'},
'snmp_community' => $community,
'snmp_oid' => "$PandoraFMS::Recon::Base::IFOPERSTATUS.$if_index"
'snmp_oid' => "$PandoraFMS::Recon::Base::IFOPERSTATUS.$if_index",
'unit' => ''
}
);
@ -741,7 +788,9 @@ sub PandoraFMS::Recon::Base::create_interface_modules($$) {
'plugin_user' => $self->{'task_data'}{'snmp_auth_user'},
'plugin_pass' => $self->{'task_data'}{'snmp_auth_pass'},
'snmp_community' => $community,
'snmp_oid' => "$PandoraFMS::Recon::Base::IFHCINOCTECTS.$if_index"
'snmp_oid' => "$PandoraFMS::Recon::Base::IFHCINOCTECTS.$if_index",
'unit' => safe_input('bytes/s')
}
);
} else {
@ -766,7 +815,9 @@ sub PandoraFMS::Recon::Base::create_interface_modules($$) {
'plugin_user' => $self->{'task_data'}{'snmp_auth_user'},
'plugin_pass' => $self->{'task_data'}{'snmp_auth_pass'},
'snmp_community' => $community,
'snmp_oid' => "$PandoraFMS::Recon::Base::IFINOCTECTS.$if_index"
'snmp_oid' => "$PandoraFMS::Recon::Base::IFINOCTECTS.$if_index",
'unit' => safe_input('bytes/s')
}
);
}
@ -784,7 +835,7 @@ sub PandoraFMS::Recon::Base::create_interface_modules($$) {
'id_modulo' => 2,
'name' => $if_name."_ifHCOutOctets",
'descripcion' => safe_input(
'The total number of octets received on the interface, including framing characters. This object is a 64-bit version of ifOutOctets.'
'The total number of octets transmitted out of the interface, including framing characters. This object is a 64-bit version of ifOutOctets.'
),
'ip_target' => $device,
'tcp_send' => $self->{'task_data'}{'snmp_version'},
@ -795,7 +846,9 @@ sub PandoraFMS::Recon::Base::create_interface_modules($$) {
'plugin_user' => $self->{'task_data'}{'snmp_auth_user'},
'plugin_pass' => $self->{'task_data'}{'snmp_auth_pass'},
'snmp_community' => $community,
'snmp_oid' => "$PandoraFMS::Recon::Base::IFHCOUTOCTECTS.$if_index"
'snmp_oid' => "$PandoraFMS::Recon::Base::IFHCOUTOCTECTS.$if_index",
'unit' => safe_input('bytes/s')
}
);
} else {
@ -809,7 +862,7 @@ sub PandoraFMS::Recon::Base::create_interface_modules($$) {
'id_modulo' => 2,
'name' => $if_name."_ifOutOctets",
'descripcion' => safe_input(
'The total number of octets received on the interface, including framing characters.'
'The total number of octets transmitted out of the interface, including framing characters.'
),
'ip_target' => $device,
'tcp_send' => $self->{'task_data'}{'snmp_version'},
@ -820,10 +873,135 @@ sub PandoraFMS::Recon::Base::create_interface_modules($$) {
'plugin_user' => $self->{'task_data'}{'snmp_auth_user'},
'plugin_pass' => $self->{'task_data'}{'snmp_auth_pass'},
'snmp_community' => $community,
'snmp_oid' => "$PandoraFMS::Recon::Base::IFOUTOCTECTS.$if_index"
'snmp_oid' => "$PandoraFMS::Recon::Base::IFOUTOCTECTS.$if_index",
'unit' => safe_input('bytes/s')
}
);
}
# Bandwidth plugin.
my $plugin = get_db_single_row(
$self->{'dbh'},
'SELECT id, macros FROM tplugin WHERE name = "Network&#x20;bandwidth&#x20;SNMP"',
);
next unless defined($plugin);
# Network Bandwidth is installed.
my $macros = p_decode_json($self->{'config'}, safe_output($plugin->{'macros'}));
my $id_plugin = $plugin->{'id'};
if(ref($macros) eq "HASH") {
# SNMP Version.
$macros->{'1'}->{'value'} = $self->{'task_data'}->{'snmp_version'};
# Community.
$macros->{'2'}->{'value'} = $community;
# Host.
$macros->{'3'}->{'value'} = $device;
# Port.
$macros->{'4'}->{'value'} = 161;
# Interface index filter.
$macros->{'5'}->{'value'} = $if_index;
# SecurityName.
$macros->{'6'}->{'value'} = $self->{'task_data'}->{'snmp_auth_user'};
# SecurityContext.
$macros->{'7'}->{'value'} = $community;
# SecurityLevel.
$macros->{'8'}->{'value'} = $self->{'task_data'}->{'snmp_security_level'};
# AuthProtocol.
$macros->{'9'}->{'value'} = $self->{'task_data'}->{'snmp_auth_method'};
# AuthKey.
$macros->{'10'}->{'value'} = $self->{'task_data'}->{'snmp_auth_pass'};
# PrivProtocol.
$macros->{'11'}->{'value'} = $self->{'task_data'}->{'snmp_privacy_method'};
# PrivKey.
$macros->{'12'}->{'value'} = $self->{'task_data'}->{'snmp_privacy_pass'};
# Hash identifier.
$macros->{'13'}->{'value'} = PandoraFMS::Tools::generate_agent_name_hash($if_name, $device);
# Get input usage.
$macros->{'14'}->{'value'} = 0;
# Get output usage.
$macros->{'15'}->{'value'} = 0;
$self->call(
'add_module',
$device,
{
'id_tipo_modulo' => 1,
'id_modulo' => 4,
'name' => $if_name."_Bandwith",
'descripcion' => safe_input(
'Amount of digital information sent and received from this interface over a particular time',
),
'unit' => '%',
'macros' => p_encode_json($self->{'config'}, $macros),
'id_plugin' => $id_plugin,
'unit' => '%',
'min_warning' => '0',
'max_warning' => '0',
'min_critical' => '85',
'max_critical' => '0',
}
);
# inUsage
# Hash identifier.
$macros->{'13'}->{'value'} = PandoraFMS::Tools::generate_agent_name_hash($if_name, $device);
# Get input usage.
$macros->{'14'}->{'value'} = 1;
# Get output usage.
$macros->{'15'}->{'value'} = 0;
$self->call(
'add_module',
$device,
{
'id_tipo_modulo' => 1,
'id_modulo' => 4,
'name' => $if_name."_inUsage",
'descripcion' => safe_input(
'Bandwidth usage received into this interface over a particular time',
),
'unit' => '%',
'macros' => p_encode_json($self->{'config'}, $macros),
'id_plugin' => $id_plugin,
'unit' => '%',
'min_warning' => '0',
'max_warning' => '0',
'min_critical' => '85',
'max_critical' => '0',
}
);
# OutUsage.
# Hash identifier.
$macros->{'13'}->{'value'} = PandoraFMS::Tools::generate_agent_name_hash($if_name, $device);
# Get input usage.
$macros->{'14'}->{'value'} = 0;
# Get output usage.
$macros->{'15'}->{'value'} = 1;
$self->call(
'add_module',
$device,
{
'id_tipo_modulo' => 1,
'id_modulo' => 4,
'name' => $if_name."_outUsage",
'descripcion' => safe_input(
'Bandwidth usage sent from this interface over a particular time',
),
'unit' => '%',
'macros' => p_encode_json($self->{'config'}, $macros),
'id_plugin' => $id_plugin,
'unit' => '%',
'min_warning' => '0',
'max_warning' => '0',
'min_critical' => '85',
'max_critical' => '0',
}
);
}
}
}
@ -1253,9 +1431,13 @@ sub PandoraFMS::Recon::Base::report_scanned_agents($;$) {
$id_tipo_modulo = get_module_id($self->{'dbh'}, $module->{'type'})
if is_empty($id_tipo_modulo);
my $description = safe_output($module->{'description'});
my $description = safe_output($module->{'descripcion'});
$description = '' if is_empty($description);
my $unit = safe_output($module->{'unit'});
$unit = '' if is_empty($unit);
if (is_enabled($module->{'__module_component'})) {
# Module from network component.
delete $module->{'__module_component'};
@ -1275,6 +1457,11 @@ sub PandoraFMS::Recon::Base::report_scanned_agents($;$) {
} else {
# Create module - Direct.
my $name = $module->{'name'};
my $description = safe_output($module->{'descripcion'});
my $unit = safe_output($module->{'unit'});
$unit = '' if is_empty($unit);
delete $module->{'name'};
delete $module->{'description'};
$agentmodule_id = pandora_create_module_from_hash(
@ -1286,7 +1473,8 @@ sub PandoraFMS::Recon::Base::report_scanned_agents($;$) {
'nombre' => safe_input($name),
'descripcion' => safe_input($description),
'id_agente' => $agent_id,
'ip_target' => $data->{'agent'}{'direccion'}
'ip_target' => $data->{'agent'}{'direccion'},
'unit' => safe_input($unit)
},
$self->{'dbh'}
);

@ -33,7 +33,7 @@ use base 'Exporter';
our @ISA = qw(Exporter);
# version: Defines actual version of Pandora Server for this module only
my $pandora_version = "7.0NG.762";
my $pandora_version = "7.0NG.763";
my $pandora_build = "220623";
our $VERSION = $pandora_version." ".$pandora_build;

@ -2,8 +2,8 @@
# Pandora FMS Server
#
%define name pandorafms_server
%define version 7.0NG.762
%define release 220623
%define version 7.0NG.763
%define release 1
Summary: Pandora FMS Server
Name: %{name}

@ -2,8 +2,8 @@
# Pandora FMS Server
#
%define name pandorafms_server
%define version 7.0NG.762
%define release 220623
%define version 7.0NG.763
%define release 1
Summary: Pandora FMS Server
Name: %{name}

@ -8,7 +8,7 @@
# This code is licensed under GPL 2.0 license.
# **********************************************************************
PI_VERSION="7.0NG.762"
PI_VERSION="7.0NG.763"
PI_BUILD="220623"
MODE=$1

@ -35,7 +35,7 @@ use PandoraFMS::Config;
use PandoraFMS::DB;
# version: define current version
my $version = "7.0NG.762 Build 220623";
my $version = "7.0NG.763 Build 220623";
# Pandora server configuration
my %conf;

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

0
pandora_server/util/plugin/pandora_snmp_bandwidth.pl Normal file → Executable file