Merge branch 'develop' into 'ent-7482-Integracion-Pandora-Integria-credenciales-de-usuario'
# Conflicts: # pandora_console/extras/mr/47.sql # pandora_console/operation/incidents/dashboard_detail_integriaims_incident.php
This commit is contained in:
commit
caaa9c407e
|
@ -270,10 +270,10 @@ vmware_dependencies=" \
|
|||
execute_cmd "yum install -y $vmware_dependencies" "Installing SDK VMware perl dependencies"
|
||||
|
||||
# Instant client Oracle
|
||||
oracle_dependencier=" \
|
||||
oracle_dependencies=" \
|
||||
https://download.oracle.com/otn_software/linux/instantclient/19800/oracle-instantclient19.8-basic-19.8.0.0.0-1.x86_64.rpm \
|
||||
https://download.oracle.com/otn_software/linux/instantclient/19800/oracle-instantclient19.8-sqlplus-19.8.0.0.0-1.x86_64.rpm"
|
||||
execute_cmd "yum install -y $vmware_dependencies" "Installing Oracle Instant client"
|
||||
execute_cmd "yum install -y $oracle_dependencies" "Installing Oracle Instant client"
|
||||
|
||||
# Disabling SELINUX and firewalld
|
||||
setenforce 0
|
||||
|
|
|
@ -160,9 +160,9 @@ echo "Updating Pandora Server version..."
|
|||
sed -i -e "s/my\s\s*\$pandora_version\s*=.*/my \$pandora_version = \"$VERSION\";/" "$SERVER_FILE"
|
||||
sed -i -e "s/my\s\s*\$pandora_build\s*=.*/my \$pandora_build = \"$BUILD\";/" "$SERVER_FILE"
|
||||
echo "Updating DB maintenance script version..."
|
||||
sed -i -e "s/my\s\s*\$version\s*=.*/my \$version = \"$VERSION PS$BUILD\";/" "$SERVER_DB_FILE"
|
||||
sed -i -e "s/my\s\s*\$version\s*=.*/my \$version = \"$VERSION Build $BUILD\";/" "$SERVER_DB_FILE"
|
||||
echo "Updating CLI script version..."
|
||||
sed -i -e "s/my\s\s*\$version\s*=.*/my \$version = \"$VERSION PS$BUILD\";/" "$SERVER_CLI_FILE"
|
||||
sed -i -e "s/my\s\s*\$version\s*=.*/my \$version = \"$VERSION Build $BUILD\";/" "$SERVER_CLI_FILE"
|
||||
sed -i -e "s/\s*\#\s*\Version.*/\# Version $VERSION/" "$SERVER_CONF_FILE"
|
||||
sed -i -e "s/\s*\!define PRODUCT_VERSION.*/\!define PRODUCT_VERSION \"$VERSION\"/" "$SERVER_WIN_MPI_OPEN_FILE"
|
||||
sed -i -e "s/\s*\!define PRODUCT_VERSION.*/\!define PRODUCT_VERSION \"$VERSION\"/" "$SERVER_WIN_MPI_ENT_FILE"
|
||||
|
@ -197,7 +197,7 @@ echo "Updating Pandora Unix Agent version..."
|
|||
sed -i -e "s/\s*use\s*constant\s*AGENT_VERSION =>.*/use constant AGENT_VERSION => '$VERSION';/" "$AGENT_UNIX_FILE"
|
||||
sed -i -e "s/\s*use\s*constant\s*AGENT_BUILD =>.*/use constant AGENT_BUILD => '$BUILD';/" "$AGENT_UNIX_FILE"
|
||||
echo "Updating Pandora Windows Agent version..."
|
||||
sed -i -e "s/\s*#define\s*PANDORA_VERSION\s*.*/#define PANDORA_VERSION (\"$VERSION(Build $BUILD)\")/" "$AGENT_WIN_FILE"
|
||||
sed -i -e "s/\s*#define\s*PANDORA_VERSION\s*.*/#define PANDORA_VERSION (\"$VERSION Build $BUILD\")/" "$AGENT_WIN_FILE"
|
||||
sed -i -e "s/{Pandora FMS Windows Agent v.*}/{Pandora FMS Windows Agent v$VERSION}/" "$AGENT_WIN_MPI_FILE"
|
||||
NUMERIC_VERSION=$(echo $VERSION | sed -e "s/\([0-9]*\.[0-9]*\).*/\1/")
|
||||
sed -i -n "1h;1!H;\${;g;s/[\r\n]InstallVersion[\r\n]{\S*}/\nInstallVersion\n{$NUMERIC_VERSION.0.0}/g;p;}" "$AGENT_WIN_MPI_FILE"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
package: pandorafms-agent-unix
|
||||
Version: 7.0NG.754-210504
|
||||
Version: 7.0NG.754-210513
|
||||
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.754-210504"
|
||||
pandora_version="7.0NG.754-210513"
|
||||
|
||||
echo "Test if you has the tools for to make the packages."
|
||||
whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null
|
||||
|
|
|
@ -1015,7 +1015,7 @@ my $Sem = undef;
|
|||
my $ThreadSem = undef;
|
||||
|
||||
use constant AGENT_VERSION => '7.0NG.754';
|
||||
use constant AGENT_BUILD => '210504';
|
||||
use constant AGENT_BUILD => '210513';
|
||||
|
||||
# Agent log default file size maximum and instances
|
||||
use constant DEFAULT_MAX_LOG_SIZE => 600000;
|
||||
|
@ -1229,7 +1229,8 @@ use constant MAX_LOOP_COUNTER => 1000000000;
|
|||
# Print usage information and exit.
|
||||
################################################################################
|
||||
sub print_usage () {
|
||||
print "\nUsage: $0 <Pandora home>\n\n";
|
||||
print "Pandora FMS Agent for Linux v" . AGENT_VERSION . " Build " . AGENT_BUILD . "\n\n";
|
||||
print "Usage: $0 <Pandora home>\n\n";
|
||||
print "\tPandora home is the directory where pandora_agent.conf is located,\n";
|
||||
print "\tby default /etc/pandora.\n\n";
|
||||
exit 1;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#
|
||||
%define name pandorafms_agent_unix
|
||||
%define version 7.0NG.754
|
||||
%define release 210504
|
||||
%define release 210513
|
||||
|
||||
Summary: Pandora FMS Linux agent, PERL version
|
||||
Name: %{name}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#
|
||||
%define name pandorafms_agent_unix
|
||||
%define version 7.0NG.754
|
||||
%define release 210504
|
||||
%define release 210513
|
||||
|
||||
Summary: Pandora FMS Linux agent, PERL version
|
||||
Name: %{name}
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
# **********************************************************************
|
||||
|
||||
PI_VERSION="7.0NG.754"
|
||||
PI_BUILD="210504"
|
||||
PI_BUILD="210513"
|
||||
OS_NAME=`uname -s`
|
||||
|
||||
FORCE=0
|
||||
|
@ -152,8 +152,8 @@ uninstall () {
|
|||
fi
|
||||
|
||||
# Stops the agent on uninstall
|
||||
if [ -f $PANDORA_BASE/etc/init.d/pandora_agent_daemon ]; then
|
||||
$PANDORA_BASE/etc/init.d/pandora_agent_daemon stop 12> /dev/null
|
||||
if [ -f /etc/init.d/pandora_agent_daemon ]; then
|
||||
/etc/init.d/pandora_agent_daemon stop 12> /dev/null
|
||||
else
|
||||
echo "$PANDORA_BASE/etc/init.d/pandora_agent_daemon not found to stop agent"
|
||||
fi
|
||||
|
|
|
@ -186,7 +186,7 @@ UpgradeApplicationID
|
|||
{}
|
||||
|
||||
Version
|
||||
{210504}
|
||||
{210513}
|
||||
|
||||
ViewReadme
|
||||
{Yes}
|
||||
|
|
|
@ -115,8 +115,8 @@ main (int argc, char *argv[]) {
|
|||
return 0;
|
||||
} else if (_stricmp(argv[i], HELP_CMDLINE_PARAM) == 0) {
|
||||
/* Help parameter */
|
||||
cout << "Pandora agent for Windows. ";
|
||||
cout << "Version " << getPandoraAgentVersion () << endl;
|
||||
cout << "Pandora agent for Windows ";
|
||||
cout << "v" << getPandoraAgentVersion () << endl << endl;
|
||||
cout << "Usage: " << argv[0] << " [OPTION]" << endl << endl;
|
||||
cout << "Available options are:" << endl;
|
||||
cout << "\t" << SERVICE_INSTALL_CMDLINE_PARAM;
|
||||
|
|
|
@ -30,7 +30,7 @@ using namespace Pandora;
|
|||
using namespace Pandora_Strutils;
|
||||
|
||||
#define PATH_SIZE _MAX_PATH+1
|
||||
#define PANDORA_VERSION ("7.0NG.754(Build 210504)")
|
||||
#define PANDORA_VERSION ("7.0NG.754 Build 210513")
|
||||
|
||||
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.754(Build 210504))"
|
||||
VALUE "ProductVersion", "(7.0NG.754(Build 210513))"
|
||||
VALUE "FileVersion", "1.0.0.0"
|
||||
END
|
||||
END
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
package: pandorafms-console
|
||||
Version: 7.0NG.754-210504
|
||||
Version: 7.0NG.754-210513
|
||||
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.754-210504"
|
||||
pandora_version="7.0NG.754-210513"
|
||||
|
||||
package_pear=0
|
||||
package_pandora=1
|
||||
|
|
|
@ -42,6 +42,10 @@ function pandora_realtime_graphs()
|
|||
global $config;
|
||||
check_login();
|
||||
|
||||
if ($config['style'] === 'pandora_black') {
|
||||
ui_require_css_file('pandora_black', 'include/styles/', true);
|
||||
}
|
||||
|
||||
$id_network = get_parameter('id_network', 0);
|
||||
$action = get_parameter('action', 'list');
|
||||
|
||||
|
@ -66,8 +70,8 @@ function pandora_realtime_graphs()
|
|||
$long_index = [];
|
||||
$no_data_image = '';
|
||||
|
||||
$canvas = '<div id="graph_container">';
|
||||
$canvas .= '<div id="chartLegend"></div>';
|
||||
$canvas = '<div id="graph_container" class="graph_container">';
|
||||
$canvas .= '<div id="chartLegend" class="chartLegend"></div>';
|
||||
|
||||
$width = 800;
|
||||
$height = 300;
|
||||
|
@ -239,7 +243,9 @@ function pandora_realtime_graphs()
|
|||
|
||||
echo '<script type="text/javascript" src="'.ui_get_full_url('include/javascript/pandora_snmp_browser.js').'"></script>';
|
||||
echo '<script type="text/javascript" src="'.ui_get_full_url('extensions/realtime_graphs/realtime_graphs.js').'"></script>';
|
||||
echo '<link rel="stylesheet" type="text/css" href="'.ui_get_full_url('extensions/realtime_graphs/realtime_graphs.css').'"></style>';
|
||||
if ($config['style'] !== 'pandora_black') {
|
||||
echo '<link rel="stylesheet" type="text/css" href="'.ui_get_full_url('extensions/realtime_graphs/realtime_graphs.css').'"></style>';
|
||||
}
|
||||
|
||||
// Store servers timezone offset to be retrieved from js.
|
||||
set_js_value('timezone_offset', date('Z', time()));
|
||||
|
|
|
@ -74,6 +74,10 @@ enterprise/extensions/ipam
|
|||
enterprise/extensions/disabled/visual_console_manager.php
|
||||
enterprise/extensions/visual_console_manager.php
|
||||
pandora_console/extensions/net_tools.php
|
||||
enterprise/godmode/agentes/module_manager_editor_web.php
|
||||
enterprise/include/ajax/web_server_module_debug.php
|
||||
enterprise/include/class/WebServerModuleDebug.class.php
|
||||
enterprise/include/styles/WebServerModuleDebug.css
|
||||
include/lib/WSManager.php
|
||||
include/lib/WebSocketServer.php
|
||||
include/lib/WebSocketUser.php
|
||||
|
|
|
@ -5,5 +5,10 @@ ALTER TABLE `tusuario` ADD COLUMN `integria_user_level_pass` VARCHAR(45);
|
|||
ALTER TABLE `tperfil` DROP COLUMN `incident_view`;
|
||||
ALTER TABLE `tperfil` DROP COLUMN `incident_edit`;
|
||||
ALTER TABLE `tperfil` DROP COLUMN `incident_management`;
|
||||
ALTER TABLE `talert_snmp_action` ADD COLUMN `al_field16` TEXT NOT NULL AFTER `al_field15`;
|
||||
ALTER TABLE `talert_snmp_action` ADD COLUMN `al_field17` TEXT NOT NULL AFTER `al_field16`;
|
||||
ALTER TABLE `talert_snmp_action` ADD COLUMN `al_field18` TEXT NOT NULL AFTER `al_field17`;
|
||||
ALTER TABLE `talert_snmp_action` ADD COLUMN `al_field19` TEXT NOT NULL AFTER `al_field18`;
|
||||
ALTER TABLE `talert_snmp_action` ADD COLUMN `al_field20` TEXT NOT NULL AFTER `al_field19`;
|
||||
|
||||
COMMIT;
|
||||
|
|
|
@ -1334,6 +1334,11 @@ ALTER TABLE talert_snmp_action ADD COLUMN `al_field12` TEXT NOT NULL DEFAULT "";
|
|||
ALTER TABLE talert_snmp_action ADD COLUMN `al_field13` TEXT NOT NULL DEFAULT "";
|
||||
ALTER TABLE talert_snmp_action ADD COLUMN `al_field14` TEXT NOT NULL DEFAULT "";
|
||||
ALTER TABLE talert_snmp_action ADD COLUMN `al_field15` TEXT NOT NULL DEFAULT "";
|
||||
ALTER TABLE `talert_snmp_action` ADD COLUMN `al_field16` TEXT NOT NULL AFTER `al_field15`;
|
||||
ALTER TABLE `talert_snmp_action` ADD COLUMN `al_field17` TEXT NOT NULL AFTER `al_field16`;
|
||||
ALTER TABLE `talert_snmp_action` ADD COLUMN `al_field18` TEXT NOT NULL AFTER `al_field17`;
|
||||
ALTER TABLE `talert_snmp_action` ADD COLUMN `al_field19` TEXT NOT NULL AFTER `al_field18`;
|
||||
ALTER TABLE `talert_snmp_action` ADD COLUMN `al_field20` TEXT NOT NULL AFTER `al_field19`;
|
||||
|
||||
-- ----------------------------------------------------------------------
|
||||
-- Table `tserver`
|
||||
|
|
|
@ -15,14 +15,14 @@ global $config;
|
|||
check_login();
|
||||
ui_require_css_file('first_task');
|
||||
?>
|
||||
<?php ui_print_info_message(['no_close' => true, 'message' => __('There are no planned downtime defined yet.') ]); ?>
|
||||
<?php ui_print_info_message(['no_close' => true, 'message' => __('There are no scheduled downtime defined yet.') ]); ?>
|
||||
|
||||
<div class="new_task">
|
||||
<div class="image_task">
|
||||
<?php echo html_print_image('images/first_task/icono_grande_visualconsole.png', true, ['title' => __('Planned Downtime')]); ?>
|
||||
<?php echo html_print_image('images/first_task/icono_grande_visualconsole.png', true, ['title' => __('Scehduled Downtime')]); ?>
|
||||
</div>
|
||||
<div class="text_task">
|
||||
<h3> <?php echo __('Create Planned Downtime'); ?></h3><p id="description_task">
|
||||
<h3> <?php echo __('Create Scheduled Downtime'); ?></h3><p id="description_task">
|
||||
<?php
|
||||
echo __(
|
||||
"%s contains a scheduled downtime management system.
|
||||
|
@ -34,7 +34,7 @@ ui_require_css_file('first_task');
|
|||
?>
|
||||
</p>
|
||||
<form action="index.php?sec=extensions&sec2=godmode/agentes/planned_downtime.editor" method="post">
|
||||
<input type="submit" class="button_task" value="<?php echo __('Create Planned Downtime'); ?>" />
|
||||
<input type="submit" class="button_task" value="<?php echo __('Create Scheduled Downtime'); ?>" />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -1004,9 +1004,9 @@ echo '<div class="action-buttons agent_manager" style="width: '.$table->width.'"
|
|||
|
||||
// The context help about the learning mode.
|
||||
if ($modo == 0) {
|
||||
echo "<span id='modules_not_learning_mode_context_help pdd_r_10px' '>";
|
||||
echo "<span id='modules_not_learning_mode_context_help' class='pdd_r_10px'>";
|
||||
} else {
|
||||
echo "<span id='modules_not_learning_mode_context_help invisible'>";
|
||||
echo "<span id='modules_not_learning_mode_context_help' class='invisible'>";
|
||||
}
|
||||
|
||||
echo clippy_context_help('modules_not_learning_mode');
|
||||
|
|
|
@ -746,9 +746,9 @@ if ($agents !== false) {
|
|||
|
||||
if ($in_planned_downtime) {
|
||||
ui_print_help_tip(
|
||||
__('Agent in planned downtime'),
|
||||
__('Agent in scheduled downtime'),
|
||||
false,
|
||||
$config['image']['minireloj_16']
|
||||
'images/minireloj-16.png'
|
||||
);
|
||||
|
||||
echo '</em>';
|
||||
|
|
|
@ -1,22 +1,38 @@
|
|||
<?php
|
||||
/**
|
||||
* Module Manager main script.
|
||||
*
|
||||
* @category Module
|
||||
* @package Pandora FMS
|
||||
* @subpackage Agent Configuration
|
||||
* @version 1.0.0
|
||||
* @license See below
|
||||
*
|
||||
* ______ ___ _______ _______ ________
|
||||
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
|
||||
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
|
||||
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
|
||||
*
|
||||
* ============================================================================
|
||||
* Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
|
||||
* Please see http://pandorafms.org for full contribution list
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation for version 2.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* ============================================================================
|
||||
*/
|
||||
|
||||
// Pandora FMS - http://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
|
||||
// Please see http://pandorafms.org for full contribution list
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation for version 2.
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
// You can redefine $url and unset $id_agente to reuse the form. Dirty (hope temporal) hack
|
||||
if (isset($id_agente)) {
|
||||
$url = 'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=module&id_agente='.$id_agente;
|
||||
} else {
|
||||
$url = 'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=module';
|
||||
}
|
||||
// You can redefine $url and unset $id_agente to reuse the form. Dirty (hope temporal) hack.
|
||||
$url_id_agente = (isset($id_agente) === true) ? '&id_agente='.$id_agente : '';
|
||||
|
||||
$url = sprintf(
|
||||
'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=module%s',
|
||||
$url_id_agente
|
||||
);
|
||||
|
||||
enterprise_include('godmode/agentes/module_manager.php');
|
||||
$isFunctionPolicies = enterprise_include_once('include/functions_policies.php');
|
||||
|
@ -56,7 +72,7 @@ echo __('Search').' '.html_print_input_text(
|
|||
);
|
||||
html_print_input_hidden('search', 1);
|
||||
// Search string filter form.
|
||||
if (($policy_page) || (isset($agent))) {
|
||||
if (($policy_page !== false) || (isset($agent) === true)) {
|
||||
echo '<form id="" method="post" action="">';
|
||||
} else {
|
||||
echo '<form id="create_module_type" method="post" action="'.$url.'">';
|
||||
|
@ -73,25 +89,31 @@ echo '</form>';
|
|||
$network_available = db_get_sql(
|
||||
'SELECT count(*)
|
||||
FROM tserver
|
||||
WHERE server_type = 1'
|
||||
WHERE server_type = '.SERVER_TYPE_NETWORK
|
||||
);
|
||||
// POSTGRESQL AND ORACLE COMPATIBLE.
|
||||
$wmi_available = db_get_sql(
|
||||
'SELECT count(*)
|
||||
FROM tserver
|
||||
WHERE server_type = 6'
|
||||
WHERE server_type = '.SERVER_TYPE_WMI
|
||||
);
|
||||
// POSTGRESQL AND ORACLE COMPATIBLE.
|
||||
$plugin_available = db_get_sql(
|
||||
'SELECT count(*)
|
||||
FROM tserver
|
||||
WHERE server_type = 4'
|
||||
WHERE server_type = '.SERVER_TYPE_PLUGIN
|
||||
);
|
||||
// POSTGRESQL AND ORACLE COMPATIBLE.
|
||||
$prediction_available = db_get_sql(
|
||||
'SELECT count(*)
|
||||
FROM tserver
|
||||
WHERE server_type = 5'
|
||||
WHERE server_type = '.SERVER_TYPE_PREDICTION
|
||||
);
|
||||
// POSTGRESQL AND ORACLE COMPATIBLE.
|
||||
$web_available = db_get_sql(
|
||||
'SELECT count(*)
|
||||
FROM tserver
|
||||
WHERE server_type = '.SERVER_TYPE_WEB
|
||||
);
|
||||
// POSTGRESQL AND ORACLE COMPATIBLE.
|
||||
// Development mode to use all servers.
|
||||
|
@ -122,6 +144,10 @@ if ($prediction_available) {
|
|||
$modules['predictionserver'] = __('Create a new prediction server module');
|
||||
}
|
||||
|
||||
if ($web_available) {
|
||||
$modules['webserver'] = __('Create a new web Server module');
|
||||
}
|
||||
|
||||
if (enterprise_installed()) {
|
||||
set_enterprise_module_types($modules);
|
||||
}
|
||||
|
@ -298,6 +324,7 @@ if ($module_action === 'delete') {
|
|||
switch ($config['dbtype']) {
|
||||
case 'mysql':
|
||||
case 'postgresql':
|
||||
default:
|
||||
$result = db_process_sql_delete(
|
||||
'tagente_estado',
|
||||
['id_agente_modulo' => $id_agent_module_del]
|
||||
|
@ -388,10 +415,8 @@ if ($module_action === 'delete') {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
// Check for errors.
|
||||
if ($error != 0) {
|
||||
} else {
|
||||
if ((int) $error == 0) {
|
||||
$count_correct_delete_modules++;
|
||||
}
|
||||
}
|
||||
|
@ -489,6 +514,7 @@ switch ($sortField) {
|
|||
switch ($config['dbtype']) {
|
||||
case 'mysql':
|
||||
case 'postgresql':
|
||||
default:
|
||||
$order[] = [
|
||||
'field' => 'tagente_modulo.nombre',
|
||||
'order' => 'ASC',
|
||||
|
@ -509,6 +535,7 @@ switch ($sortField) {
|
|||
switch ($config['dbtype']) {
|
||||
case 'mysql':
|
||||
case 'postgresql':
|
||||
default:
|
||||
$order[] = [
|
||||
'field' => 'tagente_modulo.nombre',
|
||||
'order' => 'DESC',
|
||||
|
@ -523,6 +550,10 @@ switch ($sortField) {
|
|||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
// Do none.
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -543,6 +574,10 @@ switch ($sortField) {
|
|||
'order' => 'DESC',
|
||||
];
|
||||
break;
|
||||
|
||||
default:
|
||||
// Do none.
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -563,6 +598,10 @@ switch ($sortField) {
|
|||
'order' => 'DESC',
|
||||
];
|
||||
break;
|
||||
|
||||
default:
|
||||
// Do none.
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -583,6 +622,10 @@ switch ($sortField) {
|
|||
'order' => 'DESC',
|
||||
];
|
||||
break;
|
||||
|
||||
default:
|
||||
// Do none.
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -598,6 +641,7 @@ switch ($sortField) {
|
|||
switch ($config['dbtype']) {
|
||||
case 'mysql':
|
||||
case 'postgresql':
|
||||
default:
|
||||
$order[] = [
|
||||
'field' => 'nombre',
|
||||
'order' => 'ASC',
|
||||
|
@ -622,7 +666,7 @@ if (!empty($order)) {
|
|||
|
||||
$first = true;
|
||||
foreach ($order as $ord) {
|
||||
if ($first) {
|
||||
if ($first === true) {
|
||||
$first = false;
|
||||
} else {
|
||||
$order_sql .= ',';
|
||||
|
@ -635,31 +679,35 @@ foreach ($order as $ord) {
|
|||
$limit = (int) $config['block_size'];
|
||||
$offset = (int) get_parameter('offset');
|
||||
|
||||
$params = ($checked) ? 'tagente_modulo.*, tmodule_group.*' : implode(
|
||||
',',
|
||||
[
|
||||
'tagente_modulo.id_agente_modulo',
|
||||
'id_tipo_modulo',
|
||||
'descripcion',
|
||||
'nombre',
|
||||
'max',
|
||||
'min',
|
||||
'module_interval',
|
||||
'id_modulo',
|
||||
'id_module_group',
|
||||
'disabled',
|
||||
'max_warning',
|
||||
'min_warning',
|
||||
'str_warning',
|
||||
'max_critical',
|
||||
'min_critical',
|
||||
'str_critical',
|
||||
'quiet',
|
||||
'critical_inverse',
|
||||
'warning_inverse',
|
||||
'id_policy_module',
|
||||
]
|
||||
);
|
||||
if ((bool) $checked === true) {
|
||||
$params = 'tagente_modulo.*, tmodule_group.*';
|
||||
} else {
|
||||
$params = implode(
|
||||
',',
|
||||
[
|
||||
'tagente_modulo.id_agente_modulo',
|
||||
'id_tipo_modulo',
|
||||
'descripcion',
|
||||
'nombre',
|
||||
'max',
|
||||
'min',
|
||||
'module_interval',
|
||||
'id_modulo',
|
||||
'id_module_group',
|
||||
'disabled',
|
||||
'max_warning',
|
||||
'min_warning',
|
||||
'str_warning',
|
||||
'max_critical',
|
||||
'min_critical',
|
||||
'str_critical',
|
||||
'quiet',
|
||||
'critical_inverse',
|
||||
'warning_inverse',
|
||||
'id_policy_module',
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
$where = sprintf('delete_pending = 0 AND id_agente = %s', $id_agente);
|
||||
|
||||
|
@ -686,7 +734,11 @@ if (isset($config['paginate_module'])) {
|
|||
|
||||
if ($paginate_module) {
|
||||
if (!isset($limit_sql)) {
|
||||
$limit_sql = " LIMIT $offset, $limit ";
|
||||
$limit_sql = sprintf(
|
||||
'LIMIT %s, %s',
|
||||
$offset,
|
||||
$limit
|
||||
);
|
||||
}
|
||||
} else {
|
||||
$limit_sql = '';
|
||||
|
@ -732,7 +784,13 @@ if ($modules === false) {
|
|||
}
|
||||
|
||||
// Prepare pagination.
|
||||
$url = '?'.'sec=gagente&'.'tab=module&'.'sec2=godmode/agentes/configurar_agente&'.'id_agente='.$id_agente.'&'.'sort_field='.$sortField.'&'.'&sort='.$sort.'&'.'search_string='.urlencode($search_string);
|
||||
$url = sprintf(
|
||||
'?sec=gagente&tab=module&sec2=godmode/agentes/configurar_agente&id_agente=%s&sort_field=%s&sort=%s&search_string=%s',
|
||||
$id_agente,
|
||||
$sortField,
|
||||
$sort,
|
||||
urlencode($search_string)
|
||||
);
|
||||
|
||||
if ($paginate_module) {
|
||||
ui_pagination($total_modules, $url);
|
||||
|
|
|
@ -682,6 +682,22 @@ switch ($moduletype) {
|
|||
include 'module_manager_editor_wmi.php';
|
||||
break;
|
||||
|
||||
case 'webserver':
|
||||
case MODULE_WEB:
|
||||
$moduletype = MODULE_WEB;
|
||||
// Remove content of $ip_target when it is ip_agent because
|
||||
// it is used as HTTP auth (server) ....ONLY IN NEW MODULE!!!
|
||||
if (empty($id_agent_module)
|
||||
&& ($ip_target === agents_get_address($id_agente))
|
||||
) {
|
||||
$ip_target = '';
|
||||
}
|
||||
|
||||
$categories = [9];
|
||||
include 'module_manager_editor_common.php';
|
||||
include 'module_manager_editor_web.php';
|
||||
break;
|
||||
|
||||
// WARNING: type 7 is reserved on enterprise.
|
||||
default:
|
||||
if (enterprise_include(
|
||||
|
|
|
@ -0,0 +1,468 @@
|
|||
<?php
|
||||
/**
|
||||
* Web Module Editor for Module Manager.
|
||||
*
|
||||
* @category Module manager
|
||||
* @package Pandora FMS
|
||||
* @subpackage Module manager
|
||||
* @version 1.0.0
|
||||
* @license See below
|
||||
*
|
||||
* ______ ___ _______ _______ ________
|
||||
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
|
||||
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
|
||||
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
|
||||
*
|
||||
* ============================================================================
|
||||
* Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
|
||||
* Please see http://pandorafms.org for full contribution list
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation for version 2.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* ============================================================================
|
||||
*/
|
||||
|
||||
// Begin.
|
||||
enterprise_include_once('include/functions_policies.php');
|
||||
|
||||
$disabledBecauseInPolicy = false;
|
||||
$disabledTextBecauseInPolicy = '';
|
||||
$classdisabledBecauseInPolicy = '';
|
||||
$page = get_parameter('page', '');
|
||||
if (strstr($page, 'policy_modules') === false) {
|
||||
if ($config['enterprise_installed']) {
|
||||
if (policies_is_module_linked($id_agent_module) == 1) {
|
||||
$disabledBecauseInPolicy = 1;
|
||||
} else {
|
||||
$disabledBecauseInPolicy = 0;
|
||||
}
|
||||
} else {
|
||||
$disabledBecauseInPolicy = false;
|
||||
}
|
||||
|
||||
if ($disabledBecauseInPolicy) {
|
||||
$disabledTextBecauseInPolicy = 'disabled = "disabled"';
|
||||
$classdisabledBecauseInPolicy = 'readonly';
|
||||
}
|
||||
}
|
||||
|
||||
global $id_agente;
|
||||
|
||||
$extra_title = __('Web server module');
|
||||
|
||||
// Div for modal.
|
||||
html_print_div(
|
||||
[
|
||||
'id' => 'modal',
|
||||
'style' => 'display: none;',
|
||||
]
|
||||
);
|
||||
|
||||
require_once $config['homedir'].'/include/ajax/web_server_module_debug.php';
|
||||
|
||||
define('ID_NETWORK_COMPONENT_TYPE', 7);
|
||||
|
||||
if (!$tcp_port && !$id_agent_module) {
|
||||
$tcp_port = 80;
|
||||
}
|
||||
|
||||
// plugin_server is the browser id
|
||||
if ($plugin_user == '' && !$id_agent_module) {
|
||||
$plugin_user = get_product_name().' / Webcheck';
|
||||
}
|
||||
|
||||
// plugin_server is the referer
|
||||
if ($plugin_pass == '' && !$id_agent_module) {
|
||||
$plugin_pass = 1;
|
||||
}
|
||||
|
||||
if (empty($update_module_id)) {
|
||||
// Function in module_manager_editor_common.php
|
||||
add_component_selection(ID_NETWORK_COMPONENT_TYPE);
|
||||
} else {
|
||||
// TODO: Print network component if available
|
||||
}
|
||||
|
||||
$data = [];
|
||||
$data[0] = __('Web checks');
|
||||
|
||||
$adopt = false;
|
||||
if (isset($id_agent_module)) {
|
||||
$adopt = enterprise_hook('policies_is_module_adopt', [$id_agent_module]);
|
||||
}
|
||||
|
||||
$id_policy_module = (int) get_parameter('id_policy_module', '');
|
||||
if ($id_policy_module) {
|
||||
$module = enterprise_hook('policies_get_module', [$id_policy_module]);
|
||||
$plugin_parameter = $module['plugin_parameter'];
|
||||
}
|
||||
|
||||
if ((bool) $adopt === false) {
|
||||
$data[1] = html_print_textarea(
|
||||
'plugin_parameter',
|
||||
15,
|
||||
65,
|
||||
$plugin_parameter,
|
||||
$disabledTextBecauseInPolicy,
|
||||
true
|
||||
);
|
||||
} else {
|
||||
$data[1] = html_print_textarea(
|
||||
'plugin_parameter',
|
||||
15,
|
||||
65,
|
||||
$plugin_parameter,
|
||||
false,
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
$table_simple->colspan['web_checks'][1] = 2;
|
||||
|
||||
// Disable debug button if module has not started.
|
||||
if ($id_agent_module > 0
|
||||
&& db_get_value_filter(
|
||||
'debug_content',
|
||||
'tagente_modulo',
|
||||
['id_agente_modulo' => $id_agent_module]
|
||||
) !== null
|
||||
) {
|
||||
$disableDebug = false;
|
||||
$hintDebug = __('Debug remotely this module');
|
||||
} else {
|
||||
$disableDebug = true;
|
||||
$hintDebug = __('Debug this module once it has been initialized');
|
||||
}
|
||||
|
||||
$suc_err_check = ' <span id="check_conf_suc" class="checks invisible">'.html_print_image('/images/ok.png', true).'</span>';
|
||||
$suc_err_check .= ' <span id="check_conf_err" class="checks invisible">'.html_print_image('/images/error_red.png', true).'</span>';
|
||||
$data[2] = html_print_button(
|
||||
__('Load basic'),
|
||||
'btn_loadbasic',
|
||||
false,
|
||||
'',
|
||||
'class="sub config"',
|
||||
true
|
||||
).ui_print_help_tip(__('Load a basic structure on Web Checks'), true);
|
||||
$data[2] .= '<br><br>'.html_print_button(
|
||||
__('Check'),
|
||||
'btn_checkconf',
|
||||
false,
|
||||
'',
|
||||
'class="sub upd"',
|
||||
true
|
||||
).ui_print_help_tip(__('Check the correct structure of the WebCheck'), true).$suc_err_check;
|
||||
$data[2] .= '<br><br>'.html_print_button(
|
||||
__('Debug'),
|
||||
'btn_debugModule',
|
||||
$disableDebug,
|
||||
'',
|
||||
'class="sub config" onClick="loadDebugWindow()"',
|
||||
true
|
||||
).ui_print_help_tip($hintDebug, true);
|
||||
|
||||
|
||||
push_table_simple($data, 'web_checks');
|
||||
|
||||
$http_checks_type = [
|
||||
0 => 'Anyauth',
|
||||
1 => 'NTLM',
|
||||
2 => 'DIGEST',
|
||||
3 => 'BASIC',
|
||||
];
|
||||
|
||||
$data = [];
|
||||
$data[0] = __('Check type');
|
||||
$data[1] = html_print_select($http_checks_type, 'tcp_port', $tcp_port, false, '', '', true, false, false);
|
||||
|
||||
push_table_advanced($data, 'web_0');
|
||||
|
||||
$data = [];
|
||||
$data[0] = __('Requests');
|
||||
$data[1] = html_print_input_text('plugin_pass', $plugin_pass, '', 10, 0, true, $disabledBecauseInPolicy, false, '', $classdisabledBecauseInPolicy);
|
||||
$data[2] = '';
|
||||
$data[3] = __('Agent browser id');
|
||||
$data[4] = html_print_input_text('plugin_user', $plugin_user, '', 30, 0, true, $disabledBecauseInPolicy, false, '', $classdisabledBecauseInPolicy);
|
||||
|
||||
push_table_advanced($data, 'web_1');
|
||||
|
||||
$data = [];
|
||||
$data[0] = __('HTTP auth (login)');
|
||||
$data[1] = html_print_input_text('http_user', $plugin_parameter_http_user, '', 10, 0, true, $disabledBecauseInPolicy, false, '', $classdisabledBecauseInPolicy);
|
||||
$data[2] = '';
|
||||
$data[3] = __('HTTP auth (password)');
|
||||
$data[4] = html_print_input_password('http_pass', $plugin_parameter_http_pass, '', 30, 0, true, $disabledBecauseInPolicy, false, '', $classdisabledBecauseInPolicy);
|
||||
|
||||
push_table_advanced($data, 'web_2');
|
||||
|
||||
$data = [];
|
||||
|
||||
$data[0] = __('Proxy URL');
|
||||
$data[1] = html_print_input_text('snmp_oid', $snmp_oid, '', 30, 0, true, $disabledBecauseInPolicy, false, '', $classdisabledBecauseInPolicy);
|
||||
$data[2] = $data[3] = $data[4] = '';
|
||||
push_table_advanced($data, 'web_3');
|
||||
|
||||
$data = [];
|
||||
|
||||
$data[0] = __('Proxy auth (login)');
|
||||
$data[1] = html_print_input_text('tcp_send', $tcp_send, '', 30, 0, true, $disabledBecauseInPolicy, false, '', $classdisabledBecauseInPolicy);
|
||||
|
||||
$data[2] = '';
|
||||
$data[3] = __('Proxy auth (pass)');
|
||||
$data[4] = html_print_input_password('tcp_rcv', $tcp_rcv, '', 30, 0, true, $disabledBecauseInPolicy, false, '', $classdisabledBecauseInPolicy);
|
||||
|
||||
push_table_advanced($data, 'web_4');
|
||||
|
||||
$data = [];
|
||||
|
||||
$data[0] = __('Proxy auth (server)');
|
||||
$data[1] = html_print_input_text('ip_target', $ip_target, '', 30, 100, true, $disabledBecauseInPolicy, false, '', $classdisabledBecauseInPolicy);
|
||||
|
||||
$data[2] = '';
|
||||
$data[3] = __('Proxy auth (realm)');
|
||||
$data[4] = html_print_input_text('snmp_community', $snmp_community, '', 30, 100, true, $disabledBecauseInPolicy, false, '', $classdisabledBecauseInPolicy);
|
||||
|
||||
push_table_advanced($data, 'web_5');
|
||||
|
||||
// Add some strings to be used from javascript
|
||||
$texts = [
|
||||
'lines_before_begin' => __('First line must be "task_begin"'),
|
||||
'missed_begin' => __('Webchecks configuration is empty'),
|
||||
'missed_end' => __('Last line must be "task_end"'),
|
||||
'lines_after_end' => __('Last line must be "task_end"'),
|
||||
'unknown_token' => __("There is a line with a unknown token 'token_fail'."),
|
||||
'missed_get_post' => __("There isn't get or post"),
|
||||
'correct' => __('Web checks are built correctly'),
|
||||
];
|
||||
|
||||
foreach ($texts as $code => $text) {
|
||||
echo '<span class="invisible" id="'.$code.'">'.$text.'</span>';
|
||||
}
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
var supported_tokens = [
|
||||
"task_begin",
|
||||
"post",
|
||||
"variable_name",
|
||||
"variable_value",
|
||||
"cookie",
|
||||
"resource",
|
||||
"get",
|
||||
"check_string",
|
||||
"check_not_string",
|
||||
"get_content_advanced",
|
||||
"get_content",
|
||||
"debug",
|
||||
"task_end",
|
||||
"head",
|
||||
"http_auth_user",
|
||||
"http_auth_pass"
|
||||
];
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
var plugin_parameter = $("#textarea_plugin_parameter");
|
||||
var http_auth_user = $('#text-http_user');
|
||||
var http_auth_pass = $('#password-http_pass');
|
||||
|
||||
$(plugin_parameter).keyup(function() {
|
||||
|
||||
// Check and fill textbox.
|
||||
if ($(plugin_parameter).val() == '') {
|
||||
$('#button-btn_loadbasic').removeAttr('disabled');
|
||||
} else {
|
||||
$('#button-btn_loadbasic').attr('disabled', 'disabled');
|
||||
}
|
||||
|
||||
// Update http_auth_user from conf data
|
||||
var http_auth_user_value = get_module_token_from_config('http_auth_user', plugin_parameter, "\n");
|
||||
if (http_auth_user_value != "") {
|
||||
http_auth_user.val(http_auth_user_value);
|
||||
}
|
||||
|
||||
// Update http_auth_pass from conf data
|
||||
var http_auth_pass_value = get_module_token_from_config('http_auth_pass', plugin_parameter, "\n");
|
||||
if (http_auth_pass_value != "") {
|
||||
http_auth_pass.val(http_auth_pass_value);
|
||||
}
|
||||
});
|
||||
|
||||
$('#button-btn_loadbasic').click(function() {
|
||||
if ($(plugin_parameter).val() != '') {
|
||||
return;
|
||||
}
|
||||
|
||||
$(plugin_parameter).val(
|
||||
'task_begin\ncookie 0\nresource 0\ntask_end');
|
||||
|
||||
$('#button-btn_loadbasic').attr('disabled', 'disabled');
|
||||
|
||||
// Hide success and error indicators
|
||||
$('.checks').hide();
|
||||
});
|
||||
|
||||
$('#button-btn_checkconf').click(function() {
|
||||
var msg_error = '';
|
||||
|
||||
if (plugin_parameter.val() == '') {
|
||||
msg_error = 'missed_begin';
|
||||
} else {
|
||||
var lines = plugin_parameter.val().split("\n");
|
||||
|
||||
var started = false;
|
||||
var ended = false;
|
||||
var lines_after_end = false;
|
||||
var lines_before_begin = false;
|
||||
var token_fail = false;
|
||||
var token_get_post = false;
|
||||
var token_check = true;
|
||||
var str_token_fail = '';
|
||||
|
||||
for (i = 0; i < lines.length; i++) {
|
||||
if (lines[i].match(/^\s*$/)) {
|
||||
// Empty line
|
||||
continue;
|
||||
} else if (!started) {
|
||||
if (lines[i].match(/^task_begin\s*$/)) {
|
||||
started = true;
|
||||
} else {
|
||||
// Found a not empty line before task_begin
|
||||
lines_before_begin = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (lines[i].match(/^task_end\s*$/)) {
|
||||
ended = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
//Check token is correct
|
||||
if (!lines[i].match(/^([\s])*[#]/)) {
|
||||
|
||||
var token = lines[i].match(/^([^\s]+)\s*/);
|
||||
|
||||
if (typeof(token) == 'object') {
|
||||
token = token[1];
|
||||
|
||||
if ((!token_get_post) && (token == 'get' || token == 'post' || token == 'header')) {
|
||||
token_get_post = true;
|
||||
continue;
|
||||
}
|
||||
if (token == 'check_string') {
|
||||
if (token_get_post) {
|
||||
token_check = true;
|
||||
continue;
|
||||
} else {
|
||||
token_check = false;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if ($.inArray(token, supported_tokens) == -1) {
|
||||
token_fail = true;
|
||||
str_token_fail = token;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var msg_error = '';
|
||||
|
||||
if (token_fail) {
|
||||
var temp_msg = $("#unknown_token").html();
|
||||
temp_msg = temp_msg.replace(/['](.*)[']/, "'" + str_token_fail + "'");
|
||||
|
||||
$("#unknown_token").html(temp_msg);
|
||||
|
||||
msg_error = 'unknown_token';
|
||||
} else if (lines_before_begin) {
|
||||
msg_error = 'lines_before_begin';
|
||||
} else if (!started) {
|
||||
msg_error = 'missed_begin';
|
||||
} else if (!ended) {
|
||||
msg_error = 'missed_end';
|
||||
} else if (lines_after_end) {
|
||||
msg_error = 'lines_after_end';
|
||||
} else if (!token_check) {
|
||||
msg_error = 'missed_get_post';
|
||||
} else {
|
||||
msg_error = 'correct';
|
||||
}
|
||||
|
||||
|
||||
if (msg_error == 'correct') {
|
||||
$('#check_conf_suc').find('img').eq(0)
|
||||
.attr('title', $('#' + msg_error).html());
|
||||
|
||||
$('#check_conf_err').hide();
|
||||
$('#check_conf_suc').show();
|
||||
} else {
|
||||
$('#check_conf_err').find('img').eq(0)
|
||||
.attr('title', $('#' + msg_error).html());
|
||||
|
||||
$('#check_conf_suc').hide();
|
||||
$('#check_conf_err').show();
|
||||
}
|
||||
});
|
||||
|
||||
$(plugin_parameter).trigger('keyup');
|
||||
|
||||
http_auth_user.keyup(function() {
|
||||
config = plugin_parameter.val();
|
||||
if (config.search("http_auth_user") == -1) {
|
||||
var http_auth_user_end =
|
||||
"http_auth_user " + this.value + "\n" + "task_end" + "\n";
|
||||
plugin_parameter.val(config.replace(/^task_end.*$/m, http_auth_user_end));
|
||||
} else {
|
||||
plugin_parameter.val(
|
||||
config.replace(/^http_auth_user.*$/m, "http_auth_user " + this.value)
|
||||
);
|
||||
// Hide success and error indicators
|
||||
$(".checks").hide();
|
||||
}
|
||||
});
|
||||
|
||||
http_auth_pass.keyup(function() {
|
||||
config = plugin_parameter.val();
|
||||
if (config.search("http_auth_pass") == -1) {
|
||||
var http_auth_pass_end =
|
||||
"http_auth_pass " + this.value + "\n" + "task_end" + "\n";
|
||||
plugin_parameter.val(config.replace(/^task_end.*$/m, http_auth_pass_end));
|
||||
} else {
|
||||
plugin_parameter.val(
|
||||
config.replace(/^http_auth_pass.*$/m, "http_auth_pass " + this.value)
|
||||
);
|
||||
// Hide success and error indicators
|
||||
$(".checks").hide();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function get_module_token_from_config(token_name, plugin_parameter, separator) {
|
||||
var return_var = "";
|
||||
if(token_name == null || token_name == '') {
|
||||
return '';
|
||||
}
|
||||
|
||||
data = plugin_parameter.val().split(separator);
|
||||
len = data.length;
|
||||
for (i = 0; i < len; i++) {
|
||||
if (data[i][0] == "#") continue;
|
||||
tokens = data[i].split(" ");
|
||||
if (tokens.length == 0) continue;
|
||||
token = tokens.shift();
|
||||
if (token == token_name ) return_var = tokens.join(" ");
|
||||
}
|
||||
|
||||
return_var = $.trim(return_var);
|
||||
|
||||
return return_var;
|
||||
}
|
||||
|
||||
</script>
|
|
@ -64,7 +64,7 @@ $buttons = [
|
|||
|
||||
// Header.
|
||||
ui_print_page_header(
|
||||
__('Planned Downtime'),
|
||||
__('Scheduled Downtime'),
|
||||
'images/gm_monitoring.png',
|
||||
false,
|
||||
'',
|
||||
|
@ -308,12 +308,12 @@ if ($create_downtime || $update_downtime) {
|
|||
);
|
||||
} else {
|
||||
ui_print_error_message(
|
||||
__('Each planned downtime must have a different name')
|
||||
__('Each scheduled downtime must have a different name')
|
||||
);
|
||||
}
|
||||
} else {
|
||||
ui_print_error_message(
|
||||
__('Planned downtime must have a name')
|
||||
__('Scheduled downtime must have a name')
|
||||
);
|
||||
}
|
||||
} else if ($update_downtime) {
|
||||
|
@ -345,7 +345,7 @@ if ($create_downtime || $update_downtime) {
|
|||
$values = [];
|
||||
if (trim(io_safe_output($name)) == '') {
|
||||
ui_print_error_message(
|
||||
__('Planned downtime must have a name')
|
||||
__('Scheduled downtime must have a name')
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -1489,14 +1489,14 @@ function insert_downtime_agent($id_downtime, $user_groups_ad)
|
|||
$(this).css ("width", "180px");
|
||||
});
|
||||
|
||||
// Warning message about the problems caused updating a past planned downtime
|
||||
// Warning message about the problems caused updating a past scheduled downtime
|
||||
var type_execution = "<?php echo $type_execution; ?>";
|
||||
var datetime_from = <?php echo json_encode(strtotime($once_date_from.' '.$once_time_from)); ?>;
|
||||
var datetime_now = <?php echo json_encode($utimestamp); ?>;
|
||||
var create = <?php echo json_encode($create); ?>;
|
||||
if (!create && (type_execution == 'periodically' || (type_execution == 'once' && datetime_from < datetime_now))) {
|
||||
$("input#submit-updbutton, input#submit-add_item, table#list a").click(function (e) {
|
||||
if (!confirm("<?php echo __('WARNING: If you edit this planned downtime, the data of future SLA reports may be altered'); ?>")) {
|
||||
if (!confirm("<?php echo __('WARNING: If you edit this scheduled downtime, the data of future SLA reports may be altered'); ?>")) {
|
||||
e.preventDefault();
|
||||
}
|
||||
});
|
||||
|
|
|
@ -196,5 +196,5 @@ if (!empty($downtimes)) {
|
|||
echo chr(13);
|
||||
}
|
||||
} else {
|
||||
echo '<div class="nf">'.__('No planned downtime').'</div>';
|
||||
echo '<div class="nf">'.__('No scheduled downtime').'</div>';
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ if ($migrate_malformed) {
|
|||
|
||||
if ($migration_result['status'] == false) {
|
||||
ui_print_error_message(
|
||||
__('An error occurred while migrating the malformed planned downtimes').'. '.__('Please run the migration again or contact with the administrator')
|
||||
__('An error occurred while migrating the malformed scheduled downtimes').'. '.__('Please run the migration again or contact with the administrator')
|
||||
);
|
||||
echo '<br>';
|
||||
}
|
||||
|
@ -80,7 +80,7 @@ if ($stop_downtime) {
|
|||
$result = planned_downtimes_stop($downtime);
|
||||
|
||||
if ($result === false) {
|
||||
ui_print_error_message(__('An error occurred stopping the planned downtime'));
|
||||
ui_print_error_message(__('An error occurred stopping the scheduled downtime'));
|
||||
} else {
|
||||
echo $result['message'];
|
||||
}
|
||||
|
@ -103,7 +103,7 @@ if ($delete_downtime) {
|
|||
|
||||
// The downtime shouldn't be running!!
|
||||
if ($downtime['executed']) {
|
||||
ui_print_error_message(__('This planned downtime is running'));
|
||||
ui_print_error_message(__('This scheduled downtime is running'));
|
||||
} else {
|
||||
$result = db_process_sql_delete('tplanned_downtime', ['id' => $id_downtime]);
|
||||
|
||||
|
@ -362,7 +362,7 @@ else if (!$downtimes) {
|
|||
echo '</form>';
|
||||
|
||||
// Info message.
|
||||
echo '<div class="nf">'.__('No planned downtime').'</div>';
|
||||
echo '<div class="nf">'.__('No scheduled downtime').'</div>';
|
||||
|
||||
echo '<div class="action-buttons w100p" >';
|
||||
|
||||
|
@ -572,13 +572,13 @@ $(document).ready (function () {
|
|||
$.datepicker.setDefaults($.datepicker.regional[ "<?php echo get_user_language(); ?>"]);
|
||||
|
||||
$("a#delete_downtime").click(function (e) {
|
||||
if (!confirm("<?php echo __('WARNING: If you delete this planned downtime, it will not be taken into account in future SLA reports'); ?>")) {
|
||||
if (!confirm("<?php echo __('WARNING: If you delete this scheduled downtime, it will not be taken into account in future SLA reports'); ?>")) {
|
||||
e.preventDefault();
|
||||
}
|
||||
});
|
||||
|
||||
if (<?php echo json_encode($malformed_downtimes_exist); ?> && <?php echo json_encode($migrate_malformed == false); ?>) {
|
||||
if (confirm("<?php echo __('WARNING: There are malformed planned downtimes').'.\n'.__('Do you want to migrate automatically the malformed items?'); ?>")) {
|
||||
if (confirm("<?php echo __('WARNING: There are malformed scheduled downtimes').'.\n'.__('Do you want to migrate automatically the malformed items?'); ?>")) {
|
||||
window.location.href = "index.php?sec=extensions&sec2=godmode/agentes/planned_downtime.list&migrate_malformed=1";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -469,4 +469,3 @@ if (is_central_policies_on_node() === false) {
|
|||
}
|
||||
|
||||
enterprise_hook('close_meta_frame');
|
||||
?>
|
||||
|
|
|
@ -143,7 +143,7 @@ if ($duplicate_template) {
|
|||
// If user doesn't have the permission to access All group and source template is All group, then group is changed to the first group of user.
|
||||
if ($can_edit_all == false && a_template['id_group'] == 0) {
|
||||
$a_template['id_group'] = users_get_first_group(false, 'LM', false);
|
||||
}
|
||||
}
|
||||
|
||||
$id = alerts_duplicate_alert_template($source_id, $a_template['id_group']);
|
||||
|
||||
|
@ -609,7 +609,7 @@ if ($step == 2) {
|
|||
1,
|
||||
$monday,
|
||||
true,
|
||||
$is_central_policies_on_node | $disabled
|
||||
($is_central_policies_on_node | $disabled)
|
||||
);
|
||||
$table->data[0][1] .= __('Tue');
|
||||
$table->data[0][1] .= html_print_checkbox(
|
||||
|
@ -617,7 +617,7 @@ if ($step == 2) {
|
|||
1,
|
||||
$tuesday,
|
||||
true,
|
||||
$is_central_policies_on_node | $disabled
|
||||
($is_central_policies_on_node | $disabled)
|
||||
);
|
||||
$table->data[0][1] .= __('Wed');
|
||||
$table->data[0][1] .= html_print_checkbox(
|
||||
|
@ -625,7 +625,7 @@ if ($step == 2) {
|
|||
1,
|
||||
$wednesday,
|
||||
true,
|
||||
$is_central_policies_on_node | $disabled
|
||||
($is_central_policies_on_node | $disabled)
|
||||
);
|
||||
$table->data[0][1] .= __('Thu');
|
||||
$table->data[0][1] .= html_print_checkbox(
|
||||
|
@ -633,7 +633,7 @@ if ($step == 2) {
|
|||
1,
|
||||
$thursday,
|
||||
true,
|
||||
$is_central_policies_on_node | $disabled
|
||||
($is_central_policies_on_node | $disabled)
|
||||
);
|
||||
$table->data[0][1] .= __('Fri');
|
||||
$table->data[0][1] .= html_print_checkbox(
|
||||
|
@ -641,7 +641,7 @@ if ($step == 2) {
|
|||
1,
|
||||
$friday,
|
||||
true,
|
||||
$is_central_policies_on_node | $disabled
|
||||
($is_central_policies_on_node | $disabled)
|
||||
);
|
||||
$table->data[0][1] .= __('Sat');
|
||||
$table->data[0][1] .= html_print_checkbox(
|
||||
|
@ -649,7 +649,7 @@ if ($step == 2) {
|
|||
1,
|
||||
$saturday,
|
||||
true,
|
||||
$is_central_policies_on_node | $disabled
|
||||
($is_central_policies_on_node | $disabled)
|
||||
);
|
||||
$table->data[0][1] .= __('Sun');
|
||||
$table->data[0][1] .= html_print_checkbox(
|
||||
|
@ -657,7 +657,7 @@ if ($step == 2) {
|
|||
1,
|
||||
$sunday,
|
||||
true,
|
||||
$is_central_policies_on_node | $disabled
|
||||
($is_central_policies_on_node | $disabled)
|
||||
);
|
||||
|
||||
$table->data[0][2] = __('Use special days list');
|
||||
|
@ -666,7 +666,7 @@ if ($step == 2) {
|
|||
1,
|
||||
$special_day,
|
||||
true,
|
||||
$is_central_policies_on_node | $disabled
|
||||
($is_central_policies_on_node | $disabled)
|
||||
);
|
||||
|
||||
$table->data[1][0] = __('Time from');
|
||||
|
@ -687,7 +687,7 @@ if ($step == 2) {
|
|||
'',
|
||||
'',
|
||||
'',
|
||||
$is_central_policies_on_node | $disabled
|
||||
($is_central_policies_on_node | $disabled)
|
||||
);
|
||||
$table->data[1][2] = __('Time to');
|
||||
$table->data[1][3] = html_print_input_text(
|
||||
|
@ -707,7 +707,7 @@ if ($step == 2) {
|
|||
'',
|
||||
'',
|
||||
'',
|
||||
$is_central_policies_on_node | $disabled
|
||||
($is_central_policies_on_node | $disabled)
|
||||
);
|
||||
|
||||
$table->colspan['threshold'][1] = 3;
|
||||
|
@ -723,7 +723,7 @@ if ($step == 2) {
|
|||
false,
|
||||
true,
|
||||
'',
|
||||
$is_central_policies_on_node | $disabled
|
||||
($is_central_policies_on_node | $disabled)
|
||||
);
|
||||
|
||||
$table->data[3][0] = __('Min. number of alerts');
|
||||
|
@ -744,7 +744,7 @@ if ($step == 2) {
|
|||
'',
|
||||
'',
|
||||
'',
|
||||
$is_central_policies_on_node | $disabled
|
||||
($is_central_policies_on_node | $disabled)
|
||||
);
|
||||
|
||||
$table->data[3][2] = __('Reset counter for non-sustained alerts');
|
||||
|
@ -757,7 +757,7 @@ if ($step == 2) {
|
|||
1,
|
||||
$min_alerts_reset_counter,
|
||||
true,
|
||||
$is_central_policies_on_node | $disabled,
|
||||
($is_central_policies_on_node | $disabled),
|
||||
'',
|
||||
false,
|
||||
$create_template == 1 ? 'checked=checked' : ''
|
||||
|
@ -781,7 +781,7 @@ if ($step == 2) {
|
|||
'',
|
||||
'',
|
||||
'',
|
||||
$is_central_policies_on_node | $disabled
|
||||
($is_central_policies_on_node | $disabled)
|
||||
);
|
||||
|
||||
$table->data[4][2] = __('Disable event');
|
||||
|
@ -790,7 +790,7 @@ if ($step == 2) {
|
|||
1,
|
||||
$disable_event,
|
||||
true,
|
||||
$is_central_policies_on_node | $disabled
|
||||
($is_central_policies_on_node | $disabled)
|
||||
);
|
||||
|
||||
$table->data[5][0] = __('Default action');
|
||||
|
@ -818,7 +818,7 @@ if ($step == 2) {
|
|||
true,
|
||||
false,
|
||||
false,
|
||||
$is_central_policies_on_node | $disabled,
|
||||
($is_central_policies_on_node | $disabled),
|
||||
false,
|
||||
false,
|
||||
0
|
||||
|
@ -840,7 +840,7 @@ if ($step == 2) {
|
|||
false,
|
||||
false,
|
||||
'',
|
||||
$is_central_policies_on_node | $disabled
|
||||
($is_central_policies_on_node | $disabled)
|
||||
);
|
||||
$table->data[6][1] .= '<span id="matches_value" '.($show_matches ? '' : 'class="invisible"').'>';
|
||||
$table->data[6][1] .= ' '.html_print_checkbox('matches_value', 1, $matches, true);
|
||||
|
@ -949,7 +949,7 @@ if ($step == 2) {
|
|||
false,
|
||||
false,
|
||||
'',
|
||||
$is_central_policies_on_node | $disabled
|
||||
($is_central_policies_on_node | $disabled)
|
||||
);
|
||||
$table->colspan[0][1] = 2;
|
||||
|
||||
|
@ -975,7 +975,7 @@ if ($step == 2) {
|
|||
0,
|
||||
'',
|
||||
false,
|
||||
$is_central_policies_on_node | $disabled,
|
||||
($is_central_policies_on_node | $disabled),
|
||||
"removeTinyMCE('textarea_field".$i."')",
|
||||
'',
|
||||
true
|
||||
|
@ -988,7 +988,7 @@ if ($step == 2) {
|
|||
0,
|
||||
'',
|
||||
true,
|
||||
$is_central_policies_on_node | $disabled,
|
||||
($is_central_policies_on_node | $disabled),
|
||||
"addTinyMCE('textarea_field".$i."')",
|
||||
'',
|
||||
true
|
||||
|
@ -1004,7 +1004,7 @@ if ($step == 2) {
|
|||
'class="fields" min-height-40px',
|
||||
true,
|
||||
'',
|
||||
$is_central_policies_on_node | $disabled
|
||||
($is_central_policies_on_node | $disabled)
|
||||
);
|
||||
|
||||
// Recovery.
|
||||
|
@ -1016,7 +1016,7 @@ if ($step == 2) {
|
|||
0,
|
||||
'',
|
||||
false,
|
||||
$is_central_policies_on_node | $disabled,
|
||||
($is_central_policies_on_node | $disabled),
|
||||
"removeTinyMCE('textarea_field".$i."_recovery')",
|
||||
'',
|
||||
true
|
||||
|
@ -1029,7 +1029,7 @@ if ($step == 2) {
|
|||
0,
|
||||
'',
|
||||
true,
|
||||
$is_central_policies_on_node | $disabled,
|
||||
($is_central_policies_on_node | $disabled),
|
||||
"addTinyMCE('textarea_field".$i."_recovery')",
|
||||
'',
|
||||
true
|
||||
|
@ -1045,7 +1045,7 @@ if ($step == 2) {
|
|||
'class="fields min-height-40px"',
|
||||
true,
|
||||
'',
|
||||
$is_central_policies_on_node | $disabled
|
||||
($is_central_policies_on_node | $disabled)
|
||||
);
|
||||
}
|
||||
} else {
|
||||
|
@ -1102,7 +1102,7 @@ if ($step == 2) {
|
|||
'',
|
||||
'',
|
||||
'',
|
||||
$is_central_policies_on_node | $disabled
|
||||
($is_central_policies_on_node | $disabled)
|
||||
);
|
||||
|
||||
|
||||
|
@ -1134,7 +1134,7 @@ if ($step == 2) {
|
|||
false,
|
||||
true,
|
||||
'',
|
||||
$is_central_policies_on_node | $disabled
|
||||
($is_central_policies_on_node | $disabled)
|
||||
).'</div>';
|
||||
|
||||
|
||||
|
@ -1147,7 +1147,7 @@ if ($step == 2) {
|
|||
'',
|
||||
true,
|
||||
'',
|
||||
$is_central_policies_on_node | $disabled
|
||||
($is_central_policies_on_node | $disabled)
|
||||
);
|
||||
|
||||
$table->data[2][0] = __('Priority');
|
||||
|
@ -1162,7 +1162,7 @@ if ($step == 2) {
|
|||
false,
|
||||
false,
|
||||
'',
|
||||
$is_central_policies_on_node | $disabled
|
||||
($is_central_policies_on_node | $disabled)
|
||||
);
|
||||
|
||||
if (defined('METACONSOLE')) {
|
||||
|
|
|
@ -200,11 +200,7 @@ $table->data[5] = $data;
|
|||
if ($event_response_id == 0) {
|
||||
echo '<form method="post" action="index.php?sec=geventos&sec2=godmode/events/events§ion=responses&mode=list&action=create_response&pure='.$config['pure'].'">';
|
||||
html_print_table($table);
|
||||
if (!defined('METACONSOLE')) {
|
||||
echo '<div class="w100p right_align">';
|
||||
} else {
|
||||
echo '<div class="w100p right">';
|
||||
}
|
||||
|
||||
html_print_submit_button(__('Create'), 'create_response_button', false, ['class' => 'sub next']);
|
||||
echo '</div>';
|
||||
|
@ -212,11 +208,7 @@ if ($event_response_id == 0) {
|
|||
} else {
|
||||
echo '<form method="post" action="index.php?sec=geventos&sec2=godmode/events/events§ion=responses&mode=list&action=update_response&pure='.$config['pure'].'">';
|
||||
html_print_table($table);
|
||||
if (!defined('METACONSOLE')) {
|
||||
echo '<div class="w100p right_align">';
|
||||
} else {
|
||||
echo '<div class="w100p right">';
|
||||
}
|
||||
|
||||
html_print_submit_button(__('Update'), 'update_response_button', false, ['class' => 'sub next']);
|
||||
echo '</div>';
|
||||
|
|
|
@ -3326,6 +3326,9 @@ function print_SLA_list($width, $action, $idItem=null)
|
|||
<input id="hidden-id_agent_sla" name="id_agent_sla" value="" type="hidden">
|
||||
<input id="hidden-id_server" name="id_server" value="" type="hidden">
|
||||
<?php
|
||||
// Set autocomplete image.
|
||||
$autocompleteImage = html_print_image(($config['style'] === 'pandora_black') ? 'images/agent_mc.menu.png' : 'images/search_agent.png', true, false, true);
|
||||
// Params for agent autocomplete input.
|
||||
$params = [];
|
||||
$params['show_helptip'] = true;
|
||||
$params['input_name'] = 'agent_sla';
|
||||
|
@ -3335,6 +3338,8 @@ function print_SLA_list($width, $action, $idItem=null)
|
|||
$params['javascript_is_function_select'] = true;
|
||||
$params['selectbox_id'] = 'id_agent_module_sla';
|
||||
$params['add_none_module'] = false;
|
||||
$params['check_only_empty_javascript_on_blur_function'] = true;
|
||||
$params['icon_image'] = $autocompleteImage;
|
||||
if ($meta) {
|
||||
$params['use_input_id_server'] = true;
|
||||
$params['input_id_server_id'] = 'hidden-id_server';
|
||||
|
@ -3370,6 +3375,7 @@ function print_SLA_list($width, $action, $idItem=null)
|
|||
$params['javascript_is_function_select'] = true;
|
||||
$params['selectbox_id'] = 'id_agent_module_failover';
|
||||
$params['add_none_module'] = false;
|
||||
$params['icon_image'] = $autocompleteImage;
|
||||
if ($meta) {
|
||||
$params['use_input_id_server'] = true;
|
||||
$params['input_id_server_id'] = 'hidden-id_server';
|
||||
|
@ -4734,8 +4740,10 @@ function addSLARow() {
|
|||
var serviceId = $("select#id_service>option:selected").val();
|
||||
var serviceName = $("select#id_service>option:selected").text();
|
||||
|
||||
if (((idAgent != '') && (slaMin != '') && (slaMax != '')
|
||||
&& (slaLimit != '')) || serviceId != '') {
|
||||
if ((((idAgent != '') && (idAgent > 0))
|
||||
&& ((idModule != '') && (idModule > 0)))
|
||||
|| serviceId != null)
|
||||
{
|
||||
if (nameAgent != '') {
|
||||
//Truncate nameAgent
|
||||
var params = [];
|
||||
|
@ -4892,6 +4900,7 @@ function addSLARow() {
|
|||
$("input[name=id_agent_failover]").val('');
|
||||
$("input[name=id_server]").val('');
|
||||
$("input[name=agent_sla]").val('');
|
||||
$("input[name=agent_sla]").css("background","url('<?php echo $autocompleteImage; ?>') right center no-repeat")
|
||||
$("input[name=agent_failover]").val('');
|
||||
$("#id_agent_module_sla").empty();
|
||||
$("#id_agent_module_sla").attr('disabled', 'true');
|
||||
|
|
|
@ -420,7 +420,7 @@ $table->data[$i++][1] = html_print_select(
|
|||
$config['past_planned_downtimes'] = isset(
|
||||
$config['past_planned_downtimes']
|
||||
) ? $config['past_planned_downtimes'] : 1;
|
||||
$table->data[$i][0] = __('Allow create planned downtimes in the past');
|
||||
$table->data[$i][0] = __('Allow create scheduled downtimes in the past');
|
||||
$table->data[$i++][1] = html_print_checkbox_switch(
|
||||
'past_planned_downtimes',
|
||||
1,
|
||||
|
@ -641,8 +641,8 @@ echo '<legend>'.__('Mail configuration').'</legend>';
|
|||
$table_mail_test->width = '100%';
|
||||
$table_mail_test->class = 'databox filters';
|
||||
$table_mail_test->data = [];
|
||||
$table_mail_test->style[0] = 'font-weight: bold';
|
||||
$table_mail_test->colspan[1][0] = 2;
|
||||
$table_mail_test->style[0] = 'font-weight: bold;';
|
||||
$table_mail_test->style[1] = 'font-weight: bold;display: flex;height: 54px;align-items: center;';
|
||||
|
||||
$table_mail_test->data[0][0] = __('Address');
|
||||
$table_mail_test->data[0][1] = html_print_input_text(
|
||||
|
@ -661,7 +661,9 @@ echo '<legend>'.__('Mail configuration').'</legend>';
|
|||
'',
|
||||
'class="sub next"',
|
||||
true
|
||||
).'  <span id="email_test_sent_message" class="invisible">Email sent</span><span id="email_test_failure_message" class=invisible">Email could not be sent</span>';
|
||||
);
|
||||
|
||||
$table_mail_test->data[1][1] = '  <span id="email_test_sent_message" class="invisible"><b>Email sent</b></span><span id="email_test_failure_message" class=invisible"><b>Email could not be sent</b></span>';
|
||||
|
||||
echo '<div id="email_test_'.$id.'" title="'.__('Check mail configuration').'" class="invisible">'.html_print_table($table_mail_test, true).'</div>';
|
||||
}
|
||||
|
@ -703,6 +705,9 @@ function show_email_test(id) {
|
|||
}
|
||||
|
||||
function perform_email_test () {
|
||||
$('#email_test_sent_message').hide();
|
||||
$('#email_test_failure_message').hide();
|
||||
|
||||
var test_address = $('#text-email_test_address').val();
|
||||
|
||||
$.ajax({
|
||||
|
@ -713,12 +718,15 @@ function perform_email_test () {
|
|||
success: function(data) {
|
||||
if (parseInt(data) === 1) {
|
||||
$('#email_test_sent_message').show();
|
||||
$('#email_test_failure_message').hide();
|
||||
} else {
|
||||
$('#email_test_failure_message').show();
|
||||
$('#email_test_sent_message').hide();
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
$('#email_test_failure_message').show();
|
||||
$('#email_test_sent_message').hide();
|
||||
},
|
||||
});
|
||||
}
|
||||
|
|
|
@ -290,7 +290,7 @@ $table_remote->data['integria_pass'] = $row;
|
|||
|
||||
// Integria hostname.
|
||||
$row = [];
|
||||
$row['name'] = __('API Hostname');
|
||||
$row['name'] = __('URL to Integria IMS setup').ui_print_help_tip(__('Full URL to your Integria IMS setup (e.g., http://192.168.1.20/integria, https://support.mycompany.com).'), true);
|
||||
$row['control'] = html_print_input_text('integria_hostname', $config['integria_hostname'], '', 30, 100, true);
|
||||
$table_remote->data['integria_hostname'] = $row;
|
||||
|
||||
|
@ -337,22 +337,20 @@ $row['control'] = html_print_input_text(
|
|||
true,
|
||||
false,
|
||||
false
|
||||
).ui_print_help_icon('alert_macros', true);
|
||||
);
|
||||
$table_alert_settings->data['custom_response_incident_title'] = $row;
|
||||
|
||||
// Alert incident description.
|
||||
$row = [];
|
||||
$row['name'] = __('Description');
|
||||
$row['control'] = html_print_input_text(
|
||||
$row['name'] = __('Ticket body');
|
||||
$row['control'] = html_print_textarea(
|
||||
'incident_content',
|
||||
7,
|
||||
25,
|
||||
$config['incident_content'],
|
||||
'',
|
||||
50,
|
||||
100,
|
||||
true,
|
||||
false,
|
||||
false
|
||||
).ui_print_help_icon('alert_macros', true);
|
||||
true
|
||||
);
|
||||
$table_alert_settings->data['custom_response_incident_content'] = $row;
|
||||
|
||||
// Alert default group.
|
||||
|
@ -460,22 +458,21 @@ $row['control'] = html_print_input_text(
|
|||
true,
|
||||
false,
|
||||
false
|
||||
).ui_print_help_icon('response_macros', true);
|
||||
);
|
||||
$table_cr_settings->data['custom_response_incident_title'] = $row;
|
||||
|
||||
// Custom response incident description.
|
||||
$row = [];
|
||||
$row['name'] = __('Description');
|
||||
$row['control'] = html_print_input_text(
|
||||
$row['name'] = __('Ticket body');
|
||||
$row['control'] = html_print_textarea(
|
||||
'cr_incident_content',
|
||||
7,
|
||||
25,
|
||||
$config['cr_incident_content'],
|
||||
'',
|
||||
50,
|
||||
100,
|
||||
true,
|
||||
false,
|
||||
false
|
||||
).ui_print_help_icon('response_macros', true);
|
||||
true
|
||||
);
|
||||
|
||||
$table_cr_settings->data['custom_response_incident_content'] = $row;
|
||||
|
||||
// Custom response default group.
|
||||
|
@ -607,7 +604,7 @@ if ($has_connection != false) {
|
|||
// Form alert default settings.
|
||||
echo '<div id="form_alert_settings">';
|
||||
echo '<fieldset>';
|
||||
echo '<legend>'.__('Alert default values').'</legend>';
|
||||
echo '<legend>'.__('Alert default values').' '.ui_print_help_icon('alert_macros', true).'</legend>';
|
||||
|
||||
html_print_table($table_alert_settings);
|
||||
|
||||
|
@ -617,7 +614,7 @@ if ($has_connection != false) {
|
|||
// Form custom response default settings.
|
||||
echo '<div id="form_custom_response_settings">';
|
||||
echo '<fieldset>';
|
||||
echo '<legend>'.__('Event custom response default values').'</legend>';
|
||||
echo '<legend>'.__('Event custom response default values').' '.ui_print_help_icon('alert_macros', true).'</legend>';
|
||||
|
||||
html_print_table($table_cr_settings);
|
||||
|
||||
|
|
|
@ -585,133 +585,21 @@ if ($update_alert || $duplicate_alert) {
|
|||
|
||||
// Duplicate alert snmp
|
||||
if ($duplicate_alert) {
|
||||
$sql = sprintf(
|
||||
'insert into talert_snmp (
|
||||
id_alert, al_field1, al_field2, al_field3,
|
||||
al_field4, al_field5, al_field6, al_field7,
|
||||
al_field8, al_field9, al_field10, al_field11,
|
||||
al_field12, al_field13, al_field14, al_field15,
|
||||
al_field16, al_field17, al_field18, al_field19,
|
||||
al_field20, description, alert_type, agent, custom_oid,
|
||||
oid, time_threshold, times_fired, last_fired,
|
||||
max_alerts, min_alerts, internal_counter, priority,
|
||||
'.db_escape_key_identifier('_snmp_f1_').',
|
||||
'.db_escape_key_identifier('_snmp_f2_').',
|
||||
'.db_escape_key_identifier('_snmp_f3_').',
|
||||
'.db_escape_key_identifier('_snmp_f4_').',
|
||||
'.db_escape_key_identifier('_snmp_f5_').',
|
||||
'.db_escape_key_identifier('_snmp_f6_').',
|
||||
'.db_escape_key_identifier('_snmp_f7_').',
|
||||
'.db_escape_key_identifier('_snmp_f8_').',
|
||||
'.db_escape_key_identifier('_snmp_f9_').',
|
||||
'.db_escape_key_identifier('_snmp_f10_').',
|
||||
'.db_escape_key_identifier('_snmp_f11_').',
|
||||
'.db_escape_key_identifier('_snmp_f12_').',
|
||||
'.db_escape_key_identifier('_snmp_f13_').',
|
||||
'.db_escape_key_identifier('_snmp_f14_').',
|
||||
'.db_escape_key_identifier('_snmp_f15_').',
|
||||
'.db_escape_key_identifier('_snmp_f16_').',
|
||||
'.db_escape_key_identifier('_snmp_f17_').',
|
||||
'.db_escape_key_identifier('_snmp_f18_').',
|
||||
'.db_escape_key_identifier('_snmp_f19_').',
|
||||
'.db_escape_key_identifier('_snmp_f20_').",
|
||||
trap_type, single_value, position, disable_event, id_group,
|
||||
order_1, order_2, order_3, order_4, order_5, order_6, order_7, order_8,
|
||||
order_9, order_10, order_11, order_12, order_13, order_14, order_15,
|
||||
order_16, order_17, order_18, order_19, order_20)
|
||||
VALUES
|
||||
(%d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s',
|
||||
'%s', '%s', '%s', '%s', %d, '%s', '%s', '%s', %d, %d, %d, %d, %d, %d, %d, '%s', '%s', '%s',
|
||||
'%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s',
|
||||
'%s', '%s', '%s', '%s', %d, '%s', %d, %d, %d, %d, %d, %d, %d, %d, %d,
|
||||
%d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d)",
|
||||
$id_alert,
|
||||
$al_field1,
|
||||
$al_field2,
|
||||
$al_field3,
|
||||
$al_field4,
|
||||
$al_field5,
|
||||
$al_field6,
|
||||
$al_field7,
|
||||
$al_field8,
|
||||
$al_field9,
|
||||
$al_field10,
|
||||
$al_field11,
|
||||
$al_field12,
|
||||
$al_field13,
|
||||
$al_field14,
|
||||
$al_field15,
|
||||
$al_field16,
|
||||
$al_field17,
|
||||
$al_field18,
|
||||
$al_field19,
|
||||
$al_field20,
|
||||
$description,
|
||||
$alert_type,
|
||||
$source_ip,
|
||||
$custom_value,
|
||||
$oid,
|
||||
$time_threshold,
|
||||
$times_fired,
|
||||
$last_fired,
|
||||
$max_alerts,
|
||||
$min_alerts,
|
||||
$internal_counter,
|
||||
$priority,
|
||||
$custom_oid_data_1,
|
||||
$custom_oid_data_2,
|
||||
$custom_oid_data_3,
|
||||
$custom_oid_data_4,
|
||||
$custom_oid_data_5,
|
||||
$custom_oid_data_6,
|
||||
$custom_oid_data_7,
|
||||
$custom_oid_data_8,
|
||||
$custom_oid_data_9,
|
||||
$custom_oid_data_10,
|
||||
$custom_oid_data_11,
|
||||
$custom_oid_data_12,
|
||||
$custom_oid_data_13,
|
||||
$custom_oid_data_14,
|
||||
$custom_oid_data_15,
|
||||
$custom_oid_data_16,
|
||||
$custom_oid_data_17,
|
||||
$custom_oid_data_18,
|
||||
$custom_oid_data_19,
|
||||
$custom_oid_data_20,
|
||||
$trap_type,
|
||||
$single_value,
|
||||
$position,
|
||||
$disable_event,
|
||||
$group,
|
||||
$order_1,
|
||||
$order_2,
|
||||
$order_3,
|
||||
$order_4,
|
||||
$order_5,
|
||||
$order_6,
|
||||
$order_7,
|
||||
$order_8,
|
||||
$order_9,
|
||||
$order_10,
|
||||
$order_11,
|
||||
$order_12,
|
||||
$order_13,
|
||||
$order_14,
|
||||
$order_15,
|
||||
$order_16,
|
||||
$order_17,
|
||||
$order_18,
|
||||
$order_19,
|
||||
$order_20
|
||||
);
|
||||
$result = db_process_sql($sql);
|
||||
$values_duplicate = $alert;
|
||||
if (!empty($values_duplicate)) {
|
||||
unset($values_duplicate['id_as']);
|
||||
$result = db_process_sql_insert('talert_snmp', $values_duplicate);
|
||||
|
||||
if (!$result) {
|
||||
if (!$result) {
|
||||
db_pandora_audit('SNMP management', "Fail try to duplicate snmp alert #$id_as");
|
||||
ui_print_error_message(__('There was a problem duplicating the alert'));
|
||||
} else {
|
||||
db_pandora_audit('SNMP management', "Duplicate snmp alert #$id_as");
|
||||
ui_print_success_message(__('Successfully Duplicate'));
|
||||
}
|
||||
} else {
|
||||
db_pandora_audit('SNMP management', "Fail try to duplicate snmp alert #$id_as");
|
||||
ui_print_error_message(__('There was a problem duplicating the alert'));
|
||||
} else {
|
||||
db_pandora_audit('SNMP management', "Duplicate snmp alert #$id_as");
|
||||
ui_print_success_message(__('Successfully Duplicate'));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -94,7 +94,7 @@ is not working on the metaconsole and there is no time to fix it -->
|
|||
var mr_available_header = "<?php echo __('There are db changes'); ?>\n";
|
||||
var text1_mr_file = "<?php echo __('There are new database changes available to apply. Do you want to start the DB update process?'); ?>\n";
|
||||
var text2_mr_file = "<?php echo __('We recommend launching '); ?>\n";
|
||||
var text3_mr_file = "<?php echo __('planned downtime'); ?>\n";
|
||||
var text3_mr_file = "<?php echo __('Scheduled downtime'); ?>\n";
|
||||
|
||||
var language = "<?php echo $config['language']; ?>";
|
||||
var docsUrl = (language === "es")
|
||||
|
|
|
@ -233,8 +233,7 @@ if (defined('METACONSOLE')) {
|
|||
|
||||
|
||||
$disable_user = get_parameter('disable_user', false);
|
||||
|
||||
if (isset($_GET['user_del'])) {
|
||||
if ((bool) get_parameter('user_del', false) === true) {
|
||||
// delete user
|
||||
$id_user = get_parameter('delete_user', 0);
|
||||
// Only allow delete user if is not the actual user
|
||||
|
@ -312,13 +311,13 @@ if (isset($_GET['user_del'])) {
|
|||
$result = false;
|
||||
}
|
||||
|
||||
if ($disable_user == 1) {
|
||||
if ($disable_user === 1) {
|
||||
ui_print_result_message(
|
||||
$result,
|
||||
__('Successfully disabled'),
|
||||
__('There was a problem disabling user')
|
||||
);
|
||||
} else {
|
||||
} else if ($disable_user === 0) {
|
||||
ui_print_result_message(
|
||||
$result,
|
||||
__('Successfully enabled'),
|
||||
|
@ -562,7 +561,7 @@ foreach ($info as $user_id => $user_info) {
|
|||
$iterator++;
|
||||
|
||||
if ($user_is_admin || $config['id_user'] == $user_info['id_user'] || (!$user_info['is_admin'] && (!isset($user_info['edit']) || isset($group_um[0]) || (isset($user_info['edit']) && $user_info['edit'])))) {
|
||||
$data[0] = '<a href="index.php?sec='.$sec.'&sec2=godmode/users/configure_user&pure='.$pure.'&id='.$user_id.'">'.$user_id.'</a>';
|
||||
$data[0] = '<a href="#" onclick="document.forms[\'edit_user_form_'.$user_info['id_user'].'\'].submit();">'.$user_id.'</a>';
|
||||
} else {
|
||||
$data[0] = $user_id;
|
||||
}
|
||||
|
@ -642,19 +641,126 @@ foreach ($info as $user_id => $user_info) {
|
|||
$table->cellclass[][6] = 'action_buttons';
|
||||
$data[6] = '';
|
||||
if ($user_is_admin || $config['id_user'] == $user_info['id_user'] || isset($group_um[0]) || (!$user_info['is_admin'] && (!isset($user_info['edit']) || (isset($user_info['edit']) && $user_info['edit'])))) {
|
||||
if (!isset($user_info['not_delete'])) {
|
||||
// Disable / Enable user.
|
||||
if (isset($user_info['not_delete']) === false) {
|
||||
if ($user_info['disabled'] == 0) {
|
||||
$data[6] = '<a href="index.php?sec='.$sec.'&sec2=godmode/users/user_list&disable_user=1&pure='.$pure.'&id='.$user_info['id_user'].'">'.html_print_image('images/lightbulb.png', true, ['title' => __('Disable'), 'class' => 'invert_filter']).'</a>';
|
||||
$toDoString = __('Disable');
|
||||
$toDoAction = '1';
|
||||
$toDoImage = 'images/lightbulb.png';
|
||||
} else {
|
||||
$data[6] = '<a href="index.php?sec='.$sec.'&sec2=godmode/users/user_list&disable_user=0&pure='.$pure.'&id='.$user_info['id_user'].'">'.html_print_image('images/lightbulb_off.png', true, ['title' => __('Enable')]).'</a>';
|
||||
$toDoString = __('Enable');
|
||||
$toDoAction = '0';
|
||||
$toDoImage = 'images/lightbulb_off.png';
|
||||
}
|
||||
|
||||
$data[6] = '<form method="POST" action="index.php?sec='.$sec.'&sec2=godmode/users/user_list&pure='.$pure.'" class="inline">';
|
||||
$data[6] .= html_print_input_hidden(
|
||||
'id',
|
||||
$user_info['id_user'],
|
||||
true
|
||||
);
|
||||
$data[6] .= html_print_input_hidden(
|
||||
'disable_user',
|
||||
$toDoAction,
|
||||
true
|
||||
);
|
||||
$data[6] .= html_print_input_image(
|
||||
'submit_disable_enable',
|
||||
$toDoImage,
|
||||
'',
|
||||
'',
|
||||
true,
|
||||
[
|
||||
'data-title' => $toDoString,
|
||||
'data-use_title_for_force_title' => '1',
|
||||
'class' => 'forced_title no-padding',
|
||||
]
|
||||
);
|
||||
$data[6] .= '</form>';
|
||||
}
|
||||
|
||||
$data[6] .= '<a href="index.php?sec='.$sec.'&sec2=godmode/users/configure_user&pure='.$pure.'&id='.$user_id.'">'.html_print_image('images/config.png', true, ['title' => __('Edit'), 'class' => 'invert_filter']).'</a>';
|
||||
if ($config['admin_can_delete_user'] && $user_info['id_user'] != $config['id_user'] && !isset($user_info['not_delete'])) {
|
||||
$data[6] .= "<a href='index.php?sec=".$sec.'&sec2=godmode/users/user_list&user_del=1&pure='.$pure.'&delete_user='.$user_info['id_user']."'>".html_print_image('images/cross.png', true, ['class' => 'invert_filter', 'title' => __('Delete'), 'onclick' => "if (! confirm ('".__('Deleting User').' '.$user_info['id_user'].'. '.__('Are you sure?')."')) return false"]).'</a>';
|
||||
if (defined('METACONSOLE')) {
|
||||
$data[6] .= "<a href='index.php?sec=".$sec.'&sec2=godmode/users/user_list&user_del=1&pure='.$pure.'&delete_user='.$user_info['id_user']."&delete_all=1'>".html_print_image('images/cross_double.png', true, ['class' => 'invert_filter', 'title' => __('Delete from all consoles'), 'onclick' => "if (! confirm ('".__('Deleting User %s from all consoles', $user_info['id_user']).'. '.__('Are you sure?')."')) return false"]).'</a>';
|
||||
// Edit user.
|
||||
$data[6] .= '<form method="POST" action="index.php?sec='.$sec.'&sec2=godmode/users/configure_user&pure='.$pure.'" id="edit_user_form_'.$user_info['id_user'].'" class="inline">';
|
||||
$data[6] .= html_print_input_hidden(
|
||||
'id_user',
|
||||
$user_info['id_user'],
|
||||
true
|
||||
);
|
||||
$data[6] .= html_print_input_hidden(
|
||||
'edit_user',
|
||||
'1',
|
||||
true
|
||||
);
|
||||
$data[6] .= html_print_input_image(
|
||||
'submit_edit_user',
|
||||
'images/config.png',
|
||||
'',
|
||||
'padding:0',
|
||||
true,
|
||||
[
|
||||
'data-title' => __('Edit'),
|
||||
'data-use_title_for_force_title' => '1',
|
||||
'class' => 'forced_title no-padding',
|
||||
]
|
||||
);
|
||||
$data[6] .= '</form>';
|
||||
|
||||
if ($config['admin_can_delete_user'] && $user_info['id_user'] != $config['id_user'] && isset($user_info['not_delete']) === false) {
|
||||
$data[6] .= '<form method="POST" action="index.php?sec='.$sec.'&sec2=godmode/users/user_list&pure='.$pure.'" class="inline">';
|
||||
$data[6] .= html_print_input_hidden(
|
||||
'delete_user',
|
||||
$user_info['id_user'],
|
||||
true
|
||||
);
|
||||
$data[6] .= html_print_input_hidden(
|
||||
'user_del',
|
||||
'1',
|
||||
true
|
||||
);
|
||||
$data[6] .= html_print_input_image(
|
||||
'submit_delete_user',
|
||||
'images/cross.png',
|
||||
'',
|
||||
'padding:0',
|
||||
true,
|
||||
[
|
||||
'data-title' => __('Delete'),
|
||||
'data-use_title_for_force_title' => '1',
|
||||
'class' => 'forced_title no-padding',
|
||||
]
|
||||
);
|
||||
$data[6] .= '</form>';
|
||||
|
||||
if (is_metaconsole() === true) {
|
||||
$data[6] .= '<form method="POST" action="index.php?sec='.$sec.'&sec2=godmode/users/user_list&pure='.$pure.'" class="inline">';
|
||||
$data[6] .= html_print_input_hidden(
|
||||
'delete_user',
|
||||
$user_info['id_user'],
|
||||
true
|
||||
);
|
||||
$data[6] .= html_print_input_hidden(
|
||||
'user_del',
|
||||
'1',
|
||||
true
|
||||
);
|
||||
$data[6] .= html_print_input_hidden(
|
||||
'delete_all',
|
||||
'1',
|
||||
true
|
||||
);
|
||||
$data[6] .= html_print_input_image(
|
||||
'submit_delete_all',
|
||||
'images/cross_double.png',
|
||||
'',
|
||||
'',
|
||||
true,
|
||||
[
|
||||
'data-title' => __('Delete from all consoles'),
|
||||
'data-use_title_for_force_title' => '1',
|
||||
'class' => 'forced_title no-padding',
|
||||
]
|
||||
);
|
||||
$data[6] .= '</form>';
|
||||
}
|
||||
} else {
|
||||
$data[6] .= '';
|
||||
|
|
|
@ -898,7 +898,7 @@ class HostDevices extends Wizard
|
|||
],
|
||||
[
|
||||
'label' => '<b>'.__('Networks (current)').':</b>'.ui_print_help_tip(
|
||||
__('Plese upload a new file to overwrite this content.'),
|
||||
__('Please upload a new file to overwrite this content.'),
|
||||
true
|
||||
),
|
||||
'arguments' => [
|
||||
|
|
|
@ -0,0 +1,74 @@
|
|||
<?php
|
||||
/**
|
||||
* Web Server Module Debug ajax controller.
|
||||
*
|
||||
* @category Web Server Module Debug
|
||||
* @package Pandora FMS
|
||||
* @subpackage Module Debug
|
||||
* @version 1.0.0
|
||||
* @license See below
|
||||
*
|
||||
* ______ ___ _______ _______ ________
|
||||
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
|
||||
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
|
||||
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
|
||||
*
|
||||
* ============================================================================
|
||||
* Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
|
||||
* Please see http://pandorafms.org for full contribution list
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation for version 2.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* ============================================================================
|
||||
*/
|
||||
|
||||
// Begin.
|
||||
global $config;
|
||||
global $id_agent_module;
|
||||
// Module Debug Class.
|
||||
require_once $config['homedir'].'/include/class/WebServerModuleDebug.class.php';
|
||||
|
||||
// This page.
|
||||
$ajaxPage = $config['homedir'].'/include/ajax/web_server_module_debug';
|
||||
|
||||
// Control call flow for debug window.
|
||||
try {
|
||||
// Return of id of the agent module in AJAX.
|
||||
if (is_ajax()) {
|
||||
$id_agent_module = get_parameter('idAgentModule');
|
||||
}
|
||||
|
||||
// User access and validation is being processed on class constructor.
|
||||
$obj = new WebServerModuleDebug($ajaxPage, $id_agent_module);
|
||||
} catch (Exception $e) {
|
||||
if (is_ajax()) {
|
||||
echo json_encode(['error' => '[WebServerModuleDebug]'.$e->getMessage() ]);
|
||||
exit;
|
||||
} else {
|
||||
echo '[WebServerModuleDebug]'.$e->getMessage();
|
||||
}
|
||||
|
||||
// Stop this execution, but continue 'globally'.
|
||||
return;
|
||||
}
|
||||
|
||||
// AJAX controller.
|
||||
if (is_ajax()) {
|
||||
$method = get_parameter('method');
|
||||
|
||||
if (method_exists($obj, $method) === true) {
|
||||
$obj->{$method}();
|
||||
} else {
|
||||
$obj->error('Method not found. ['.$method.']');
|
||||
}
|
||||
|
||||
// Stop any execution.
|
||||
exit;
|
||||
} else {
|
||||
// Run.
|
||||
$obj->run();
|
||||
}
|
|
@ -765,7 +765,7 @@ class AgentsAlerts extends HTML
|
|||
|
||||
// Start Header form.
|
||||
$headerForm = [
|
||||
'action' => ui_get_full_url(),
|
||||
'action' => ui_get_full_url('index.php?sec=view&sec2=extensions/agents_alerts'),
|
||||
'id' => 'form-header-filters',
|
||||
'method' => 'POST',
|
||||
'class' => 'modal flex flex-row',
|
||||
|
|
|
@ -286,7 +286,11 @@ class Diagnostics extends Wizard
|
|||
$return .= '</div>';
|
||||
}
|
||||
|
||||
return false;
|
||||
if ($this->pdf === true) {
|
||||
return $return;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -1599,7 +1603,7 @@ class Diagnostics extends Wizard
|
|||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -462,6 +462,12 @@ class ExternalTools extends HTML
|
|||
$ids[] = join(',', $address);
|
||||
}
|
||||
|
||||
// Must be an a IP at least for work.
|
||||
if (empty($ids) === true) {
|
||||
ui_print_message(__('The agent doesn`t have an IP yet'), 'error', true);
|
||||
return;
|
||||
}
|
||||
|
||||
$ips = db_get_all_rows_sql(
|
||||
sprintf(
|
||||
'SELECT ip FROM taddress WHERE id_a IN (%s)',
|
||||
|
@ -469,18 +475,6 @@ class ExternalTools extends HTML
|
|||
)
|
||||
);
|
||||
|
||||
// Must be an a IP at least for work.
|
||||
if (empty($ips) === true) {
|
||||
html_print_div(
|
||||
[
|
||||
'class' => 'error',
|
||||
'style' => 'margin-top:5px',
|
||||
'content' => __('The agent hasn\'t got IP'),
|
||||
]
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
// Make the data for show in table.
|
||||
$ipsSelect = array_reduce(
|
||||
$ips,
|
||||
|
|
|
@ -1020,7 +1020,7 @@ class Tree
|
|||
$agent_search_filter = $this->getAgentSearchFilter();
|
||||
$agent_status_filter = $this->getAgentStatusFilter();
|
||||
$module_search_filter = $this->getModuleSearchFilter();
|
||||
$module_status_filter = $this->getModuleStatusFilter();
|
||||
$module_status_filter = $this->getModuleStatusFilterFromTestado($this->filter['statusModule']);
|
||||
|
||||
$condition = $this->L2condition;
|
||||
$condition_inside = $this->L2conditionInside;
|
||||
|
|
|
@ -0,0 +1,407 @@
|
|||
<?php
|
||||
/**
|
||||
* WebServer Module debug feature.
|
||||
*
|
||||
* @category Class
|
||||
* @package Pandora FMS
|
||||
* @subpackage Web Server Module
|
||||
* @version 1.0.0
|
||||
* @license See below
|
||||
*
|
||||
* ______ ___ _______ _______ ________
|
||||
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
|
||||
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
|
||||
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
|
||||
*
|
||||
* ============================================================================
|
||||
* Copyright (c) 2005-2020 Artica Soluciones Tecnologicas
|
||||
* Please see http://pandorafms.org for full contribution list
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation for version 2.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* ============================================================================
|
||||
*/
|
||||
|
||||
// Begin.
|
||||
global $config;
|
||||
|
||||
require_once $config['homedir'].'/godmode/wizards/Wizard.main.php';
|
||||
|
||||
/**
|
||||
* Class WebServerModuleDebug.
|
||||
*/
|
||||
class WebServerModuleDebug extends Wizard
|
||||
{
|
||||
|
||||
/**
|
||||
* Controller Url.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $ajaxController;
|
||||
|
||||
/**
|
||||
* Timeout for HTTP requests.
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
private $requestTimeout;
|
||||
|
||||
/**
|
||||
* CURL Query.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $query;
|
||||
|
||||
/**
|
||||
* Id of the current module.
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
private $idAgentModule;
|
||||
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*
|
||||
* @param string $ajaxController Ajax Page Controller.
|
||||
* @param integer $idAgentModule Id of the module.
|
||||
*/
|
||||
public function __construct(string $ajaxController, int $idAgentModule)
|
||||
{
|
||||
global $config;
|
||||
|
||||
// Check access.
|
||||
check_login();
|
||||
|
||||
if (! check_acl($config['id_user'], 0, 'AR')) {
|
||||
db_pandora_audit(
|
||||
'ACL Violation',
|
||||
'Trying to access event viewer'
|
||||
);
|
||||
|
||||
if (is_ajax()) {
|
||||
echo json_encode(['error' => 'noaccess']);
|
||||
}
|
||||
|
||||
include 'general/noaccess.php';
|
||||
exit;
|
||||
}
|
||||
|
||||
// Parameter assigments.
|
||||
$this->ajaxController = $ajaxController;
|
||||
$this->query = '';
|
||||
$this->idAgentModule = $idAgentModule;
|
||||
// Hardcoded request timeout.
|
||||
$this->requestTimeout = 15;
|
||||
|
||||
return $this;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Run Module Debug window.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
// Added all necessary basic files for QueryResult.
|
||||
ui_require_css_file('ace');
|
||||
ui_require_javascript_file('ace', 'include/javascript/ace/');
|
||||
// Load Javascript.
|
||||
$this->loadJS();
|
||||
// CSS.
|
||||
ui_require_css_file('wizard');
|
||||
ui_require_css_file('discovery');
|
||||
// Specific CSS for this feature.
|
||||
ui_require_css_file('WebServerModuleDebug', '/include/styles/', true);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Show the modal with the QueryResult.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function showWebServerDebug()
|
||||
{
|
||||
// Show QueryResult editor.
|
||||
ui_query_result_editor('webserverdebug');
|
||||
// Spinner for wait loads.
|
||||
html_print_div(
|
||||
[
|
||||
'id' => 'WebServerDebugSpinner',
|
||||
'style' => 'visibility: hidden;',
|
||||
'content' => __('Performing query. Please wait.').' '.html_print_image('images/spinner.gif', true),
|
||||
]
|
||||
);
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function(){
|
||||
// Query section
|
||||
var query = ace.edit("webserverdebug_editor");
|
||||
let queryDefined = "<?php echo $this->defineQuery(); ?>";
|
||||
let queryRegex = /([-]+[a-zA-Z]\s)|(([-]{2})+[a-z]+[-]*[a-z]*)/g;
|
||||
query.setValue(queryDefined.replace(queryRegex, "\n$&"));
|
||||
query.clearSelection();
|
||||
// Result section
|
||||
var results = ace.edit("webserverdebug_view");
|
||||
var text = '';
|
||||
results.setTheme("ace/theme/textmate");
|
||||
results.session.setMode("ace/mode/json");
|
||||
results.renderer.setShowGutter(false);
|
||||
results.setReadOnly(true);
|
||||
results.setShowPrintMargin(false);
|
||||
|
||||
$("#submit-execute_query").click(function() {
|
||||
// Show the spinner.
|
||||
showSpinner(true);
|
||||
// Empty the results container.
|
||||
results.setValue("");
|
||||
// Get the entire text.
|
||||
text = query.getValue();
|
||||
// There are not values in the query section.
|
||||
if (text === null || text === undefined) {
|
||||
results.setValue('<?php echo __('No results'); ?>');
|
||||
results.clearSelection();
|
||||
// Hide spinner.
|
||||
showSpinner(false);
|
||||
return;
|
||||
}
|
||||
// Clean the carriage jumps.
|
||||
text = text.split("\n").join("");
|
||||
// Call to the method for execute the command.
|
||||
$.ajax({
|
||||
method: "post",
|
||||
url: "<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",
|
||||
data: {
|
||||
page: "<?php echo $this->ajaxController; ?>",
|
||||
method: "executeCommand",
|
||||
text: text,
|
||||
idAgentModule: "<?php echo $this->idAgentModule; ?>",
|
||||
},
|
||||
datatype: "json",
|
||||
success: function(result) {
|
||||
results.setValue(result);
|
||||
},
|
||||
error: function(e) {
|
||||
results.setValue('<?php echo __('Error performing execution'); ?>');
|
||||
},
|
||||
complete: function() {
|
||||
results.clearSelection();
|
||||
showSpinner(false);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Definition of the query
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function defineQuery()
|
||||
{
|
||||
// Get the value of the debug_content.
|
||||
$outputDebugQuery = db_get_value_filter(
|
||||
'debug_content',
|
||||
'tagente_modulo',
|
||||
[
|
||||
'id_agente_modulo' => $this->idAgentModule,
|
||||
]
|
||||
);
|
||||
|
||||
$this->query = ($outputDebugQuery !== false) ? $outputDebugQuery : __('Please, wait for a first execution of module');
|
||||
|
||||
return $this->query;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Perform the cURL execution.
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception $e Error message.
|
||||
*/
|
||||
public function executeCommand()
|
||||
{
|
||||
try {
|
||||
$executionForPerform = io_safe_output(get_parameter('text'));
|
||||
// If the execution comes empty.
|
||||
if (empty($executionForPerform) === true) {
|
||||
throw new Exception('Execution failed');
|
||||
}
|
||||
|
||||
// For security reasons, only allow the 'curl' command.
|
||||
$executionForPerform = strstr($executionForPerform, 'curl');
|
||||
// Avoid pipes or concatenation of commands.
|
||||
$unallowedChars = [
|
||||
'|',
|
||||
'&',
|
||||
'||',
|
||||
'&&',
|
||||
';',
|
||||
'\n',
|
||||
];
|
||||
$executionForPerform = str_replace(
|
||||
$unallowedChars,
|
||||
' ',
|
||||
$executionForPerform
|
||||
);
|
||||
// Set execution timeout.
|
||||
$executionForPerform .= sprintf(
|
||||
$executionForPerform.' -m %d',
|
||||
$this->requestTimeout
|
||||
);
|
||||
|
||||
// Perform the execution.
|
||||
system($executionForPerform, $returnCode);
|
||||
// If execution does not got well.
|
||||
if ($returnCode != 0) {
|
||||
switch ($returnCode) {
|
||||
case '2':
|
||||
throw new Exception('Failed to initialize. Review the syntax.');
|
||||
|
||||
case '3':
|
||||
throw new Exception('URL malformed. The syntax was not correct.');
|
||||
|
||||
case '5':
|
||||
throw new Exception('Couldn\'t resolve proxy. The given proxy host could not be resolved.');
|
||||
|
||||
case '6':
|
||||
throw new Exception('Couldn\'t resolve host. The given remote host could not be resolved.');
|
||||
|
||||
case '7':
|
||||
throw new Exception('Failed to connect to host.');
|
||||
|
||||
default:
|
||||
throw new Exception('Failed getting data.');
|
||||
}
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
// Show execution error message.
|
||||
echo __($e->getMessage());
|
||||
}
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Loads JS and return code.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function loadJS()
|
||||
{
|
||||
$str = '';
|
||||
ob_start();
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
|
||||
$(document).ready(function(){
|
||||
$('#button-btn_debugModule').click(function() {
|
||||
load_modal({
|
||||
target: $("#modal"),
|
||||
form: "add_module_form",
|
||||
url: "<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",
|
||||
ajax_callback: showMsg,
|
||||
modal: {
|
||||
title: "<?php echo __('Debug'); ?>",
|
||||
},
|
||||
extradata: [
|
||||
{
|
||||
name: "idAgentModule",
|
||||
value: "<?php echo $this->idAgentModule; ?>"
|
||||
}],
|
||||
onshow: {
|
||||
page: "<?php echo $this->ajaxController; ?>",
|
||||
width: 800,
|
||||
method: "showWebServerDebug"
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* Toggle the visibility of spinner.
|
||||
*/
|
||||
function showSpinner(setVisibility) {
|
||||
var spinner = $('#WebServerDebugSpinner');
|
||||
if (setVisibility) {
|
||||
spinner.css('visibility', 'visible');
|
||||
} else {
|
||||
spinner.css('visibility', 'hidden');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Process ajax responses and shows a dialog with results.
|
||||
*/
|
||||
function showMsg(data) {
|
||||
var title = "<?php echo __('Success'); ?>";
|
||||
var text = "";
|
||||
var failed = 0;
|
||||
try {
|
||||
data = JSON.parse(data);
|
||||
text = data["result"];
|
||||
} catch (err) {
|
||||
title = "<?php echo __('Failed'); ?>";
|
||||
text = err.message;
|
||||
failed = 1;
|
||||
}
|
||||
if (!failed && data["error"] != undefined) {
|
||||
title = "<?php echo __('Failed'); ?>";
|
||||
text = data["error"];
|
||||
failed = 1;
|
||||
}
|
||||
if (data["report"] != undefined) {
|
||||
data["report"].forEach(function(item) {
|
||||
text += "<br>" + item;
|
||||
});
|
||||
}
|
||||
|
||||
$("#msg").empty();
|
||||
$("#msg").html(text);
|
||||
$("#msg").dialog({
|
||||
width: 450,
|
||||
position: {
|
||||
my: "center",
|
||||
at: "center",
|
||||
of: window,
|
||||
collision: "fit"
|
||||
},
|
||||
title: title
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
<?php
|
||||
// Get the JS script.
|
||||
$str = ob_get_clean();
|
||||
// Return the loaded JS.
|
||||
echo $str;
|
||||
return $str;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -20,7 +20,7 @@
|
|||
/**
|
||||
* Pandora build version and version
|
||||
*/
|
||||
$build_version = 'PC210504';
|
||||
$build_version = 'PC210513';
|
||||
$pandora_version = 'v7.0NG.754';
|
||||
|
||||
// Do not overwrite default timezone set if defined.
|
||||
|
|
|
@ -2755,7 +2755,7 @@ function alerts_ui_update_or_create_actions($update=true)
|
|||
$al_action = alerts_get_alert_action($id);
|
||||
if ($al_action !== false) {
|
||||
if ($al_action['id_group'] == 0) {
|
||||
if (! check_acl($config['id_user'], 0, 'PM')) {
|
||||
if (! check_acl($config['id_user'], 0, 'PM') && ! check_acl($config['id_user'], 0, 'LM')) {
|
||||
db_pandora_audit(
|
||||
'ACL Violation',
|
||||
'Trying to access Alert Management'
|
||||
|
|
|
@ -1,16 +1,33 @@
|
|||
<?php
|
||||
|
||||
// Pandora FMS- http://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
|
||||
// Please see http://pandorafms.org for full contribution list
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public License
|
||||
// as published by the Free Software Foundation; version 2
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
/**
|
||||
* Functions for API.
|
||||
*
|
||||
* @category Functions.
|
||||
* @package Pandora FMS
|
||||
* @subpackage API.
|
||||
* @version 1.0.0
|
||||
* @license See below
|
||||
*
|
||||
* ______ ___ _______ _______ ________
|
||||
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
|
||||
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
|
||||
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
|
||||
*
|
||||
* ============================================================================
|
||||
* Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
|
||||
* Please see http://pandorafms.org for full contribution list
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation for version 2.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* ============================================================================
|
||||
*/
|
||||
|
||||
// Begin.
|
||||
global $config;
|
||||
|
||||
// Set character encoding to UTF-8 - fixes a lot of multibyte character headaches
|
||||
|
@ -1614,6 +1631,302 @@ function api_set_update_agent($id_agent, $thrash2, $other, $thrash3)
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Update an agent by indicating a pair of field - value separated by comma.
|
||||
*
|
||||
* @param integer $id_agent Id (or alias) agent to upadate.
|
||||
* @param boolean $use_agent_alias Use alias instead of id.
|
||||
* @param array $params Pair of parameter/value separated by comma. Available fields are:
|
||||
* 'alias',
|
||||
* 'direccion',
|
||||
* 'id_parent',
|
||||
* 'id_grupo',
|
||||
* 'cascade_protection',
|
||||
* 'cascade_protection_module',
|
||||
* 'intervalo',
|
||||
* 'id_os',
|
||||
* 'server_name',
|
||||
* 'custom_id',
|
||||
* 'modo',
|
||||
* 'disabled',
|
||||
* 'comentarios'
|
||||
*
|
||||
* eg . http://127.0.0.1/pandora_console/include/api.php?op=set&op2=update_agent_field&id=pandora&other=id_os,1|alias,pandora|direccion,192.168.10.16|id_parent,1cascade_protection,1|cascade_protection_module,1|intervalo,5||modo|3|&other_mode=url_encode_separator_|&apipass=1234&user=admin&pass=pandora
|
||||
*/
|
||||
function api_set_update_agent_field($id_agent, $use_agent_alias, $params)
|
||||
{
|
||||
global $config;
|
||||
$return = false;
|
||||
|
||||
if (defined('METACONSOLE')) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!check_acl($config['id_user'], 0, 'AW')) {
|
||||
returnError('forbidden', 'string');
|
||||
return;
|
||||
}
|
||||
|
||||
// Check the agent.
|
||||
if ((bool) $use_agent_alias === true) {
|
||||
$agents_by_alias = agents_get_agent_id_by_alias($id_agent);
|
||||
if (empty($agents_by_alias) === false) {
|
||||
foreach ($agents_by_alias as $agent) {
|
||||
if (agents_check_access_agent($agent['id_agente'], 'AW') === true) {
|
||||
$agents[] = $agent['id_agente'];
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($agents) === true) {
|
||||
returnError('forbidden', 'string');
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
returnError('Alias does not match any agent.');
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (!util_api_check_agent_and_print_error($id_agent, 'string', 'AW')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$agents[] = $id_agent;
|
||||
}
|
||||
|
||||
// Serialize the data for update.
|
||||
if ($params['type'] === 'array') {
|
||||
// Keys available to change.
|
||||
$available_fields = [
|
||||
'alias',
|
||||
'direccion',
|
||||
'id_parent',
|
||||
'id_grupo',
|
||||
'cascade_protection',
|
||||
'cascade_protection_module',
|
||||
'intervalo',
|
||||
'id_os',
|
||||
'server_name',
|
||||
'custom_id',
|
||||
'modo',
|
||||
'disabled',
|
||||
'comentarios',
|
||||
];
|
||||
|
||||
foreach ($params['data'] as $key_value) {
|
||||
list($key, $value) = explode(',', $key_value, 2);
|
||||
if (in_array($key, $available_fields) === true) {
|
||||
$fields[$key] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($fields) === true) {
|
||||
returnError('Selected field not available. Please, select one the fields avove');
|
||||
return;
|
||||
}
|
||||
|
||||
// Check fields.
|
||||
foreach ($fields as $field => $data) {
|
||||
switch ($field) {
|
||||
case 'alias':
|
||||
if (empty($data)) {
|
||||
returnError('No agent alias specified');
|
||||
return;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'id_grupo':
|
||||
if (db_get_value_sql('SELECT FROM tgrupo WHERE id_grupo = '.$data) === false) {
|
||||
returnError('The group doesn`t exist.');
|
||||
return;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'id_os':
|
||||
if (db_get_value_sql('SELECT id_os FROM tconfig_os WHERE id_os = '.$data) === false) {
|
||||
returnError('The OS doesn`t exist.');
|
||||
return;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'server_name':
|
||||
$server_name = db_get_value_sql('SELECT name FROM tserver WHERE BINARY name LIKE "'.$data.'"');
|
||||
if ($server_name === false) {
|
||||
returnError('The server doesn`t exist.');
|
||||
return;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'cascade_protection':
|
||||
if ($data == 1) {
|
||||
if (($field['id_parent'] != 0) && (db_get_value_sql(
|
||||
'SELECT id_agente_modulo
|
||||
FROM tagente_modulo
|
||||
WHERE id_agente = '.$fields['id_parent'].' AND id_agente_modulo = '.$fields['cascade_protection_module']
|
||||
) === false)
|
||||
) {
|
||||
returnError('Cascade protection is not applied because it is not a parent module');
|
||||
}
|
||||
} else {
|
||||
unset($fields['cascade_protection']);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'id_grupo':
|
||||
// Check ACL group.
|
||||
if (!check_acl($config['id_user'], $data, 'AW')) {
|
||||
returnError('forbidden', 'string');
|
||||
return;
|
||||
}
|
||||
|
||||
if ($data == 0) {
|
||||
$agent_update_error = 'The agent could not be modified. For security reasons, use a group other than 0.';
|
||||
returnError($agent_update_error);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'id_parent':
|
||||
$parentCheck = agents_check_access_agent($data);
|
||||
if (is_null($parentCheck) === true) {
|
||||
returnError('The parent agent does not exist.');
|
||||
return;
|
||||
}
|
||||
|
||||
if ($parentCheck === false) {
|
||||
returnError('The user cannot access to parent agent.');
|
||||
return;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
// Default empty.
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Var applied in case there is more than one agent.
|
||||
$return = false;
|
||||
$applied = 0;
|
||||
foreach ($agents as $agent) {
|
||||
$values_old = db_get_row_filter(
|
||||
'tagente',
|
||||
['id_agente' => $agent],
|
||||
[
|
||||
'id_grupo',
|
||||
'disabled',
|
||||
]
|
||||
);
|
||||
|
||||
$tpolicy_group_old = db_get_all_rows_sql(
|
||||
'SELECT id_policy FROM tpolicy_groups
|
||||
WHERE id_group = '.$values_old['id_grupo']
|
||||
);
|
||||
|
||||
$return = db_process_sql_update(
|
||||
'tagente',
|
||||
$fields,
|
||||
['id_agente' => $agent]
|
||||
);
|
||||
|
||||
if ((count($agents) > 1) && $return !== 0) {
|
||||
$applied += 1;
|
||||
}
|
||||
|
||||
if ($return && !isset($field['direccion'])) {
|
||||
// register ip for this agent in 'taddress'.
|
||||
agents_add_address($agent, $field['direccion']);
|
||||
}
|
||||
|
||||
if ($return) {
|
||||
// Update config file
|
||||
if (isset($field['disabled']) && $values_old['disabled'] != $field['disabled']) {
|
||||
enterprise_hook(
|
||||
'config_agents_update_config_token',
|
||||
[
|
||||
$agent,
|
||||
'standby',
|
||||
$field['disabled'],
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
if ($tpolicy_group_old) {
|
||||
foreach ($tpolicy_group_old as $key => $value) {
|
||||
$tpolicy_agents_old = db_get_sql(
|
||||
'SELECT * FROM tpolicy_agents
|
||||
WHERE id_policy = '.$value['id_policy'].' AND id_agent = '.$agent
|
||||
);
|
||||
|
||||
if ($tpolicy_agents_old) {
|
||||
$result2 = db_process_sql_update(
|
||||
'tpolicy_agents',
|
||||
['pending_delete' => 1],
|
||||
[
|
||||
'id_agent' => $agent,
|
||||
'id_policy' => $value['id_policy'],
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$tpolicy_group = db_get_all_rows_sql(
|
||||
'SELECT id_policy FROM tpolicy_groups
|
||||
WHERE id_group = '.$field['id_grupo']
|
||||
);
|
||||
|
||||
if ($tpolicy_group) {
|
||||
foreach ($tpolicy_group as $key => $value) {
|
||||
$tpolicy_agents = db_get_sql(
|
||||
'SELECT * FROM tpolicy_agents
|
||||
WHERE id_policy = '.$value['id_policy'].' AND id_agent ='.$agent
|
||||
);
|
||||
|
||||
if (!$tpolicy_agents) {
|
||||
db_process_sql_insert(
|
||||
'tpolicy_agents',
|
||||
[
|
||||
'id_policy' => $value['id_policy'],
|
||||
'id_agent' => $agent,
|
||||
]
|
||||
);
|
||||
} else {
|
||||
$result3 = db_process_sql_update(
|
||||
'tpolicy_agents',
|
||||
['pending_delete' => 0],
|
||||
[
|
||||
'id_agent' => $agent,
|
||||
'id_policy' => $value['id_policy'],
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (count($agents) > 1) {
|
||||
returnData(
|
||||
'string',
|
||||
[
|
||||
'type' => 'string',
|
||||
'data' => __('Updated %d/%d agents', $applied, count($agents)),
|
||||
]
|
||||
);
|
||||
} else {
|
||||
returnData(
|
||||
'string',
|
||||
[
|
||||
'type' => 'string',
|
||||
'data' => __('Agent updated.'),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create a new agent, and print the id for new agent.
|
||||
*
|
||||
|
@ -2004,13 +2317,13 @@ function api_set_delete_agent($id, $thrash1, $other, $returnType)
|
|||
|
||||
foreach ($servers as $server) {
|
||||
if (metaconsole_connect($server) == NOERR) {
|
||||
if ($other['data'][0] === '1') {
|
||||
if ($agent_by_alias) {
|
||||
$idAgent = agents_get_agent_id_by_alias($id);
|
||||
} else {
|
||||
$idAgent[0] = agents_get_agent_id($id, true);
|
||||
}
|
||||
|
||||
if (!empty($idAgent)) {
|
||||
if (empty($idAgent) === false) {
|
||||
$result = agents_delete_agent($idAgent[0], true);
|
||||
}
|
||||
|
||||
|
@ -2121,9 +2434,9 @@ function api_get_all_agents($thrash1, $thrash2, $other, $returnType)
|
|||
}
|
||||
|
||||
$ag_groups = implode(',', (array) $ag_groups);
|
||||
}
|
||||
|
||||
$where .= ' AND (id_grupo IN ('.$ag_groups.') OR id_group IN ('.$ag_groups.'))';
|
||||
$where .= ' AND (id_grupo IN ('.$ag_groups.') OR id_group IN ('.$ag_groups.'))';
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($other['data'][3])) {
|
||||
|
@ -6717,7 +7030,7 @@ function api_set_stop_downtime($id, $thrash1, $other, $thrash3)
|
|||
$data = db_get_row_sql($sql);
|
||||
|
||||
if ($data['type_execution'] == 'periodically' && $data['executed'] == 1) {
|
||||
returnError('error_stop_downtime', __('Error stopping downtime. Periodical and running planned downtime cannot be stopped.'));
|
||||
returnError('error_stop_downtime', __('Error stopping downtime. Periodical and running scheduled downtime cannot be stopped.'));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -7203,7 +7516,7 @@ function api_set_planned_downtimes_additem($id, $thrash1, $other, $thrash3)
|
|||
}
|
||||
|
||||
if (empty($agents)) {
|
||||
returnError('No agents to create planned downtime items');
|
||||
returnError('No agents to create scheduled downtime items');
|
||||
} else {
|
||||
if (!empty($returned['bad_modules'])) {
|
||||
$bad_modules = __("and this modules are doesn't exists or not applicable a this agents: ").implode(', ', $returned['bad_modules']);
|
||||
|
@ -8412,6 +8725,7 @@ function api_set_create_group($id, $thrash1, $other, $thrash3)
|
|||
$values['contact'] = $safe_other_data[6];
|
||||
$values['other'] = $safe_other_data[7];
|
||||
$values['max_agents'] = $safe_other_data[8];
|
||||
$values['password'] = $safe_other_data[9];
|
||||
|
||||
$id_group = groups_create_group($group_name, $values);
|
||||
|
||||
|
@ -11248,10 +11562,10 @@ function api_set_add_user_profile($id, $thrash1, $other, $thrash2)
|
|||
return;
|
||||
}
|
||||
|
||||
$group = $other['data'][0];
|
||||
$group = (int) $other['data'][0];
|
||||
$profile = $other['data'][1];
|
||||
|
||||
if (db_get_value('id_grupo', 'tgrupo', 'id_grupo', $group) === false) {
|
||||
if ($group !== 0 && db_get_value('id_grupo', 'tgrupo', 'id_grupo', $group) === false) {
|
||||
returnError('There is not any group with the ID provided.');
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -319,7 +319,7 @@ function config_update_config()
|
|||
}
|
||||
|
||||
if (!config_update_value('past_planned_downtimes', get_parameter('past_planned_downtimes'))) {
|
||||
$error_update[] = __('Allow create planned downtimes in the past');
|
||||
$error_update[] = __('Allow create scheduled downtimes in the past');
|
||||
}
|
||||
|
||||
if (!config_update_value('limit_parameters_massive', get_parameter('limit_parameters_massive'))) {
|
||||
|
|
|
@ -3792,7 +3792,7 @@ function events_page_responses($event, $childrens_ids=[])
|
|||
$('.params_rows').remove();
|
||||
|
||||
$('#responses_table')
|
||||
.append('<tr class=\"params_rows\"><td>".__('Description')."</td><td class=\"left height_30px\" colspan=\"2\">'+description+'</td></tr>');
|
||||
.append('<tr class=\"params_rows\"><td>".__('Description')."</td><td class=\"height_30px\" colspan=\"2\">'+description+'</td></tr>');
|
||||
|
||||
if (params.length == 1 && params[0] == '') {
|
||||
return;
|
||||
|
@ -4318,10 +4318,6 @@ function events_page_details($event, $server='')
|
|||
|
||||
$table_class = 'table_modal_alternate';
|
||||
|
||||
if ($config['style'] === 'pandora_black') {
|
||||
$table_class = 'black_table_modal_alternate';
|
||||
}
|
||||
|
||||
// Details.
|
||||
$table_details = new stdClass;
|
||||
$table_details->width = '100%';
|
||||
|
@ -4526,7 +4522,7 @@ function events_page_details($event, $server='')
|
|||
$link = "winopeng_var('".$url.'?'.$graph_params_str."','".$win_handle."', 800, 480)";
|
||||
|
||||
$data[1] = '<a href="javascript:'.$link.'">';
|
||||
$data[1] .= html_print_image('images/chart_curve.png', true);
|
||||
$data[1] .= html_print_image('images/chart_curve.png', true, ['class' => 'invert_filter']);
|
||||
$data[1] .= '</a>';
|
||||
$table_details->data[] = $data;
|
||||
}
|
||||
|
@ -4546,13 +4542,19 @@ function events_page_details($event, $server='')
|
|||
$data[1] .= html_print_image(
|
||||
'images/bell.png',
|
||||
true,
|
||||
['title' => __('Go to data overview')]
|
||||
[
|
||||
'title' => __('Go to data overview'),
|
||||
'class' => 'invert_filter',
|
||||
]
|
||||
);
|
||||
} else {
|
||||
$data[1] .= html_print_image(
|
||||
'images/bell_pause.png',
|
||||
true,
|
||||
['title' => __('Go to data overview')]
|
||||
[
|
||||
'title' => __('Go to data overview'),
|
||||
'class' => 'invert_filter',
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -2765,6 +2765,8 @@ function html_print_input_image($name, $src, $value, $style='', $return=false, $
|
|||
'lang',
|
||||
'tabindex',
|
||||
'title',
|
||||
'data-title',
|
||||
'data-use_title_for_force_title',
|
||||
'xml:lang',
|
||||
'onclick',
|
||||
'ondblclick',
|
||||
|
@ -5078,10 +5080,13 @@ function html_print_input_multicheck(array $data):string
|
|||
/**
|
||||
* Print an autocomplete input filled out with Integria IMS users.
|
||||
*
|
||||
* @param string $name The name of ajax control, by default is "users".
|
||||
* @param string $default The default value to show in the ajax control.
|
||||
* @param boolean $return If it is true return a string with the output instead to echo the output.
|
||||
* @param string $size Size.
|
||||
* @param string $name The name of ajax control, by default is "users".
|
||||
* @param string $default The default value to show in the ajax control.
|
||||
* @param boolean $return If it is true return a string with the output instead to echo the output.
|
||||
* @param string $size Size.
|
||||
* @param boolean $disable Disable the button (optional, button enabled by default).
|
||||
* @param boolean $required Attribute required.
|
||||
* @param string $class Text inpunt class.
|
||||
*
|
||||
* @return mixed If the $return is true, return the output as string.
|
||||
*/
|
||||
|
@ -5091,7 +5096,8 @@ function html_print_autocomplete_users_from_integria(
|
|||
$return=false,
|
||||
$size='30',
|
||||
$disable=false,
|
||||
$required=false
|
||||
$required=false,
|
||||
$class=null
|
||||
) {
|
||||
global $config;
|
||||
|
||||
|
@ -5108,6 +5114,10 @@ function html_print_autocomplete_users_from_integria(
|
|||
$attrs['required'] = 'required';
|
||||
}
|
||||
|
||||
if (empty($class) === false) {
|
||||
$attrs['class'] = $class;
|
||||
}
|
||||
|
||||
html_print_input_text_extended(
|
||||
$name,
|
||||
$default,
|
||||
|
|
|
@ -211,7 +211,7 @@ function integria_api_call($api_hostname=null, $user=null, $user_pass=null, $api
|
|||
}
|
||||
|
||||
// Build URL for API request.
|
||||
$url = $api_hostname.'/integria/include/api.php';
|
||||
$url = $api_hostname.'/include/api.php';
|
||||
|
||||
// ob_start();
|
||||
// $out = fopen('php://output', 'w');
|
||||
|
|
|
@ -590,3 +590,32 @@ function io_output_password($password)
|
|||
|
||||
return io_safe_output($plaintext);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Clean html tags symbols for prevent use JS
|
||||
*
|
||||
* @param string $string String for safe.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function io_safe_html_tags(string $string)
|
||||
{
|
||||
// Must have safe output for work properly.
|
||||
$string = io_safe_output($string);
|
||||
if (strpos($string, '<') !== false && strpos($string, '>') !== false) {
|
||||
$output = strstr($string, '<', true);
|
||||
$tmpOutput = strstr($string, '<');
|
||||
$output .= strstr(substr($tmpOutput, 1), '>', true);
|
||||
$tmpOutput = strstr($string, '>');
|
||||
$output .= substr($tmpOutput, 1);
|
||||
// If the string still contains tags symbols.
|
||||
if (strpos($string, '<') !== false && strpos($string, '>') !== false) {
|
||||
$output = io_safe_html_tags($output);
|
||||
}
|
||||
} else {
|
||||
$output = $string;
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
|
|
@ -1,22 +1,32 @@
|
|||
<?php
|
||||
|
||||
// Pandora FMS - http://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
|
||||
// Please see http://pandorafms.org for full contribution list
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public License
|
||||
// as published by the Free Software Foundation; version 2
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
/**
|
||||
* @package Include
|
||||
* @subpackage Modules
|
||||
* Functions for modules.
|
||||
*
|
||||
* @category Functions script.
|
||||
* @package Pandora FMS
|
||||
* @subpackage Modules.
|
||||
* @version 1.0.0
|
||||
* @license See below
|
||||
*
|
||||
* ______ ___ _______ _______ ________
|
||||
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
|
||||
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
|
||||
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
|
||||
*
|
||||
* ============================================================================
|
||||
* Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
|
||||
* Please see http://pandorafms.org for full contribution list
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation for version 2.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* ============================================================================
|
||||
*/
|
||||
|
||||
// Begin.
|
||||
require_once $config['homedir'].'/include/functions_agents.php';
|
||||
require_once $config['homedir'].'/include/functions_users.php';
|
||||
require_once $config['homedir'].'/include/functions_tags.php';
|
||||
|
@ -567,7 +577,7 @@ function modules_update_agent_module(
|
|||
* Creates a module in an agent.
|
||||
*
|
||||
* @param integer $id_agent Agent id.
|
||||
* @param integer $name Module name id.
|
||||
* @param string $name Module name id.
|
||||
* @param array $values Extra values for the module.
|
||||
* @param boolean $disableACL Disable the ACL checking, for default false.
|
||||
* @param mixed $tags Array with tag's ids or false.
|
||||
|
@ -575,35 +585,36 @@ function modules_update_agent_module(
|
|||
* @return New module id if the module was created. False if not.
|
||||
*/
|
||||
function modules_create_agent_module(
|
||||
$id_agent,
|
||||
$name,
|
||||
$values=false,
|
||||
$disableACL=false,
|
||||
int $id_agent,
|
||||
string $name,
|
||||
array $values=[],
|
||||
bool $disableACL=false,
|
||||
$tags=false
|
||||
) {
|
||||
global $config;
|
||||
|
||||
if (!$disableACL) {
|
||||
if (!users_is_admin() && (empty($id_agent)
|
||||
|| !users_access_to_agent($id_agent, 'AW'))
|
||||
if ((bool) $disableACL === false) {
|
||||
if ((bool) users_is_admin() === false
|
||||
&& (empty($id_agent) === true
|
||||
|| users_access_to_agent($id_agent, 'AW') === false)
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($name)) {
|
||||
if (empty($name) === true) {
|
||||
return ERR_INCOMPLETE;
|
||||
}
|
||||
|
||||
// Check for non valid characters in module name.
|
||||
if (mb_ereg_match('[\xc2\xa1\xc2\xbf\xc3\xb7\xc2\xba\xc2\xaa]', io_safe_output($name)) !== false) {
|
||||
if (mb_ereg_match(
|
||||
'[\xc2\xa1\xc2\xbf\xc3\xb7\xc2\xba\xc2\xaa]',
|
||||
io_safe_output($name)
|
||||
) !== false
|
||||
) {
|
||||
return ERR_GENERIC;
|
||||
}
|
||||
|
||||
if (! is_array($values)) {
|
||||
$values = [];
|
||||
}
|
||||
|
||||
$values['nombre'] = $name;
|
||||
$values['id_agente'] = (int) $id_agent;
|
||||
|
||||
|
@ -616,29 +627,39 @@ function modules_create_agent_module(
|
|||
]
|
||||
);
|
||||
|
||||
if ($exists) {
|
||||
if ($exists === true) {
|
||||
return ERR_EXIST;
|
||||
}
|
||||
|
||||
// Encrypt passwords.
|
||||
if (isset($values['plugin_pass'])) {
|
||||
// Avoid two times encryption
|
||||
if (isset($values['plugin_pass']) === true) {
|
||||
// Avoid two times encryption.
|
||||
$plugin_pass = io_safe_output($values['plugin_pass']);
|
||||
|
||||
$values['plugin_pass'] = io_input_password($plugin_pass);
|
||||
}
|
||||
|
||||
// Encrypt SNMPv3 passwords.
|
||||
if (isset($values['id_tipo_modulo']) && ($values['id_tipo_modulo'] >= 15
|
||||
&& $values['id_tipo_modulo'] <= 18)
|
||||
&& isset($values['tcp_send']) && ($values['tcp_send'] == 3)
|
||||
&& isset($values['custom_string_2'])
|
||||
if (isset($values['id_tipo_modulo']) === true
|
||||
&& ((int) $values['id_tipo_modulo'] >= MODULE_TYPE_REMOTE_SNMP
|
||||
&& (int) $values['id_tipo_modulo'] <= MODULE_TYPE_REMOTE_SNMP_PROC)
|
||||
&& isset($values['tcp_send']) === true
|
||||
&& ((int) $values['tcp_send'] === 3)
|
||||
&& isset($values['custom_string_2']) === true
|
||||
) {
|
||||
$values['custom_string_2'] = io_input_password(
|
||||
$values['custom_string_2']
|
||||
);
|
||||
}
|
||||
|
||||
// Only for Web server modules.
|
||||
if (isset($values['id_tipo_modulo']) === true
|
||||
&& ($values['id_tipo_modulo'] >= MODULE_TYPE_WEB_ANALYSIS
|
||||
&& $values['id_tipo_modulo'] <= MODULE_TYPE_WEB_CONTENT_STRING)
|
||||
) {
|
||||
$values['debug_content'] = io_safe_input($values['debug_content']);
|
||||
}
|
||||
|
||||
$id_agent_module = db_process_sql_insert('tagente_modulo', $values);
|
||||
|
||||
if ($id_agent_module === false) {
|
||||
|
@ -646,7 +667,7 @@ function modules_create_agent_module(
|
|||
}
|
||||
|
||||
$return_tag = true;
|
||||
if (($tags !== false) || (empty($tags))) {
|
||||
if (($tags !== false) || (empty($tags) === true)) {
|
||||
$return_tag = tags_insert_module_tag($id_agent_module, $tags);
|
||||
}
|
||||
|
||||
|
@ -659,10 +680,10 @@ function modules_create_agent_module(
|
|||
return ERR_DB;
|
||||
}
|
||||
|
||||
if (isset($values['id_tipo_modulo'])
|
||||
&& ($values['id_tipo_modulo'] == 21
|
||||
|| $values['id_tipo_modulo'] == 22
|
||||
|| $values['id_tipo_modulo'] == 23)
|
||||
if (isset($values['id_tipo_modulo']) === true
|
||||
&& ((int) $values['id_tipo_modulo'] === MODULE_TYPE_ASYNC_PROC
|
||||
|| (int) $values['id_tipo_modulo'] === MODULE_TYPE_ASYNC_DATA
|
||||
|| (int) $values['id_tipo_modulo'] === MODULE_TYPE_ASYNC_STRING)
|
||||
) {
|
||||
// Async modules start in normal status.
|
||||
$status = AGENT_MODULE_STATUS_NORMAL;
|
||||
|
@ -706,8 +727,8 @@ function modules_create_agent_module(
|
|||
}
|
||||
|
||||
// Update module status count if the module is not created disabled.
|
||||
if ((!isset($values['disabled']) || $values['disabled'] == 0) && $values['id_modulo'] > 0) {
|
||||
if ($status == 0) {
|
||||
if (isset($values['disabled']) === false || (int) $values['disabled'] === 0) {
|
||||
if ((int) $status === AGENT_MODULE_STATUS_NORMAL) {
|
||||
db_process_sql(
|
||||
'UPDATE tagente
|
||||
SET total_count=total_count+1, normal_count=normal_count+1
|
||||
|
@ -2362,7 +2383,7 @@ function modules_get_agentmodule_data_for_humans($module)
|
|||
}
|
||||
} else {
|
||||
$data_macro = modules_get_unit_macro($module['datos'], $module['unit']);
|
||||
if ($data_macro) {
|
||||
if ($data_macro !== false) {
|
||||
$salida = $data_macro;
|
||||
} else {
|
||||
$salida = ui_print_module_string_value(
|
||||
|
|
|
@ -95,12 +95,12 @@ function planned_downtimes_update($values, $downtime_id=0, $check_dates=true)
|
|||
$name_exists = (bool) db_get_value('id', 'tplanned_downtime', 'name', $values['name']);
|
||||
|
||||
if ($name_exists) {
|
||||
$result['message'] = ui_print_error_message(__('Each planned downtime must have a different name'), '', true);
|
||||
$result['message'] = ui_print_error_message(__('Each scheduled downtime must have a different name'), '', true);
|
||||
|
||||
return $result;
|
||||
}
|
||||
} else {
|
||||
$result['message'] = ui_print_error_message(__('Planned downtime must have a name'), '', true);
|
||||
$result['message'] = ui_print_error_message(__('Scheduled downtime must have a name'), '', true);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
@ -811,13 +811,13 @@ function planned_downtimes_created($values)
|
|||
} else {
|
||||
return [
|
||||
'return' => false,
|
||||
'message' => __('Each planned downtime must have a different name'),
|
||||
'message' => __('Each scheduled downtime must have a different name'),
|
||||
];
|
||||
}
|
||||
} else {
|
||||
return [
|
||||
'return' => false,
|
||||
'message' => __('Planned downtime must have a name'),
|
||||
'message' => __('Scheduled downtime must have a name'),
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -904,16 +904,16 @@ function delete_planned_downtimes($filter)
|
|||
$downtime_execute = db_get_row_filter('tplanned_downtime', ['id' => $filter['id_downtime']], 'execute');
|
||||
|
||||
if ($downtime_execute) {
|
||||
$return = __("This planned downtime are executed now. Can't delete in this moment.");
|
||||
$return = __("This scheduled downtime are executed now. Can't delete in this moment.");
|
||||
} else {
|
||||
$delete = db_process_sql_delete(
|
||||
'tplanned_downtime',
|
||||
['id' => $filter['id_downtime']]
|
||||
);
|
||||
if ($delete) {
|
||||
$return = __('Deleted this planned downtime successfully.');
|
||||
$return = __('Deleted this scheduled downtime successfully.');
|
||||
} else {
|
||||
$return = __('Problems for deleted this planned downtime.');
|
||||
$return = __('Problems for deleted this scheduled downtime.');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -42,6 +42,7 @@ require_once $config['homedir'].'/include/functions_users.php';
|
|||
enterprise_include_once('include/functions_reporting.php');
|
||||
enterprise_include_once('include/functions_metaconsole.php');
|
||||
enterprise_include_once('include/functions_inventory.php');
|
||||
enterprise_include_once('include/functions_cron.php');
|
||||
require_once $config['homedir'].'/include/functions_forecast.php';
|
||||
require_once $config['homedir'].'/include/functions_ui.php';
|
||||
require_once $config['homedir'].'/include/functions_netflow.php';
|
||||
|
@ -13948,3 +13949,69 @@ function reporting_module_histogram_graph($report, $content, $pdf=0)
|
|||
|
||||
return reporting_check_structure_content($return);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Email template for sending reports.
|
||||
*
|
||||
* @param string $subjectEmail Subject of email.
|
||||
* @param string $bodyEmail Body of email.
|
||||
* @param string $scheduled Id of schedule report.
|
||||
* @param string $reportName Report name.
|
||||
* @param string $email Serialized list of destination emails.
|
||||
* @param array $attachments Attachments.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function reporting_email_template(
|
||||
string $subjectEmail='',
|
||||
string $bodyEmail='',
|
||||
string $scheduled='',
|
||||
string $reportName='',
|
||||
string $email='',
|
||||
array $attachments=null
|
||||
) {
|
||||
// Subject.
|
||||
$subject = (empty($subjectEmail) === true) ? '[Pandora] '.__('Reports') : $subjectEmail;
|
||||
// Body.
|
||||
if (empty($bodyEmail) === true) {
|
||||
$body = __('Greetings').',';
|
||||
$body .= '<p />';
|
||||
$body .= __('Attached to this email there\'s a PDF file of the').' ';
|
||||
$body .= $scheduled.' '.__('report');
|
||||
$body .= ' <strong>"'.$reportName.'"</strong>';
|
||||
$body .= '<p />';
|
||||
$body .= __('Generated at').' '.date('Y/m/d H:i:s');
|
||||
$body .= '<p />';
|
||||
$body .= __('Thanks for your time.');
|
||||
$body .= '<p />';
|
||||
$body .= __('Best regards, Pandora FMS');
|
||||
$body .= '<p />';
|
||||
$body .= '<em>'.__('This is an automatically generated email from Pandora FMS, please do not reply.').'</em>';
|
||||
} else {
|
||||
$bodyEmail = str_replace(
|
||||
[
|
||||
"\r\n",
|
||||
"\r",
|
||||
'
',
|
||||
],
|
||||
"\n",
|
||||
$bodyEmail
|
||||
);
|
||||
|
||||
$body = '<p>'.implode("</p>\n<p>", explode("\n", $bodyEmail)).'</p>';
|
||||
}
|
||||
|
||||
// Extract list of emails.
|
||||
$destinationEmails = explode(',', io_safe_output($email));
|
||||
foreach ($destinationEmails as $destination) {
|
||||
$destination = trim($destination);
|
||||
|
||||
// Skip the empty 'to'.
|
||||
if (empty($destination) === false) {
|
||||
send_email_attachment($destination, $body, $subject, $attachments);
|
||||
} else {
|
||||
db_pandora_audit('ERROR:', 'Cron jobs mail, empty destination email.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -856,7 +856,7 @@ function reporting_html_SLA($table, $item, $mini, $pdf=0)
|
|||
$table1->size[10] = '2%';
|
||||
$table1->data[0][10] = '<img src ="'.$src.'images/square_light_gray.png">';
|
||||
$table1->size[11] = '15%';
|
||||
$table1->data[0][11] = '<span>'.__('Planned Downtime').'</span>';
|
||||
$table1->data[0][11] = '<span>'.__('Scheduled Downtime').'</span>';
|
||||
|
||||
if ($pdf === 0) {
|
||||
$table->colspan['legend']['cell'] = 2;
|
||||
|
@ -4081,7 +4081,7 @@ function reporting_html_availability_graph($table, $item, $pdf=0)
|
|||
$table2->size[10] = '2%';
|
||||
$table2->data[0][10] = '<img src ="'.$src.$hack_metaconsole.'images/square_light_gray.png">';
|
||||
$table2->size[11] = '15%';
|
||||
$table2->data[0][11] = '<span>'.__('Planned Downtime').'</span>';
|
||||
$table2->data[0][11] = '<span>'.__('Scheduled Downtime').'</span>';
|
||||
}
|
||||
|
||||
if ($pdf !== 0) {
|
||||
|
@ -5609,8 +5609,8 @@ function reporting_html_planned_downtimes_table($planned_downtimes)
|
|||
|
||||
$table = new StdClass();
|
||||
$table->width = '99%';
|
||||
$table->title = __('This SLA has been affected by the following planned downtimes').ui_print_help_tip(
|
||||
__('If the duration of the planned downtime is less than 5 minutes it will not be represented in the graph'),
|
||||
$table->title = __('This SLA has been affected by the following scheduled downtimes').ui_print_help_tip(
|
||||
__('If the duration of the scheduled downtime is less than 5 minutes it will not be represented in the graph'),
|
||||
true
|
||||
);
|
||||
$table->head = [];
|
||||
|
@ -5648,7 +5648,7 @@ function reporting_html_planned_downtimes_table($planned_downtimes)
|
|||
|
||||
if ($downtime_malformed) {
|
||||
$info_malformed = ui_print_error_message(
|
||||
__('This item is affected by a malformed planned downtime').'. '.__('Go to the planned downtimes section to solve this').'.',
|
||||
__('This item is affected by a malformed scheduled downtime').'. '.__('Go to the scheduled downtimes section to solve this').'.',
|
||||
'',
|
||||
true
|
||||
);
|
||||
|
|
|
@ -1187,7 +1187,7 @@ function snmp_browser_create_modules_snmp(
|
|||
}
|
||||
}
|
||||
|
||||
$fail_modules = [];
|
||||
$fail_modules = [];
|
||||
|
||||
foreach ($targets_oids as $key => $target_oid) {
|
||||
$oid = snmp_browser_get_oid(
|
||||
|
@ -1243,7 +1243,7 @@ function snmp_browser_create_modules_snmp(
|
|||
'min' => 0,
|
||||
'tcp_send' => $snmp_version,
|
||||
'tcp_rcv' => '',
|
||||
'tcp_port' => 0,
|
||||
'tcp_port' => $target_port,
|
||||
'snmp_oid' => $oid['numeric_oid'],
|
||||
'snmp_community' => $community,
|
||||
'id_module_group' => 3,
|
||||
|
|
|
@ -1483,7 +1483,10 @@ function ui_require_css_file($name, $path='include/styles/', $echo_tag=false)
|
|||
return false;
|
||||
}
|
||||
|
||||
if (is_metaconsole()) {
|
||||
if (is_metaconsole()
|
||||
&& (isset($config['requirements_use_base_url']) === false
|
||||
|| $config['requirements_use_base_url'] === false)
|
||||
) {
|
||||
$config['css'][$name] = '/../../'.$filename;
|
||||
} else {
|
||||
$config['css'][$name] = $filename;
|
||||
|
@ -1535,7 +1538,10 @@ function ui_require_javascript_file($name, $path='include/javascript/', $echo_ta
|
|||
return false;
|
||||
}
|
||||
|
||||
if (is_metaconsole()) {
|
||||
if (is_metaconsole()
|
||||
&& (isset($config['requirements_use_base_url']) === false
|
||||
|| $config['requirements_use_base_url'] === false)
|
||||
) {
|
||||
$config['js'][$name] = '../../'.$filename;
|
||||
} else {
|
||||
$config['js'][$name] = $filename;
|
||||
|
@ -5178,6 +5184,11 @@ function ui_print_agent_autocomplete_input($parameters)
|
|||
$javascript_function_change = '';
|
||||
// Default value.
|
||||
$javascript_function_change .= '
|
||||
function setInputBackground(inputId, image) {
|
||||
$("#"+inputId)
|
||||
.css("background","url(\'"+image+"\') right center no-repeat");
|
||||
}
|
||||
|
||||
function set_functions_change_autocomplete_'.$input_name.'() {
|
||||
var cache_'.$input_name.' = {};
|
||||
|
||||
|
@ -5192,10 +5203,9 @@ function ui_print_agent_autocomplete_input($parameters)
|
|||
if (cache_'.$input_name.'[groupId] == null) {
|
||||
cache_'.$input_name.'[groupId] = {};
|
||||
}
|
||||
|
||||
|
||||
//Set loading
|
||||
$("#'.$input_id.'")
|
||||
.css("background","url(\"'.$spinner_image.'\") right center no-repeat");
|
||||
setInputBackground("'.$input_id.'", "'.$spinner_image.'");
|
||||
|
||||
//Function to call when the source
|
||||
if ('.((int) !empty($javascript_function_action_into_source_js_call)).') {
|
||||
|
@ -5209,8 +5219,7 @@ function ui_print_agent_autocomplete_input($parameters)
|
|||
response(cache_'.$input_name.'[groupId][term]);
|
||||
|
||||
//Set icon
|
||||
$("#'.$input_id.'")
|
||||
.css("background","url(\"'.$icon_image.'\") right center no-repeat '.$icon_image.'");
|
||||
setInputBackground("'.$input_id.'", "'.$icon_image.'");
|
||||
return;
|
||||
}
|
||||
else {
|
||||
|
@ -5228,7 +5237,9 @@ function ui_print_agent_autocomplete_input($parameters)
|
|||
response(cache_'.$input_name.'[groupId][oldterm]);
|
||||
|
||||
found = true;
|
||||
|
||||
|
||||
//Set icon
|
||||
setInputBackground("'.$input_id.'", "'.$icon_image.'");
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
@ -5244,11 +5255,10 @@ function ui_print_agent_autocomplete_input($parameters)
|
|||
|
||||
if (found) {
|
||||
//Set icon
|
||||
$("#'.$input_id.'")
|
||||
.css("background","url(\"'.$icon_image.'\") right center no-repeat");
|
||||
setInputBackground("'.$input_id.'", "'.$icon_image.'");
|
||||
|
||||
select_item_click = 0;
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -5263,16 +5273,13 @@ function ui_print_agent_autocomplete_input($parameters)
|
|||
response(data);
|
||||
|
||||
//Set icon
|
||||
$("#'.$input_id.'")
|
||||
.css("background",
|
||||
"url(\"'.$icon_image.'\") right center no-repeat");
|
||||
|
||||
select_item_click = 0;
|
||||
setInputBackground("'.$input_id.'", "'.$icon_image.'");
|
||||
select_item_click = 0;
|
||||
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
return;
|
||||
},
|
||||
//---END source-----------------------------------------
|
||||
|
@ -5451,15 +5458,23 @@ function ui_print_agent_autocomplete_input($parameters)
|
|||
return;
|
||||
}
|
||||
|
||||
if ('.((int) $check_only_empty_javascript_on_blur_function).') {
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
if (select_item_click) {
|
||||
select_item_click = 0;
|
||||
$("#'.$input_id.'")
|
||||
.css("background",
|
||||
"url(\"'.$icon_image.'\") right center no-repeat");
|
||||
return;
|
||||
}
|
||||
|
||||
} else {
|
||||
// Clear selectbox if item is not selected.
|
||||
$("#'.$selectbox_id.'").empty();
|
||||
$("#'.$selectbox_id.'").append($("<option value=0>'.__('Select an Agent first').'</option>"));
|
||||
$("#'.$selectbox_id.'").attr("disabled", "disabled");
|
||||
// Not allow continue on blur .
|
||||
if ('.((int) $check_only_empty_javascript_on_blur_function).') {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
//Set loading
|
||||
$("#'.$input_id.'")
|
||||
.css("background",
|
||||
|
@ -5533,7 +5548,7 @@ function ui_print_agent_autocomplete_input($parameters)
|
|||
if ('.((int) !empty($javascript_function_action_after_select_js_call)).') {
|
||||
'.$javascript_function_action_after_select_js_call.'
|
||||
}
|
||||
|
||||
|
||||
//Set icon
|
||||
$("#'.$input_id.'")
|
||||
.css("background",
|
||||
|
|
|
@ -1428,7 +1428,7 @@ function update_manager_check_online_free_packages($is_ajax=true)
|
|||
var mr_available_header = "<?php echo __('There are db changes'); ?>\n";
|
||||
var text1_mr_file = "<?php echo __('There are new database changes available to apply. Do you want to start the DB update process?'); ?>\n";
|
||||
var text2_mr_file = "<?php echo __('We recommend launching '); ?>\n";
|
||||
var text3_mr_file = "<?php echo __('planned downtime'); ?>\n";
|
||||
var text3_mr_file = "<?php echo __('Scheduled downtime'); ?>\n";
|
||||
|
||||
var language = "<?php echo $config['language']; ?>";
|
||||
var docsUrl = (language === "es")
|
||||
|
|
|
@ -1609,6 +1609,7 @@ function paint_graph_status(
|
|||
svg
|
||||
.append("g")
|
||||
.attr("transform", "translate(100, 150)")
|
||||
.attr("class", "invert_filter")
|
||||
.call(yAxis);
|
||||
|
||||
//legend Normal text
|
||||
|
@ -1623,6 +1624,7 @@ function paint_graph_status(
|
|||
.style("font-family", "arial")
|
||||
.style("font-weight", "bold")
|
||||
.style("font-size", "8pt")
|
||||
.attr("class", "invert_filter")
|
||||
.html(legend_normal)
|
||||
.style("text-anchor", "first")
|
||||
.attr("width", 300)
|
||||
|
@ -1649,6 +1651,7 @@ function paint_graph_status(
|
|||
.style("font-family", "arial")
|
||||
.style("font-weight", "bold")
|
||||
.style("font-size", "8pt")
|
||||
.attr("class", "invert_filter")
|
||||
.html(legend_warning)
|
||||
.style("text-anchor", "first");
|
||||
|
||||
|
@ -1673,6 +1676,7 @@ function paint_graph_status(
|
|||
.style("font-family", "arial")
|
||||
.style("font-weight", "bold")
|
||||
.style("font-size", "8pt")
|
||||
.attr("class", "invert_filter")
|
||||
.html(legend_critical)
|
||||
.style("text-anchor", "first");
|
||||
|
||||
|
|
|
@ -48,6 +48,8 @@ function show_event_dialog(event, dialog_page, result) {
|
|||
resizable: true,
|
||||
draggable: true,
|
||||
modal: true,
|
||||
minWidth: 710,
|
||||
minHeight: 600,
|
||||
close: function() {
|
||||
$("#refrcounter").countdown("resume");
|
||||
$("div.vc-countdown").countdown("resume");
|
||||
|
|
|
@ -1078,7 +1078,6 @@ class Item extends CachedModel
|
|||
$mobile_navigation = true;
|
||||
}
|
||||
|
||||
error_log(obhd($_SERVER['PHP_SELF']));
|
||||
// Load side libraries.
|
||||
include_once $config['homedir'].'/include/functions_ui.php';
|
||||
if (\is_metaconsole() === true) {
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
/* Web Server Module Debug Specific CSS file */
|
||||
.query_result_editor,
|
||||
.query_result_view {
|
||||
min-height: 45em;
|
||||
height: 45em;
|
||||
}
|
||||
|
||||
#query_result_container {
|
||||
margin-top: 30px;
|
||||
}
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
.dataTables_wrapper {
|
||||
min-height: 150px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.datatables-td-title {
|
||||
|
|
|
@ -8501,3 +8501,8 @@ div.stat-win-spinner img {
|
|||
.font_11pt {
|
||||
font-size: 11pt;
|
||||
}
|
||||
|
||||
.checkbox-random-name {
|
||||
width: 100px !important;
|
||||
margin-left: 20px;
|
||||
}
|
||||
|
|
|
@ -387,7 +387,6 @@ table#diagnostic_info tbody td div {
|
|||
color: #fff;
|
||||
}
|
||||
|
||||
.ui-widget-content.ui-autocomplete,
|
||||
.ui-widget-content.ui-autocomplete a {
|
||||
color: #333;
|
||||
}
|
||||
|
@ -1000,3 +999,23 @@ table.databox {
|
|||
.tactical_set {
|
||||
border-color: #707070;
|
||||
}
|
||||
|
||||
li.ui-tabs-tab.ui-corner-top.ui-state-default.ui-tab {
|
||||
border: 1px solid #707070;
|
||||
}
|
||||
.chartLegend {
|
||||
width: 100%;
|
||||
position: relative;
|
||||
height: 30px;
|
||||
}
|
||||
|
||||
.chartLegend table {
|
||||
position: absolute;
|
||||
right: 0px;
|
||||
}
|
||||
|
||||
.graph_container {
|
||||
width: 800px;
|
||||
margin: 20px auto;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
|
|
@ -220,7 +220,8 @@ echo '<head>'."\n";
|
|||
// This starts the page head. In the callback function,
|
||||
// $page['head'] array content will be processed into the head.
|
||||
ob_start('ui_process_page_head');
|
||||
|
||||
// Avoid clickjacking.
|
||||
header('X-Frame-Options: SAMEORIGIN');
|
||||
// Enterprise main.
|
||||
enterprise_include_once('index.php');
|
||||
|
||||
|
|
|
@ -129,7 +129,7 @@
|
|||
<div style='height: 10px'>
|
||||
<?php
|
||||
$version = '7.0NG.754';
|
||||
$build = '210504';
|
||||
$build = '210513';
|
||||
$banner = "v$version Build $build";
|
||||
|
||||
error_reporting(0);
|
||||
|
|
|
@ -688,7 +688,7 @@ if (!empty($table->data)) {
|
|||
);
|
||||
}
|
||||
|
||||
echo '<div id="alerts_list w100p">';
|
||||
echo '<div id="alerts_list" class="w100p">';
|
||||
html_print_table($table);
|
||||
echo '</div>';
|
||||
|
||||
|
|
|
@ -808,9 +808,9 @@ foreach ($agents as $agent) {
|
|||
|
||||
if ($in_planned_downtime) {
|
||||
$data[0] .= ui_print_help_tip(
|
||||
__('Agent in planned downtime'),
|
||||
__('Agent in scheduled downtime'),
|
||||
true,
|
||||
$config['image']['minireloj_16']
|
||||
'images/minireloj-16.png'
|
||||
);
|
||||
$data[0] .= '</em>';
|
||||
}
|
||||
|
|
|
@ -137,7 +137,7 @@ if ($agent['disabled']) {
|
|||
|
||||
if ($in_planned_downtime && !$agent['disabled'] && !$agent['quiet']) {
|
||||
$agent_name .= '<em> '.ui_print_help_tip(
|
||||
__('Agent in planned downtime'),
|
||||
__('Agent in scheduled downtime'),
|
||||
true,
|
||||
'images/minireloj-16.png'
|
||||
).'</em>';
|
||||
|
@ -145,7 +145,7 @@ if ($in_planned_downtime && !$agent['disabled'] && !$agent['quiet']) {
|
|||
|| ($in_planned_downtime && !$agent['quiet'])
|
||||
) {
|
||||
$agent_name .= ' '.ui_print_help_tip(
|
||||
__('Agent in planned downtime'),
|
||||
__('Agent in scheduled downtime'),
|
||||
true,
|
||||
'images/minireloj-16.png'
|
||||
).'</em>';
|
||||
|
|
|
@ -68,6 +68,9 @@ if (file_exists('../../include/languages/'.$user_language.'.mo')) {
|
|||
}
|
||||
|
||||
echo '<link rel="stylesheet" href="../../include/styles/pandora.css" type="text/css"/>';
|
||||
if ($config['style'] === 'pandora_black') {
|
||||
ui_require_css_file('pandora_black', 'include/styles/', true);
|
||||
}
|
||||
|
||||
$interface_name = (string) $params['interface_name'];
|
||||
$agent_id = (int) $params['agent_id'];
|
||||
|
@ -190,6 +193,7 @@ $data[1] .= html_print_image(
|
|||
[
|
||||
'onclick' => "scwShow(scwID('text-start_date'),this);",
|
||||
'style' => 'vertical-align: bottom;',
|
||||
'class' => 'invert_filter',
|
||||
],
|
||||
false,
|
||||
false,
|
||||
|
@ -251,7 +255,8 @@ $options[2] = 'x2';
|
|||
$options[3] = 'x3';
|
||||
$options[4] = 'x4';
|
||||
$options[5] = __('Full');
|
||||
$data[1] = html_print_select(
|
||||
/*
|
||||
$data[1] = html_print_select(
|
||||
$options,
|
||||
'zoom',
|
||||
$zoom,
|
||||
|
@ -261,9 +266,9 @@ $data[1] = html_print_select(
|
|||
true,
|
||||
false,
|
||||
false
|
||||
);
|
||||
$table->data[] = $data;
|
||||
$table->rowclass[] = '';
|
||||
);
|
||||
$table->data[] = $data;
|
||||
$table->rowclass[] = '';*/
|
||||
|
||||
$form_table = html_print_table($table, true);
|
||||
$form_table .= '<div class="w100p right right_align">';
|
||||
|
@ -284,7 +289,7 @@ if (empty($server_id) === false) {
|
|||
$menu_form .= html_print_input_hidden('server', $server_id, true);
|
||||
}
|
||||
|
||||
$menu_form .= '<div class="module_graph_menu_dropdown">';
|
||||
$menu_form .= '<div class="module_graph_menu_dropdown mrgn_top_20px">';
|
||||
$menu_form .= '<div id="module_graph_menu_header" class="module_graph_menu_header">';
|
||||
$menu_form .= html_print_image(
|
||||
'images/arrow_down_green.png',
|
||||
|
@ -312,13 +317,6 @@ $menu_form .= '</div>';
|
|||
$menu_form .= '</form>';
|
||||
|
||||
echo $menu_form;
|
||||
echo '<div class="module_graph_menu_dropdown">
|
||||
<div id="module_graph_menu_header" class="module_graph_menu_header">
|
||||
'.html_print_image('images/arrow_down_green.png', true, ['class' => 'module_graph_menu_arrow', 'float' => 'left'], false, false, true).'
|
||||
<span class="flex_2">'.__('Graph configuration menu').'</span></div>
|
||||
<div class="module_graph_menu_content module_graph_menu_content_closed invisible" >'.$form_table.'</div>
|
||||
</div>';
|
||||
echo '</form>';
|
||||
|
||||
// Hidden div to forced title.
|
||||
html_print_div(
|
||||
|
|
|
@ -390,7 +390,7 @@ if ($not_found) {
|
|||
'circo' => 'circular',
|
||||
'neato' => 'spring1',
|
||||
'fdp' => 'spring2',
|
||||
'radial_dinamic' => 'radial dinamic',
|
||||
'radial_dinamic' => 'radial dynamic',
|
||||
];
|
||||
|
||||
$table->data[7][0] = __('Method generation networkmap');
|
||||
|
|
|
@ -64,6 +64,10 @@ if (file_exists('../../include/languages/'.$user_language.'.mo')) {
|
|||
$l10n->load_tables();
|
||||
}
|
||||
|
||||
if ($config['style'] === 'pandora_black') {
|
||||
ui_require_css_file('pandora_black', 'include/styles/', true);
|
||||
}
|
||||
|
||||
echo '<link rel="stylesheet" href="../../include/styles/pandora.css" type="text/css"/>';
|
||||
?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
|
@ -92,6 +96,10 @@ echo '<link rel="stylesheet" href="../../include/styles/pandora.css" type="text/
|
|||
include_javascript_dependencies_flot_graph();
|
||||
?>
|
||||
</head>
|
||||
<?php
|
||||
if ($config['style'] === 'pandora_black') {
|
||||
}
|
||||
?>
|
||||
<body bgcolor="#ffffff" class='bg_white'>
|
||||
<?php
|
||||
if (!check_acl($config['id_user'], 0, 'AR')) {
|
||||
|
|
|
@ -151,11 +151,34 @@ ui_print_message_dialog(
|
|||
|
||||
// ACL.
|
||||
$all_groups = agents_get_all_groups_agent($agent_id);
|
||||
if (!check_acl_one_of_groups($config['id_user'], $all_groups, 'AR')) {
|
||||
|
||||
// If in metaconsole, resotre DB to check meta user acl.
|
||||
if (is_metaconsole()) {
|
||||
metaconsole_restore_db();
|
||||
}
|
||||
|
||||
if (check_acl_one_of_groups($config['id_user'], $all_groups, 'AR') !== true) {
|
||||
include $config['homedir'].'/general/noaccess.php';
|
||||
exit;
|
||||
}
|
||||
|
||||
// Metaconsole connection to the node.
|
||||
$server_id = (int) get_parameter('server', 0);
|
||||
if (is_metaconsole() === true && empty($server_id) === false) {
|
||||
$server = metaconsole_get_connection_by_id($server_id);
|
||||
// Error connecting.
|
||||
if (metaconsole_connect($server) !== NOERR) {
|
||||
echo '<html>';
|
||||
echo '<body>';
|
||||
ui_print_error_message(
|
||||
__('There was a problem connecting with the node')
|
||||
);
|
||||
echo '</body>';
|
||||
echo '</html>';
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$draw_alerts = get_parameter('draw_alerts', 0);
|
||||
|
||||
$period = get_parameter('period');
|
||||
|
|
|
@ -244,6 +244,10 @@ if ($ag_modulename != '') {
|
|||
$sql_conditions .= " AND tagente_modulo.nombre LIKE '%".$ag_modulename."%'";
|
||||
}
|
||||
|
||||
if ($id_module) {
|
||||
$sql_conditions .= sprintf(' AND tagente_modulo.id_agente_modulo = \'%d\'', $id_module);
|
||||
}
|
||||
|
||||
if ($module_option !== 0) {
|
||||
if ($module_option == 1) {
|
||||
// Only enabled
|
||||
|
|
|
@ -156,32 +156,30 @@ $table->colspan[3][0] = 3;
|
|||
|
||||
$help_macros = isset($_GET['from_event']) ? ui_print_help_icon('response_macros', true) : '';
|
||||
|
||||
if (isset($_GET['from_event'])) {
|
||||
if ($update) {
|
||||
$input_value_title = $incident_details[3];
|
||||
$input_value_type = $incident_details[17];
|
||||
$input_value_status = $incident_details[6];
|
||||
$input_value_group = $incident_details[8];
|
||||
$input_value_criticity = $incident_details[7];
|
||||
$input_value_owner = $incident_details[5];
|
||||
$input_value_content = $incident_details[4];
|
||||
} else if (isset($_GET['from_event'])) {
|
||||
$input_value_title = $config['cr_incident_title'];
|
||||
$input_value_type = $config['cr_incident_type'];
|
||||
$input_value_status = $config['cr_incident_status'];
|
||||
$input_value_group = $config['cr_default_group'];
|
||||
$input_value_criticity = $config['cr_default_criticity'];
|
||||
$input_value_owner = $config['cr_default_owner'];
|
||||
$input_value_content = $config['cr_incident_content'];
|
||||
} else {
|
||||
$input_value_title = '';
|
||||
$input_value_type = '';
|
||||
$input_value_status = '';
|
||||
$input_value_group = '';
|
||||
$input_value_criticity = '';
|
||||
$input_value_owner = '';
|
||||
$input_value_content = '';
|
||||
}
|
||||
if ($update) {
|
||||
$input_value_title = $incident_details[3];
|
||||
$input_value_type = $incident_details[17];
|
||||
$input_value_status = $incident_details[6];
|
||||
$input_value_group = $incident_details[8];
|
||||
$input_value_criticity = $incident_details[7];
|
||||
$input_value_owner = $incident_details[5];
|
||||
$input_value_content = $incident_details[4];
|
||||
} else if (isset($_GET['from_event'])) {
|
||||
$input_value_title = $config['cr_incident_title'];
|
||||
$input_value_type = $config['cr_incident_type'];
|
||||
$input_value_status = $config['cr_incident_status'];
|
||||
$input_value_group = $config['cr_default_group'];
|
||||
$input_value_criticity = $config['cr_default_criticity'];
|
||||
$input_value_owner = $config['cr_default_owner'];
|
||||
$input_value_content = $config['cr_incident_content'];
|
||||
} else {
|
||||
$input_value_title = '';
|
||||
$input_value_type = '';
|
||||
$input_value_status = '';
|
||||
$input_value_group = '';
|
||||
$input_value_criticity = '';
|
||||
$input_value_owner = '';
|
||||
$input_value_content = '';
|
||||
}
|
||||
|
||||
$table->data[0][0] = '<div class="label_select"><p class="input_label">'.__('Title').': '.$help_macros.'</p>';
|
||||
|
@ -288,7 +286,11 @@ $table->data[2][2] = '<div class="label_select"><p class="input_label">'.__('Own
|
|||
$table->data[2][2] .= '<div class="label_select_parent">'.html_print_autocomplete_users_from_integria(
|
||||
'owner',
|
||||
$input_value_owner,
|
||||
true
|
||||
true,
|
||||
'30',
|
||||
false,
|
||||
false,
|
||||
'w100p'
|
||||
).'</div>';
|
||||
|
||||
$table->data[3][0] = '<div class="label_select"><p class="input_label">'.__('Description').': '.$help_macros.'</p>';
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
<?php
|
||||
/**
|
||||
* Extension to manage a list of gateways and the node address where they should
|
||||
* point to.
|
||||
* Message Edition.
|
||||
*
|
||||
* @category Extensions
|
||||
* @category Workspace
|
||||
* @package Pandora FMS
|
||||
* @subpackage Community
|
||||
* @version 1.0.0
|
||||
|
@ -27,6 +26,7 @@
|
|||
* ============================================================================
|
||||
*/
|
||||
|
||||
// Begin.
|
||||
global $config;
|
||||
|
||||
require_once 'include/functions_users.php';
|
||||
|
@ -34,14 +34,16 @@ require_once 'include/functions_groups.php';
|
|||
require_once 'include/functions_io.php';
|
||||
|
||||
// Parse parameters.
|
||||
$new_msg = get_parameter('new_msg', 0);
|
||||
$dst_user = get_parameter('dst_user');
|
||||
$dst_group = get_parameter('dst_group');
|
||||
$subject = get_parameter('subject', '');
|
||||
$message = get_parameter('message');
|
||||
$read_message = get_parameter('read_message', 0);
|
||||
$reply = get_parameter('reply', 0);
|
||||
$show_sent = get_parameter('show_sent', 0);
|
||||
$send_mes = (bool) get_parameter('send_mes', false);
|
||||
$new_msg = (string) get_parameter('new_msg');
|
||||
$dst_user = get_parameter('dst_user');
|
||||
$dst_group = get_parameter('dst_group');
|
||||
$subject = io_safe_html_tags(get_parameter('subject'));
|
||||
$message = (string) get_parameter('message');
|
||||
$read_message = (bool) get_parameter('read_message', false);
|
||||
$reply = (bool) get_parameter('reply', false);
|
||||
$replied = (bool) get_parameter('replied', false);
|
||||
$show_sent = get_parameter('show_sent', 0);
|
||||
|
||||
$buttons['message_list'] = [
|
||||
'active' => false,
|
||||
|
@ -92,7 +94,7 @@ ui_print_page_header(
|
|||
// Read a message.
|
||||
if ($read_message) {
|
||||
$message_id = (int) get_parameter('id_message');
|
||||
if ($show_sent) {
|
||||
if ((bool) $show_sent === true) {
|
||||
$message = messages_get_message_sent($message_id);
|
||||
} else {
|
||||
$message = messages_get_message($message_id);
|
||||
|
@ -196,26 +198,36 @@ if ($read_message) {
|
|||
return;
|
||||
}
|
||||
|
||||
// Create message (destination user).
|
||||
if (($new_msg) && (!empty($dst_user)) && (!$reply)) {
|
||||
$return = messages_create_message(
|
||||
$config['id_user'],
|
||||
[$dst_user],
|
||||
[],
|
||||
$subject,
|
||||
$message
|
||||
);
|
||||
if ($send_mes === true) {
|
||||
if (empty($dst_user) === true && empty($dst_group) === true) {
|
||||
// The user or group must be selected for send the message.
|
||||
ui_print_error_message(__('User or group must be selected.'));
|
||||
} else {
|
||||
// Create message (destination user).
|
||||
$return = messages_create_message(
|
||||
$config['id_user'],
|
||||
[$dst_user],
|
||||
[],
|
||||
$subject,
|
||||
$message
|
||||
);
|
||||
|
||||
$user_name = get_user_fullname($dst_user);
|
||||
if (!$user_name) {
|
||||
$user_name = $dst_user;
|
||||
$user_name = get_user_fullname($dst_user);
|
||||
if (empty($user_name) === true) {
|
||||
$user_name = $dst_user;
|
||||
}
|
||||
|
||||
ui_print_result_message(
|
||||
$return,
|
||||
__('Message successfully sent to user %s', $user_name),
|
||||
__('Error sending message to user %s', $user_name)
|
||||
);
|
||||
|
||||
// If is a reply, is not necessary do more.
|
||||
if ($replied === true) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
ui_print_result_message(
|
||||
$return,
|
||||
__('Message successfully sent to user %s', $user_name),
|
||||
__('Error sending message to user %s', $user_name)
|
||||
);
|
||||
}
|
||||
|
||||
// Message creation form.
|
||||
|
@ -230,11 +242,7 @@ $table->data = [];
|
|||
|
||||
$table->data[0][0] = __('Sender');
|
||||
|
||||
if (!empty($own_info['fullname'])) {
|
||||
$table->data[0][1] = $own_info['fullname'];
|
||||
} else {
|
||||
$table->data[0][1] = $config['id_user'];
|
||||
}
|
||||
$table->data[0][1] = (empty($own_info['fullname']) === false) ? $own_info['fullname'] : $config['id_user'];
|
||||
|
||||
$table->data[1][0] = __('Destination');
|
||||
|
||||
|
@ -245,7 +253,7 @@ $is_admin = (bool) db_get_value(
|
|||
$config['id_user']
|
||||
);
|
||||
|
||||
if ($is_admin) {
|
||||
if ($is_admin === true) {
|
||||
$users_full = db_get_all_rows_filter(
|
||||
'tusuario',
|
||||
[],
|
||||
|
@ -264,51 +272,58 @@ if ($is_admin) {
|
|||
|
||||
$users = [];
|
||||
foreach ($users_full as $user_id => $user_info) {
|
||||
$users[$user_info['id_user']] = $user_info['fullname'];
|
||||
$users[$user_info['id_user']] = (empty($user_info['fullname']) === true) ? $user_info['id_user'] : $user_info['fullname'];
|
||||
}
|
||||
|
||||
// Check if the user to reply is in the list, if not add reply user.
|
||||
if ($reply) {
|
||||
if (!array_key_exists($dst_user, $users)) {
|
||||
// Add the user to reply.
|
||||
$user_reply = db_get_row('tusuario', 'id_user', $dst_user);
|
||||
$users[$user_reply['id_user']] = $user_reply['fullname'];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($own_info['is_admin'] || check_acl($config['id_user'], 0, 'PM')) {
|
||||
$return_all_groups = true;
|
||||
if ($reply === true) {
|
||||
$table->data[1][1] = (array_key_exists($dst_user, $users) === true) ? $users[$dst_user] : $dst_user;
|
||||
$table->data[1][1] .= html_print_input_hidden(
|
||||
'dst_user',
|
||||
$dst_user,
|
||||
true
|
||||
);
|
||||
$table->data[1][1] .= html_print_input_hidden(
|
||||
'replied',
|
||||
'1',
|
||||
true
|
||||
);
|
||||
} else {
|
||||
$return_all_groups = false;
|
||||
}
|
||||
$return_all_groups = ((bool) $own_info['is_admin'] === true
|
||||
|| check_acl($config['id_user'], 0, 'PM') === true);
|
||||
|
||||
$groups = users_get_groups($config['id_user'], 'AR');
|
||||
// Get a list of all groups.
|
||||
$table->data[1][1] = html_print_select(
|
||||
$users,
|
||||
'dst_user',
|
||||
$dst_user,
|
||||
'',
|
||||
__('Select user'),
|
||||
false,
|
||||
true,
|
||||
false,
|
||||
'',
|
||||
false
|
||||
);
|
||||
$table->data[1][1] .= ' '.__('OR').' ';
|
||||
$table->data[1][1] .= '<div class="w250px inline">'.html_print_select_groups(
|
||||
$config['id_user'],
|
||||
'AR',
|
||||
$return_all_groups,
|
||||
'dst_group',
|
||||
$dst_group,
|
||||
'',
|
||||
__('Select group'),
|
||||
'',
|
||||
true
|
||||
).'</div>';
|
||||
$groups = users_get_groups($config['id_user'], 'AR');
|
||||
// Get a list of all groups.
|
||||
$table->data[1][1] = html_print_select(
|
||||
$users,
|
||||
'dst_user',
|
||||
$dst_user,
|
||||
'changeStatusOtherSelect(\'dst_user\', \'dst_group\')',
|
||||
__('Select user'),
|
||||
false,
|
||||
true,
|
||||
false,
|
||||
''
|
||||
);
|
||||
$table->data[1][1] .= ' '.__('OR').' ';
|
||||
$table->data[1][1] .= html_print_div(
|
||||
[
|
||||
'class' => 'w250px inline',
|
||||
'content' => html_print_select_groups(
|
||||
$config['id_user'],
|
||||
'AR',
|
||||
$return_all_groups,
|
||||
'dst_group',
|
||||
$dst_group,
|
||||
'changeStatusOtherSelect(\'dst_group\', \'dst_user\')',
|
||||
__('Select group'),
|
||||
'',
|
||||
true
|
||||
),
|
||||
],
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
$table->data[2][0] = __('Subject');
|
||||
$table->data[2][1] = html_print_input_text(
|
||||
|
@ -330,15 +345,40 @@ $table->data[3][1] = html_print_textarea(
|
|||
true
|
||||
);
|
||||
|
||||
echo '<form method="post" action="index.php?sec=message_list&sec2=operation/messages/message_edit&new_msg=1">';
|
||||
html_print_table($table);
|
||||
$jsOutput = '';
|
||||
ob_start();
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
function changeStatusOtherSelect(myId, otherId) {
|
||||
if (document.getElementById(myId).value !== "") {
|
||||
if (otherId === "dst_group") {
|
||||
$('#'+otherId).select2('val', '0');
|
||||
} else {
|
||||
document.getElementById(otherId).value = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<?php
|
||||
$jsOutput = ob_get_clean();
|
||||
|
||||
echo '<div class="action-buttons" style="width: '.$table->width.'">';
|
||||
html_print_submit_button(
|
||||
__('Send message'),
|
||||
'send_mes',
|
||||
false,
|
||||
'class="sub wand"'
|
||||
);
|
||||
echo '</form>';
|
||||
echo '</div>';
|
||||
echo '<form method="post" action="index.php?sec=message_list&sec2=operation/messages/message_edit&new_msg=1">';
|
||||
// Print the main table.
|
||||
html_print_table($table);
|
||||
// Print the action buttons section.
|
||||
html_print_div(
|
||||
[
|
||||
'class' => 'action-buttons',
|
||||
'style' => 'width: '.$table->width,
|
||||
'content' => html_print_submit_button(
|
||||
__('Send message'),
|
||||
'send_mes',
|
||||
false,
|
||||
'class="sub wand"',
|
||||
true
|
||||
),
|
||||
]
|
||||
);
|
||||
|
||||
echo '</form>';
|
||||
echo $jsOutput;
|
|
@ -95,7 +95,7 @@ if (!$agents || !$searchAgents) {
|
|||
);
|
||||
|
||||
if ($in_planned_downtime) {
|
||||
$cellName .= '<em>'.ui_print_help_tip(__('Agent in planned downtime'), true, 'images/minireloj-16.png');
|
||||
$cellName .= '<em>'.ui_print_help_tip(__('Agent in scheduled downtime'), true, 'images/minireloj-16.png');
|
||||
$cellName .= '</em>';
|
||||
}
|
||||
|
||||
|
|
|
@ -141,6 +141,7 @@ function snmp_browser_show_add_module_massive(module_target = 'agent') {
|
|||
|
||||
var title = '<?php echo __('Add modules'); ?>';
|
||||
var snmp_extradata = snmp_browser_create_modules(module_target);
|
||||
snmp_extradata.push({name:"target_port", value:$("#target_port").val()});
|
||||
// Load dinamically modal form.
|
||||
load_modal({
|
||||
form: 'snmp_browser_add_module_form',
|
||||
|
|
|
@ -356,27 +356,33 @@ enterprise_hook('close_meta_frame');
|
|||
if (data.success) {
|
||||
$(".loading_tree").hide();
|
||||
var foundMessage = '';
|
||||
switch (parameters['type']) {
|
||||
case 'policies':
|
||||
foundMessage = "<?php echo __('Policies found'); ?>";
|
||||
break;
|
||||
case 'os':
|
||||
foundMessage = "<?php echo __('Operating systems found'); ?>";
|
||||
break;
|
||||
case 'tag':
|
||||
foundMessage = "<?php echo __('Tags found'); ?>";
|
||||
break;
|
||||
case 'module_group':
|
||||
foundMessage = "<?php echo __('Module Groups found'); ?>";
|
||||
break;
|
||||
case 'module':
|
||||
foundMessage = "<?php echo __('Modules found'); ?>";
|
||||
break;
|
||||
case 'group':
|
||||
default:
|
||||
foundMessage = "<?php echo __('Groups found'); ?>";
|
||||
break;
|
||||
if (data.tree.length === 0) {
|
||||
foundMessage = "<?php echo __('No data found'); ?>";
|
||||
$("div#tree-controller-recipient").append(foundMessage);
|
||||
} else {
|
||||
switch (parameters['type']) {
|
||||
case 'policies':
|
||||
foundMessage = "<?php echo __('Policies found'); ?>";
|
||||
break;
|
||||
case 'os':
|
||||
foundMessage = "<?php echo __('Operating systems found'); ?>";
|
||||
break;
|
||||
case 'tag':
|
||||
foundMessage = "<?php echo __('Tags found'); ?>";
|
||||
break;
|
||||
case 'module_group':
|
||||
foundMessage = "<?php echo __('Module Groups found'); ?>";
|
||||
break;
|
||||
case 'module':
|
||||
foundMessage = "<?php echo __('Modules found'); ?>";
|
||||
break;
|
||||
case 'group':
|
||||
default:
|
||||
foundMessage = "<?php echo __('Groups found'); ?>";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
treeController.init({
|
||||
recipient: $("div#tree-controller-recipient"),
|
||||
|
|
|
@ -32,7 +32,7 @@ global $config;
|
|||
// Load the header.
|
||||
require $config['homedir'].'/operation/users/user_edit_header.php';
|
||||
|
||||
if (!is_metaconsole()) {
|
||||
if (is_metaconsole() === false) {
|
||||
date_default_timezone_set('UTC');
|
||||
include 'include/javascript/timezonepicker/includes/parser.inc';
|
||||
|
||||
|
@ -649,11 +649,13 @@ foreach ($timezones as $timezone_name => $tz) {
|
|||
}
|
||||
|
||||
if (is_metaconsole()) {
|
||||
echo '<form name="user_mod" method="post" action="'.ui_get_full_url('index.php?sec=advanced&sec2=advanced/users_setup').'&tab=user_edit&modified=1&id='.$id.'&pure='.$config['pure'].'">';
|
||||
echo '<form name="user_mod" method="post" action="'.ui_get_full_url('index.php?sec=advanced&sec2=advanced/users_setup').'&tab=user_edit&modified=1&pure='.$config['pure'].'">';
|
||||
} else {
|
||||
echo '<form name="user_mod" method="post" action="'.ui_get_full_url('index.php?sec=workspace&sec2=operation/users/user_edit').'&modified=1&id='.$id.'&pure='.$config['pure'].'">';
|
||||
echo '<form name="user_mod" method="post" action="'.ui_get_full_url('index.php?sec=workspace&sec2=operation/users/user_edit').'&modified=1&pure='.$config['pure'].'">';
|
||||
}
|
||||
|
||||
html_print_input_hidden('id', $id, false, false, false, 'id');
|
||||
|
||||
echo '<div id="user_form">
|
||||
<div class="user_edit_first_row">
|
||||
<div class="edit_user_info white_box">
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#
|
||||
%define name pandorafms_console
|
||||
%define version 7.0NG.754
|
||||
%define release 210504
|
||||
%define release 210513
|
||||
|
||||
# User and Group under which Apache is running
|
||||
%define httpd_name httpd
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#
|
||||
%define name pandorafms_console
|
||||
%define version 7.0NG.754
|
||||
%define release 210504
|
||||
%define release 210513
|
||||
|
||||
# User and Group under which Apache is running
|
||||
%define httpd_name httpd
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#
|
||||
%define name pandorafms_console
|
||||
%define version 7.0NG.754
|
||||
%define release 210504
|
||||
%define release 210513
|
||||
%define httpd_name httpd
|
||||
# User and Group under which Apache is running
|
||||
%define httpd_name apache2
|
||||
|
|
|
@ -2262,6 +2262,11 @@ CREATE TABLE IF NOT EXISTS `talert_snmp_action` (
|
|||
`al_field13` text NOT NULL,
|
||||
`al_field14` text NOT NULL,
|
||||
`al_field15` text NOT NULL,
|
||||
`al_field16` text NOT NULL,
|
||||
`al_field17` text NOT NULL,
|
||||
`al_field18` text NOT NULL,
|
||||
`al_field19` text NOT NULL,
|
||||
`al_field20` text NOT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
package: pandorafms-server
|
||||
Version: 7.0NG.754-210504
|
||||
Version: 7.0NG.754-210513
|
||||
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.754-210504"
|
||||
pandora_version="7.0NG.754-210513"
|
||||
|
||||
package_cpan=0
|
||||
package_pandora=1
|
||||
|
|
|
@ -38,6 +38,7 @@ use PandoraFMS::DiscoveryServer;
|
|||
use PandoraFMS::WMIServer;
|
||||
use PandoraFMS::PluginServer;
|
||||
use PandoraFMS::PredictionServer;
|
||||
use PandoraFMS::WebServer;
|
||||
|
||||
# Constants for Win32 services.
|
||||
use constant WIN32_SERVICE_STOPPED => 0x01;
|
||||
|
@ -123,6 +124,7 @@ sub pandora_startup () {
|
|||
push (@Servers, new PandoraFMS::WMIServer (\%Config, $DBH));
|
||||
push (@Servers, new PandoraFMS::PluginServer (\%Config, $DBH));
|
||||
push (@Servers, new PandoraFMS::PredictionServer (\%Config, $DBH));
|
||||
push (@Servers, new PandoraFMS::WebServer (\%Config, $DBH));
|
||||
} else {
|
||||
# Metaconsole service modules are run by the prediction server
|
||||
push (@Servers, new PandoraFMS::PredictionServer (\%Config, $DBH));
|
||||
|
|
|
@ -25,6 +25,7 @@ incomingdir /var/spool/pandora/data_in
|
|||
log_file /var/log/pandora/pandora_server.log
|
||||
|
||||
# Log file for Pandora FMS SNMP console. Its generated by NetSNMP Trap daemon
|
||||
# If you change it, please update the file /etc/logrotate.d/pandora_server accordingly.
|
||||
|
||||
snmp_logfile /var/log/pandora/pandora_snmptrap.log
|
||||
|
||||
|
@ -424,11 +425,11 @@ update_parent 1
|
|||
|
||||
# openstreetmaps_description 1
|
||||
|
||||
# Enable (1) or disable (0) Pandora FMS Web Server/Goliat (PANDORA FMS ENTERPRISE ONLY).
|
||||
# Enable (1) or disable (0) Pandora FMS Web Server/Goliat.
|
||||
|
||||
webserver 1
|
||||
|
||||
# Number of threads for the Web Server/Goliat (PANDORA FMS ENTERPRISE ONLY).
|
||||
# Number of threads for the Web Server/Goliat.
|
||||
|
||||
web_threads 1
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ our @EXPORT = qw(
|
|||
|
||||
# version: Defines actual version of Pandora Server for this module only
|
||||
my $pandora_version = "7.0NG.754";
|
||||
my $pandora_build = "210504";
|
||||
my $pandora_build = "210513";
|
||||
our $VERSION = $pandora_version." ".$pandora_build;
|
||||
|
||||
# Setup hash
|
||||
|
@ -77,7 +77,7 @@ sub help_screen {
|
|||
sub pandora_init {
|
||||
my $pa_config = $_[0];
|
||||
my $init_string = $_[1];
|
||||
print "\n$init_string $pandora_version Build $pandora_build Copyright (c) 2004-20".substr($pandora_build,0,2)." " . pandora_get_initial_copyright_notice() . "\n";
|
||||
print "$init_string v$pandora_version Build $pandora_build\n\n";
|
||||
print "This program is OpenSource, licensed under the terms of GPL License version 2.\n";
|
||||
print "You can download latest versions and documentation at official web page.\n\n";
|
||||
|
||||
|
@ -117,9 +117,9 @@ sub pandora_init {
|
|||
($pa_config->{"pandora_path"} = $parametro);
|
||||
}
|
||||
}
|
||||
if ($pa_config->{"pandora_path"} eq ""){
|
||||
print " [ERROR] I need at least one parameter: Complete path to " . pandora_get_initial_product_name() . " configuration file. \n";
|
||||
print " For example: ./pandora_server /etc/pandora/pandora_server.conf \n\n";
|
||||
if (!defined ($pa_config->{"pandora_path"}) || $pa_config->{"pandora_path"} eq ""){
|
||||
print "[ERROR] I need at least one parameter: Complete path to " . pandora_get_initial_product_name() . " configuration file. \n";
|
||||
print "For example: ./pandora_server /etc/pandora/pandora_server.conf \n\n";
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1339,6 +1339,9 @@ sub pandora_execute_action ($$$$$$$$$;$) {
|
|||
my $cid_data = "CID_IMAGE";
|
||||
my $dataname = "CID_IMAGE.png";
|
||||
|
||||
# Decode ampersand. Used for macros with encoded names.
|
||||
$field3 =~ s/&/&/g;
|
||||
|
||||
if (defined($data) && $data =~ /^data:image\/png;base64, /) {
|
||||
# macro _data_ substitution in case is image.
|
||||
$attach_data_as_image = 1;
|
||||
|
@ -4028,6 +4031,12 @@ sub pandora_evaluate_snmp_alerts ($$$$$$$$$) {
|
|||
$alert->{'al_field13'} = subst_alert_macros ($alert->{'al_field13'}, \%macros);
|
||||
$alert->{'al_field14'} = subst_alert_macros ($alert->{'al_field14'}, \%macros);
|
||||
$alert->{'al_field15'} = subst_alert_macros ($alert->{'al_field15'}, \%macros);
|
||||
$alert->{'al_field16'} = subst_alert_macros ($alert->{'al_field16'}, \%macros);
|
||||
$alert->{'al_field17'} = subst_alert_macros ($alert->{'al_field17'}, \%macros);
|
||||
$alert->{'al_field18'} = subst_alert_macros ($alert->{'al_field18'}, \%macros);
|
||||
$alert->{'al_field19'} = subst_alert_macros ($alert->{'al_field19'}, \%macros);
|
||||
$alert->{'al_field20'} = subst_alert_macros ($alert->{'al_field20'}, \%macros);
|
||||
|
||||
|
||||
# Check time threshold
|
||||
$alert->{'last_fired'} = '1970-01-01 00:00:00' unless defined ($alert->{'last_fired'});
|
||||
|
@ -4067,6 +4076,14 @@ sub pandora_evaluate_snmp_alerts ($$$$$$$$$) {
|
|||
'field13' => $alert->{'al_field13'},
|
||||
'field14' => $alert->{'al_field14'},
|
||||
'field15' => $alert->{'al_field15'},
|
||||
'field16' => $alert->{'al_field16'},
|
||||
'field17' => $alert->{'al_field17'},
|
||||
'field18' => $alert->{'al_field18'},
|
||||
'field19' => $alert->{'al_field19'},
|
||||
'field20' => $alert->{'al_field20'},
|
||||
|
||||
|
||||
|
||||
'description' => $alert->{'description'},
|
||||
'times_fired' => $times_fired,
|
||||
'time_threshold' => 0,
|
||||
|
@ -4152,6 +4169,12 @@ sub pandora_evaluate_snmp_alerts ($$$$$$$$$) {
|
|||
'field13' => $other_alert->{'al_field13'},
|
||||
'field14' => $other_alert->{'al_field14'},
|
||||
'field15' => $other_alert->{'al_field15'},
|
||||
'field16' => $other_alert->{'al_field16'},
|
||||
'field17' => $other_alert->{'al_field17'},
|
||||
'field18' => $other_alert->{'al_field18'},
|
||||
'field19' => $other_alert->{'al_field19'},
|
||||
'field20' => $other_alert->{'al_field20'},
|
||||
|
||||
'description' => '',
|
||||
'times_fired' => $times_fired,
|
||||
'time_threshold' => 0,
|
||||
|
|
|
@ -0,0 +1,365 @@
|
|||
##################################################################################
|
||||
# Goliath Tools CURL Module
|
||||
##################################################################################
|
||||
# Copyright (c) 2013-2021 Artica Soluciones Tecnologicas S.L
|
||||
# This code is not free or OpenSource. Please don't redistribute.
|
||||
##################################################################################
|
||||
|
||||
package PandoraFMS::Goliat::GoliatCURL;
|
||||
|
||||
use PandoraFMS::Goliat::GoliatTools;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use Data::Dumper;
|
||||
use PandoraFMS::DB;
|
||||
|
||||
use IO::Socket::INET6;
|
||||
use URI::Escape;
|
||||
use Time::Local;
|
||||
use Time::HiRes qw ( gettimeofday );
|
||||
|
||||
# Japanese encoding support
|
||||
use Encode::Guess qw/euc-jp shiftjis iso-2022-jp/;
|
||||
|
||||
require Exporter;
|
||||
|
||||
our @ISA = ("Exporter");
|
||||
our %EXPORT_TAGS = ( 'all' => [ qw() ] );
|
||||
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
|
||||
our @EXPORT = qw(
|
||||
g_http_task
|
||||
@task_requests
|
||||
@task_reqsec
|
||||
@task_fails
|
||||
@task_time
|
||||
@task_end
|
||||
@task_sessions
|
||||
@task_ssec
|
||||
@task_get_string
|
||||
@task_get_content
|
||||
@task_session_fails
|
||||
);
|
||||
|
||||
our @task_requests;
|
||||
our @task_reqsec;
|
||||
our @task_fails ;
|
||||
our @task_time;
|
||||
our @task_end;
|
||||
our @task_sessions;
|
||||
our @task_ssec;
|
||||
our @task_get_string;
|
||||
our @task_get_content;
|
||||
our @task_session_fails;
|
||||
our $goliat_abort;
|
||||
|
||||
# Returns a string than can be safely used as a command line parameter for CURL
|
||||
sub safe_param ($) {
|
||||
my $string = shift;
|
||||
|
||||
$string =~ s/'/"/g;
|
||||
return "'" . $string . "'";
|
||||
}
|
||||
|
||||
sub g_http_task {
|
||||
my ( $config, $thread_id, @work_list ) = @_;
|
||||
my ( $ax, $bx, $cx ); # used in FOR loop
|
||||
my ( $ttime1, $ttime2, $ttime_tot );
|
||||
|
||||
my $resp; # HTTP Response
|
||||
my $total_requests = 0;
|
||||
my $total_valid_requests = 0;
|
||||
my $total_invalid_request = 0;
|
||||
my $cookie_file = "/tmp/gtc_".$thread_id."_".g_trash_ascii (3);
|
||||
my $check_string = 1;
|
||||
my $get_string = "";
|
||||
my $get_content = "";
|
||||
my $get_content_advanced = "";
|
||||
my $timeout = 10;
|
||||
|
||||
#my $ua = new LWP::UserAgent;
|
||||
$task_requests [$thread_id] = 0 ;
|
||||
$task_sessions [$thread_id] = 0 ;
|
||||
$task_reqsec[$thread_id] = 0;
|
||||
$task_fails[$thread_id] = 0;
|
||||
$task_session_fails[$thread_id] = 0;
|
||||
$task_ssec[$thread_id] = 0;
|
||||
$task_end[$thread_id] = 0;
|
||||
$task_time[$thread_id] = 0;
|
||||
$task_get_string[$thread_id] = "";
|
||||
$task_get_content[$thread_id] = "";
|
||||
|
||||
# Set command line options for CURL
|
||||
my $curl_opts;
|
||||
|
||||
# Follow redirects
|
||||
$curl_opts .= " --location-trusted";
|
||||
|
||||
# User agent
|
||||
if ($config->{"agent"} ne '') {
|
||||
$curl_opts .= " -A " . safe_param($config->{"agent"})
|
||||
}
|
||||
|
||||
# Prevent pages from being cached
|
||||
$curl_opts .= " -H 'Pragma: no-cache'";
|
||||
|
||||
# Timeout
|
||||
if (defined ($config->{"timeout"}) && $config->{"timeout"} > 0) {
|
||||
$timeout = $config->{"timeout"};
|
||||
}
|
||||
|
||||
# Maximum file size
|
||||
if (defined($config->{"maxsize"}) && $config->{"maxsize"} > 0) {
|
||||
$curl_opts .= " --max-filesize " . $config->{"maxsize"};
|
||||
}
|
||||
|
||||
# Disable SSL certificate host verification
|
||||
$curl_opts .= " -k";
|
||||
|
||||
# Proxy
|
||||
if ($config->{'proxy'} ne ""){
|
||||
$curl_opts .= " -x " . safe_param($config->{'proxy'});
|
||||
}
|
||||
|
||||
# Proxy HTTP authentication
|
||||
if ($config->{'auth_user'} ne "") {
|
||||
$curl_opts .= " --proxy-anyauth -U " . safe_param($config->{'auth_user'} . ':' . $config->{'auth_pass'});
|
||||
}
|
||||
|
||||
# Delete existing cookies
|
||||
my $cookie_carry_on = 0;
|
||||
if ( -e $cookie_file){
|
||||
unlink ($cookie_file);
|
||||
}
|
||||
|
||||
$ttime1 = Time::HiRes::gettimeofday();
|
||||
for ($ax = 0; $ax != $config->{'retries'}; $ax++){
|
||||
for ($bx = 0; $bx < $config->{"work_items"}; $bx++){
|
||||
if ($config->{'con_delay'} > 0){
|
||||
sleep ($config->{'con_delay'});
|
||||
}
|
||||
$total_requests++;
|
||||
# Start to count!
|
||||
$check_string = 1;
|
||||
# Prepare parameters
|
||||
my $task_curl_opts = $curl_opts;
|
||||
my $params = "";
|
||||
$cx = 0;
|
||||
while (defined($work_list[$bx]->{'variable_name'}[$cx])){
|
||||
if ($cx > 0){
|
||||
$params = $params."&";
|
||||
}
|
||||
$params = $params . $work_list[$bx]->{'variable_name'}[$cx] . "=" . uri_escape($work_list[$bx]->{'variable_value'}[$cx]);
|
||||
$cx++;
|
||||
}
|
||||
|
||||
# Cookie carry on
|
||||
if (defined ($work_list[$bx]->{'cookie'}) && $work_list[$bx]->{'cookie'} == 1){
|
||||
$cookie_carry_on = 1;
|
||||
}
|
||||
|
||||
if ($cookie_carry_on == 1) {
|
||||
$task_curl_opts .= " -c " . safe_param ($cookie_file);
|
||||
$task_curl_opts .= " -b " . safe_param ($cookie_file);
|
||||
}
|
||||
|
||||
# HTTP authentication
|
||||
if ($work_list[$bx]->{'http_auth_user'} ne "" && $work_list[$bx]->{'http_auth_pass'} ne "") {
|
||||
|
||||
if($config->{'http_check_type'} == 0){
|
||||
$task_curl_opts .= " --anyauth -u " . safe_param($work_list[$bx]->{'http_auth_user'} . ':' . $work_list[$bx]->{'http_auth_pass'});
|
||||
}
|
||||
|
||||
if ($config->{'http_check_type'} == 1) {
|
||||
$task_curl_opts .= " --ntlm -u " . safe_param($work_list[$bx]->{'http_auth_user'} . ':' . $work_list[$bx]->{'http_auth_pass'});
|
||||
}
|
||||
|
||||
if ($config->{'http_check_type'} == 2) {
|
||||
$task_curl_opts .= " --digest -u " . safe_param($work_list[$bx]->{'http_auth_user'} . ':' . $work_list[$bx]->{'http_auth_pass'});
|
||||
}
|
||||
|
||||
if ($config->{'http_check_type'} == 3) {
|
||||
$task_curl_opts .= " --basic -u " . safe_param($work_list[$bx]->{'http_auth_user'} . ':' . $work_list[$bx]->{'http_auth_pass'});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
# GET
|
||||
if ($work_list[$bx]->{'type'} eq "GET"){
|
||||
$task_curl_opts .= " -H 'Accept: text/html'";
|
||||
if ($cx > 0){
|
||||
$params = $work_list[$bx]->{'url'} . "?" . $params;
|
||||
} else {
|
||||
$params = $work_list[$bx]->{'url'};
|
||||
}
|
||||
|
||||
$resp = curl ($config->{"plugin_exec"}, $timeout, $task_curl_opts, $params, $work_list[$bx]->{'headers'}, $work_list[$bx]->{'debug'}, $config->{"moduleId"}, $config->{"dbh"});
|
||||
|
||||
# POST
|
||||
} elsif ($work_list[$bx]->{'type'} eq "POST") {
|
||||
$task_curl_opts .= " -d " . safe_param($params);
|
||||
$task_curl_opts .= " -H 'Content-type: application/x-www-form-urlencoded'";
|
||||
$resp = curl ($config->{"plugin_exec"}, $timeout, $task_curl_opts, $work_list[$bx]->{'url'}, $work_list[$bx]->{'headers'}, $work_list[$bx]->{'debug'}, $config->{"moduleId"}, $config->{"dbh"});
|
||||
|
||||
# HEAD
|
||||
} else {
|
||||
$task_curl_opts .= " -I";
|
||||
if ($cx > 0){
|
||||
$params = $work_list[$bx]->{'url'} . "?" . uri_escape($params);
|
||||
} else {
|
||||
$params = $work_list[$bx]->{'url'};
|
||||
}
|
||||
$resp = curl ($config->{"plugin_exec"}, $timeout, $task_curl_opts, $params, $work_list[$bx]->{'headers'}, $work_list[$bx]->{'debug'}, $config->{"moduleId"}, $config->{"dbh"});
|
||||
}
|
||||
|
||||
# Get string ?
|
||||
if (defined($work_list[$bx]->{'get_string'})) {
|
||||
my $temp = $work_list[$bx]->{'get_string'};
|
||||
if ($resp =~ m/($temp)/) {
|
||||
$task_get_string[$thread_id] = $1;
|
||||
}
|
||||
}
|
||||
|
||||
# Get response ?
|
||||
if ($work_list[$bx]->{'get_content_advanced'} ne "") {
|
||||
my $temp = $work_list[$bx]->{'get_content_advanced'};
|
||||
if ($resp =~ m/$temp/) {
|
||||
$task_get_content[$thread_id] = $1 if defined ($1);
|
||||
}
|
||||
} elsif ($work_list[$bx]->{'get_content'} ne "") {
|
||||
my $temp = $work_list[$bx]->{'get_content'};
|
||||
if ($resp =~ m/($temp)/) {
|
||||
$task_get_content[$thread_id] = $1;
|
||||
}
|
||||
} else {
|
||||
$task_get_content[$thread_id] = $resp;
|
||||
}
|
||||
|
||||
# Resource bashing
|
||||
#if ((defined($work_list[$bx]->{'get_resources'})) && ($work_list[$bx]->{'get_resources'} == 1)){
|
||||
# $total_requests = g_get_all_links ($config, $ua, $resp, $total_requests, $work_list[$bx]->{'url'}, $work_list[$bx]->{'headers'}, $work_list[$bx]->{'debug'});
|
||||
#}
|
||||
|
||||
# CHECKSTRING check
|
||||
$cx = 0;
|
||||
while (defined($work_list[$bx]->{'checkstring'}[$cx])) {
|
||||
my $match_string = $work_list[$bx]->{'checkstring'}[$cx];
|
||||
my $as_string = $resp;
|
||||
my $guess = Encode::Guess::guess_encoding($as_string);
|
||||
if (ref $guess) {
|
||||
$as_string = $guess->decode($as_string);
|
||||
}
|
||||
unless (utf8::is_utf8($match_string)) {
|
||||
utf8::decode($match_string);
|
||||
}
|
||||
|
||||
if ( $as_string =~ m/$match_string/i ){
|
||||
$total_valid_requests++;
|
||||
} else {
|
||||
$total_invalid_request++;
|
||||
$bx = $config->{"work_items"}; # Abort session remaining request
|
||||
$check_string=0;
|
||||
}
|
||||
$cx++;
|
||||
}
|
||||
|
||||
# CHECKNOTSTRING check
|
||||
$cx = 0;
|
||||
while (defined($work_list[$bx]->{'checknotstring'}[$cx])) {
|
||||
my $match_string = $work_list[$bx]->{'checknotstring'}[$cx];
|
||||
my $as_string = $resp;
|
||||
|
||||
my $guess = Encode::Guess::guess_encoding($as_string);
|
||||
if (ref $guess) {
|
||||
$as_string = $guess->decode($as_string);
|
||||
}
|
||||
unless (utf8::is_utf8($match_string)) {
|
||||
utf8::decode($match_string);
|
||||
}
|
||||
|
||||
if ( $as_string !~ m/$match_string/i ){
|
||||
$total_valid_requests++;
|
||||
} else {
|
||||
$total_invalid_request++;
|
||||
$bx = $config->{"work_items"}; # Abort session remaining request
|
||||
$check_string=0;
|
||||
}
|
||||
$cx++;
|
||||
}
|
||||
|
||||
# End just now by pressing CTRL-C or Kill Signal !
|
||||
#if ($goliat_abort == 1){
|
||||
#$ax = $config->{'retries'};
|
||||
#$bx = $config->{'items'};
|
||||
#goto END_LOOP;
|
||||
#}
|
||||
} #main work_detail loop
|
||||
$ttime2 = Time::HiRes::gettimeofday();
|
||||
|
||||
$ttime_tot = $ttime2 - $ttime1; # Total time for this task
|
||||
$task_time[$thread_id] = $ttime_tot;
|
||||
$task_requests [$thread_id] = $total_requests;
|
||||
if ($ttime_tot > 0 ){
|
||||
$task_reqsec[$thread_id] = $total_requests / $ttime_tot;
|
||||
} else {
|
||||
$task_reqsec[$thread_id] = $total_requests;
|
||||
}
|
||||
$task_fails[$thread_id] = $total_invalid_request;
|
||||
if ($check_string == 0){
|
||||
$task_session_fails[$thread_id]++
|
||||
}
|
||||
$task_sessions [$thread_id]++;
|
||||
if ($task_sessions [$thread_id] > 0 ){
|
||||
$task_ssec[$thread_id] = $ttime_tot / $task_sessions [$thread_id];
|
||||
} else {
|
||||
$task_ssec[$thread_id] = $task_sessions[$thread_id];
|
||||
}
|
||||
sleep $config->{'ses_delay'};
|
||||
}
|
||||
END_LOOP:
|
||||
|
||||
if ( -f $cookie_file){
|
||||
unlink ($cookie_file);
|
||||
}
|
||||
|
||||
$task_end[$thread_id] = 1;
|
||||
}
|
||||
|
||||
# Call CURL and return its output.
|
||||
sub curl {
|
||||
my ($exec, $timeout, $curl_opts, $url, $headers, $debug, $moduleId, $dbh) = @_;
|
||||
|
||||
while (my ($header, $value) = each %{$headers}) {
|
||||
$curl_opts .= " -H " . safe_param($header . ':' . $value);
|
||||
}
|
||||
|
||||
my $cmd = "curl $curl_opts " . safe_param($url);
|
||||
my $response = `"$exec" $timeout $cmd 2>/dev/null`;
|
||||
|
||||
# Curl command stored for live debugging feature.
|
||||
set_update_agentmodule ($dbh, $moduleId, { 'debug_content' => $cmd }) if defined($dbh);
|
||||
|
||||
return $response if ($debug eq '');
|
||||
|
||||
# Debug
|
||||
if (open (DEBUG, '>>', $debug . '.req')) {
|
||||
print DEBUG "[Goliat debug " . time () . "]\n";
|
||||
print DEBUG $cmd;
|
||||
print "\n";
|
||||
close (DEBUG);
|
||||
}
|
||||
if (open (DEBUG, '>>', $debug . '.res')) {
|
||||
print DEBUG "[Goliat debug " . time () . "]\n";
|
||||
print DEBUG $response;
|
||||
print "\n";
|
||||
close (DEBUG);
|
||||
}
|
||||
return $response;
|
||||
}
|
||||
|
||||
# End of function declaration
|
||||
# End of defined Code
|
||||
|
||||
1;
|
||||
__END__
|
|
@ -0,0 +1,265 @@
|
|||
##########################################################################
|
||||
# Goliat Config package
|
||||
##########################################################################
|
||||
# Copyright (c) 2007-2021 Artica Soluciones Tecnologicas S.L
|
||||
# This code is not free or OpenSource. Please don't redistribute.
|
||||
##########################################################################
|
||||
|
||||
package PandoraFMS::Goliat::GoliatConfig;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use PandoraFMS::Tools;
|
||||
use PandoraFMS::Goliat::GoliatTools;
|
||||
|
||||
require Exporter;
|
||||
our @ISA = ("Exporter");
|
||||
our %EXPORT_TAGS = ( 'all' => [ qw( ) ] );
|
||||
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
|
||||
our @EXPORT = qw( g_help_screen
|
||||
g_init
|
||||
g_load_config );
|
||||
|
||||
my $g_version = "1.0";
|
||||
my $g_build = "110929";
|
||||
our $VERSION = $g_version." ".$g_build;
|
||||
|
||||
|
||||
sub g_load_config {
|
||||
my ( $config , $work_list )= @_ ;
|
||||
my $archivo_cfg = $config->{'config_file'};
|
||||
my $buffer_line;
|
||||
my $task_block = 0;
|
||||
my $commit_block = 0;
|
||||
my $task_url = "";
|
||||
my $task_cookie = 0;
|
||||
my $task_resources = 1;
|
||||
my $task_type = "";
|
||||
my $task_headers = {};
|
||||
my $task_debug = "";
|
||||
my $http_auth_user = "";
|
||||
my $http_auth_pass = "";
|
||||
my $http_auth_realm = "";
|
||||
my $http_auth_serverport = "";
|
||||
my $get_string = "";
|
||||
my $get_content = "";
|
||||
my $get_content_advanced = "";
|
||||
my @task_variable_name;
|
||||
my @task_variable_value;
|
||||
my @task_check_string;
|
||||
my @task_check_not_string;
|
||||
my $parametro;
|
||||
my $temp1;
|
||||
|
||||
# Default options
|
||||
$config->{'con_delay'} =0;
|
||||
$config->{'ses_delay'} =0;
|
||||
if (!defined($config->{'agent'})){
|
||||
$config->{'agent'}="PandoraFMS/Goliat 4.0; Linux)";
|
||||
}
|
||||
if (!defined($config->{'proxy'})){
|
||||
$config->{'proxy'}="";
|
||||
}
|
||||
|
||||
if (!defined($config->{'retries'})){
|
||||
$config->{'retries'} = 1;
|
||||
}
|
||||
|
||||
if ((!is_numeric($config->{'retries'})) || ($config->{'retries'} == 0)){
|
||||
$config->{'retries'} = 1;
|
||||
}
|
||||
|
||||
$config->{'refresh'} = "5";
|
||||
$config->{"max_depth"} = 25;
|
||||
$config->{'log_file'}="/var/log/pandora/pandora_goliat.log";
|
||||
$config->{'log_output'} = 0;
|
||||
|
||||
# Collect items from config file and put in an array
|
||||
open (CFG, "< $archivo_cfg");
|
||||
while (<CFG>){
|
||||
$buffer_line = $_;
|
||||
if ($buffer_line =~ /^[a-zA-Z]/){ # begins with letters
|
||||
$parametro = $buffer_line;
|
||||
} else {
|
||||
$parametro = "";
|
||||
}
|
||||
# Need to commit block ??
|
||||
if (($commit_block == 1) && ($task_block == 1)) {
|
||||
my %work_item;
|
||||
$work_item{'url'} = $task_url;
|
||||
$work_item{'cookie'} = $task_cookie;
|
||||
$work_item{'type'} = $task_type;
|
||||
$work_item{'get_resources'} = $task_resources;
|
||||
$work_item{'get_string'} = $get_string;
|
||||
$work_item{'get_content'} = $get_content;
|
||||
$work_item{'get_content_advanced'} = $get_content_advanced;
|
||||
$work_item{'http_auth_user'} = $http_auth_user;
|
||||
$work_item{'http_auth_pass'} = $http_auth_pass;
|
||||
$work_item{'http_auth_realm'} = $http_auth_realm;
|
||||
$work_item{'http_auth_serverport'} = $http_auth_serverport;
|
||||
$work_item{'headers'} = $task_headers;
|
||||
$work_item{'debug'} = $task_debug;
|
||||
|
||||
my $ax=0;
|
||||
while ($#task_check_string >= 0){
|
||||
$temp1 = pop (@task_check_string);
|
||||
$work_item{'checkstring'}[$ax] = $temp1;
|
||||
$ax++;
|
||||
}
|
||||
$ax=0;
|
||||
while ($#task_check_not_string >= 0){
|
||||
$temp1 = pop (@task_check_not_string);
|
||||
$work_item{'checknotstring'}[$ax] = $temp1;
|
||||
$ax++;
|
||||
}
|
||||
$ax=0;
|
||||
while ($#task_variable_name >= 0){
|
||||
$temp1 = pop (@task_variable_name);
|
||||
$work_item{'variable_name'}[$ax] = $temp1;
|
||||
$ax++;
|
||||
}
|
||||
$ax=0;
|
||||
while ($#task_variable_value >= 0){
|
||||
$temp1 = pop (@task_variable_value);
|
||||
$work_item{'variable_value'}[$ax] = $temp1;
|
||||
$ax++;
|
||||
|
||||
}
|
||||
push @{$work_list}, \%work_item;
|
||||
$commit_block = 0;
|
||||
$task_block = 0;
|
||||
$task_url = "";
|
||||
$task_cookie = 0;
|
||||
$task_resources = 0;
|
||||
$task_type = "";
|
||||
$task_headers = {};
|
||||
$task_debug = "";
|
||||
$config->{"work_items"}++;
|
||||
$commit_block = 0;
|
||||
$task_block = 0;
|
||||
$http_auth_user = "";
|
||||
$http_auth_pass = "";
|
||||
$http_auth_realm = "";
|
||||
$get_string = "";
|
||||
$get_content = "";
|
||||
$get_content_advanced = "";
|
||||
}
|
||||
# ~~~~~~~~~~~~~~
|
||||
# Main setup items
|
||||
# ~~~~~~~~~~~~~~
|
||||
|
||||
if ($parametro =~ m/^task_begin/i) {
|
||||
$task_block = 1;
|
||||
}
|
||||
elsif ($parametro =~ m/^task_end/i) {
|
||||
$commit_block = 1;
|
||||
}
|
||||
elsif ($parametro =~ m/^ses_delay\s(.*)/i) {
|
||||
$config->{'ses_delay'} = $1;
|
||||
}
|
||||
elsif ($parametro =~ m/^con_delay\s(.*)/i) {
|
||||
$config->{'con_delay'} = $1;
|
||||
}
|
||||
elsif ($parametro =~ m/^agent\s(.*)/i) {
|
||||
$config->{'agent'} = $1;
|
||||
}
|
||||
elsif ($parametro =~ m/^proxy\s(.*)/i) {
|
||||
$config->{'proxy'} = $1;
|
||||
}
|
||||
elsif ($parametro =~ m/^max_depth\s(.*)/i) {
|
||||
$config->{'max_depth'} = $1;
|
||||
}
|
||||
elsif ($parametro =~ m/^log_file\s(.*)/i) {
|
||||
$config->{"log_file"} = $1;
|
||||
}
|
||||
elsif ($parametro =~ m/^log_output\s(.*)/i) {
|
||||
$config->{"log_output"} = $1;
|
||||
}
|
||||
elsif ($parametro =~ m/^log_http\s(.*)/i) {
|
||||
$config->{"log_http"} = $1;
|
||||
}
|
||||
elsif ($parametro =~ m/^retries\s(.*)/i) {
|
||||
$config->{"retries"} = $1;
|
||||
}
|
||||
# ~~~~~~~~~~~~~~
|
||||
# Task items
|
||||
# ~~~~~~~~~~~~~~
|
||||
elsif ($parametro =~ m/^variable_name\s(.*)/i) {
|
||||
push (@task_variable_name, $1);
|
||||
}
|
||||
elsif ($parametro =~ m/^variable_value\s(.*)/i) {
|
||||
push (@task_variable_value, $1);
|
||||
}
|
||||
elsif ($parametro =~ m/^check_string\s(.*)/i) {
|
||||
push (@task_check_string, $1);
|
||||
}
|
||||
elsif ($parametro =~ m/^check_not_string\s(.*)/i) {
|
||||
push (@task_check_not_string, $1);
|
||||
}
|
||||
elsif ($parametro =~ m/^get\s(.*)/i) {
|
||||
$task_type = "GET";
|
||||
$task_url = $1;
|
||||
}
|
||||
elsif ($parametro =~ m/^post\s(.*)/i) {
|
||||
$task_type = "POST";
|
||||
$task_url = $1;
|
||||
}
|
||||
elsif ($parametro =~ m/^head\s(.*)/i) {
|
||||
$task_type = "HEAD";
|
||||
$task_url = $1;
|
||||
}
|
||||
# New in 4.0 version
|
||||
elsif ($parametro =~ m/^get_string\s(.*)/i) {
|
||||
$get_string = $1;
|
||||
}
|
||||
elsif ($parametro =~ m/^get_content\s(.*)/i) {
|
||||
$get_content = $1;
|
||||
}
|
||||
elsif ($parametro =~ m/^get_content_advanced\s(.*)/i) {
|
||||
$get_content_advanced = $1;
|
||||
}
|
||||
elsif ($parametro =~ m/^http_auth_user\s(.*)/i) {
|
||||
$http_auth_user = $1;
|
||||
}
|
||||
elsif ($parametro =~ m/^http_auth_pass\s(.*)/i) {
|
||||
$http_auth_pass = $1;
|
||||
}
|
||||
elsif ($parametro =~ m/^http_auth_realm\s(.*)/i) {
|
||||
$http_auth_realm = $1;
|
||||
}
|
||||
elsif ($parametro =~ m/^http_auth_serverport\s(.*)/i) {
|
||||
$http_auth_serverport = $1;
|
||||
}
|
||||
elsif ($parametro =~ m/^cookie\s(.*)/i) {
|
||||
if ($1 =~ m/1/i){
|
||||
$task_cookie = 1;
|
||||
} else {
|
||||
$task_cookie = 0;
|
||||
}
|
||||
}
|
||||
elsif ($parametro =~ m/^resource\s(.*)/i) {
|
||||
if ($1 =~ m/1/i){
|
||||
$task_resources = 1;
|
||||
} else {
|
||||
$task_resources = 0;
|
||||
}
|
||||
}
|
||||
# New in 5.0 version
|
||||
elsif ($parametro =~ m/^header\s+(\S+)\s(.*)/i) {
|
||||
$task_headers->{$1} = $2;
|
||||
}
|
||||
elsif ($parametro =~ m/^debug\s+(.*)/i) {
|
||||
$task_debug = $1;
|
||||
}
|
||||
|
||||
}
|
||||
close (CFG);
|
||||
}
|
||||
|
||||
# End of function declaration
|
||||
# End of defined Code
|
||||
|
||||
1;
|
||||
__END__
|
||||
|
||||
|
|
@ -0,0 +1,478 @@
|
|||
##################################################################################
|
||||
# Goliath Tools LWP Module
|
||||
##################################################################################
|
||||
# Copyright (c) 2007-2021 Artica Soluciones Tecnologicas S.L
|
||||
# This code is not free or OpenSource. Please don't redistribute.
|
||||
##################################################################################
|
||||
|
||||
package PandoraFMS::Goliat::GoliatLWP;
|
||||
|
||||
use PandoraFMS::Goliat::GoliatTools;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use Data::Dumper;
|
||||
|
||||
use IO::Socket::INET6;
|
||||
use LWP::UserAgent;
|
||||
use LWP::ConnCache;
|
||||
use HTTP::Request::Common;
|
||||
use HTTP::Response;
|
||||
use HTML::TreeBuilder;
|
||||
use HTML::Element;
|
||||
use HTTP::Cookies;
|
||||
use URI::URL;
|
||||
use Time::Local;
|
||||
use Time::HiRes qw ( gettimeofday );
|
||||
|
||||
# For IPv6 support in Net::HTTP.
|
||||
BEGIN {
|
||||
$Net::HTTP::SOCKET_CLASS = 'IO::Socket::INET6';
|
||||
require Net::HTTP;
|
||||
}
|
||||
|
||||
# Japanese encoding support
|
||||
use Encode::Guess qw/euc-jp shiftjis iso-2022-jp/;
|
||||
|
||||
require Exporter;
|
||||
|
||||
our @ISA = ("Exporter");
|
||||
our %EXPORT_TAGS = ( 'all' => [ qw() ] );
|
||||
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
|
||||
our @EXPORT = qw(
|
||||
g_http_task
|
||||
@task_requests
|
||||
@task_reqsec
|
||||
@task_fails
|
||||
@task_time
|
||||
@task_end
|
||||
@task_sessions
|
||||
@task_ssec
|
||||
@task_get_string
|
||||
@task_get_content
|
||||
@task_session_fails
|
||||
);
|
||||
|
||||
our @task_requests;
|
||||
our @task_reqsec;
|
||||
our @task_fails;
|
||||
our @task_time;
|
||||
our @task_end;
|
||||
our @task_sessions;
|
||||
our @task_ssec;
|
||||
our @task_get_string;
|
||||
our @task_get_content;
|
||||
our @task_session_fails;
|
||||
our $goliat_abort;
|
||||
|
||||
sub parse_html ($;$)
|
||||
{
|
||||
my $p = $_[1];
|
||||
$p = _new_tree_maker() unless $p;
|
||||
$p->parse($_[0]);
|
||||
}
|
||||
|
||||
|
||||
sub parse_htmlfile ($;$)
|
||||
{
|
||||
my($file, $p) = @_;
|
||||
local(*HTML);
|
||||
open(HTML, $file) or return undef;
|
||||
$p = _new_tree_maker() unless $p;
|
||||
$p->parse_file(\*HTML);
|
||||
}
|
||||
|
||||
sub _new_tree_maker
|
||||
{
|
||||
my $p = HTML::TreeBuilder->new(implicit_tags => 1,
|
||||
ignore_unknown => 1,
|
||||
ignore_text => 0,
|
||||
'warn' => 0,
|
||||
);
|
||||
$p->strict_comment(1);
|
||||
$p;
|
||||
}
|
||||
|
||||
|
||||
sub g_http_task {
|
||||
my ( $config, $thread_id, @work_list ) = @_;
|
||||
my ( $ax, $bx, $cx ); # used in FOR loop
|
||||
my ( $ttime1, $ttime2, $ttime_tot );
|
||||
|
||||
my $resp; # HTTP Response
|
||||
my $total_requests = 0;
|
||||
my $total_valid_requests = 0;
|
||||
my $total_invalid_request = 0;
|
||||
my $cookie_file = "/tmp/gtc_".$thread_id."_".g_trash_ascii (3);
|
||||
my $check_string = 1;
|
||||
my $get_string = "";
|
||||
my $get_content = "";
|
||||
my $get_content_advanced = "";
|
||||
|
||||
my $ua = new LWP::UserAgent;
|
||||
$task_requests [$thread_id] = 0 ;
|
||||
$task_sessions [$thread_id] = 0 ;
|
||||
$task_reqsec[$thread_id] = 0;
|
||||
$task_fails[$thread_id] = 0;
|
||||
$task_session_fails[$thread_id] = 0;
|
||||
$task_ssec[$thread_id] = 0;
|
||||
$task_end[$thread_id] = 0;
|
||||
$task_time[$thread_id] = 0;
|
||||
$task_get_string[$thread_id] = "";
|
||||
$task_get_content[$thread_id] = "";
|
||||
|
||||
$ua->agent($config->{"agent"});
|
||||
$ua->protocols_allowed( ['http', 'https'] );
|
||||
$ua->default_headers->push_header('pragma' => "no-cache");
|
||||
$ua->timeout ($config->{"timeout"});
|
||||
$ua->max_size($config->{"maxsize"});
|
||||
$ua->use_alarm($config->{"alarm"});
|
||||
|
||||
# Disable SSL certificate host verification
|
||||
if ($ua->can ('ssl_opts')) {
|
||||
$ua->ssl_opts("verify_hostname" => 0);
|
||||
}
|
||||
|
||||
# Set proxy
|
||||
|
||||
if ($config->{'proxy'} ne ""){
|
||||
$ua->proxy(['http','https'], $config->{'proxy'});
|
||||
}
|
||||
|
||||
# Set HTTP Proxy auth
|
||||
if ($config->{'auth_user'} ne "") {
|
||||
$ua->credentials(
|
||||
$config->{'auth_server'},
|
||||
$config->{'auth_realm'},
|
||||
$config->{'auth_user'} => $config->{'auth_pass'} );
|
||||
}
|
||||
|
||||
if ( -e $cookie_file){
|
||||
unlink ($cookie_file);
|
||||
}
|
||||
my $cookies = HTTP::Cookies->new ('file' => $cookie_file, 'autosave' => '0');
|
||||
|
||||
$ttime1 = Time::HiRes::gettimeofday();
|
||||
for ($ax = 0; $ax != $config->{'retries'}; $ax++){
|
||||
for ($bx = 0; $bx < $config->{"work_items"}; $bx++){
|
||||
if ($config->{'con_delay'} > 0){
|
||||
sleep ($config->{'con_delay'});
|
||||
}
|
||||
$total_requests++;
|
||||
# Start to count!
|
||||
$check_string = 1;
|
||||
# Prepare parameters
|
||||
my $params = "";
|
||||
$cx = 0;
|
||||
while (defined($work_list[$bx]->{'variable_name'}[$cx])){
|
||||
if ($cx > 0){
|
||||
$params = $params."&";
|
||||
}
|
||||
$params = $params . $work_list[$bx]->{'variable_name'}[$cx] . "=" . $work_list[$bx]->{'variable_value'}[$cx];
|
||||
$cx++;
|
||||
}
|
||||
|
||||
if ( (defined($work_list[$bx]->{'http_auth_realm'})) && (defined($work_list[$bx]->{'http_auth_serverport'}))&& (defined($work_list[$bx]->{'http_auth_user'})) && (defined($work_list[$bx]->{'http_auth_pass'}))) {
|
||||
if ($work_list[$bx]->{'http_auth_realm'} ne "") {
|
||||
$ua->credentials(
|
||||
$work_list[$bx]->{'http_auth_serverport'},
|
||||
$work_list[$bx]->{'http_auth_realm'},
|
||||
$work_list[$bx]->{'http_auth_user'} => $work_list[$bx]->{'http_auth_pass'}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
# GET
|
||||
if ($work_list[$bx]->{'type'} eq "GET"){
|
||||
if ($cx > 0){
|
||||
$params = $work_list[$bx]->{'url'} . "?" . $params;
|
||||
} else {
|
||||
$params = $work_list[$bx]->{'url'};
|
||||
}
|
||||
$resp = g_get_page ( $ua, $params, $work_list[$bx]->{'headers'}, $work_list[$bx]->{'debug'});
|
||||
|
||||
# POST
|
||||
} elsif ($work_list[$bx]->{'type'} eq "POST") {
|
||||
$resp = g_post_page ( $ua, $work_list[$bx]->{'url'}, $params, $work_list[$bx]->{'headers'}, $work_list[$bx]->{'debug'});
|
||||
|
||||
# HEAD
|
||||
} else {
|
||||
if ($cx > 0){
|
||||
$params = $work_list[$bx]->{'url'} . "?" . $params;
|
||||
} else {
|
||||
$params = $work_list[$bx]->{'url'};
|
||||
}
|
||||
$resp = g_head_page ( $ua, $params, $work_list[$bx]->{'headers'}, $work_list[$bx]->{'debug'});
|
||||
}
|
||||
|
||||
# Check for errors.
|
||||
if ($resp->code() == 500) {
|
||||
$total_invalid_request++;
|
||||
$bx = $config->{"work_items"};
|
||||
$check_string=0;
|
||||
last;
|
||||
}
|
||||
|
||||
# Get string ?
|
||||
if (defined($work_list[$bx]->{'get_string'})) {
|
||||
my $as_string = $resp->as_string;
|
||||
my $temp = $work_list[$bx]->{'get_string'};
|
||||
if ($as_string =~ m/($temp)/) {
|
||||
$task_get_string[$thread_id] = $1;
|
||||
}
|
||||
}
|
||||
|
||||
# Get response ?
|
||||
if ($work_list[$bx]->{'get_content_advanced'} ne "") {
|
||||
my $content = $resp->decoded_content;
|
||||
my $temp = $work_list[$bx]->{'get_content_advanced'};
|
||||
if ($content =~ m/$temp/) {
|
||||
$task_get_content[$thread_id] = $1 if defined ($1);
|
||||
}
|
||||
} elsif ($work_list[$bx]->{'get_content'} ne "") {
|
||||
my $content = $resp->decoded_content;
|
||||
my $temp = $work_list[$bx]->{'get_content'};
|
||||
if ($content =~ m/($temp)/) {
|
||||
$task_get_content[$thread_id] = $1;
|
||||
}
|
||||
}
|
||||
|
||||
# Resource bashing
|
||||
if ((defined($work_list[$bx]->{'get_resources'})) && ($work_list[$bx]->{'get_resources'} == 1)){
|
||||
$total_requests = g_get_all_links ($config, $ua, $resp, $total_requests, $work_list[$bx]->{'url'}, $work_list[$bx]->{'headers'}, $work_list[$bx]->{'debug'});
|
||||
}
|
||||
|
||||
# CHECKSTRING check
|
||||
$cx = 0;
|
||||
while (defined($work_list[$bx]->{'checkstring'}[$cx])) {
|
||||
my $match_string = $work_list[$bx]->{'checkstring'}[$cx];
|
||||
my $as_string = $resp->as_string;
|
||||
|
||||
my $guess = Encode::Guess::guess_encoding($as_string);
|
||||
if (ref $guess) {
|
||||
$as_string = $guess->decode($as_string);
|
||||
}
|
||||
unless (utf8::is_utf8($match_string)) {
|
||||
utf8::decode($match_string);
|
||||
}
|
||||
|
||||
if ( $as_string =~ m/$match_string/i ){
|
||||
$total_valid_requests++;
|
||||
} else {
|
||||
$total_invalid_request++;
|
||||
$bx = $config->{"work_items"}; # Abort session remaining request
|
||||
$check_string=0;
|
||||
}
|
||||
$cx++;
|
||||
}
|
||||
|
||||
# CHECKNOTSTRING check
|
||||
$cx = 0;
|
||||
while (defined($work_list[$bx]->{'checknotstring'}[$cx])) {
|
||||
my $match_string = $work_list[$bx]->{'checknotstring'}[$cx];
|
||||
my $as_string = $resp->as_string;
|
||||
|
||||
my $guess = Encode::Guess::guess_encoding($as_string);
|
||||
if (ref $guess) {
|
||||
$as_string = $guess->decode($as_string);
|
||||
}
|
||||
unless (utf8::is_utf8($match_string)) {
|
||||
utf8::decode($match_string);
|
||||
}
|
||||
|
||||
if ( $as_string !~ m/$match_string/i ){
|
||||
$total_valid_requests++;
|
||||
} else {
|
||||
$total_invalid_request++;
|
||||
$bx = $config->{"work_items"}; # Abort session remaining request
|
||||
$check_string=0;
|
||||
}
|
||||
$cx++;
|
||||
}
|
||||
|
||||
# Cookie carry on
|
||||
if (defined ($work_list[$bx]->{'cookie'}) && $work_list[$bx]->{'cookie'} == 1){
|
||||
$cookies->extract_cookies($resp);
|
||||
$ua->cookie_jar($cookies);
|
||||
}
|
||||
|
||||
# End just now by pressing CTRL-C or Kill Signal !
|
||||
#if ($goliat_abort == 1){
|
||||
#$ax = $config->{'retries'};
|
||||
#$bx = $config->{'items'};
|
||||
#goto END_LOOP;
|
||||
#}
|
||||
} #main work_detail loop
|
||||
$ttime2 = Time::HiRes::gettimeofday();
|
||||
|
||||
$ttime_tot = $ttime2 - $ttime1; # Total time for this task
|
||||
$task_time[$thread_id] = $ttime_tot;
|
||||
$task_requests [$thread_id] = $total_requests;
|
||||
if ($ttime_tot > 0 ){
|
||||
$task_reqsec[$thread_id] = $total_requests / $ttime_tot;
|
||||
} else {
|
||||
$task_reqsec[$thread_id] = $total_requests;
|
||||
}
|
||||
$task_fails[$thread_id] = $total_invalid_request;
|
||||
if ($check_string == 0){
|
||||
$task_session_fails[$thread_id]++
|
||||
}
|
||||
$task_sessions [$thread_id]++;
|
||||
if ($task_sessions [$thread_id] > 0 ){
|
||||
$task_ssec[$thread_id] = $ttime_tot / $task_sessions [$thread_id];
|
||||
} else {
|
||||
$task_ssec[$thread_id] = $task_sessions[$thread_id];
|
||||
}
|
||||
sleep $config->{'ses_delay'};
|
||||
}
|
||||
END_LOOP:
|
||||
|
||||
$cookies->clear;
|
||||
|
||||
if ( -f $cookie_file){
|
||||
unlink ($cookie_file);
|
||||
}
|
||||
|
||||
$task_end[$thread_id] = 1;
|
||||
}
|
||||
|
||||
|
||||
sub g_get_all_links {
|
||||
my ($config, $ua, $response, $counter, $myurl, $headers, $debug) = @_;
|
||||
my $html;
|
||||
|
||||
if ($response->is_success) {
|
||||
$html = $response->content;
|
||||
} else {
|
||||
return $counter;
|
||||
}
|
||||
# Beware this funcion, needs to be destroyed after use it !!!
|
||||
my $parsed_html = parse_html($html);
|
||||
#$ua->conn_cache(LWP::ConnCache->new());
|
||||
|
||||
my @url_list;
|
||||
my $url = "";
|
||||
my $link;
|
||||
my $full_url;
|
||||
|
||||
for (@{ $parsed_html->extract_links( ) }) {
|
||||
$link=$_->[0];
|
||||
if (($link =~ m/.png/i) || ($link =~ m/.gif/i) || ($link =~ m/.htm/i) ||
|
||||
($link =~ m/.html/i) || ($link =~ m/.pdf/i) || ($link =~ m/.jpg/i)
|
||||
|| ($link =~ m/.ico/i)){
|
||||
$url = new URI::URL $link;
|
||||
$full_url = $url->abs($myurl);
|
||||
@url_list = $full_url;
|
||||
}
|
||||
|
||||
}
|
||||
$parsed_html->delete;
|
||||
my $ax = 0;
|
||||
while ($full_url = pop(@url_list)) {
|
||||
g_get_page ($ua, $full_url, $headers, $debug);
|
||||
$counter++;
|
||||
$ax++;
|
||||
if ($ax > $config->{"max_depth"}){
|
||||
return $counter;
|
||||
}
|
||||
}
|
||||
return $counter;
|
||||
}
|
||||
|
||||
sub g_get_page {
|
||||
my $ua = $_[0];
|
||||
my $url = $_[1];
|
||||
my $headers = $_[2];
|
||||
my $debug = $_[3];
|
||||
|
||||
my $req = HTTP::Request->new(GET => $url);
|
||||
$req->header('Accept' => 'text/html');
|
||||
while (my ($header, $value) = each %{$headers}) {
|
||||
$req->header($header => $value);
|
||||
}
|
||||
my $response = $ua->request($req);
|
||||
return $response if ($debug eq '');
|
||||
|
||||
# Debug
|
||||
if (open (DEBUG, '>>', $debug . '.req')) {
|
||||
print DEBUG "[Goliat debug " . time () . "]\n";
|
||||
print DEBUG $req->as_string ();
|
||||
print "\n";
|
||||
close (DEBUG);
|
||||
}
|
||||
if (open (DEBUG, '>>', $debug . '.res')) {
|
||||
print DEBUG "[Goliat debug " . time () . "]\n";
|
||||
print DEBUG $response->as_string ();
|
||||
print "\n";
|
||||
close (DEBUG);
|
||||
}
|
||||
return $response;
|
||||
}
|
||||
|
||||
sub g_head_page {
|
||||
my $ua = $_[0];
|
||||
my $url = $_[1];
|
||||
my $headers = $_[2];
|
||||
my $debug = $_[3];
|
||||
|
||||
my $req = HTTP::Request->new(HEAD => $url);
|
||||
$req->header('Accept' => 'text/html');
|
||||
while (my ($header, $value) = each %{$headers}) {
|
||||
$req->header($header => $value);
|
||||
}
|
||||
my $response = $ua->request($req);
|
||||
return $response if ($debug eq '');
|
||||
|
||||
# Debug
|
||||
if (open (DEBUG, '>>', $debug . '.req')) {
|
||||
print DEBUG "[Goliat debug " . time () . "]\n";
|
||||
print DEBUG $req->as_string ();
|
||||
print "\n";
|
||||
close (DEBUG);
|
||||
}
|
||||
if (open (DEBUG, '>>', $debug . '.res')) {
|
||||
print DEBUG "[Goliat debug " . time () . "]\n";
|
||||
print DEBUG $response->as_string ();
|
||||
print "\n";
|
||||
close (DEBUG);
|
||||
}
|
||||
return $response;
|
||||
}
|
||||
|
||||
sub g_post_page {
|
||||
my $ua = $_[0];
|
||||
my $url = $_[1];
|
||||
my $content = $_[2];
|
||||
my $headers = $_[3];
|
||||
my $debug = $_[4];
|
||||
|
||||
my $req = HTTP::Request->new(POST => $url);
|
||||
$req->content_type('application/x-www-form-urlencoded');
|
||||
$req->content ($content);
|
||||
while (my ($header, $value) = each %{$headers}) {
|
||||
$req->header($header => $value);
|
||||
}
|
||||
my $response = $ua->request($req);
|
||||
return $response if ($debug eq '');
|
||||
|
||||
# Debug
|
||||
if (open (DEBUG, '>>', $debug . '.req')) {
|
||||
print DEBUG "[Goliat debug " . time () . "]\n";
|
||||
print DEBUG $req->as_string ();
|
||||
print "\n";
|
||||
close (DEBUG);
|
||||
}
|
||||
if (open (DEBUG, '>>', $debug . '.res')) {
|
||||
print DEBUG "[Goliat debug " . time () . "]\n";
|
||||
print DEBUG $response->as_string ();
|
||||
print "\n";
|
||||
close (DEBUG);
|
||||
}
|
||||
return $response;
|
||||
}
|
||||
|
||||
# End of function declaration
|
||||
# End of defined Code
|
||||
|
||||
1;
|
||||
__END__
|
|
@ -0,0 +1,222 @@
|
|||
###############################################################################
|
||||
# Goliath Tools Module
|
||||
###############################################################################
|
||||
# Copyright (c) 2007-2021 Artica Soluciones Tecnologicas S.L
|
||||
# This code is not free or OpenSource. Please don't redistribute.
|
||||
###############################################################################
|
||||
|
||||
package PandoraFMS::Goliat::GoliatTools;
|
||||
|
||||
use 5.008004;
|
||||
use strict;
|
||||
use warnings;
|
||||
use integer;
|
||||
|
||||
require Exporter;
|
||||
|
||||
our @ISA = ("Exporter");
|
||||
our %EXPORT_TAGS = ( 'all' => [ qw() ] );
|
||||
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
|
||||
our @EXPORT = qw(
|
||||
g_clean_string
|
||||
g_clean_string_unicode
|
||||
g_random_string
|
||||
g_trash_ascii
|
||||
g_trash_unicode
|
||||
g_unicode );
|
||||
|
||||
# Delaracion de funciones publicas
|
||||
|
||||
##############################################################################
|
||||
# clean_string (string) - Purge a string for any forbidden characters (esc, etc)
|
||||
##############################################################################
|
||||
sub g_clean_string {
|
||||
my $micadena;
|
||||
$micadena = $_[0];
|
||||
$micadena =~ s/[^\-\:\;\.\,\_\s\a\*\=\(\)a-zA-Z0-9]/ /g;
|
||||
$micadena =~ s/[\n\l\f]/ /g;
|
||||
return $micadena;
|
||||
}
|
||||
|
||||
##############################################################################
|
||||
# limpia_cadena_unicode (string) - Purge a string for any unicode character
|
||||
##############################################################################
|
||||
sub g_clean_string_unicode {
|
||||
my $micadena;
|
||||
$micadena = $_[0];
|
||||
$micadena =~ s/[%]/%%/g;
|
||||
return $micadena;
|
||||
}
|
||||
|
||||
#############################################################################
|
||||
# Hex converter - Convert dec value in hex representation (00 - FF)
|
||||
#############################################################################
|
||||
sub g_decToHex { #return a 16bit (o uno de 8bit) hex value
|
||||
my @hex = (0,1,2,3,4,5,6,7,8,9,"A","B","C","D","E","F");
|
||||
my @dec = @_;
|
||||
my $s3 = $hex[($dec[0]/4096)%16];
|
||||
my $s2 = $hex[($dec[0]/256)%16];
|
||||
my $s1 = $hex[($dec[0]/16)%16];
|
||||
my $s0 = $hex[$dec[0]%16];
|
||||
return "$s1$s0";
|
||||
}
|
||||
|
||||
#############################################################################
|
||||
# unicode - Generate unicode string (recursive)
|
||||
#############################################################################
|
||||
|
||||
sub g_unicode {
|
||||
my $config_word = $_[0];
|
||||
my $config_depth = $_[1];
|
||||
my $config_char="%";
|
||||
if ($config_depth == 0) {
|
||||
return $config_word;
|
||||
}
|
||||
|
||||
my $a;
|
||||
my $pos=0;
|
||||
my $output="";
|
||||
my $len;
|
||||
|
||||
for ($a=0;$a<$config_depth;$a++){
|
||||
$len = length($config_word);
|
||||
while ($pos < $len ) {
|
||||
my $item;
|
||||
$item = substr($config_word,$pos,1);
|
||||
$output = $output.$config_char.decToHex(ord($item));
|
||||
$pos++;
|
||||
}
|
||||
$config_word = $output;
|
||||
}
|
||||
return $output
|
||||
}
|
||||
|
||||
#############################################################################
|
||||
# trash - Generate "unicode" style trash string
|
||||
#############################################################################
|
||||
|
||||
sub g_trash_unicode {
|
||||
my $config_depth = $_[0];
|
||||
my $config_char="%";
|
||||
my $a;
|
||||
my $output;
|
||||
|
||||
for ($a=0;$a<$config_depth;$a++){
|
||||
$output = $output.$config_char.decToHex(int(rand(25)+97));
|
||||
}
|
||||
return $output
|
||||
}
|
||||
|
||||
#############################################################################
|
||||
# trash_ascii - Generate ASCII random strings
|
||||
#############################################################################
|
||||
|
||||
sub g_trash_ascii {
|
||||
my $config_depth = $_[0];
|
||||
my $config_char="%";
|
||||
my $a;
|
||||
my $output;
|
||||
|
||||
for ($a=0;$a<$config_depth;$a++){
|
||||
$output = $output.chr(int(rand(25)+97));
|
||||
}
|
||||
return $output
|
||||
}
|
||||
|
||||
#############################################################################
|
||||
# random_string (min, max, type) - Generate ASCII alphanumeric string,
|
||||
# from min and max
|
||||
#############################################################################
|
||||
|
||||
sub g_random_string {
|
||||
my $config_min = $_[0];
|
||||
my $config_max = $_[1];
|
||||
my $config_type = $_[2]; # alphanumeric, alpha, numeric, lowalpha, highalpha
|
||||
my $a;
|
||||
my $output = "";
|
||||
my @valid_chars;
|
||||
my $rango;
|
||||
|
||||
# First fill list of valid chars (A-Z, a-z, 0-9)
|
||||
if (($config_type eq "alphanumeric") || ($config_type eq "numeric")){
|
||||
for ($a=48;$a<58;$a++){ # numeric
|
||||
push @valid_chars, chr($a);
|
||||
}
|
||||
}
|
||||
|
||||
if (($config_type eq "alphanumeric") || ($config_type eq "alpha") ||
|
||||
($config_type eq "highalpha") || ($config_type eq "lowalpha") ){
|
||||
if (($config_type eq "alphanumeric") || ($config_type eq "highalpha") || ($config_type eq "alpha")){
|
||||
for ($a=65;$a<91;$a++){ # alpha (CAPS)
|
||||
push @valid_chars, chr($a);
|
||||
}
|
||||
}
|
||||
if (($config_type eq "alphanumeric") || ($config_type eq "lowalpha") || ($config_type eq "alpha")){
|
||||
for ($a=97;$a<123;$a++){ # alpha (low)
|
||||
push @valid_chars, chr($a);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$rango = @valid_chars;
|
||||
|
||||
# Fill min. value
|
||||
for ($a=0;$a<$config_min;$a++){
|
||||
$output = $output.$valid_chars[(int(rand($rango)))];
|
||||
}
|
||||
|
||||
# Fill to max;
|
||||
if (($config_max - $config_min) != 0){
|
||||
for ($a=0;$a<rand($config_max - $config_min +1)-1;$a++){
|
||||
$output = $output.$valid_chars[(int(rand($rango)))];
|
||||
}
|
||||
}
|
||||
return $output
|
||||
}
|
||||
|
||||
1;
|
||||
__END__
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Goliath-Tools Library tools for Goliath application.
|
||||
This is an internal module, does not use for independent apps.
|
||||
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
use GoliatTools;
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
|
||||
=head2 EXPORT
|
||||
|
||||
Pues no se que poner aqui :)
|
||||
|
||||
=head1 SEE ALSO
|
||||
|
||||
Mention other useful documentation such as the documentation of
|
||||
related modules or operating system documentation (such as man pages
|
||||
in UNIX), or any relevant external documentation such as RFCs or
|
||||
standards.
|
||||
|
||||
If you have a mailing list set up for your module, mention it here.
|
||||
|
||||
If you have a web site set up for your module, mention it here.
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
slerena, E<lt>slerena@Egmail.com<gt>
|
||||
|
||||
=head1 COPYRIGHT AND LICENSE
|
||||
|
||||
Copyright (C) 2005 by Sancho Lerena
|
||||
|
||||
This library is free software; you can redistribute it and/or modify
|
||||
it under the same terms as Perl itself, either Perl version 5.8.4 or,
|
||||
at your option, any later version of Perl 5 you may have available.
|
||||
|
||||
Licenced under GPL
|
||||
|
||||
=cut
|
|
@ -34,7 +34,7 @@ our @ISA = qw(Exporter);
|
|||
|
||||
# version: Defines actual version of Pandora Server for this module only
|
||||
my $pandora_version = "7.0NG.754";
|
||||
my $pandora_build = "210504";
|
||||
my $pandora_build = "210513";
|
||||
our $VERSION = $pandora_version." ".$pandora_build;
|
||||
|
||||
our %EXPORT_TAGS = ( 'all' => [ qw() ] );
|
||||
|
@ -792,7 +792,8 @@ sub transfer_xml {
|
|||
my $file_name;
|
||||
my $file_path;
|
||||
|
||||
if (! -f $xml) {
|
||||
if ($xml =~ /\n/ || ! -f $xml) {
|
||||
# Not a file, it's content.
|
||||
if (! (empty ($name))) {
|
||||
$file_name = $name . "." . sprintf("%d",getCurrentUTimeMilis(). (rand()*10000)) . ".data";
|
||||
}
|
||||
|
|
|
@ -0,0 +1,304 @@
|
|||
package PandoraFMS::WebServer;
|
||||
##########################################################################
|
||||
# Pandora FMS Web Server.
|
||||
# Pandora FMS. the Flexible Monitoring System. http://www.pandorafms.org
|
||||
##########################################################################
|
||||
# Copyright (c) 2007-2021 Artica Soluciones Tecnologicas S.L
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public License
|
||||
# as published by the Free Software Foundation; version 2
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
##########################################################################
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use threads;
|
||||
use threads::shared;
|
||||
use Thread::Semaphore;
|
||||
|
||||
use File::Temp qw(tempfile);
|
||||
use HTML::Entities;
|
||||
use POSIX qw(strftime);
|
||||
|
||||
# Default lib dir for RPM and DEB packages
|
||||
use lib '/usr/lib/perl5';
|
||||
|
||||
use PandoraFMS::Tools;
|
||||
use PandoraFMS::DB;
|
||||
use PandoraFMS::Core;
|
||||
use PandoraFMS::ProducerConsumerServer;
|
||||
|
||||
use PandoraFMS::Goliat::GoliatTools;
|
||||
use PandoraFMS::Goliat::GoliatConfig;
|
||||
|
||||
# Inherits from PandoraFMS::ProducerConsumerServer
|
||||
our @ISA = qw(PandoraFMS::ProducerConsumerServer);
|
||||
|
||||
# Global variables
|
||||
my @TaskQueue :shared;
|
||||
my %PendingTasks :shared;
|
||||
my $Sem :shared;
|
||||
my $TaskSem :shared;
|
||||
|
||||
########################################################################################
|
||||
# Web Server class constructor.
|
||||
########################################################################################
|
||||
sub new ($$;$) {
|
||||
my ($class, $config, $dbh) = @_;
|
||||
|
||||
return undef unless defined ($config->{'webserver'}) and ($config->{'webserver'} == 1);
|
||||
|
||||
# Initialize semaphores and queues
|
||||
@TaskQueue = ();
|
||||
%PendingTasks = ();
|
||||
$Sem = Thread::Semaphore->new;
|
||||
$TaskSem = Thread::Semaphore->new (0);
|
||||
|
||||
# Call the constructor of the parent class
|
||||
my $self = $class->SUPER::new($config, WEBSERVER, \&PandoraFMS::WebServer::data_producer, \&PandoraFMS::WebServer::data_consumer, $dbh);
|
||||
|
||||
bless $self, $class;
|
||||
return $self;
|
||||
}
|
||||
|
||||
###############################################################################
|
||||
# Run.
|
||||
###############################################################################
|
||||
sub run ($) {
|
||||
my $self = shift;
|
||||
my $pa_config = $self->getConfig ();
|
||||
|
||||
print_message ($pa_config, " [*] Starting " . $pa_config->{'rb_product_name'} . " Web Server.", 1);
|
||||
|
||||
# Use Goliat with CURL
|
||||
if ($pa_config->{'web_engine'} eq 'curl') {
|
||||
require PandoraFMS::Goliat::GoliatCURL;
|
||||
PandoraFMS::Goliat::GoliatCURL->import;
|
||||
|
||||
# Check for CURL binary
|
||||
if (system ("curl -V >$DEVNULL 2>&1") >> 8 != 0) {
|
||||
logger ($pa_config, ' [E] CURL binary not found. Install CURL or uncomment the web_engine configuration token to use LWP.', 1);
|
||||
print_message ($pa_config, ' [E] CURL binary not found. Install CURL or uncomment the web_engine configuration token to use LWP.', 1);
|
||||
return undef;
|
||||
}
|
||||
# Check for pandora_exec binary
|
||||
if (system ("\"" . $pa_config->{'plugin_exec'} . "\" 10 echo >$DEVNULL 2>&1") >> 8 != 0) {
|
||||
logger ($pa_config, ' [E] ' . $pa_config->{'plugin_exec'} . ' not found. Please install it or add it to the PATH.', 1);
|
||||
print_message ($pa_config, ' [E] ' . $pa_config->{'plugin_exec'} . ' not found. Please install it or add it to the PATH.', 1);
|
||||
return undef;
|
||||
}
|
||||
}
|
||||
# Use LWP by default
|
||||
else {
|
||||
require PandoraFMS::Goliat::GoliatLWP;
|
||||
PandoraFMS::Goliat::GoliatLWP->import;
|
||||
|
||||
if (! LWP::UserAgent->can('ssl_opts')) {
|
||||
logger($pa_config, "LWP version $LWP::VERSION does not support SSL. Make sure version 6.0 or higher is installed.", 1);
|
||||
print_message ($pa_config, " [W] LWP version $LWP::VERSION does not support SSL. Make sure version 6.0 or higher is installed.", 1);
|
||||
}
|
||||
}
|
||||
|
||||
$self->setNumThreads ($pa_config->{'web_threads'});
|
||||
$self->SUPER::run (\@TaskQueue, \%PendingTasks, $Sem, $TaskSem);
|
||||
}
|
||||
|
||||
###############################################################################
|
||||
# Data producer.
|
||||
###############################################################################
|
||||
sub data_producer ($) {
|
||||
my $self = shift;
|
||||
my ($pa_config, $dbh) = ($self->getConfig (), $self->getDBH ());
|
||||
|
||||
my @tasks;
|
||||
my @rows;
|
||||
|
||||
if (pandora_is_master($pa_config) == 0) {
|
||||
@rows = get_db_rows ($dbh, 'SELECT tagente_modulo.id_agente_modulo, tagente_modulo.flag, tagente_estado.current_interval + tagente_estado.last_execution_try AS time_left, last_execution_try
|
||||
FROM tagente, tagente_modulo, tagente_estado
|
||||
WHERE server_name = ?
|
||||
AND tagente_modulo.id_agente = tagente.id_agente
|
||||
AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo
|
||||
AND tagente.disabled = 0
|
||||
AND tagente_modulo.id_modulo = 7
|
||||
AND tagente_modulo.disabled = 0
|
||||
AND (tagente_modulo.flag = 1 OR ((tagente_estado.last_execution_try + tagente_estado.current_interval) < UNIX_TIMESTAMP()))
|
||||
ORDER BY tagente_modulo.flag DESC, time_left ASC, last_execution_try ASC ', $pa_config->{'servername'});
|
||||
} else {
|
||||
@rows = get_db_rows ($dbh, 'SELECT DISTINCT(tagente_modulo.id_agente_modulo), tagente_modulo.flag, tagente_estado.current_interval + tagente_estado.last_execution_try AS time_left, last_execution_try
|
||||
FROM tagente, tagente_modulo, tagente_estado, tserver
|
||||
WHERE ((server_name = ?) OR (server_name = ANY(SELECT server_name FROM tserver WHERE status = 0 AND server_type = ?)))
|
||||
AND tagente_modulo.id_agente = tagente.id_agente
|
||||
AND tagente.disabled = 0
|
||||
AND tagente_modulo.disabled = 0
|
||||
AND tagente_modulo.id_modulo = 7
|
||||
AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo
|
||||
AND ((tagente_estado.last_execution_try + tagente_estado.current_interval) < UNIX_TIMESTAMP() OR tagente_modulo.flag = 1 )
|
||||
ORDER BY tagente_modulo.flag DESC, time_left ASC, last_execution_try ASC', $pa_config->{'servername'}, WEBSERVER);
|
||||
}
|
||||
|
||||
foreach my $row (@rows) {
|
||||
|
||||
# Reset forced execution flag
|
||||
if ($row->{'flag'} == 1) {
|
||||
db_do ($dbh, 'UPDATE tagente_modulo SET flag = 0 WHERE id_agente_modulo = ?', $row->{'id_agente_modulo'});
|
||||
}
|
||||
|
||||
push (@tasks, $row->{'id_agente_modulo'});
|
||||
}
|
||||
|
||||
return @tasks;
|
||||
}
|
||||
|
||||
###############################################################################
|
||||
# Data consumer.
|
||||
###############################################################################
|
||||
sub data_consumer ($$) {
|
||||
my ($self, $module_id) = @_;
|
||||
my ($pa_config, $dbh) = ($self->getConfig (), $self->getDBH ());
|
||||
our (@task_fails, @task_time, @task_ssec, @task_get_content); # Defined in GoliatLWP.pm and GoliatCURL.
|
||||
|
||||
# Retrieve module data
|
||||
my $module = get_db_single_row ($dbh, 'SELECT * FROM tagente_modulo WHERE id_agente_modulo = ?', $module_id);
|
||||
return unless defined ($module);
|
||||
|
||||
# Retrieve agent data
|
||||
my $agent = get_db_single_row ($dbh, 'SELECT * FROM tagente WHERE id_agente = ?', $module->{'id_agente'});
|
||||
return unless defined $agent;
|
||||
|
||||
# Save Goliat config to a temporary file
|
||||
my ($fh, $temp_file) = tempfile();
|
||||
return unless defined ($fh);
|
||||
|
||||
# Read the Goliat task
|
||||
my $task = safe_output($module->{'plugin_parameter'});
|
||||
|
||||
# Delete any carriage returns
|
||||
$task =~ s/\r//g;
|
||||
|
||||
# Agent and module macros
|
||||
my %macros = (_agent_ => (defined ($agent)) ? $agent->{'alias'} : '',
|
||||
_agentdescription_ => (defined ($agent)) ? $agent->{'comentarios'} : '',
|
||||
_agentstatus_ => (defined ($agent)) ? get_agent_status ($pa_config, $dbh, $agent->{'id_agente'}) : '',
|
||||
_address_ => (defined ($agent)) ? $agent->{'direccion'} : '',
|
||||
_module_ => (defined ($module)) ? $module->{'nombre'} : '',
|
||||
_modulegroup_ => (defined ($module)) ? (get_module_group_name ($dbh, $module->{'id_module_group'}) || '') : '',
|
||||
_moduledescription_ => (defined ($module)) ? $module->{'descripcion'} : '',
|
||||
_modulestatus_ => (defined ($module)) ? get_agentmodule_status($pa_config, $dbh, $module->{'id_agente_modulo'}) : '',
|
||||
_moduletags_ => (defined ($module)) ? pandora_get_module_url_tags ($pa_config, $dbh, $module->{'id_agente_modulo'}) : '',
|
||||
_id_agent_ => (defined ($module)) ? $module->{'id_agente'} : '',
|
||||
_interval_ => (defined ($module) && $module->{'module_interval'} != 0) ? $module->{'module_interval'} : (defined ($agent)) ? $agent->{'intervalo'} : '',
|
||||
_target_ip_ => (defined ($agent)) ? $agent->{'direccion'} : '',
|
||||
_target_port_ => (defined ($module)) ? $module->{'tcp_port'} : '',
|
||||
_policy_ => (defined ($module)) ? enterprise_hook('get_policy_name', [$dbh, $module->{'id_policy_module'}]) : '',
|
||||
_plugin_parameters_ => (defined ($module)) ? $module->{'plugin_parameter'} : '',
|
||||
_email_tag_ => (defined ($module)) ? pandora_get_module_email_tags ($pa_config, $dbh, $module->{'id_agente_modulo'}) : '',
|
||||
_phone_tag_ => (defined ($module)) ? pandora_get_module_phone_tags ($pa_config, $dbh, $module->{'id_agente_modulo'}) : '',
|
||||
_name_tag_ => (defined ($module)) ? pandora_get_module_tags ($pa_config, $dbh, $module->{'id_agente_modulo'}) : '',
|
||||
);
|
||||
$task = subst_alert_macros ($task, \%macros);
|
||||
|
||||
# Goliat has some trouble parsing conf files without the newlines
|
||||
$fh->print ("\n\n" . $task . "\n\n");
|
||||
close ($fh);
|
||||
|
||||
# Global vars needed by Goliat
|
||||
my (%config, @work_list, $check_string);
|
||||
|
||||
# Goliat config defaults
|
||||
$config{'verbosity'} = 1;
|
||||
$config{'slave'} = 0;
|
||||
$config{'port'} = 80;
|
||||
$config{'log_file'} = "$DEVNULL";
|
||||
$config{'log_output'} = 0;
|
||||
$config{'log_http'} = 0;
|
||||
$config{'work_items'} = 0;
|
||||
$config{'config_file'} = $temp_file;
|
||||
$config{'agent'} = safe_output($module->{'plugin_user'});
|
||||
if ($module->{'max_retries'} != 0) {
|
||||
$config{'retries'} = $module->{'max_retries'};
|
||||
}
|
||||
if ($module->{'max_timeout'} != 0) {
|
||||
$config{'timeout'} = $module->{'max_timeout'};
|
||||
} else {
|
||||
$config{'timeout'} = $pa_config->{'web_timeout'};
|
||||
}
|
||||
|
||||
$config{'proxy'} = $module->{'snmp_oid'};
|
||||
$config{'auth_user'} = safe_output($module->{'tcp_send'});
|
||||
$config{'auth_pass'} = safe_output($module->{'tcp_rcv'});
|
||||
$config{'auth_server'} = $module->{'ip_target'};
|
||||
$config{'auth_realm'} = $module->{'snmp_community'};
|
||||
$config{'http_check_type'} = $module->{'tcp_port'};
|
||||
$config{'moduleId'} = $module_id;
|
||||
$config{'dbh'} = $dbh;
|
||||
|
||||
# Pandora FMS variables passed to Goliat.
|
||||
$config{'plugin_exec'} = $pa_config->{'plugin_exec'};
|
||||
|
||||
eval {
|
||||
# Load Goliat config
|
||||
g_load_config(\%config, \@work_list);
|
||||
|
||||
# Run Goliat task
|
||||
g_http_task (\%config, 0, @work_list);
|
||||
};
|
||||
|
||||
if ($@) {
|
||||
pandora_update_module_on_error ($pa_config, $module, $dbh);
|
||||
unlink ($temp_file);
|
||||
return;
|
||||
}
|
||||
|
||||
unlink ($temp_file);
|
||||
|
||||
my $utimestamp = time ();
|
||||
my $timestamp = strftime ("%Y-%m-%d %H:%M:%S", localtime($utimestamp));
|
||||
|
||||
# Get module type
|
||||
my $module_type = get_db_value ($dbh, 'SELECT nombre FROM ttipo_modulo WHERE id_tipo = ?', $module->{'id_tipo_modulo'});
|
||||
|
||||
# Get data from Goliat
|
||||
my $module_data;
|
||||
{
|
||||
no strict 'vars';
|
||||
if ($module_type eq 'web_proc') {
|
||||
$module_data = ($task_fails[0] == 0 && $task_get_content[0] ne "") ? 1 : 0;
|
||||
}
|
||||
elsif ($module_type eq 'web_data') {
|
||||
$module_data = $task_ssec[0];
|
||||
} elsif ($module_type eq 'web_server_status_code_string') {
|
||||
my @resp_lines = split "\r\n", $task_get_content[0];
|
||||
$module_data = $resp_lines[0];
|
||||
} else {
|
||||
$module_data = $task_get_content[0];
|
||||
}
|
||||
}
|
||||
|
||||
my %data = ("data" => $module_data);
|
||||
pandora_process_module ($pa_config, \%data, undef, $module, $module_type, $timestamp, $utimestamp, $self->getServerID (), $dbh);
|
||||
|
||||
my $agent_os_version = get_db_value ($dbh, 'SELECT os_version FROM tagente WHERE id_agente = ?', $module->{'id_agente'});
|
||||
|
||||
if (! defined ($agent_os_version) || $agent_os_version eq '') {
|
||||
$agent_os_version = $pa_config->{'servername'}.'_Web';
|
||||
}
|
||||
|
||||
# Todo: Implement here
|
||||
# 1. Detect if exists a module with the same name, but with type generic_string.
|
||||
# 2. If not, create the module, get the id's
|
||||
# 3. Insert data coming from $task_get_string in that module
|
||||
|
||||
pandora_update_agent ($pa_config, $timestamp, $module->{'id_agente'}, undef, undef, -1, $dbh);
|
||||
}
|
||||
|
||||
1;
|
||||
__END__
|
|
@ -3,7 +3,7 @@
|
|||
#
|
||||
%define name pandorafms_server
|
||||
%define version 7.0NG.754
|
||||
%define release 210504
|
||||
%define release 210513
|
||||
|
||||
Summary: Pandora FMS Server
|
||||
Name: %{name}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#
|
||||
%define name pandorafms_server
|
||||
%define version 7.0NG.754
|
||||
%define release 210504
|
||||
%define release 210513
|
||||
|
||||
Summary: Pandora FMS Server
|
||||
Name: %{name}
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
# **********************************************************************
|
||||
|
||||
PI_VERSION="7.0NG.754"
|
||||
PI_BUILD="210504"
|
||||
PI_BUILD="210513"
|
||||
|
||||
MODE=$1
|
||||
if [ $# -gt 1 ]; then
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue