Backup upload
This commit is contained in:
parent
8882124487
commit
311b259684
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -1,66 +1,67 @@
|
|||
<?php
|
||||
/**
|
||||
* Wizard for SNMP / WMI discover.
|
||||
*
|
||||
* @category Agent Wizard
|
||||
* @package Pandora FMS
|
||||
* @subpackage Opensource
|
||||
* @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.
|
||||
* ============================================================================
|
||||
*/
|
||||
|
||||
// Pandora FMS - http://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2011 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; 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;
|
||||
|
||||
check_login();
|
||||
|
||||
$wizard_section = get_parameter('wizard_section', 'snmp_interfaces_explorer');
|
||||
$idAgent = (int) get_parameter('id_agente', 0);
|
||||
$ipAgent = db_get_value('direccion', 'tagente', 'id_agente', $idAgent);
|
||||
|
||||
switch ($wizard_section) {
|
||||
case 'snmp_interfaces_explorer':
|
||||
$snmp_interfaces_explorer_style = 'font-weight: bold;';
|
||||
$wmi_explorer_style = '';
|
||||
break;
|
||||
|
||||
case 'wmi_explorer':
|
||||
$snmp_interfaces_explorer_style = '';
|
||||
$wmi_explorer_style = 'font-weight: bold;';
|
||||
break;
|
||||
|
||||
case 'snmp_explorer':
|
||||
$snmp_interfaces_explorer_style = '';
|
||||
$wmi_explorer_style = 'font-weight: bold;';
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
echo "<div style='text-align: right; width: 98%; padding-top: 10px; padding-bottom: 10px;'>";
|
||||
echo "<a href='index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=agent_wizard&wizard_section=snmp_interfaces_explorer&id_agente=$idAgent' style='" . $snmp_interfaces_explorer_style . "'>" . __('SNMP Interfaces explorer') . "</a>";
|
||||
echo " | ";
|
||||
echo "<a href='index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=agent_wizard&wizard_section=wmi_explorer&id_agente=$idAgent' style='" . $wmi_explorer_style . "'>" . __('WMI explorer') . "</a>";
|
||||
echo "</div>";
|
||||
*/
|
||||
|
||||
require 'agent_wizard.'.$wizard_section.'.php';
|
||||
|
||||
?>
|
||||
<script language="javascript" type="text/javascript">
|
||||
|
||||
function satellite_remote_warn(id_satellite, remote)
|
||||
{
|
||||
if(!remote)
|
||||
{
|
||||
$('#server_to_exec option[value='+id_satellite+']').prop('disabled', true);
|
||||
$('#satellite_remote_tip').removeAttr("style").show();
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#satellite_remote_tip').removeAttr("style").hide();
|
||||
// Require needed class.
|
||||
require_once $config['homedir'].'/include/class/AgentWizard.class.php';
|
||||
// This page.
|
||||
$ajaxPage = 'godmode/agentes/agent_wizard';
|
||||
$pageName = '[AgentWizard]';
|
||||
// Control call flow.
|
||||
try {
|
||||
// User access and validation is being processed on class constructor.
|
||||
$obj = new AgentWizard($ajaxPage);
|
||||
} catch (Exception $e) {
|
||||
if (is_ajax()) {
|
||||
echo json_encode(['error' => $pageName.$e->getMessage() ]);
|
||||
exit;
|
||||
} else {
|
||||
echo $pageName.$e->getMessage();
|
||||
}
|
||||
|
||||
// Stop this execution, but continue 'globally'.
|
||||
return;
|
||||
}
|
||||
|
||||
</script>
|
||||
// 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();
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,743 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Extension to manage a list of gateways and the node address where they should
|
||||
* point to.
|
||||
*
|
||||
* @category SNMP interfaces.
|
||||
* @package Pandora FMS
|
||||
* @subpackage Community
|
||||
* @version 1.0.0
|
||||
* @license See below
|
||||
*
|
||||
* ______ ___ _______ _______ ________
|
||||
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
|
||||
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
|
||||
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
|
||||
*
|
||||
* ============================================================================
|
||||
* Copyright (c) 2005-2019 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.
|
||||
* ============================================================================
|
||||
*/
|
||||
|
||||
global $config;
|
||||
require_once $config['homedir'].'/include/functions_agents.php';
|
||||
require_once 'include/functions_modules.php';
|
||||
require_once 'include/functions_alerts.php';
|
||||
require_once 'include/functions_reporting.php';
|
||||
require_once 'include/graphs/functions_utils.php';
|
||||
|
||||
|
||||
$idAgent = (int) get_parameter('id_agente', 0);
|
||||
$ipAgent = db_get_value('direccion', 'tagente', 'id_agente', $idAgent);
|
||||
|
||||
check_login();
|
||||
$ip_target = (string) get_parameter('ip_target', $ipAgent);
|
||||
$use_agent = get_parameter('use_agent');
|
||||
$snmp_community = (string) get_parameter('snmp_community', 'public');
|
||||
$server_to_exec = get_parameter('server_to_exec', 0);
|
||||
$snmp_version = get_parameter('snmp_version', '1');
|
||||
$snmp3_auth_user = io_safe_output(get_parameter('snmp3_auth_user'));
|
||||
$snmp3_security_level = get_parameter('snmp3_security_level');
|
||||
$snmp3_auth_method = get_parameter('snmp3_auth_method');
|
||||
$snmp3_auth_pass = io_safe_output(get_parameter('snmp3_auth_pass'));
|
||||
$snmp3_privacy_method = get_parameter('snmp3_privacy_method');
|
||||
$snmp3_privacy_pass = io_safe_output(get_parameter('snmp3_privacy_pass'));
|
||||
$tcp_port = (string) get_parameter('tcp_port');
|
||||
|
||||
// See if id_agente is set (either POST or GET, otherwise -1.
|
||||
$id_agent = $idAgent;
|
||||
|
||||
// Get passed variables.
|
||||
$snmpwalk = (int) get_parameter('snmpwalk', 0);
|
||||
$create_modules = (int) get_parameter('create_modules', 0);
|
||||
|
||||
$interfaces = [];
|
||||
$interfaces_ip = [];
|
||||
|
||||
if ($snmpwalk) {
|
||||
// OID Used is for SNMP MIB-2 Interfaces.
|
||||
$snmpis = get_snmpwalk(
|
||||
$ip_target,
|
||||
$snmp_version,
|
||||
$snmp_community,
|
||||
$snmp3_auth_user,
|
||||
$snmp3_security_level,
|
||||
$snmp3_auth_method,
|
||||
$snmp3_auth_pass,
|
||||
$snmp3_privacy_method,
|
||||
$snmp3_privacy_pass,
|
||||
0,
|
||||
'.1.3.6.1.2.1.2',
|
||||
$tcp_port,
|
||||
$server_to_exec
|
||||
);
|
||||
// IfXTable is also used.
|
||||
$ifxitems = get_snmpwalk(
|
||||
$ip_target,
|
||||
$snmp_version,
|
||||
$snmp_community,
|
||||
$snmp3_auth_user,
|
||||
$snmp3_security_level,
|
||||
$snmp3_auth_method,
|
||||
$snmp3_auth_pass,
|
||||
$snmp3_privacy_method,
|
||||
$snmp3_privacy_pass,
|
||||
0,
|
||||
'.1.3.6.1.2.1.31.1.1',
|
||||
$tcp_port,
|
||||
$server_to_exec
|
||||
);
|
||||
|
||||
// Get the interfaces IPV4/IPV6.
|
||||
$snmp_int_ip = get_snmpwalk(
|
||||
$ip_target,
|
||||
$snmp_version,
|
||||
$snmp_community,
|
||||
$snmp3_auth_user,
|
||||
$snmp3_security_level,
|
||||
$snmp3_auth_method,
|
||||
$snmp3_auth_pass,
|
||||
$snmp3_privacy_method,
|
||||
$snmp3_privacy_pass,
|
||||
0,
|
||||
'.1.3.6.1.2.1.4.34.1.3',
|
||||
$tcp_port,
|
||||
$server_to_exec
|
||||
);
|
||||
|
||||
// Build a [<interface id>] => [<interface ip>] array.
|
||||
if (!empty($snmp_int_ip)) {
|
||||
foreach ($snmp_int_ip as $key => $value) {
|
||||
// The key is something like IP-MIB::ipAddressIfIndex.ipv4."<ip>".
|
||||
// or IP-MIB::ipAddressIfIndex.ipv6."<ip>".
|
||||
// The value is something like INTEGER: <interface id>.
|
||||
$data = explode(': ', $value);
|
||||
$interface_id = !empty($data) && isset($data[1]) ? $data[1] : false;
|
||||
|
||||
if (preg_match('/^.+"(.+)"$/', $key, $matches) && isset($matches[1])) {
|
||||
$interface_ip = $matches[1];
|
||||
}
|
||||
|
||||
// Get the first ip.
|
||||
if ($interface_id !== false && !empty($interface_ip) && !isset($interfaces_ip[$interface_id])) {
|
||||
$interfaces_ip[$interface_id] = $interface_ip;
|
||||
}
|
||||
}
|
||||
|
||||
unset($snmp_int_ip);
|
||||
}
|
||||
|
||||
$snmpis = array_merge((($snmpis === false) ? [] : $snmpis), (($ifxitems === false) ? [] : $ifxitems));
|
||||
|
||||
$interfaces = [];
|
||||
|
||||
// We get here only the interface part of the MIB, not full mib.
|
||||
foreach ($snmpis as $key => $snmp) {
|
||||
$data = explode(': ', $snmp, 2);
|
||||
$keydata = explode('::', $key);
|
||||
$keydata2 = explode('.', $keydata[1]);
|
||||
|
||||
// Avoid results without index and interfaces without name.
|
||||
if (!isset($keydata2[1]) || !isset($data[1])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (array_key_exists(1, $data)) {
|
||||
$interfaces[$keydata2[1]][$keydata2[0]]['type'] = $data[0];
|
||||
$interfaces[$keydata2[1]][$keydata2[0]]['value'] = $data[1];
|
||||
} else {
|
||||
$interfaces[$keydata2[1]][$keydata2[0]]['type'] = '';
|
||||
$interfaces[$keydata2[1]][$keydata2[0]]['value'] = $data[0];
|
||||
}
|
||||
|
||||
$interfaces[$keydata2[1]][$keydata2[0]]['oid'] = $key;
|
||||
$interfaces[$keydata2[1]][$keydata2[0]]['checked'] = 0;
|
||||
}
|
||||
|
||||
unset($interfaces[0]);
|
||||
}
|
||||
|
||||
if ($create_modules) {
|
||||
$id_snmp_serialize = get_parameter_post('id_snmp_serialize');
|
||||
$interfaces = unserialize_in_temp($id_snmp_serialize);
|
||||
|
||||
$id_snmp_int_ip_serialize = get_parameter_post('id_snmp_int_ip_serialize');
|
||||
$interfaces_ip = unserialize_in_temp($id_snmp_int_ip_serialize);
|
||||
|
||||
if (!$interfaces) {
|
||||
$interfaces = [];
|
||||
}
|
||||
|
||||
if (!$interfaces_ip) {
|
||||
$interfaces_ip = [];
|
||||
}
|
||||
|
||||
$values = [];
|
||||
|
||||
if ($tcp_port != '') {
|
||||
$values['tcp_port'] = $tcp_port;
|
||||
}
|
||||
|
||||
$values['snmp_community'] = $snmp_community;
|
||||
if ($use_agent) {
|
||||
$values['ip_target'] = 'auto';
|
||||
} else {
|
||||
$values['ip_target'] = $ip_target;
|
||||
}
|
||||
|
||||
$values['tcp_send'] = $snmp_version;
|
||||
|
||||
if ($snmp_version == '3') {
|
||||
$values['plugin_user'] = $snmp3_auth_user;
|
||||
$values['plugin_pass'] = $snmp3_auth_pass;
|
||||
$values['plugin_parameter'] = $snmp3_auth_method;
|
||||
$values['custom_string_1'] = $snmp3_privacy_method;
|
||||
$values['custom_string_2'] = $snmp3_privacy_pass;
|
||||
$values['custom_string_3'] = $snmp3_security_level;
|
||||
}
|
||||
|
||||
$oids = [];
|
||||
foreach ($interfaces as $key => $interface) {
|
||||
foreach ($interface as $key2 => $module) {
|
||||
$oid = get_parameter($key.'-'.$key2, '');
|
||||
if ($oid != '') {
|
||||
$interfaces[$key][$key2]['checked'] = 1;
|
||||
$oids[$key][] = $interfaces[$key][$key2]['oid'];
|
||||
} else {
|
||||
$interfaces[$key][$key2]['checked'] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$modules = get_parameter('module', []);
|
||||
$id_snmp = get_parameter('id_snmp');
|
||||
|
||||
if ($id_snmp == false) {
|
||||
ui_print_error_message(__('No modules selected'));
|
||||
$id_snmp = [];
|
||||
}
|
||||
|
||||
if (agents_get_name($id_agent) == false) {
|
||||
ui_print_error_message(__('No agent selected or the agent does not exist'));
|
||||
$id_snmp = [];
|
||||
}
|
||||
|
||||
$result = false;
|
||||
|
||||
$errors = [];
|
||||
$done = 0;
|
||||
|
||||
foreach ($id_snmp as $id) {
|
||||
$ifname = '';
|
||||
$ifPhysAddress = '';
|
||||
|
||||
if (isset($interfaces[$id]['ifName']) && $interfaces[$id]['ifName']['value'] != '') {
|
||||
$ifname = $interfaces[$id]['ifName']['value'];
|
||||
} else if (isset($interfaces[$id]['ifDescr']) && $interfaces[$id]['ifDescr']['value'] != '') {
|
||||
$ifname = $interfaces[$id]['ifDescr']['value'];
|
||||
}
|
||||
|
||||
if (isset($interfaces[$id]['ifPhysAddress']) && $interfaces[$id]['ifPhysAddress']['value'] != '') {
|
||||
$ifPhysAddress = $interfaces[$id]['ifPhysAddress']['value'];
|
||||
$ifPhysAddress = strtoupper($ifPhysAddress);
|
||||
}
|
||||
|
||||
foreach ($modules as $module) {
|
||||
$oid_array = explode('.', $module);
|
||||
$oid_array[(count($oid_array) - 1)] = $id;
|
||||
$oid = implode('.', $oid_array);
|
||||
|
||||
// Get the name.
|
||||
$name_array = explode('::', $oid_array[0]);
|
||||
$name = $ifname.'_'.$name_array[1];
|
||||
|
||||
// If you select "show all modules" and the module is not from the interface.
|
||||
if (!array_key_exists($name_array[1], $interfaces[$id])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Clean the name.
|
||||
$name = str_replace('"', '', $name);
|
||||
|
||||
// Proc moduletypes.
|
||||
if (preg_match('/Status/', $name_array[1])) {
|
||||
$module_type = 18;
|
||||
} else if (preg_match('/Present/', $name_array[1])) {
|
||||
$module_type = 18;
|
||||
} else if (preg_match('/PromiscuousMode/', $name_array[1])) {
|
||||
$module_type = 18;
|
||||
} else if (preg_match('/Alias/', $name_array[1])) {
|
||||
// String moduletypes.
|
||||
$module_type = 17;
|
||||
} else if (preg_match('/Address/', $name_array[1])) {
|
||||
$module_type = 17;
|
||||
} else if (preg_match('/Name/', $name_array[1])) {
|
||||
$module_type = 17;
|
||||
} else if (preg_match('/Specific/', $name_array[1])) {
|
||||
$module_type = 17;
|
||||
} else if (preg_match('/Descr/', $name_array[1])) {
|
||||
$module_type = 17;
|
||||
} else if (preg_match('/s$/', $name_array[1])) {
|
||||
// Specific counters (ends in s).
|
||||
$module_type = 16;
|
||||
} else {
|
||||
// Otherwise, numeric.
|
||||
$module_type = 15;
|
||||
}
|
||||
|
||||
$values['unit'] = '';
|
||||
if (preg_match('/Octets/', $name_array[1])) {
|
||||
$values['unit'] = 'Bytes';
|
||||
}
|
||||
|
||||
$module_server = 2;
|
||||
|
||||
if ($server_to_exec != 0) {
|
||||
$sql = sprintf('SELECT server_type, ip_address FROM tserver WHERE id_server = %d', $server_to_exec);
|
||||
$row = db_get_row_sql($sql);
|
||||
|
||||
if ($row['server_type'] == 13) {
|
||||
if (preg_match('/ifPhysAddress/', $name_array[1])) {
|
||||
$module_type = 3;
|
||||
} else if (preg_match('/ifSpecific/', $name_array[1])) {
|
||||
$module_type = 3;
|
||||
} else if (preg_match('/ifType/', $name_array[1])) {
|
||||
$module_type = 1;
|
||||
} else if (preg_match('/ifSpeed/', $name_array[1])) {
|
||||
$module_type = 1;
|
||||
} else if (preg_match('/ifPromiscuousMode/', $name_array[1])) {
|
||||
$module_type = 2;
|
||||
} else if (preg_match('/ifOutQLen/', $name_array[1])) {
|
||||
$module_type = 1;
|
||||
} else if (preg_match('/ifName/', $name_array[1])) {
|
||||
$module_type = 3;
|
||||
} else if (preg_match('/ifMtu/', $name_array[1])) {
|
||||
$module_type = 1;
|
||||
} else if (preg_match('/ifLinkUpDownTrapEnable/', $name_array[1])) {
|
||||
$module_type = 1;
|
||||
} else if (preg_match('/ifLastChange/', $name_array[1])) {
|
||||
$module_type = 1;
|
||||
} else if (preg_match('/ifIndex/', $name_array[1])) {
|
||||
$module_type = 1;
|
||||
} else if (preg_match('/ifDescr/', $name_array[1])) {
|
||||
$module_type = 3;
|
||||
} else if (preg_match('/ifCounterDiscontinuityTime/', $name_array[1])) {
|
||||
$module_type = 1;
|
||||
} else if (preg_match('/ifConnectorPresent/', $name_array[1])) {
|
||||
$module_type = 2;
|
||||
} else if (preg_match('/ifAdminStatus/', $name_array[1])) {
|
||||
$module_type = 2;
|
||||
} else if (preg_match('/ifOperStatus/', $name_array[1])) {
|
||||
$module_type = 2;
|
||||
} else {
|
||||
$module_type = 4;
|
||||
}
|
||||
|
||||
$module_server = 1;
|
||||
|
||||
$output_oid = '';
|
||||
|
||||
exec('snmptranslate -On '.$oid, $output_oid, $rc);
|
||||
|
||||
$conf_oid = $output_oid[0];
|
||||
$oid = $conf_oid;
|
||||
}
|
||||
}
|
||||
|
||||
$values['id_tipo_modulo'] = $module_type;
|
||||
|
||||
if (!empty($ifPhysAddress) && isset($interfaces_ip[$id])) {
|
||||
$values['descripcion'] = io_safe_input('(IP: '.$interfaces_ip[$id].' - MAC: '.$ifPhysAddress.' - '.$name.') '.$interfaces[$id]['ifDescr']['value']);
|
||||
} else if (!empty($ifPhysAddress)) {
|
||||
$values['descripcion'] = io_safe_input('(MAC: '.$ifPhysAddress.' - '.$name.') '.$interfaces[$id]['ifDescr']['value']);
|
||||
} else if (isset($interfaces_ip[$id])) {
|
||||
$values['descripcion'] = io_safe_input('(IP: '.$interfaces_ip[$id].' - '.$name.') '.$interfaces[$id]['ifDescr']['value']);
|
||||
} else {
|
||||
$values['descripcion'] = io_safe_input('('.$name.') '.$interfaces[$id]['ifDescr']['value']);
|
||||
}
|
||||
|
||||
$values['snmp_oid'] = $oid;
|
||||
$values['id_modulo'] = $module_server;
|
||||
|
||||
$result = modules_create_agent_module($id_agent, io_safe_input($name), $values);
|
||||
|
||||
if (is_error($result)) {
|
||||
if (!isset($errors[$result])) {
|
||||
$errors[$result] = 0;
|
||||
}
|
||||
|
||||
$errors[$result]++;
|
||||
} else {
|
||||
if ($server_to_exec != 0) {
|
||||
$sql = sprintf('SELECT server_type FROM tserver WHERE id_server = %d', $server_to_exec);
|
||||
$row = db_get_row_sql($sql);
|
||||
|
||||
if ($row['server_type'] == 13) {
|
||||
$module_type_name = db_get_value_filter('nombre', 'ttipo_modulo', ['id_tipo' => $values['id_tipo_modulo']]);
|
||||
|
||||
$new_module_configuration_data = "module_begin\nmodule_name ".io_safe_input($name)."\nmodule_description ".io_safe_output($values['descripcion'])."\nmodule_type ".$module_type_name."\nmodule_snmp\nmodule_version ".$snmp_version."\nmodule_oid ".$conf_oid."\nmodule_community ".$values['snmp_community'];
|
||||
|
||||
if ($snmp_version == '3') {
|
||||
$new_module_configuration_data .= "\nmodule_secname ".$snmp3_auth_user;
|
||||
$new_module_configuration_data .= "\nmodule_seclevel ".$snmp3_security_level;
|
||||
|
||||
if ($snmp3_security_level == 'authNoPriv' || $snmp3_security_level == 'authPriv') {
|
||||
$new_module_configuration_data .= "\nmodule_authpass ".$snmp3_auth_pass;
|
||||
$new_module_configuration_data .= "\nmodule_authproto ".$snmp3_auth_method;
|
||||
}
|
||||
|
||||
if ($snmp3_security_level == 'authPriv') {
|
||||
$new_module_configuration_data .= "\nmodule_privproto ".$snmp3_privacy_method;
|
||||
$new_module_configuration_data .= "\nmodule_privpass ".$snmp3_privacy_pass;
|
||||
}
|
||||
}
|
||||
|
||||
$new_module_configuration_data .= "\nmodule_end";
|
||||
|
||||
config_agents_add_module_in_conf($id_agent, $new_module_configuration_data);
|
||||
}
|
||||
}
|
||||
|
||||
$done++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($done > 0) {
|
||||
ui_print_success_message(
|
||||
__('Successfully modules created').' ('.$done.')'
|
||||
);
|
||||
}
|
||||
|
||||
if (!empty($errors)) {
|
||||
$msg = __('Could not be created').':';
|
||||
|
||||
|
||||
foreach ($errors as $code => $number) {
|
||||
switch ($code) {
|
||||
case ERR_EXIST:
|
||||
$msg .= '<br>'.__('Another module already exists with the same name').' ('.$number.')';
|
||||
break;
|
||||
|
||||
case ERR_INCOMPLETE:
|
||||
$msg .= '<br>'.__('Some required fields are missed').': ('.__('name').') ('.$number.')';
|
||||
break;
|
||||
|
||||
case ERR_DB:
|
||||
case ERR_GENERIC:
|
||||
default:
|
||||
$msg .= '<br>'.__('Processing error').' ('.$number.')';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ui_print_error_message($msg);
|
||||
}
|
||||
}
|
||||
|
||||
// Create the interface list for the interface.
|
||||
$interfaces_list = [];
|
||||
foreach ($interfaces as $interface) {
|
||||
// Get the interface name, removing " " characters and avoid "blank" interfaces.
|
||||
if (isset($interface['ifDescr']) && $interface['ifDescr']['value'] != '') {
|
||||
$ifname = $interface['ifDescr']['value'];
|
||||
} else if (isset($interface['ifName']) && $interface['ifName']['value'] != '') {
|
||||
$ifname = $interface['ifName']['value'];
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
|
||||
$interfaces_list[$interface['ifIndex']['value']] = str_replace('"', '', $ifname);
|
||||
}
|
||||
|
||||
echo '<span id ="none_text" style="display: none;">'.__('None').'</span>';
|
||||
echo "<form method='post' id='walk_form' action='index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=agent_wizard&wizard_section=snmp_interfaces_explorer&id_agente=".$id_agent."'>";
|
||||
|
||||
$table->width = '100%';
|
||||
$table->cellpadding = 0;
|
||||
$table->cellspacing = 0;
|
||||
$table->class = 'databox filters';
|
||||
|
||||
$table->data[0][0] = '<b>'.__('Target IP').'</b>';
|
||||
$table->data[0][1] = html_print_input_text('ip_target', $ip_target, '', 15, 60, true);
|
||||
|
||||
$table->data[0][2] = '<b>'.__('Port').'</b>';
|
||||
$table->data[0][3] = html_print_input_text('tcp_port', $tcp_port, '', 5, 20, true);
|
||||
|
||||
$table->data[1][0] = '<b>'.__('Use agent ip').'</b>';
|
||||
$table->data[1][1] = html_print_checkbox('use_agent', 1, $use_agent, true);
|
||||
|
||||
$servers_to_exec = [];
|
||||
$servers_to_exec[0] = __('Local console');
|
||||
if (enterprise_installed()) {
|
||||
enterprise_include_once('include/functions_satellite.php');
|
||||
|
||||
$rows = get_proxy_servers();
|
||||
|
||||
// Check if satellite server has remote configuration enabled.
|
||||
$satellite_remote = config_agents_has_remote_configuration($id_agent);
|
||||
|
||||
foreach ($rows as $row) {
|
||||
if ($row['server_type'] != 13) {
|
||||
$s_type = ' (Standard)';
|
||||
} else {
|
||||
$id_satellite = $row['id_server'];
|
||||
$s_type = ' (Satellite)';
|
||||
}
|
||||
|
||||
$servers_to_exec[$row['id_server']] = $row['name'].$s_type;
|
||||
}
|
||||
}
|
||||
|
||||
$table->data[1][2] = '<b>'.__('Server to execute command').'</b>'.ui_print_help_icon('agent_snmp_explorer_tab', true);
|
||||
$table->data[1][2] .= '<span id=satellite_remote_tip>'.ui_print_help_tip(__('In order to use remote executions you need to enable remote execution in satellite server'), true, 'images/tip_help.png', false, 'display:').'</span>';
|
||||
$table->data[1][4] = html_print_select(
|
||||
$servers_to_exec,
|
||||
'server_to_exec',
|
||||
$server_to_exec,
|
||||
'satellite_remote_warn('.$id_satellite.','.$satellite_remote.')',
|
||||
'',
|
||||
'',
|
||||
true
|
||||
);
|
||||
|
||||
$snmp_versions['1'] = 'v. 1';
|
||||
$snmp_versions['2'] = 'v. 2';
|
||||
$snmp_versions['2c'] = 'v. 2c';
|
||||
$snmp_versions['3'] = 'v. 3';
|
||||
|
||||
$table->data[2][0] = '<b>'.__('SNMP community').'</b>';
|
||||
$table->data[2][1] = html_print_input_text('snmp_community', $snmp_community, '', 15, 60, true);
|
||||
|
||||
$table->data[2][2] = '<b>'.__('SNMP version').'</b>';
|
||||
$table->data[2][3] = html_print_select($snmp_versions, 'snmp_version', $snmp_version, '', '', '', true, false, false, '');
|
||||
|
||||
$table->data[2][3] .= '<div id="spinner_modules" style="float: left; display: none;">'.html_print_image('images/spinner.gif', true).'</div>';
|
||||
html_print_input_hidden('snmpwalk', 1);
|
||||
|
||||
html_print_table($table);
|
||||
|
||||
unset($table);
|
||||
|
||||
// SNMP3 OPTIONS.
|
||||
$table->width = '100%';
|
||||
|
||||
$table->data[2][1] = '<b>'.__('Auth user').'</b>';
|
||||
$table->data[2][2] = html_print_input_text('snmp3_auth_user', $snmp3_auth_user, '', 15, 60, true);
|
||||
$table->data[2][3] = '<b>'.__('Auth password').'</b>';
|
||||
$table->data[2][4] = html_print_input_password('snmp3_auth_pass', $snmp3_auth_pass, '', 15, 60, true);
|
||||
$table->data[2][4] .= html_print_input_hidden_extended('active_snmp_v3', 0, 'active_snmp_v3_awsie', true);
|
||||
|
||||
$table->data[5][0] = '<b>'.__('Privacy method').'</b>';
|
||||
$table->data[5][1] = html_print_select(['DES' => __('DES'), 'AES' => __('AES')], 'snmp3_privacy_method', $snmp3_privacy_method, '', '', '', true);
|
||||
$table->data[5][2] = '<b>'.__('privacy pass').'</b>';
|
||||
$table->data[5][3] = html_print_input_password('snmp3_privacy_pass', $snmp3_privacy_pass, '', 15, 60, true);
|
||||
|
||||
$table->data[6][0] = '<b>'.__('Auth method').'</b>';
|
||||
$table->data[6][1] = html_print_select(['MD5' => __('MD5'), 'SHA' => __('SHA')], 'snmp3_auth_method', $snmp3_auth_method, '', '', '', true);
|
||||
$table->data[6][2] = '<b>'.__('Security level').'</b>';
|
||||
$table->data[6][3] = html_print_select(
|
||||
[
|
||||
'noAuthNoPriv' => __('Not auth and not privacy method'),
|
||||
'authNoPriv' => __('Auth and not privacy method'),
|
||||
'authPriv' => __('Auth and privacy method'),
|
||||
],
|
||||
'snmp3_security_level',
|
||||
$snmp3_security_level,
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
true
|
||||
);
|
||||
|
||||
if ($snmp_version == 3) {
|
||||
echo '<div id="snmp3_options">';
|
||||
} else {
|
||||
echo '<div id="snmp3_options" style="display: none;">';
|
||||
}
|
||||
|
||||
html_print_table($table);
|
||||
echo '</div>';
|
||||
|
||||
echo "<div style='text-align:right; width:".$table->width."'>";
|
||||
echo '<span id="oid_loading" class="invisible">'.html_print_image('images/spinner.gif', true).'</span>';
|
||||
html_print_submit_button(__('SNMP Walk'), 'snmp_walk', false, ['class' => 'sub next']);
|
||||
echo '</div>';
|
||||
|
||||
if ($snmpwalk && !$snmpis) {
|
||||
ui_print_error_message(__('Unable to do SNMP walk'));
|
||||
}
|
||||
|
||||
unset($table);
|
||||
|
||||
echo '</form>';
|
||||
|
||||
if (!empty($interfaces_list)) {
|
||||
echo '<span id ="none_text" style="display: none;">'.__('None').'</span>';
|
||||
echo "<form method='post' action='index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=agent_wizard&wizard_section=snmp_interfaces_explorer&id_agente=".$id_agent."'>";
|
||||
echo '<span id="form_interfaces">';
|
||||
|
||||
$id_snmp_serialize = serialize_in_temp($interfaces, $config['id_user'].'_snmp');
|
||||
html_print_input_hidden('id_snmp_serialize', $id_snmp_serialize);
|
||||
|
||||
$id_snmp_int_ip_serialize = serialize_in_temp($interfaces_ip, $config['id_user'].'_snmp_int_ip');
|
||||
html_print_input_hidden('id_snmp_int_ip_serialize', $id_snmp_int_ip_serialize);
|
||||
|
||||
html_print_input_hidden('create_modules', 1);
|
||||
html_print_input_hidden('ip_target', $ip_target);
|
||||
html_print_input_hidden('use_agent', $use_agent);
|
||||
html_print_input_hidden('tcp_port', $tcp_port);
|
||||
html_print_input_hidden('snmp_community', $snmp_community);
|
||||
html_print_input_hidden('snmp_version', $snmp_version);
|
||||
html_print_input_hidden('snmp3_auth_user', $snmp3_auth_user);
|
||||
html_print_input_hidden('snmp3_auth_pass', $snmp3_auth_pass);
|
||||
html_print_input_hidden('snmp3_auth_method', $snmp3_auth_method);
|
||||
html_print_input_hidden('snmp3_privacy_method', $snmp3_privacy_method);
|
||||
html_print_input_hidden('snmp3_privacy_pass', $snmp3_privacy_pass);
|
||||
html_print_input_hidden('snmp3_security_level', $snmp3_security_level);
|
||||
html_print_input_hidden('server_to_exec', $server_to_exec);
|
||||
|
||||
$table->width = '100%';
|
||||
|
||||
// Agent selector.
|
||||
$table->data[0][0] = '<b>'.__('Interfaces').'</b>';
|
||||
$table->data[0][1] = '';
|
||||
$table->data[0][2] = '<b>'.__('Modules').'</b>';
|
||||
|
||||
$table->data[1][0] = html_print_select($interfaces_list, 'id_snmp[]', 0, false, '', '', true, true, true, '', false, 'width:500px; overflow: auto;');
|
||||
|
||||
$table->data[1][1] = __('When selecting interfaces');
|
||||
$table->data[1][1] .= '<br>';
|
||||
$table->data[1][1] .= html_print_select(
|
||||
[
|
||||
1 => __('Show common modules'),
|
||||
0 => __('Show all modules'),
|
||||
],
|
||||
'modules_selection_mode',
|
||||
1,
|
||||
false,
|
||||
'',
|
||||
'',
|
||||
true,
|
||||
false,
|
||||
false
|
||||
);
|
||||
|
||||
$table->data[1][2] = html_print_select([], 'module[]', 0, false, '', 0, true, true, true, '', false, 'width:200px;');
|
||||
$table->data[1][2] .= html_print_input_hidden('agent', $id_agent, true);
|
||||
|
||||
html_print_table($table);
|
||||
|
||||
echo "<div style='text-align:right; width:".$table->width."'>";
|
||||
html_print_submit_button(__('Create modules'), '', false, ['class' => 'sub add']);
|
||||
echo '</div>';
|
||||
unset($table);
|
||||
|
||||
echo '</span>';
|
||||
echo '</form>';
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
ui_require_jquery_file('pandora.controls');
|
||||
ui_require_jquery_file('ajaxqueue');
|
||||
ui_require_jquery_file('bgiframe');
|
||||
?>
|
||||
<script language="javascript" type="text/javascript">
|
||||
/* <![CDATA[ */
|
||||
|
||||
$(document).ready (function () {
|
||||
var inputActive = true;
|
||||
|
||||
$('#server_to_exec option').trigger('change');
|
||||
|
||||
$(document).data('text_for_module', $("#none_text").html());
|
||||
|
||||
$("#id_snmp").change(snmp_changed_by_multiple_snmp);
|
||||
|
||||
$("#snmp_version").change(function () {
|
||||
if (this.value == "3") {
|
||||
$("#snmp3_options").css("display", "");
|
||||
}
|
||||
else {
|
||||
$("#snmp3_options").css("display", "none");
|
||||
}
|
||||
});
|
||||
|
||||
$("#walk_form").submit(function() {
|
||||
$("#submit-snmp_walk").disable ();
|
||||
$("#oid_loading").show ();
|
||||
$("#no_snmp").hide ();
|
||||
$("#form_interfaces").hide ();
|
||||
});
|
||||
|
||||
// When select interfaces changes
|
||||
$("#modules_selection_mode").change (function() {
|
||||
$("#id_snmp").trigger('change');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
function snmp_changed_by_multiple_snmp (event, id_snmp, selected) {
|
||||
var idSNMP = Array();
|
||||
var get_common_modules = $("#modules_selection_mode option:selected").val();
|
||||
|
||||
jQuery.each ($("#id_snmp option:selected"), function (i, val) {
|
||||
idSNMP.push($(val).val());
|
||||
});
|
||||
$('#module').attr ('disabled', 1);
|
||||
$('#module').empty ();
|
||||
$('#module').append ($('<option></option>').html ("Loading...").attr ("value", 0));
|
||||
|
||||
jQuery.post ('ajax.php',
|
||||
{"page" : "godmode/agentes/agent_manager",
|
||||
"get_modules_json_for_multiple_snmp": 1,
|
||||
"get_common_modules" : get_common_modules,
|
||||
"id_snmp[]": idSNMP,
|
||||
"id_snmp_serialize": $("#hidden-id_snmp_serialize").val()
|
||||
},
|
||||
function (data) {
|
||||
$('#module').empty ();
|
||||
c = 0;
|
||||
jQuery.each (data, function (i, val) {
|
||||
s = js_html_entity_decode(val);
|
||||
$('#module').append ($('<option></option>').html (s).attr ("value", i));
|
||||
$('#module').fadeIn ('normal');
|
||||
c++;
|
||||
});
|
||||
|
||||
if (c == 0) {
|
||||
if (typeof($(document).data('text_for_module')) != 'undefined') {
|
||||
$('#module').append ($('<option></option>').html ($(document).data('text_for_module')).attr("value", 0).prop('selected', true));
|
||||
}
|
||||
else {
|
||||
if (typeof(data['any_text']) != 'undefined') {
|
||||
$('#module').append ($('<option></option>').html (data['any_text']).attr ("value", 0).prop('selected', true));
|
||||
}
|
||||
else {
|
||||
var anyText = $("#any_text").html(); //Trick for catch the translate text.
|
||||
|
||||
if (anyText == null) {
|
||||
anyText = 'Any';
|
||||
}
|
||||
|
||||
$('#module').append ($('<option></option>').html (anyText).attr ("value", 0).prop('selected', true));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (selected != undefined)
|
||||
$('#module').attr ('value', selected);
|
||||
$('#module').removeAttr('disabled');
|
||||
},
|
||||
"json");
|
||||
}
|
||||
|
||||
/* ]]> */
|
||||
</script>
|
|
@ -1,873 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Pandora FMS - http://pandorafms.com.
|
||||
* * ==================================================
|
||||
* * Copyright (c) 2005-2011 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; 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.
|
||||
*/
|
||||
|
||||
global $config;
|
||||
require_once $config['homedir'].'/include/functions_agents.php';
|
||||
require_once 'include/functions_modules.php';
|
||||
require_once 'include/functions_alerts.php';
|
||||
require_once 'include/functions_reporting.php';
|
||||
require_once 'include/functions_network_components.php';
|
||||
require_once 'include/functions_wmi.php';
|
||||
require_once 'include/graphs/functions_utils.php';
|
||||
|
||||
check_login();
|
||||
|
||||
$ip_target = (string) get_parameter('ip_target', $ipAgent);
|
||||
// Host.
|
||||
$plugin_user = (string) get_parameter('plugin_user', 'Administrator');
|
||||
// Username.
|
||||
$plugin_pass = io_safe_output(get_parameter('plugin_pass', ''));
|
||||
// Password.
|
||||
$tcp_send = (string) get_parameter('tcp_send');
|
||||
// Namespace.
|
||||
$server_to_exec = get_parameter('server_to_exec', 0);
|
||||
|
||||
// See if id_agente is set (either POST or GET, otherwise -1.
|
||||
$id_agent = $idAgent;
|
||||
|
||||
// Get passed variables.
|
||||
$wmiexplore = (int) get_parameter('wmiexplore', 0);
|
||||
$create_modules = (int) get_parameter('create_modules', 0);
|
||||
|
||||
$interfaces = [];
|
||||
|
||||
$wmi_client = 'wmic';
|
||||
|
||||
if ($wmiexplore) {
|
||||
$wmi_command = wmi_compose_query(
|
||||
$wmi_client,
|
||||
$plugin_user,
|
||||
$plugin_pass,
|
||||
$ip_target,
|
||||
$tcp_send
|
||||
);
|
||||
|
||||
$processes = [];
|
||||
$services = [];
|
||||
$disks = [];
|
||||
$network_component_groups = [];
|
||||
|
||||
// Processes.
|
||||
$wmi_processes = $wmi_command.' "select Name from Win32_Process"';
|
||||
$processes_name_field = 1;
|
||||
if (enterprise_installed() && (int) $server_to_exec != 0) {
|
||||
$server_data = db_get_row('tserver', 'id_server', $server_to_exec);
|
||||
|
||||
if (empty($server_data['port'])) {
|
||||
exec(
|
||||
'ssh pandora_exec_proxy@'.$server_data['ip_address']."
|
||||
'".$wmi_processes."'",
|
||||
$output,
|
||||
$rc
|
||||
);
|
||||
} else {
|
||||
exec(
|
||||
'ssh -p '.$server_data['port'].' pandora_exec_proxy@'.$server_data['ip_address']."
|
||||
'".$wmi_processes."'",
|
||||
$output,
|
||||
$rc
|
||||
);
|
||||
}
|
||||
} else {
|
||||
exec($wmi_processes, $output);
|
||||
}
|
||||
|
||||
$fail = false;
|
||||
if (preg_match('/^Failed/', $output[0])) {
|
||||
$fail = true;
|
||||
}
|
||||
|
||||
if (!$fail) {
|
||||
foreach ($output as $index => $row) {
|
||||
// First and second rows are Class and column names, ignore it.
|
||||
if ($index < 2) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$row_exploded = explode('|', $row);
|
||||
|
||||
if (!in_array($row_exploded[$processes_name_field], $processes)) {
|
||||
if (preg_match('/ERROR/', $row_exploded[$processes_name_field])) {
|
||||
$processes[$row_exploded[$prouycesses_name_field]] = __('None');
|
||||
} else {
|
||||
$processes[$row_exploded[$prouycesses_name_field]] = $row_exploded[$processes_name_field];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unset($output);
|
||||
|
||||
// Services.
|
||||
$wmi_services = $wmi_command.' "select Name from Win32_Service"';
|
||||
$services_name_field = 0;
|
||||
$services_check_field = 1;
|
||||
|
||||
if (enterprise_installed() && (int) $server_to_exec != 0) {
|
||||
$server_data = db_get_row(
|
||||
'tserver',
|
||||
'id_server',
|
||||
$server_to_exec
|
||||
);
|
||||
if (empty($server_data['port'])) {
|
||||
exec(
|
||||
'ssh pandora_exec_proxy@'.$server_data['ip_address']."
|
||||
'".$wmi_services."'",
|
||||
$output,
|
||||
$rc
|
||||
);
|
||||
} else {
|
||||
exec(
|
||||
'ssh -p '.$server_data['port'].' pandora_exec_proxy@'.$server_data['ip_address']."
|
||||
'".$wmi_services."'",
|
||||
$output,
|
||||
$rc
|
||||
);
|
||||
}
|
||||
} else {
|
||||
exec($wmi_services, $output);
|
||||
}
|
||||
|
||||
foreach ($output as $index => $row) {
|
||||
// First and second rows are Class and column names, ignore it.
|
||||
if ($index < 2) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$row_exploded = explode('|', $row);
|
||||
|
||||
if (!in_array($row_exploded[$services_name_field], $services)) {
|
||||
if (preg_match('/ERROR/', $row_exploded[$services_name_field])) {
|
||||
$services[$row_exploded[$services_name_field]] = __('None');
|
||||
} else {
|
||||
$services[$row_exploded[$services_name_field]] = $row_exploded[$services_name_field];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unset($output);
|
||||
|
||||
// Disks.
|
||||
$wmi_disks = $wmi_command.' "Select DeviceID from Win32_LogicalDisk"';
|
||||
$disks_name_field = 0;
|
||||
|
||||
if (enterprise_installed() && (int) $server_to_exec != 0) {
|
||||
$server_data = db_get_row('tserver', 'id_server', $server_to_exec);
|
||||
|
||||
if (empty($server_data['port'])) {
|
||||
exec(
|
||||
'ssh pandora_exec_proxy@'.$server_data['ip_address']."
|
||||
'".$wmi_disks."'",
|
||||
$output,
|
||||
$rc
|
||||
);
|
||||
} else {
|
||||
exec(
|
||||
'ssh -p '.$server_data['port'].' pandora_exec_proxy@'.$server_data['ip_address']."
|
||||
'".$wmi_disks."'",
|
||||
$output,
|
||||
$rc
|
||||
);
|
||||
}
|
||||
} else {
|
||||
exec($wmi_disks, $output);
|
||||
}
|
||||
|
||||
foreach ($output as $index => $row) {
|
||||
// First and second rows are Class and column names, ignore it.
|
||||
if ($index < 2) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$row_exploded = explode('|', $row);
|
||||
|
||||
if (!in_array($row_exploded[$disks_name_field], $services)) {
|
||||
if (preg_match('/ERROR/', $row_exploded[$disks_name_field])) {
|
||||
$disks[$row_exploded[$disks_name_field]] = __('None');
|
||||
} else {
|
||||
$disk_string = sprintf(
|
||||
__('Free space on %s'),
|
||||
$row_exploded[$disks_name_field]
|
||||
);
|
||||
$disks[$row_exploded[$disks_name_field]] = $disk_string;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unset($output);
|
||||
|
||||
// WMI Components.
|
||||
$network_component_groups = network_components_get_groups(MODULE_WMI);
|
||||
}
|
||||
}
|
||||
|
||||
if ($create_modules) {
|
||||
$modules = get_parameter('module', []);
|
||||
|
||||
$services = [];
|
||||
$processes = [];
|
||||
$disks = [];
|
||||
$components = [];
|
||||
|
||||
foreach ($modules as $module) {
|
||||
// Split module data to get type.
|
||||
$module_exploded = explode('_', $module);
|
||||
$type = $module_exploded[0];
|
||||
|
||||
// Delete type from module data.
|
||||
unset($module_exploded[0]);
|
||||
|
||||
// Rebuild module data.
|
||||
$module = implode('_', $module_exploded);
|
||||
|
||||
switch ($type) {
|
||||
case 'service':
|
||||
$services[] = $module;
|
||||
break;
|
||||
|
||||
case 'process':
|
||||
$processes[] = $module;
|
||||
break;
|
||||
|
||||
case 'disk':
|
||||
$disks[] = $module;
|
||||
break;
|
||||
|
||||
case 'component':
|
||||
$components[] = $module;
|
||||
break;
|
||||
|
||||
default:
|
||||
// Default.
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Common values for WMI modules.
|
||||
$values = [
|
||||
'ip_target' => $ip_target,
|
||||
'tcp_send' => $tcp_send,
|
||||
'plugin_user' => $plugin_user,
|
||||
'plugin_pass' => $plugin_pass,
|
||||
'id_modulo' => MODULE_WMI,
|
||||
];
|
||||
|
||||
if ($server_to_exec != 0) {
|
||||
$sql = sprintf(
|
||||
'SELECT server_type FROM tserver WHERE id_server = %d',
|
||||
$server_to_exec
|
||||
);
|
||||
$row = db_get_row_sql($sql);
|
||||
|
||||
if ($row['server_type'] == 13) {
|
||||
$values['id_modulo'] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
// Create Service modules.
|
||||
$services_values = $values;
|
||||
|
||||
$services_values['snmp_community'] = 'Running';
|
||||
// Key string.
|
||||
$services_values['tcp_port'] = 1;
|
||||
// Field number (Running/Stopped).
|
||||
$services_values['id_tipo_modulo'] = 2;
|
||||
// Generic boolean.
|
||||
$services_result = wmi_create_wizard_modules(
|
||||
$id_agent,
|
||||
$services,
|
||||
'services',
|
||||
$services_values,
|
||||
0,
|
||||
0,
|
||||
$server_to_exec
|
||||
);
|
||||
|
||||
// Create Process modules.
|
||||
$processes_values = $values;
|
||||
|
||||
$processes_values['tcp_port'] = 0;
|
||||
// Field number (OID).
|
||||
$processes_values['id_tipo_modulo'] = 2;
|
||||
// Generic boolean.
|
||||
$processes_result = wmi_create_wizard_modules(
|
||||
$id_agent,
|
||||
$processes,
|
||||
'processes',
|
||||
$processes_values,
|
||||
0,
|
||||
0,
|
||||
$server_to_exec
|
||||
);
|
||||
|
||||
// Create Space on disk modules.
|
||||
$disks_values = $values;
|
||||
|
||||
$disks_values['tcp_port'] = 1;
|
||||
// Free space in bytes.
|
||||
$disks_values['id_tipo_modulo'] = 1;
|
||||
// Generic numeric.
|
||||
$disks_values['unit'] = 'Bytes';
|
||||
// Unit.
|
||||
$disks_result = wmi_create_wizard_modules(
|
||||
$id_agent,
|
||||
$disks,
|
||||
'disks',
|
||||
$disks_values,
|
||||
0,
|
||||
0,
|
||||
$server_to_exec
|
||||
);
|
||||
|
||||
// Create modules from component.
|
||||
$components_values = $values;
|
||||
|
||||
$components_values['id_agente'] = $id_agent;
|
||||
|
||||
$components_result = wmi_create_module_from_components(
|
||||
$components,
|
||||
$components_values,
|
||||
0,
|
||||
0,
|
||||
$server_to_exec
|
||||
);
|
||||
|
||||
|
||||
// Errors/Success messages.
|
||||
$success_message = '';
|
||||
$error_message = '';
|
||||
if (!empty($services_result)) {
|
||||
if (count($services_result[NOERR]) > 0) {
|
||||
$success_message .= sprintf(
|
||||
__('%s service modules created succesfully'),
|
||||
count($services_result[NOERR])
|
||||
).'<br>';
|
||||
}
|
||||
|
||||
if (count($services_result[ERR_GENERIC]) > 0) {
|
||||
$error_message .= sprintf(
|
||||
__('Error creating %s service modules'),
|
||||
count($services_result[ERR_GENERIC])
|
||||
).'<br>';
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($processes_result)) {
|
||||
if (count($processes_result[NOERR]) > 0) {
|
||||
$success_message .= sprintf(
|
||||
__('%s process modules created succesfully'),
|
||||
count($processes_result[NOERR])
|
||||
).'<br>';
|
||||
}
|
||||
|
||||
if (count($processes_result[ERR_GENERIC]) > 0) {
|
||||
$error_message .= sprintf(
|
||||
__('Error creating %s process modules'),
|
||||
count($processes_result[ERR_GENERIC])
|
||||
).'<br>';
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($disks_result)) {
|
||||
if (count($disks_result[NOERR]) > 0) {
|
||||
$success_message .= sprintf(
|
||||
__('%s disk space modules created succesfully'),
|
||||
count($disks_result[NOERR])
|
||||
).'<br>';
|
||||
}
|
||||
|
||||
if (count($disks_result[ERR_GENERIC]) > 0) {
|
||||
$error_message .= sprintf(
|
||||
__('Error creating %s disk space modules'),
|
||||
count($disks_result[ERR_GENERIC])
|
||||
).'<br>';
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($components_result)) {
|
||||
if (count($components_result[NOERR]) > 0) {
|
||||
$success_message .= sprintf(
|
||||
__('%s modules created from components succesfully'),
|
||||
count($components_result[NOERR])
|
||||
).'<br>';
|
||||
}
|
||||
|
||||
if (count($components_result[ERR_GENERIC]) > 0) {
|
||||
$error_message .= sprintf(
|
||||
__('Error creating %s modules from components'),
|
||||
count($components_result[ERR_GENERIC])
|
||||
).'<br>';
|
||||
}
|
||||
|
||||
if (count($components_result[ERR_EXIST]) > 0) {
|
||||
$error_message .= sprintf(
|
||||
__('%s modules already exist'),
|
||||
count($components_result[ERR_EXIST])
|
||||
).'<br>';
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($success_message)) {
|
||||
ui_print_success_message($success_message);
|
||||
}
|
||||
|
||||
if (!empty($error_message)) {
|
||||
ui_print_error_message($error_message);
|
||||
}
|
||||
}
|
||||
|
||||
echo '<span id ="none_text" style="display: none;">'.__('None').'</span>';
|
||||
echo "<form method='post' id='wmi_form'
|
||||
action='index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=agent_wizard&wizard_section=wmi_explorer&id_agente=$id_agent'>";
|
||||
|
||||
$table->width = '100%';
|
||||
$table->cellpadding = 0;
|
||||
$table->cellspacing = 0;
|
||||
$table->class = 'databox filters';
|
||||
|
||||
$table->data[0][0] = '<b>'.__('Target IP').'</b>';
|
||||
$table->data[0][1] = html_print_input_text(
|
||||
'ip_target',
|
||||
$ip_target,
|
||||
'',
|
||||
15,
|
||||
60,
|
||||
true
|
||||
);
|
||||
|
||||
$table->data[0][2] = '<b>'.__('Namespace').'</b>';
|
||||
$table->data[0][3] = html_print_input_text(
|
||||
'tcp_send',
|
||||
$tcp_send,
|
||||
'',
|
||||
15,
|
||||
60,
|
||||
true
|
||||
);
|
||||
|
||||
$table->data[1][0] = '<b>'.__('Username').'</b>';
|
||||
$table->data[1][1] = html_print_input_text(
|
||||
'plugin_user',
|
||||
$plugin_user,
|
||||
'',
|
||||
15,
|
||||
60,
|
||||
true
|
||||
);
|
||||
|
||||
$table->data[1][2] = '<b>'.__('Password').'</b>';
|
||||
$table->data[1][3] = html_print_input_password(
|
||||
'plugin_pass',
|
||||
$plugin_pass,
|
||||
'',
|
||||
15,
|
||||
60,
|
||||
true
|
||||
);
|
||||
|
||||
$table->data[1][3] .= '<div id="spinner_modules" style="float: left; display: none;">
|
||||
'.html_print_image('images/spinner.gif', true).'</div>';
|
||||
html_print_input_hidden('wmiexplore', 1);
|
||||
|
||||
$servers_to_exec = [];
|
||||
$servers_to_exec[0] = __('Local console');
|
||||
if (enterprise_installed()) {
|
||||
enterprise_include_once('include/functions_satellite.php');
|
||||
|
||||
$rows = get_proxy_servers();
|
||||
foreach ($rows as $row) {
|
||||
if ($row['server_type'] != 13) {
|
||||
$s_type = ' (Standard)';
|
||||
} else {
|
||||
$s_type = ' (Satellite)';
|
||||
}
|
||||
|
||||
$servers_to_exec[$row['id_server']] = $row['name'].$s_type;
|
||||
}
|
||||
}
|
||||
|
||||
$table->data[2][0] = '<b>'.__('Server to execute command').'</b>'.ui_print_help_icon('agent_snmp_explorer_tab', true);
|
||||
$table->data[2][1] = html_print_select(
|
||||
$servers_to_exec,
|
||||
'server_to_exec',
|
||||
$server_to_exec,
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
true
|
||||
);
|
||||
|
||||
html_print_table($table);
|
||||
|
||||
echo "<div style='text-align:right; width:".$table->width."'>";
|
||||
echo '<span id="oid_loading" class="invisible">
|
||||
'.html_print_image('images/spinner.gif', true).'</span>';
|
||||
html_print_submit_button(
|
||||
__('WMI Explore'),
|
||||
'wmi_explore',
|
||||
false,
|
||||
['class' => 'sub next']
|
||||
);
|
||||
echo '</div><br>';
|
||||
|
||||
if ($wmiexplore && $fail) {
|
||||
ui_print_error_message(__('Unable to do WMI explorer'));
|
||||
}
|
||||
|
||||
unset($table);
|
||||
|
||||
echo '</form>';
|
||||
|
||||
if ($wmiexplore && !$fail) {
|
||||
echo '<br><span id ="none_text" style="display: none;">'.__('None').'</span>';
|
||||
echo "<form method='post'
|
||||
action='index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=agent_wizard&wizard_section=wmi_explorer&id_agente=$id_agent'>";
|
||||
echo '<span id="form_interfaces">';
|
||||
|
||||
html_print_input_hidden('create_modules', 1);
|
||||
html_print_input_hidden('ip_target', $ip_target);
|
||||
// Host.
|
||||
html_print_input_hidden('plugin_user', $plugin_user);
|
||||
// User.
|
||||
html_print_input_hidden('plugin_pass', $plugin_pass);
|
||||
// Password.
|
||||
html_print_input_hidden('tcp_send', $tcp_send);
|
||||
// Namespace.
|
||||
html_print_input_hidden('server_to_exec', $server_to_exec);
|
||||
|
||||
$table->width = '100%';
|
||||
|
||||
// Mode selector.
|
||||
$modes = [];
|
||||
$modes['services'] = __('Services');
|
||||
$modes['processes'] = __('Processes');
|
||||
$modes['disks'] = __('Free space on disk');
|
||||
$modes['components'] = __('WMI components');
|
||||
|
||||
$table->data[1][0] = __('Wizard mode').': ';
|
||||
$table->data[1][0] .= html_print_select(
|
||||
$modes,
|
||||
'wmi_wizard_modes',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
true,
|
||||
false,
|
||||
false
|
||||
);
|
||||
$table->cellstyle[1][0] = 'vertical-align: middle;';
|
||||
|
||||
$table->colspan[1][0] = 2;
|
||||
$table->data[1][2] = '<b>'.__('Modules').'</b>';
|
||||
$table->cellstyle[1][2] = 'text-align: center;';
|
||||
|
||||
// Components list.
|
||||
$table->data[2][0] = '<div class="wizard_mode_form wizard_mode_components">';
|
||||
$table->data[2][0] .= __('Filter by group').'<br>';
|
||||
$table->data[2][0] .= html_print_select(
|
||||
$network_component_groups,
|
||||
'network_component_group',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
'',
|
||||
false,
|
||||
'width: 300px;'
|
||||
).'<br>';
|
||||
$table->data[2][0] .= html_print_select(
|
||||
[],
|
||||
'network_component',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
'',
|
||||
false,
|
||||
'width: 300px;'
|
||||
);
|
||||
$table->data[2][0] .= '</div>';
|
||||
|
||||
// Services list.
|
||||
$table->data[2][0] .= '<div class="wizard_mode_form wizard_mode_services">';
|
||||
$table->data[2][0] .= html_print_select(
|
||||
$services,
|
||||
'services',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
'',
|
||||
false,
|
||||
'width: 300px;'
|
||||
);
|
||||
$table->data[2][0] .= '</div>';
|
||||
// Processes list.
|
||||
$table->data[2][0] .= '<div class="wizard_mode_form wizard_mode_processes">';
|
||||
$table->data[2][0] .= html_print_select(
|
||||
$processes,
|
||||
'processes',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
'',
|
||||
false,
|
||||
'width: 300px;'
|
||||
);
|
||||
$table->data[2][0] .= '</div>';
|
||||
$table->data[2][0] .= '<span id="no_component"
|
||||
class="invisible error wizard_mode_form wizard_mode_components">';
|
||||
|
||||
$table->data[2][0] .= __('No component was found');
|
||||
$table->data[2][0] .= '</span>';
|
||||
|
||||
// Disks list.
|
||||
$table->data[2][0] .= '<div class="wizard_mode_form wizard_mode_disks">';
|
||||
$table->data[2][0] .= html_print_select(
|
||||
$disks,
|
||||
'disks',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
'',
|
||||
false,
|
||||
'width: 300px;'
|
||||
);
|
||||
$table->data[2][0] .= '</div>';
|
||||
$table->cellstyle[2][0] = 'vertical-align: bottom; text-align: center;';
|
||||
|
||||
|
||||
// Components arrow.
|
||||
$table->data[2][1] = '<div
|
||||
class="wizard_mode_form wizard_mode_components wizard_mode_components_arrow clickable">
|
||||
'.html_print_image(
|
||||
'images/darrowright.png',
|
||||
true,
|
||||
['title' => __('Add to modules list')]
|
||||
).'</div>';
|
||||
// Services arrow.
|
||||
$table->data[2][1] .= '<div
|
||||
class="wizard_mode_form wizard_mode_services wizard_mode_services_arrow clickable">
|
||||
'.html_print_image(
|
||||
'images/darrowright.png',
|
||||
true,
|
||||
['title' => __('Add to modules list')]
|
||||
).'</div>';
|
||||
// Processes arrow.
|
||||
$table->data[2][1] .= '<div
|
||||
class="wizard_mode_form wizard_mode_processes wizard_mode_processes_arrow clickable">
|
||||
'.html_print_image(
|
||||
'images/darrowright.png',
|
||||
true,
|
||||
['title' => __('Add to modules list')]
|
||||
).'</div>';
|
||||
// Disks arrow.
|
||||
$table->data[2][1] .= '<div
|
||||
class="wizard_mode_form wizard_mode_disks wizard_mode_disks_arrow clickable">
|
||||
'.html_print_image(
|
||||
'images/darrowright.png',
|
||||
true,
|
||||
['title' => __('Add to modules list')]
|
||||
).'</div>';
|
||||
|
||||
|
||||
$table->data[2][1] .= '<br><br>
|
||||
<div class="wizard_mode_delete_arrow clickable">
|
||||
'.html_print_image(
|
||||
'images/cross.png',
|
||||
true,
|
||||
['title' => __('Remove from modules list')]
|
||||
).'</div>';
|
||||
$table->cellstyle[2][1] = 'vertical-align: middle; text-align: center;';
|
||||
|
||||
$table->data[2][2] = html_print_select(
|
||||
[],
|
||||
'module[]',
|
||||
0,
|
||||
false,
|
||||
'',
|
||||
0,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
'',
|
||||
false,
|
||||
'width:300px; height: 100%;'
|
||||
);
|
||||
$table->data[2][2] .= html_print_input_hidden(
|
||||
'agent',
|
||||
$id_agent,
|
||||
true
|
||||
);
|
||||
$table->cellstyle[2][2] = 'vertical-align: top; text-align: center;';
|
||||
|
||||
html_print_table($table);
|
||||
|
||||
echo "<div style='text-align:right; width:".$table->width."'>";
|
||||
html_print_submit_button(
|
||||
__('Create modules'),
|
||||
'create_modules_btn',
|
||||
false,
|
||||
['class' => 'sub add']
|
||||
);
|
||||
echo '</div>';
|
||||
unset($table);
|
||||
|
||||
echo '</span>';
|
||||
echo '</form>';
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
ui_require_jquery_file('pandora.controls');
|
||||
ui_require_jquery_file('ajaxqueue');
|
||||
ui_require_jquery_file('bgiframe');
|
||||
ui_require_javascript_file('pandora_modules');
|
||||
|
||||
?>
|
||||
<script language="javascript" type="text/javascript">
|
||||
/* <![CDATA[ */
|
||||
|
||||
$(document).ready (function () {
|
||||
$("#wmi_form").submit(function() {
|
||||
$("#oid_loading").show ();
|
||||
});
|
||||
|
||||
network_component_group_change_event();
|
||||
$('#network_component_group').trigger('change');
|
||||
|
||||
$("#wmi_wizard_modes").change(function() {
|
||||
$(".wizard_mode_form").hide();
|
||||
var selected_mode = $("#wmi_wizard_modes").val();
|
||||
$(".wizard_mode_" + selected_mode).show();
|
||||
$('#form_interfaces').show();
|
||||
});
|
||||
|
||||
$("#wmi_wizard_modes").trigger('change');
|
||||
|
||||
<?php
|
||||
if (!$wmiexplore || $fail) {
|
||||
?>
|
||||
$('#form_interfaces').hide();
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
$('.wizard_mode_services_arrow').click(function() {
|
||||
jQuery.each($("select[name='services'] option:selected"), function (key, value) {
|
||||
var id = 'service_' + $(value).attr('value');
|
||||
var name = $(value).html() + ' (<?php echo __('Service'); ?>)';
|
||||
if (name != <?php echo "'".__('None')."'"; ?>) {
|
||||
if($("#module").find("option[value='" + id + "']").length == 0) {
|
||||
$("select[name='module[]']").append($("<option></option>").val(id).html(name));
|
||||
}
|
||||
else {
|
||||
alert("<?php echo __('Repeated'); ?>");
|
||||
}
|
||||
$("#module").find("option[value='0']").remove();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('.wizard_mode_processes_arrow').click(function() {
|
||||
jQuery.each($("select[name='processes'] option:selected"), function (key, value) {
|
||||
var id = 'process_' + $(value).attr('value');
|
||||
var name = $(value).html() + ' (<?php echo __('Process'); ?>)';
|
||||
if (name != <?php echo "'".__('None')."'"; ?>) {
|
||||
if($("#module").find("option[value='" + id + "']").length == 0) {
|
||||
$("select[name='module[]']").append($("<option></option>").val(id).html(name));
|
||||
}
|
||||
else {
|
||||
alert("<?php echo __('Repeated'); ?>");
|
||||
}
|
||||
$("#module").find("option[value='0']").remove();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('.wizard_mode_disks_arrow').click(function() {
|
||||
jQuery.each($("select[name='disks'] option:selected"), function (key, value) {
|
||||
var id = 'disk_' + $(value).attr('value');
|
||||
var name = $(value).html();
|
||||
if (name != <?php echo "'".__('None')."'"; ?>) {
|
||||
if($("#module").find("option[value='" + id + "']").length == 0) {
|
||||
$("select[name='module[]']").append($("<option></option>").val(id).html(name));
|
||||
}
|
||||
else {
|
||||
alert("<?php echo __('Repeated'); ?>");
|
||||
}
|
||||
$("#module").find("option[value='0']").remove();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('.wizard_mode_components_arrow').click(function() {
|
||||
jQuery.each($("select[name='network_component'] option:selected"), function (key, value) {
|
||||
var id = 'component_' + $(value).attr('value');
|
||||
var name = $(value).html();
|
||||
if (name != <?php echo "'".__('None')."'"; ?>) {
|
||||
if($("#module").find("option[value='" + id + "']").length == 0) {
|
||||
$("select[name='module[]']").append($("<option></option>").val(id).html(name));
|
||||
}
|
||||
else {
|
||||
alert("<?php echo __('Repeated'); ?>");
|
||||
}
|
||||
$("#module").find("option[value='0']").remove();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('.wizard_mode_delete_arrow').click(function() {
|
||||
jQuery.each($("select[name='module[]'] option:selected"), function (key, value) {
|
||||
var name = $(value).html();
|
||||
if (name != <?php echo "'".__('None')."'"; ?>) {
|
||||
$(value).remove();
|
||||
}
|
||||
});
|
||||
|
||||
if($("#module option").length == 0) {
|
||||
$("select[name='module[]']").append($("<option></option>").val(0).html(<?php echo "'".__('None')."'"; ?>));
|
||||
}
|
||||
});
|
||||
|
||||
$("#submit-create_modules_btn").click(function () {
|
||||
if($("#module option").length == 0 || ($("#module option").length == 1 && $("#module option").eq(0).val() == 0)) {
|
||||
alert("<?php echo __('Modules list is empty'); ?>");
|
||||
return false;
|
||||
}
|
||||
$('#module option').map(function() {
|
||||
$(this).prop('selected', true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
/* ]]> */
|
||||
</script>
|
|
@ -1378,8 +1378,8 @@ if ($update_module || $create_module) {
|
|||
$ip_target = (string) get_parameter('ip_target');
|
||||
// No autofill if the module is a webserver module.
|
||||
if ($ip_target == ''
|
||||
&& $id_module_type < MODULE_WEBSERVER_CHECK_LATENCY
|
||||
&& $id_module_type > MODULE_WEBSERVER_RETRIEVE_STRING_DATA
|
||||
&& $id_module_type < MODULE_TYPE_WEB_DATA
|
||||
&& $id_module_type > MODULE_TYPE_WEB_CONTENT_STRING
|
||||
) {
|
||||
$ip_target = 'auto';
|
||||
}
|
||||
|
|
|
@ -47,6 +47,40 @@ require_once $config['homedir'].'/include/functions_categories.php';
|
|||
enterprise_include_once('meta/include/functions_components_meta.php');
|
||||
require_once $config['homedir'].'/include/functions_component_groups.php';
|
||||
|
||||
// Header.
|
||||
if (defined('METACONSOLE')) {
|
||||
components_meta_print_header();
|
||||
$sec = 'advanced';
|
||||
|
||||
$id_modulo = (int) get_parameter('id_component_type');
|
||||
$new_component = (bool) get_parameter('new_component');
|
||||
} else {
|
||||
$id_modulo = (int) get_parameter('id_component_type');
|
||||
$new_component = (bool) get_parameter('new_component');
|
||||
if ($id_modulo == COMPONENT_TYPE_NETWORK || $id_modulo == COMPONENT_TYPE_PLUGIN || $id_modulo == COMPONENT_TYPE_WMI || $id_modulo == COMPONENT_TYPE_WIZARD) {
|
||||
$help_header = 'local_module_tab';
|
||||
} else if (!$new_component) {
|
||||
$help_header = 'network_component_tab';
|
||||
} else {
|
||||
$help_header = 'network_component_tab';
|
||||
}
|
||||
|
||||
ui_print_page_header(
|
||||
__('Remote components'),
|
||||
'',
|
||||
false,
|
||||
$help_header,
|
||||
true,
|
||||
'',
|
||||
false,
|
||||
'modulemodal',
|
||||
GENERIC_SIZE_TEXT,
|
||||
'',
|
||||
__('Configuration').' / '.__('Templates').' / '.__('Remote components')
|
||||
);
|
||||
$sec = 'gmodules';
|
||||
}
|
||||
|
||||
$type = (int) get_parameter('type');
|
||||
$name = (string) get_parameter('name');
|
||||
$description = (string) get_parameter('description');
|
||||
|
@ -180,6 +214,68 @@ if ($duplicate_network_component) {
|
|||
$id = 0;
|
||||
}
|
||||
|
||||
// Wizard Common.
|
||||
$module_enabled = get_parameter_switch('module_enabled');
|
||||
$module_protocol = get_parameter('module_protocol', 'snmp');
|
||||
$scan_type = (int) get_parameter('scan_type', SCAN_TYPE_FIXED);
|
||||
$execution_type = (int) get_parameter('execution_type', EXECUTION_TYPE_NETWORK);
|
||||
// Wizard SNMP.
|
||||
$manufacturer_id = get_parameter('manufacturer_id');
|
||||
$name_oid = get_parameter('name_oid');
|
||||
$value = get_parameter('value_oid');
|
||||
// Other Wizard WMI fields.
|
||||
$query_filter = '';
|
||||
$wmi_class = get_parameter('wmi_class');
|
||||
$query_key_field = get_parameter('query_key_field');
|
||||
// Enabled Module.
|
||||
$enabled = get_parameter_switch('enabled');
|
||||
|
||||
if ($id_modulo === COMPONENT_TYPE_WIZARD) {
|
||||
// Wizard Common extra fields.
|
||||
$macros = [];
|
||||
|
||||
$macros['satellite_execution'] = get_parameter('satellite_execution_'.$module_protocol);
|
||||
$macros['value_operation'] = get_parameter('value_operation_'.$module_protocol);
|
||||
$macros['server_plugin'] = get_parameter('server_plugin_'.$module_protocol);
|
||||
|
||||
if ($module_protocol === 'snmp') {
|
||||
// If not select any manufacturer_id, there is 'all'.
|
||||
if (empty($manufacturer_id) === true) {
|
||||
$manufacturer_id = 'all';
|
||||
}
|
||||
} else if ($module_protocol === 'wmi') {
|
||||
// Wizard WMI Query filters.
|
||||
$query_filter = [];
|
||||
$query_filter['scan'] = get_parameter('query_filter_scan');
|
||||
$query_filter['execution'] = get_parameter('query_filter_execution');
|
||||
$query_filter['field'] = get_parameter('field_value_filter');
|
||||
$query_filter['key_string'] = get_parameter('key_string_filter');
|
||||
$query_filter = json_encode($query_filter);
|
||||
}
|
||||
|
||||
// Default extra field.
|
||||
$extra_fields = [ 'extra_field_1' => '' ];
|
||||
// If Plugin execution is selected.
|
||||
if ($execution_type === EXECUTION_TYPE_PLUGIN || $module_protocol === 'wmi') {
|
||||
// Search all parameters received with extra_fields.
|
||||
foreach ($_REQUEST as $parameter => $thisValue) {
|
||||
// Extra fields (OIDs Macros or WMI Extra fields)
|
||||
if (preg_match('/extra_field_'.$module_protocol.'_/', $parameter) !== 0) {
|
||||
$tmpParameter = explode('_', $parameter);
|
||||
$extra_fields['extra_field_'.$tmpParameter[3]] = get_parameter($parameter);
|
||||
}
|
||||
|
||||
// The plugin macros.
|
||||
if (preg_match('/'.$module_protocol.'_field/', $parameter) !== 0) {
|
||||
$macros[$parameter] = io_safe_input($thisValue);
|
||||
}
|
||||
}
|
||||
|
||||
// All of macros saved in the same array.
|
||||
$macros = json_encode(array_merge($extra_fields, $macros));
|
||||
}
|
||||
}
|
||||
|
||||
$custom_string_1 = '';
|
||||
$custom_string_2 = '';
|
||||
$custom_string_3 = '';
|
||||
|
@ -210,7 +306,7 @@ if (defined('METACONSOLE')) {
|
|||
$sec = 'gmodules';
|
||||
}
|
||||
|
||||
if ($type >= 15 && $type <= 18) {
|
||||
if ($type >= MODULE_TYPE_REMOTE_SNMP && $type <= MODULE_TYPE_REMOTE_SNMP_PROC) {
|
||||
// New support for snmp v3.
|
||||
$tcp_send = $snmp_version;
|
||||
$plugin_user = $snmp3_auth_user;
|
||||
|
@ -219,7 +315,7 @@ if ($type >= 15 && $type <= 18) {
|
|||
$custom_string_1 = $snmp3_privacy_method;
|
||||
$custom_string_2 = $snmp3_privacy_pass;
|
||||
$custom_string_3 = $snmp3_security_level;
|
||||
} else if ($type >= 34 && $type <= 37) {
|
||||
} else if ($type >= MODULE_TYPE_REMOTE_CMD && $type <= MODULE_TYPE_REMOTE_CMD_INC) {
|
||||
$tcp_send = $command_text;
|
||||
$custom_string_1 = $command_credential_identifier;
|
||||
$custom_string_2 = $command_os;
|
||||
|
@ -275,7 +371,6 @@ if ($create_component) {
|
|||
'post_process' => $post_process,
|
||||
'unit' => $unit,
|
||||
'wizard_level' => $wizard_level,
|
||||
'macros' => $macros,
|
||||
'critical_instructions' => $critical_instructions,
|
||||
'warning_instructions' => $warning_instructions,
|
||||
'unknown_instructions' => $unknown_instructions,
|
||||
|
@ -289,6 +384,17 @@ if ($create_component) {
|
|||
'min_ff_event_critical' => $ff_event_critical,
|
||||
'ff_type' => $ff_type,
|
||||
'each_ff' => $each_ff,
|
||||
'manufacturer_id' => $manufacturer_id,
|
||||
'protocol' => $module_protocol,
|
||||
'scan_type' => $scan_type,
|
||||
'execution_type' => $execution_type,
|
||||
'value' => $value,
|
||||
'query_class' => $wmi_class,
|
||||
'query_key_field' => $query_key_field,
|
||||
'query_filters' => $query_filter,
|
||||
'name_oid' => $name_oid,
|
||||
'module_enabled' => $module_enabled,
|
||||
'enabled' => $enabled,
|
||||
]
|
||||
);
|
||||
} else {
|
||||
|
@ -298,9 +404,17 @@ if ($create_component) {
|
|||
if ($id === false || !$id) {
|
||||
db_pandora_audit(
|
||||
'Module management',
|
||||
'Fail try to create network component'
|
||||
'Fail try to create remote component'
|
||||
);
|
||||
ui_print_error_message(__('Could not be created'));
|
||||
|
||||
if ($name_check !== false) {
|
||||
// If name exists, advice about it.
|
||||
ui_print_error_message(__('Could not be created because the component exists'));
|
||||
} else {
|
||||
// Other cases.
|
||||
ui_print_error_message(__('Could not be created'));
|
||||
}
|
||||
|
||||
include_once 'godmode/modules/manage_network_components_form.php';
|
||||
return;
|
||||
}
|
||||
|
@ -356,7 +470,6 @@ if ($update_component) {
|
|||
'post_process' => $post_process,
|
||||
'unit' => $unit,
|
||||
'wizard_level' => $wizard_level,
|
||||
'macros' => $macros,
|
||||
'critical_instructions' => $critical_instructions,
|
||||
'warning_instructions' => $warning_instructions,
|
||||
'unknown_instructions' => $unknown_instructions,
|
||||
|
@ -370,6 +483,17 @@ if ($update_component) {
|
|||
'min_ff_event_critical' => $ff_event_critical,
|
||||
'ff_type' => $ff_type,
|
||||
'each_ff' => $each_ff,
|
||||
'manufacturer_id' => $manufacturer_id,
|
||||
'protocol' => $module_protocol,
|
||||
'scan_type' => $scan_type,
|
||||
'execution_type' => $execution_type,
|
||||
'value' => $value,
|
||||
'query_class' => $wmi_class,
|
||||
'query_key_field' => $query_key_field,
|
||||
'query_filters' => $query_filter,
|
||||
'name_oid' => $name_oid,
|
||||
'module_enabled' => $module_enabled,
|
||||
'enabled' => $enabled,
|
||||
]
|
||||
);
|
||||
} else {
|
||||
|
@ -559,11 +683,6 @@ foreach ($component_groups as $component_group_key => $component_group_val) {
|
|||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Only show component groups with local components.
|
||||
if ($num_components == 0 && $num_components_childs == 0) {
|
||||
unset($component_groups[$component_group_key]);
|
||||
}
|
||||
}
|
||||
|
||||
$table->data[0][1] = html_print_select(
|
||||
|
@ -665,14 +784,16 @@ $table->head['checkbox'] = html_print_checkbox(
|
|||
false
|
||||
);
|
||||
$table->head[0] = __('Module name');
|
||||
$table->head[1] = __('Type');
|
||||
$table->head[1] = __('Server');
|
||||
$table->head[2] = __('Type');
|
||||
$table->head[3] = __('Description');
|
||||
$table->head[4] = __('Group');
|
||||
$table->head[5] = __('Max/Min');
|
||||
$table->head[6] = __('Action');
|
||||
$table->size = [];
|
||||
$table->size['checkbox'] = '20px';
|
||||
$table->size[1] = '75px';
|
||||
$table->size[1] = '40px';
|
||||
$table->size[2] = '50px';
|
||||
$table->size[6] = '80px';
|
||||
$table->align[6] = 'left';
|
||||
$table->data = [];
|
||||
|
@ -698,7 +819,6 @@ foreach ($components as $component) {
|
|||
$data[0] = '<a href="index.php?sec='.$sec.'&sec2=godmode/modules/manage_network_components&id='.$component['id_nc'].'&pure='.$pure.'">';
|
||||
$data[0] .= io_safe_output($component['name']);
|
||||
$data[0] .= '</a>';
|
||||
$data[1] = ui_print_moduletype_icon($component['type'], true);
|
||||
switch ($component['id_modulo']) {
|
||||
case MODULE_NETWORK:
|
||||
$data[1] .= html_print_image(
|
||||
|
@ -724,11 +844,20 @@ foreach ($components as $component) {
|
|||
);
|
||||
break;
|
||||
|
||||
case MODULE_WIZARD:
|
||||
$data[1] .= html_print_image(
|
||||
'images/wand.png',
|
||||
true,
|
||||
['title' => __('Wizard module')]
|
||||
);
|
||||
break;
|
||||
|
||||
default:
|
||||
// Not possible.
|
||||
break;
|
||||
}
|
||||
|
||||
$data[2] = ui_print_moduletype_icon($component['type'], true);
|
||||
$data[3] = "<span style='font-size: 8px'>".mb_strimwidth(io_safe_output($component['description']), 0, 60, '...').'</span>';
|
||||
$data[4] = network_components_get_group_name($component['id_group']);
|
||||
$data[5] = $component['max'].' / '.$component['min'];
|
||||
|
@ -777,9 +906,10 @@ echo '<div class="" style="float:right;">';
|
|||
html_print_input_hidden('new_component', 1);
|
||||
html_print_select(
|
||||
[
|
||||
2 => __('Create a new network component'),
|
||||
4 => __('Create a new plugin component'),
|
||||
6 => __('Create a new WMI component'),
|
||||
COMPONENT_TYPE_NETWORK => __('Create a new network component'),
|
||||
COMPONENT_TYPE_PLUGIN => __('Create a new plugin component'),
|
||||
COMPONENT_TYPE_WMI => __('Create a new WMI component'),
|
||||
COMPONENT_TYPE_WIZARD => __('Create a new wizard component'),
|
||||
],
|
||||
'id_component_type',
|
||||
'',
|
||||
|
|
|
@ -110,56 +110,69 @@ if ($create_network_from_module) {
|
|||
if (isset($id)) {
|
||||
$component = network_components_get_network_component((int) $id);
|
||||
if ($component !== false) {
|
||||
$id_component_type = $component['id_modulo'];
|
||||
$name = $component['name'];
|
||||
$type = $component['type'];
|
||||
$description = $component['description'];
|
||||
$max = $component['max'];
|
||||
$min = $component['min'];
|
||||
$module_interval = $component['module_interval'];
|
||||
$tcp_port = $component['tcp_port'];
|
||||
$tcp_rcv = $component['tcp_rcv'];
|
||||
$tcp_send = $component['tcp_send'];
|
||||
$snmp_community = $component['snmp_community'];
|
||||
$snmp_oid = $component['snmp_oid'];
|
||||
$id_module_group = $component['id_module_group'];
|
||||
$id_group = $component['id_group'];
|
||||
$id_plugin = $component['id_plugin'];
|
||||
$plugin_user = $component['plugin_user'];
|
||||
$plugin_pass = io_output_password($component['plugin_pass']);
|
||||
$plugin_parameter = $component['plugin_parameter'];
|
||||
$macros = $component['macros'];
|
||||
$max_timeout = $component['max_timeout'];
|
||||
$max_retries = $component['max_retries'];
|
||||
$dynamic_interval = $component['dynamic_interval'];
|
||||
$dynamic_max = $component['dynamic_max'];
|
||||
$dynamic_min = $component['dynamic_min'];
|
||||
$dynamic_two_tailed = $component['dynamic_two_tailed'];
|
||||
$min_warning = $component['min_warning'];
|
||||
$max_warning = $component['max_warning'];
|
||||
$str_warning = $component['str_warning'];
|
||||
$max_critical = $component['max_critical'];
|
||||
$min_critical = $component['min_critical'];
|
||||
$str_critical = $component['str_critical'];
|
||||
$ff_event = $component['min_ff_event'];
|
||||
$history_data = $component['history_data'];
|
||||
$post_process = $component['post_process'];
|
||||
$unit = $component['unit'];
|
||||
$wizard_level = $component['wizard_level'];
|
||||
$critical_instructions = $component['critical_instructions'];
|
||||
$warning_instructions = $component['warning_instructions'];
|
||||
$unknown_instructions = $component['unknown_instructions'];
|
||||
$critical_inverse = $component['critical_inverse'];
|
||||
$warning_inverse = $component['warning_inverse'];
|
||||
$id_category = $component['id_category'];
|
||||
$tags = $component['tags'];
|
||||
$ff_event_normal = $component['min_ff_event_normal'];
|
||||
$ff_event_warning = $component['min_ff_event_warning'];
|
||||
$ff_event_critical = $component['min_ff_event_critical'];
|
||||
$ff_type = $component['ff_type'];
|
||||
$each_ff = $component['each_ff'];
|
||||
$id_component_type = $component['id_modulo'];
|
||||
$name = $component['name'];
|
||||
$type = $component['type'];
|
||||
$description = $component['description'];
|
||||
$max = $component['max'];
|
||||
$min = $component['min'];
|
||||
$module_interval = $component['module_interval'];
|
||||
$tcp_port = $component['tcp_port'];
|
||||
$tcp_rcv = $component['tcp_rcv'];
|
||||
$tcp_send = $component['tcp_send'];
|
||||
$snmp_community = $component['snmp_community'];
|
||||
$snmp_oid = $component['snmp_oid'];
|
||||
$id_module_group = $component['id_module_group'];
|
||||
$id_group = $component['id_group'];
|
||||
$id_plugin = $component['id_plugin'];
|
||||
$plugin_user = $component['plugin_user'];
|
||||
$plugin_pass = io_output_password($component['plugin_pass']);
|
||||
$plugin_parameter = $component['plugin_parameter'];
|
||||
$macros = $component['macros'];
|
||||
$max_timeout = $component['max_timeout'];
|
||||
$max_retries = $component['max_retries'];
|
||||
$dynamic_interval = $component['dynamic_interval'];
|
||||
$dynamic_max = $component['dynamic_max'];
|
||||
$dynamic_min = $component['dynamic_min'];
|
||||
$dynamic_two_tailed = $component['dynamic_two_tailed'];
|
||||
$min_warning = $component['min_warning'];
|
||||
$max_warning = $component['max_warning'];
|
||||
$str_warning = $component['str_warning'];
|
||||
$max_critical = $component['max_critical'];
|
||||
$min_critical = $component['min_critical'];
|
||||
$str_critical = $component['str_critical'];
|
||||
$ff_event = $component['min_ff_event'];
|
||||
$history_data = $component['history_data'];
|
||||
$post_process = $component['post_process'];
|
||||
$unit = $component['unit'];
|
||||
$wizard_level = $component['wizard_level'];
|
||||
$critical_instructions = $component['critical_instructions'];
|
||||
$warning_instructions = $component['warning_instructions'];
|
||||
$unknown_instructions = $component['unknown_instructions'];
|
||||
$critical_inverse = $component['critical_inverse'];
|
||||
$warning_inverse = $component['warning_inverse'];
|
||||
$id_category = $component['id_category'];
|
||||
$tags = $component['tags'];
|
||||
$ff_event_normal = $component['min_ff_event_normal'];
|
||||
$ff_event_warning = $component['min_ff_event_warning'];
|
||||
$ff_event_critical = $component['min_ff_event_critical'];
|
||||
$ff_type = $component['ff_type'];
|
||||
$each_ff = $component['each_ff'];
|
||||
$manufacturer_id = $component['manufacturer_id'];
|
||||
$module_protocol = $component['protocol'];
|
||||
$scan_type = $component['scan_type'];
|
||||
$execution_type = $component['execution_type'];
|
||||
$value = $component['value'];
|
||||
$wmi_class = $component['query_class'];
|
||||
$query_key_field = $component['query_key_field'];
|
||||
$query_Key_wmi = $component['key_string'];
|
||||
$name_oid = $component['name_oid'];
|
||||
$value_oid = $component['value_oid'];
|
||||
$query_filter = $component['query_filters'];
|
||||
$module_enabled = $component['module_enabled'];
|
||||
$enabled = $component['enabled'];
|
||||
|
||||
if ($type >= 15 && $type <= 18) {
|
||||
if ($type >= MODULE_TYPE_REMOTE_SNMP && $type <= MODULE_TYPE_REMOTE_SNMP_PROC) {
|
||||
// New support for snmp v3.
|
||||
$snmp_version = $component['tcp_send'];
|
||||
$snmp3_auth_user = $component['plugin_user'];
|
||||
|
@ -170,7 +183,7 @@ if (isset($id)) {
|
|||
$component['custom_string_2']
|
||||
);
|
||||
$snmp3_security_level = $component['custom_string_3'];
|
||||
} else if ($type >= 34 && $type <= 37) {
|
||||
} else if ($type >= MODULE_TYPE_REMOTE_CMD && $type <= MODULE_TYPE_REMOTE_CMD_INC) {
|
||||
$command_text = $component['tcp_send'];
|
||||
$command_credential_identifier = $component['custom_string_1'];
|
||||
$command_os = $component['custom_string_2'];
|
||||
|
@ -192,7 +205,7 @@ if (isset($id)) {
|
|||
$tcp_send = '';
|
||||
$snmp_community = '';
|
||||
$id_module_group = '';
|
||||
if ($id_component_type == 6) {
|
||||
if ($id_component_type == COMPONENT_TYPE_WMI) {
|
||||
$id_group = 14;
|
||||
} else {
|
||||
$id_group = '';
|
||||
|
@ -238,28 +251,67 @@ if (isset($id)) {
|
|||
$command_text = '';
|
||||
$command_os = 'inherited';
|
||||
$command_credential_identifier = '';
|
||||
|
||||
$macros = '';
|
||||
$manufacturer_id = '';
|
||||
$module_protocol = 'snmp';
|
||||
$scan_type = SCAN_TYPE_FIXED;
|
||||
$execution_type = EXECUTION_TYPE_NETWORK;
|
||||
$value = '';
|
||||
$wmi_class = '';
|
||||
$query_key_field = '';
|
||||
$query_Key_wmi = '';
|
||||
$name_oid = '';
|
||||
$value_oid = '';
|
||||
$query_filter = '';
|
||||
$module_enabled = true;
|
||||
$enabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
$table = new stdClass();
|
||||
|
||||
if ($id_component_type == 6) {
|
||||
|
||||
/**
|
||||
* Common function for adding rows to main table
|
||||
*
|
||||
* @param array $row Array with the data for add.
|
||||
* @param mixed $id If added, the DOM id for this block.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function push_table_row($row, $id=false)
|
||||
{
|
||||
global $table;
|
||||
|
||||
if ($id) {
|
||||
$data = [$id => $row];
|
||||
} else {
|
||||
$data = [$row];
|
||||
}
|
||||
|
||||
$table->data = array_merge($table->data, $data);
|
||||
}
|
||||
|
||||
|
||||
$remote_components_path = $config['homedir'].'/godmode/modules/';
|
||||
if ($id_component_type == COMPONENT_TYPE_WMI) {
|
||||
$categories = [
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
];
|
||||
include $config['homedir'].'/godmode/modules/manage_network_components_form_common.php';
|
||||
include $config['homedir'].'/godmode/modules/manage_network_components_form_wmi.php';
|
||||
} else if ($id_component_type == 4) {
|
||||
include $remote_components_path.'manage_network_components_form_common.php';
|
||||
include $remote_components_path.'manage_network_components_form_wmi.php';
|
||||
} else if ($id_component_type == COMPONENT_TYPE_PLUGIN) {
|
||||
$categories = [
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
];
|
||||
include $config['homedir'].'/godmode/modules/manage_network_components_form_common.php';
|
||||
include $config['homedir'].'/godmode/modules/manage_network_components_form_plugin.php';
|
||||
} else if ($id_component_type == 2 || $create_network_from_module) {
|
||||
include $remote_components_path.'manage_network_components_form_common.php';
|
||||
include $remote_components_path.'manage_network_components_form_plugin.php';
|
||||
} else if ($id_component_type == COMPONENT_TYPE_WIZARD) {
|
||||
$categories = [
|
||||
3,
|
||||
4,
|
||||
|
@ -269,8 +321,19 @@ if ($id_component_type == 6) {
|
|||
$categories[] = 10;
|
||||
}
|
||||
|
||||
include $config['homedir'].'/godmode/modules/manage_network_components_form_common.php';
|
||||
include $config['homedir'].'/godmode/modules/manage_network_components_form_network.php';
|
||||
include $remote_components_path.'manage_network_components_form_wizard.php';
|
||||
} else if ($id_component_type == COMPONENT_TYPE_NETWORK || $create_network_from_module) {
|
||||
$categories = [
|
||||
3,
|
||||
4,
|
||||
5,
|
||||
];
|
||||
if (enterprise_installed()) {
|
||||
$categories[] = 10;
|
||||
}
|
||||
|
||||
include $remote_components_path.'manage_network_components_form_common.php';
|
||||
include $remote_components_path.'manage_network_components_form_network.php';
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
@ -291,15 +354,10 @@ if (defined('METACONSOLE')) {
|
|||
$table->headstyle[0] = 'text-align: center';
|
||||
}
|
||||
|
||||
$table->colspan['description'][1] = 3;
|
||||
$data = [];
|
||||
$data[0] = __('Description');
|
||||
$data[1] = html_print_textarea('description', 2, 65, $description, '', true);
|
||||
push_table_row($data, 'description');
|
||||
|
||||
html_print_table($table);
|
||||
|
||||
echo '<div class="action-buttons" style="width: '.$table->width.'">';
|
||||
html_print_button(__('Go back'), 'go_back', false, 'history.go(-1);', 'class="sub cancel"');
|
||||
html_print_input_hidden('id_component_type', $id_component_type);
|
||||
if ($id) {
|
||||
html_print_input_hidden('update_component', 1);
|
||||
|
|
|
@ -23,23 +23,6 @@ if (! check_acl($config['id_user'], 0, 'PM') && ! check_acl($config['id_user'],
|
|||
return;
|
||||
}
|
||||
|
||||
include_javascript_d3();
|
||||
|
||||
|
||||
function push_table_row($row, $id=false)
|
||||
{
|
||||
global $table;
|
||||
|
||||
if ($id) {
|
||||
$data = [$id => $row];
|
||||
} else {
|
||||
$data = [$row];
|
||||
}
|
||||
|
||||
$table->data = array_merge($table->data, $data);
|
||||
}
|
||||
|
||||
|
||||
$table->id = 'network_component';
|
||||
$table->width = '100%';
|
||||
$table->class = 'databox';
|
||||
|
@ -323,7 +306,11 @@ $table->data[12][0] = __('Unknown instructions').ui_print_help_tip(__('Instructi
|
|||
$table->data[12][1] = html_print_textarea('unknown_instructions', 2, 65, $unknown_instructions, '', true);
|
||||
$table->colspan[12][1] = 3;
|
||||
|
||||
$next_row = 13;
|
||||
$table->data[13][0] = __('Description');
|
||||
$table->data[13][1] = html_print_textarea('description', 2, 65, $description, '', true);
|
||||
$table->colspan[13][1] = 3;
|
||||
|
||||
$next_row = 14;
|
||||
|
||||
if (check_acl($config['id_user'], 0, 'PM')) {
|
||||
$table->data[$next_row][0] = __('Category');
|
||||
|
|
|
@ -187,8 +187,21 @@ $data[1] = html_print_extended_select_for_post_process(
|
|||
false,
|
||||
true
|
||||
);
|
||||
$data[2] = '';
|
||||
$data[3] = '';
|
||||
|
||||
$data[2] = __('Name OID').' '.ui_print_help_icon('xxx', true);
|
||||
$data[3] = html_print_input_text_extended(
|
||||
'name_oid',
|
||||
$name_oid,
|
||||
'name_oid',
|
||||
'',
|
||||
30,
|
||||
10000,
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
true
|
||||
);
|
||||
|
||||
push_table_row($data, 'field_process');
|
||||
|
||||
// Advanced stuff.
|
||||
|
|
|
@ -0,0 +1,839 @@
|
|||
<?php
|
||||
// Pandora FMS - http://pandorafms.com
|
||||
// ==================================================
|
||||
// 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.
|
||||
global $config;
|
||||
require_once $config['homedir'].'/include/graphs/functions_d3.php';
|
||||
|
||||
check_login();
|
||||
include_javascript_d3();
|
||||
|
||||
if (!check_acl($config['id_user'], 0, 'PM')
|
||||
&& !check_acl($config['id_user'], 0, 'AW')
|
||||
) {
|
||||
db_pandora_audit('ACL Violation', 'Trying to access Agent Management');
|
||||
include 'general/noaccess.php';
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add to the table the extra fields.
|
||||
*
|
||||
* @param array $extra_fields Array with the extra fields needed.
|
||||
* @param string $protocol Protocol for define the text.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function generateExtraFields($extra_fields, $protocol)
|
||||
{
|
||||
global $table;
|
||||
$cntFields = 0;
|
||||
|
||||
foreach ($extra_fields as $k => $field) {
|
||||
// Avoid the not extra fields.
|
||||
if (preg_match('/extra_field_/', $k) === 0) {
|
||||
continue;
|
||||
} else {
|
||||
$cntFields++;
|
||||
}
|
||||
|
||||
// Get the number of extra field.
|
||||
$tmpExtraField = explode('_', $k);
|
||||
$idField = $tmpExtraField[2];
|
||||
|
||||
if ($protocol === 'snmp') {
|
||||
$extraFieldText = '_oid_'.$idField.'_';
|
||||
$rowId = 'pluginRow-'.$protocol.'Row';
|
||||
} else if ($protocol === 'wmi') {
|
||||
$extraFieldText = '_field_wmi_'.$idField.'_';
|
||||
$rowId = $protocol.'Row';
|
||||
}
|
||||
|
||||
$data = [];
|
||||
$data[0] = '<div style="text-align: right;">'.$extraFieldText.'</div>';
|
||||
$data[1] = html_print_input_text_extended(
|
||||
'extra_field_'.$protocol.'_'.$idField,
|
||||
$field,
|
||||
'extra_field_'.$protocol.'_'.$idField,
|
||||
'',
|
||||
100,
|
||||
10000,
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
true
|
||||
);
|
||||
|
||||
$table->colspan['oid-list-'.$rowId.'-row-'.$idField][1] = 3;
|
||||
push_table_row($data, 'oid-list-'.$rowId.'-row-'.$idField);
|
||||
}
|
||||
|
||||
$data = [];
|
||||
$image_add = html_print_div(
|
||||
[
|
||||
'id' => 'add_field_button',
|
||||
'class' => 'float-right clickable',
|
||||
'content' => html_print_image(
|
||||
'images/add.png',
|
||||
true,
|
||||
[
|
||||
'title' => __('Add a macro oid'),
|
||||
'onclick' => 'manageComponentFields(\'add\', \'oid-list-'.$rowId.'\');',
|
||||
]
|
||||
),
|
||||
],
|
||||
true
|
||||
);
|
||||
|
||||
$image_del = html_print_div(
|
||||
[
|
||||
'id' => 'del_field_button',
|
||||
'class' => 'float-right',
|
||||
'style' => $cntFields <= 1 ? 'opacity: 0.5;' : '',
|
||||
'content' => html_print_image(
|
||||
'images/cross.png',
|
||||
true,
|
||||
[
|
||||
'title' => __('Remove last macro oid'),
|
||||
'onclick' => 'manageComponentFields(\'del\', \'oid-list-'.$rowId.'\');',
|
||||
'style' => 'margin-left: 1em;',
|
||||
]
|
||||
),
|
||||
],
|
||||
true
|
||||
);
|
||||
|
||||
$data[0] = html_print_div(
|
||||
[
|
||||
'id' => 'combo_oid_button',
|
||||
'content' => $image_del.$image_add,
|
||||
],
|
||||
true
|
||||
);
|
||||
|
||||
push_table_row($data, 'manage-oid-list-'.$rowId);
|
||||
}
|
||||
|
||||
|
||||
// Get the data.
|
||||
$module_type_list = [
|
||||
MODULE_TYPE_NUMERIC => __('Numeric'),
|
||||
MODULE_TYPE_INCREMENTAL => __('Incremental'),
|
||||
MODULE_TYPE_BOOLEAN => __('Boolean'),
|
||||
MODULE_TYPE_ALPHANUMERIC => __('Alphanumeric'),
|
||||
];
|
||||
|
||||
$module_protocol_list = [
|
||||
'snmp' => 'SNMP',
|
||||
'wmi' => 'WMI',
|
||||
];
|
||||
|
||||
$scan_type_list = [
|
||||
SCAN_TYPE_FIXED => 'Fixed',
|
||||
SCAN_TYPE_DYNAMIC => 'Dynamic',
|
||||
];
|
||||
|
||||
$execution_type_list = [
|
||||
EXECUTION_TYPE_NETWORK => 'Network',
|
||||
EXECUTION_TYPE_PLUGIN => 'Plugin',
|
||||
];
|
||||
// Establish module type value.
|
||||
switch ($type) {
|
||||
case MODULE_TYPE_REMOTE_SNMP:
|
||||
case MODULE_TYPE_GENERIC_DATA:
|
||||
$module_type = MODULE_TYPE_NUMERIC;
|
||||
break;
|
||||
|
||||
case MODULE_TYPE_REMOTE_SNMP_INC:
|
||||
case MODULE_TYPE_GENERIC_DATA_INC:
|
||||
$module_type = MODULE_TYPE_INCREMENTAL;
|
||||
break;
|
||||
|
||||
case MODULE_TYPE_REMOTE_SNMP_STRING:
|
||||
case MODULE_TYPE_GENERIC_DATA_STRING:
|
||||
$module_type = MODULE_TYPE_ALPHANUMERIC;
|
||||
break;
|
||||
|
||||
case MODULE_TYPE_REMOTE_SNMP_PROC:
|
||||
case MODULE_TYPE_GENERIC_PROC:
|
||||
$module_type = MODULE_TYPE_BOOLEAN;
|
||||
break;
|
||||
|
||||
default:
|
||||
$module_type = MODULE_TYPE_NUMERIC;
|
||||
break;
|
||||
}
|
||||
|
||||
if (empty($query_filter) === false) {
|
||||
$query_filter = json_decode($query_filter, true);
|
||||
}
|
||||
|
||||
$component_group_list = network_components_get_groups();
|
||||
|
||||
// List of server plugins related with Wizard SNMP.
|
||||
$server_plugin_data = [];
|
||||
$server_plugin_list = [];
|
||||
$plugins = db_get_all_rows_sql(
|
||||
'SELECT id, description, execute, name, macros, parameters FROM tplugin'
|
||||
);
|
||||
foreach ($plugins as $plugin) {
|
||||
$server_plugin_list[$plugin['id']] = $plugin['name'];
|
||||
$server_plugin_data[$plugin['id']] = [
|
||||
'description' => $plugin['description'],
|
||||
'name' => $plugin['name'],
|
||||
'parameters' => $plugin['parameters'],
|
||||
'macros' => array_reverse(json_decode($plugin['macros'], true)),
|
||||
'execute' => $plugin['execute'],
|
||||
'macrosElement' => base64_encode(json_encode(io_safe_output(json_decode($macros, true)))),
|
||||
];
|
||||
}
|
||||
|
||||
// Store the plugin data for JS managing in JSON format.
|
||||
$hiddenPluginServers = '';
|
||||
foreach ($server_plugin_data as $index => $plugin) {
|
||||
// Description can have special chars that would crash Javascript.
|
||||
$plugin['description'] = mb_strimwidth(io_safe_output($plugin['description']), 0, 80, '...');
|
||||
$hiddenPluginServers .= html_print_input_hidden(
|
||||
'server_plugin_data_'.$index,
|
||||
json_encode(io_safe_input($plugin))
|
||||
);
|
||||
}
|
||||
|
||||
// Generate needed OID macros.
|
||||
$extra_fields_names = [];
|
||||
foreach ($extra_fields as $k => $field) {
|
||||
$extra_fields_names[$k] = $module_protocol === 'snmp' ? '_oid_'.$k.'_' : $k;
|
||||
}
|
||||
|
||||
// Convert the string DB format of macros to JSON.
|
||||
$macros = json_decode($macros);
|
||||
// Only for extra field generate purposes.
|
||||
if (empty($macros) === true) {
|
||||
$macros = ['extra_field_1' => ''];
|
||||
}
|
||||
|
||||
//
|
||||
// Construction of form.
|
||||
//
|
||||
$table->id = 'network_component';
|
||||
$table->width = '100%';
|
||||
$table->class = 'databox';
|
||||
$table->style = [];
|
||||
$table->style[0] = 'font-weight: bold';
|
||||
$table->style[2] = 'font-weight: bold';
|
||||
$table->colspan = [];
|
||||
if (!enterprise_installed()) {
|
||||
$table->colspan[0][1] = 3;
|
||||
}
|
||||
|
||||
$table->data = [];
|
||||
|
||||
$data = [];
|
||||
$data[0] = __('Enabled');
|
||||
$data[1] = html_print_checkbox_switch(
|
||||
'enabled',
|
||||
1,
|
||||
$enabled,
|
||||
true,
|
||||
false,
|
||||
'',
|
||||
false
|
||||
);
|
||||
|
||||
$data[2] = __('Add by default');
|
||||
$data[3] = html_print_checkbox_switch(
|
||||
'module_enabled',
|
||||
1,
|
||||
$module_enabled,
|
||||
true,
|
||||
false,
|
||||
'',
|
||||
false
|
||||
);
|
||||
|
||||
push_table_row($data, 'module-enable-row');
|
||||
|
||||
$data = [];
|
||||
$data[0] = __('Module name');
|
||||
$data[1] = html_print_input_text_extended(
|
||||
'name',
|
||||
$name,
|
||||
'name',
|
||||
'',
|
||||
50,
|
||||
255,
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
true
|
||||
);
|
||||
|
||||
$data[2] = __('Module protocol');
|
||||
$data[3] = html_print_select(
|
||||
$module_protocol_list,
|
||||
'module_protocol',
|
||||
$module_protocol,
|
||||
'manageVisibleFields()',
|
||||
'',
|
||||
'',
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
''
|
||||
).' '.html_print_image(
|
||||
'images/'.$module_protocol.'.png',
|
||||
true,
|
||||
[
|
||||
'title' => strtoupper($module_protocol).' '.__('Protocol'),
|
||||
'class' => 'add_comments_button',
|
||||
'style' => 'width: 18px;',
|
||||
'id' => 'module_protocol_symbol',
|
||||
]
|
||||
);
|
||||
$type = 4;
|
||||
$data[4] = html_print_input_hidden('type', $type, true);
|
||||
|
||||
push_table_row($data, 'module-name-type-row');
|
||||
|
||||
$data = [];
|
||||
|
||||
$data[0] = __('Name OID');
|
||||
$data[1] = html_print_input_text('name_oid', $name_oid, '', 50, 255, true);
|
||||
|
||||
$data[2] = __('Manufacturer ID');
|
||||
$data[3] = html_print_select_from_sql(
|
||||
'SELECT manufacturer as `id`, manufacturer FROM tpen GROUP BY manufacturer',
|
||||
'manufacturer_id',
|
||||
$manufacturer_id,
|
||||
'',
|
||||
'All',
|
||||
'',
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
''
|
||||
);
|
||||
|
||||
push_table_row($data, 'manufacturer-nameOID-snmpRow-row');
|
||||
|
||||
$data = [];
|
||||
|
||||
$data[0] = __('Module type');
|
||||
$data[1] = html_print_select(
|
||||
$module_type_list,
|
||||
'module_type',
|
||||
$module_type,
|
||||
'changeModuleType()',
|
||||
'',
|
||||
'',
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
''
|
||||
);
|
||||
|
||||
$data[2] = __('Component Group');
|
||||
$data[3] = html_print_select(
|
||||
$component_group_list,
|
||||
'id_group',
|
||||
$id_group,
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
''
|
||||
);
|
||||
|
||||
push_table_row($data, 'moduleType-blockName-row');
|
||||
|
||||
$data = [];
|
||||
|
||||
$data[0] = __('Module unit');
|
||||
$data[1] = html_print_extended_select_for_unit(
|
||||
'unit',
|
||||
$unit,
|
||||
'',
|
||||
'',
|
||||
'0',
|
||||
false,
|
||||
true,
|
||||
false,
|
||||
false
|
||||
);
|
||||
|
||||
push_table_row($data, 'moduleUnit-blockName-row');
|
||||
|
||||
$data = [];
|
||||
$data[0] = __('Warning');
|
||||
// Warning interval values.
|
||||
$data[1] = '<span class="minmax_values" id="warning_minmax_values">';
|
||||
$data[1] .= '<em>'.__('Min.').'</em> ';
|
||||
$data[1] .= html_print_input_text('min_warning', $min_warning, '', 5, 15, true);
|
||||
$data[1] .= '<br /><em>'.__('Max.').'</em> ';
|
||||
$data[1] .= html_print_input_text('max_warning', $max_warning, '', 5, 15, true);
|
||||
$data[1] .= '</span>';
|
||||
// Warning string values.
|
||||
$data[1] .= '<span class="string_values" id="warning_string_values"><em>'.__('String').' </em> ';
|
||||
$data[1] .= html_print_input_text('str_warning', $str_warning, '', 5, 1024, true).'</span>';
|
||||
// Warning inverse values.
|
||||
$data[1] .= '<br /><em>'.__('Inverse interval').'</em> ';
|
||||
$data[1] .= html_print_checkbox('warning_inverse', 1, $warning_inverse, true);
|
||||
|
||||
$data[2] = '<svg id="svg_dinamic" width="500" height="300"> </svg>';
|
||||
$table->colspan['warning-svg-row'][2] = 2;
|
||||
$table->rowspan['warning-svg-row'][2] = 3;
|
||||
|
||||
push_table_row($data, 'warning-svg-row');
|
||||
|
||||
$data = [];
|
||||
$data[0] = __('Critical');
|
||||
// Critical interval values.
|
||||
$data[1] = '<span class="minmax_values" id="critical_minmax_values">';
|
||||
$data[1] .= '<em>'.__('Min.').'</em> ';
|
||||
$data[1] .= html_print_input_text(
|
||||
'min_critical',
|
||||
$min_critical,
|
||||
'',
|
||||
5,
|
||||
15,
|
||||
true
|
||||
);
|
||||
$data[1] .= '<br /><em>'.__('Max.').'</em> ';
|
||||
$data[1] .= html_print_input_text(
|
||||
'max_critical',
|
||||
$max_critical,
|
||||
'',
|
||||
5,
|
||||
15,
|
||||
true
|
||||
);
|
||||
$data[1] .= '</span>';
|
||||
// Critical string values.
|
||||
$data[1] .= '<span class="string_values" id="critical_string_values"><em>'.__('String').' </em> ';
|
||||
$data[1] .= html_print_input_text('str_critical', $str_critical, '', 5, 1024, true).'</span>';
|
||||
// Critical inverse values.
|
||||
$data[1] .= '<br /><em>'.__('Inverse interval').'</em> ';
|
||||
$data[1] .= html_print_checkbox('critical_inverse', 1, $critical_inverse, true);
|
||||
|
||||
push_table_row($data, 'critical-row');
|
||||
|
||||
$data = [];
|
||||
$data[0] = __('Description');
|
||||
$data[1] = html_print_textarea('description', 2, 65, $description, '', true);
|
||||
$table->colspan['module-description-row'][1] = 3;
|
||||
|
||||
push_table_row($data, 'module-description-row');
|
||||
|
||||
$data = [];
|
||||
$data[0] = __('Scan Type');
|
||||
$data[1] = html_print_select(
|
||||
$scan_type_list,
|
||||
'scan_type',
|
||||
$scan_type,
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
''
|
||||
);
|
||||
|
||||
$data[2] = __('Execution type');
|
||||
$data[3] = html_print_select(
|
||||
$execution_type_list,
|
||||
'execution_type',
|
||||
$execution_type,
|
||||
'manageVisibleFields()',
|
||||
'',
|
||||
'',
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
''
|
||||
);
|
||||
|
||||
push_table_row($data, 'scan-execution-row');
|
||||
|
||||
//
|
||||
// SNMP rows.
|
||||
//
|
||||
$data = [];
|
||||
$data[0] = __('Value OID');
|
||||
$data[1] = html_print_input_text_extended(
|
||||
'value_oid',
|
||||
(string) $value,
|
||||
'value_oid',
|
||||
'',
|
||||
100,
|
||||
10000,
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
true
|
||||
);
|
||||
$table->colspan['value-oid-networkRow-snmpRow'][1] = 3;
|
||||
push_table_row($data, 'value-oid-networkRow-snmpRow');
|
||||
|
||||
$data = [];
|
||||
$data[0] = __('Macros OID');
|
||||
|
||||
push_table_row($data, 'title-oid-macros-pluginRow-snmpRow');
|
||||
|
||||
// Generation of extra fields needed.
|
||||
generateExtraFields($macros, 'snmp');
|
||||
|
||||
$data = [];
|
||||
$data[0] = __('Value operation');
|
||||
$data[1] = html_print_input_text_extended(
|
||||
'value_operation_snmp',
|
||||
$macros->value_operation,
|
||||
'value_operation_snmp',
|
||||
'',
|
||||
100,
|
||||
10000,
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
true
|
||||
);
|
||||
$table->colspan['value-operation-pluginRow-snmpRow'][1] = 3;
|
||||
push_table_row($data, 'value-operation-pluginRow-snmpRow');
|
||||
|
||||
$data = [];
|
||||
$data[0] = __('Satellite execution');
|
||||
$data[1] = html_print_input_text_extended(
|
||||
'satellite_execution_snmp',
|
||||
$macros->satellite_execution,
|
||||
'satellite_execution_snmp',
|
||||
'',
|
||||
100,
|
||||
10000,
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
true
|
||||
);
|
||||
$table->colspan['satellite-execution-pluginRow-snmpRow'][1] = 3;
|
||||
push_table_row($data, 'satellite-execution-pluginRow-snmpRow');
|
||||
|
||||
$data = [];
|
||||
$data[0] = __('Server plugin');
|
||||
$data[1] = html_print_select(
|
||||
$server_plugin_list,
|
||||
'server_plugin_snmp',
|
||||
$macros->server_plugin,
|
||||
'changePlugin()',
|
||||
'',
|
||||
'',
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
''
|
||||
).' <span id="selected_plugin_description_snmp"></span>';
|
||||
|
||||
push_table_row($data, 'server-plugin-pluginRow-snmpRow');
|
||||
|
||||
// The creation of this fields will be dynamically.
|
||||
$data = [];
|
||||
$data[0] = 'field0';
|
||||
$data[1] = html_print_input_text_extended(
|
||||
'field0_snmp_field',
|
||||
'',
|
||||
'field0_snmp_fields',
|
||||
'',
|
||||
30,
|
||||
255,
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
true
|
||||
);
|
||||
|
||||
push_table_row($data, 'plugin-snmp-fields-dynamicMacroRow-pluginRow-snmpRow-0');
|
||||
|
||||
//
|
||||
// WMI Fields.
|
||||
//
|
||||
$data = [];
|
||||
$data[0] = __('WMI class');
|
||||
$data[1] = html_print_input_text_extended(
|
||||
'wmi_class',
|
||||
$wmi_class,
|
||||
'wmi_class',
|
||||
'',
|
||||
100,
|
||||
10000,
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
true
|
||||
);
|
||||
$table->colspan['wmi-class-wmiRow'][1] = 3;
|
||||
push_table_row($data, 'wmi-class-wmiRow');
|
||||
|
||||
$data = [];
|
||||
$data[0] = __('Query key field').' (_field_wmi_0_)';
|
||||
$data[1] = html_print_input_text_extended(
|
||||
'query_key_field',
|
||||
$query_key_field,
|
||||
'query_key_field',
|
||||
'',
|
||||
100,
|
||||
10000,
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
true
|
||||
);
|
||||
$table->colspan['query-key-field-wmiRow'][1] = 3;
|
||||
push_table_row($data, 'query-key-field-wmiRow');
|
||||
|
||||
$data = [];
|
||||
$data[0] = __('Query extra fields');
|
||||
|
||||
push_table_row($data, 'title-extra-field-wmiRow');
|
||||
|
||||
// Generation of extra fields needed.
|
||||
generateExtraFields($macros, 'wmi');
|
||||
|
||||
$data = [];
|
||||
$data[0] = __('Query filters');
|
||||
$table->style[0] = 'font-weight: bold;';
|
||||
|
||||
push_table_row($data, 'title-query-filters-wmiRow');
|
||||
|
||||
$data = [];
|
||||
$data[0] = '<div style="text-align: right;">'.__('Scan').'</div>';
|
||||
$data[1] = html_print_input_text_extended(
|
||||
'query_filter_scan',
|
||||
$query_filter['scan'],
|
||||
'query_filter_scan',
|
||||
'',
|
||||
100,
|
||||
10000,
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
true
|
||||
);
|
||||
$table->colspan['query-filter-scan-wmiRow'][1] = 3;
|
||||
push_table_row($data, 'query-filter-scan-wmiRow');
|
||||
|
||||
if ($execution_type == EXECUTION_TYPE_NETWORK) {
|
||||
$data = [];
|
||||
$data[0] = '<div style="text-align: right;">'.__('Execution').'</div>';
|
||||
$data[1] = html_print_input_text_extended(
|
||||
'query_filter_execution',
|
||||
$query_filter['execution'],
|
||||
'query_filter_execution',
|
||||
'',
|
||||
100,
|
||||
10000,
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
true
|
||||
);
|
||||
$table->colspan['query-filter-execution-wmiRow'][1] = 3;
|
||||
push_table_row($data, 'query-filter-execution-wmiRow');
|
||||
}
|
||||
|
||||
|
||||
$data = [];
|
||||
$data[0] = __('Field value');
|
||||
$data[1] = html_print_input_number(
|
||||
[
|
||||
'name' => 'field_value_filter',
|
||||
'value' => $query_filter['field'],
|
||||
'id' => 'field_value_filter',
|
||||
'min' => 0,
|
||||
'return' => true,
|
||||
]
|
||||
);
|
||||
|
||||
$data[2] = __('Key string');
|
||||
$data[3] = html_print_input_text_extended(
|
||||
'key_string_filter',
|
||||
$query_filter['key_string'],
|
||||
'key_string_filter',
|
||||
'',
|
||||
30,
|
||||
255,
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
true
|
||||
);
|
||||
|
||||
push_table_row($data, 'filters-list-fields-networkRow-wmiRow');
|
||||
|
||||
$data = [];
|
||||
$data[0] = __('Value operation');
|
||||
$data[1] = html_print_input_text_extended(
|
||||
'value_operation_wmi',
|
||||
$macros->value_operation,
|
||||
'value_operation_wmi',
|
||||
'',
|
||||
100,
|
||||
10000,
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
true
|
||||
);
|
||||
$table->colspan['value-operation-pluginRow-wmiRow'][1] = 3;
|
||||
push_table_row($data, 'value-operation-pluginRow-wmiRow');
|
||||
|
||||
$data = [];
|
||||
$data[0] = __('Satellite execution');
|
||||
$data[1] = html_print_input_text_extended(
|
||||
'satellite_execution_wmi',
|
||||
$macros->satellite_execution,
|
||||
'satellite_execution_wmi',
|
||||
'',
|
||||
100,
|
||||
10000,
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
true
|
||||
);
|
||||
$table->colspan['satellite-execution-pluginRow-wmiRow'][1] = 3;
|
||||
push_table_row($data, 'satellite-execution-pluginRow-wmiRow');
|
||||
|
||||
$data = [];
|
||||
$data[0] = __('Server plugin');
|
||||
$data[1] = html_print_select(
|
||||
$server_plugin_list,
|
||||
'server_plugin_wmi',
|
||||
$macros->server_plugin,
|
||||
'changePlugin()',
|
||||
'',
|
||||
'',
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
''
|
||||
).' <span id="selected_plugin_description_wmi"></span>';
|
||||
|
||||
push_table_row($data, 'server-plugin-pluginRow-wmiRow');
|
||||
|
||||
// The creation of this fields will be dynamically.
|
||||
$data = [];
|
||||
$data[0] = 'field0';
|
||||
$data[1] = html_print_input_text_extended(
|
||||
'field0_wmi_field',
|
||||
'',
|
||||
'field0_wmi_fields',
|
||||
'',
|
||||
30,
|
||||
255,
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
true
|
||||
);
|
||||
|
||||
push_table_row($data, 'plugin-wmi-fields-dynamicMacroRow-pluginRow-wmiRow-0');
|
||||
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
// Definition of constants
|
||||
const EXECUTION_TYPE_NETWORK =
|
||||
<?php
|
||||
echo '"'.EXECUTION_TYPE_NETWORK.'"';
|
||||
?>
|
||||
;
|
||||
const EXECUTION_TYPE_PLUGIN =
|
||||
<?php
|
||||
echo '"'.EXECUTION_TYPE_PLUGIN.'"';
|
||||
?>
|
||||
;
|
||||
const MODULE_TYPE_NUMERIC =
|
||||
<?php
|
||||
echo '"'.MODULE_TYPE_NUMERIC.'"';
|
||||
?>
|
||||
;
|
||||
const MODULE_TYPE_INCREMENTAL =
|
||||
<?php
|
||||
echo '"'.MODULE_TYPE_INCREMENTAL.'"';
|
||||
?>
|
||||
;
|
||||
const MODULE_TYPE_BOOLEAN =
|
||||
<?php
|
||||
echo '"'.MODULE_TYPE_BOOLEAN.'"';
|
||||
?>
|
||||
;
|
||||
const MODULE_TYPE_ALPHANUMERIC =
|
||||
<?php
|
||||
echo '"'.MODULE_TYPE_ALPHANUMERIC.'"';
|
||||
?>
|
||||
;
|
||||
|
||||
const MODULE_TYPE_REMOTE_SNMP =
|
||||
<?php
|
||||
echo '"'.MODULE_TYPE_REMOTE_SNMP.'"';
|
||||
?>
|
||||
;
|
||||
const MODULE_TYPE_REMOTE_SNMP_INC =
|
||||
<?php
|
||||
echo '"'.MODULE_TYPE_REMOTE_SNMP_INC.'"';
|
||||
?>
|
||||
;
|
||||
const MODULE_TYPE_REMOTE_SNMP_STRING =
|
||||
<?php
|
||||
echo '"'.MODULE_TYPE_REMOTE_SNMP_STRING.'"';
|
||||
?>
|
||||
;
|
||||
const MODULE_TYPE_REMOTE_SNMP_PROC =
|
||||
<?php
|
||||
echo '"'.MODULE_TYPE_REMOTE_SNMP_PROC.'"';
|
||||
?>
|
||||
;
|
||||
const MODULE_TYPE_GENERIC_DATA =
|
||||
<?php
|
||||
echo '"'.MODULE_TYPE_GENERIC_DATA.'"';
|
||||
?>
|
||||
;
|
||||
const MODULE_TYPE_GENERIC_PROC =
|
||||
<?php
|
||||
echo '"'.MODULE_TYPE_GENERIC_PROC.'"';
|
||||
?>
|
||||
;
|
||||
const MODULE_TYPE_GENERIC_DATA_STRING =
|
||||
<?php
|
||||
echo '"'.MODULE_TYPE_GENERIC_DATA_STRING.'"';
|
||||
?>
|
||||
;
|
||||
const MODULE_TYPE_GENERIC_DATA_INC =
|
||||
<?php
|
||||
echo '"'.MODULE_TYPE_GENERIC_DATA_INC.'"';
|
||||
?>
|
||||
;
|
||||
|
||||
$(document).ready(function(){
|
||||
// Show the needed fields.
|
||||
manageVisibleFields();
|
||||
// Show the proper module type
|
||||
changeModuleType();
|
||||
$(
|
||||
"#network_component-plugin-snmp-fields-dynamicMacroRow-pluginRow-snmpRow-0"
|
||||
).attr("style", "display: none;");
|
||||
// Change plugin values and macros.
|
||||
changePlugin();
|
||||
});
|
||||
|
||||
</script>
|
File diff suppressed because it is too large
Load Diff
|
@ -50,7 +50,9 @@ define('EVENT_NO_VALIDATED', 3);
|
|||
define('AGENT_ENABLED', 0);
|
||||
define('AGENT_DISABLED', 1);
|
||||
|
||||
|
||||
// Module disabled status.
|
||||
define('MODULE_ENABLED', 0);
|
||||
define('MODULE_DISABLED', 1);
|
||||
|
||||
// Error report codes.
|
||||
define('NOERR', 11111);
|
||||
|
@ -347,6 +349,7 @@ define('MODULE_PREDICTION', 5);
|
|||
define('MODULE_WMI', 6);
|
||||
define('MODULE_WEB', 7);
|
||||
define('MODULE_WUX', 8);
|
||||
define('MODULE_WIZARD', 9);
|
||||
|
||||
// Type of Modules of Prediction.
|
||||
define('MODULE_PREDICTION_SERVICE', 2);
|
||||
|
@ -674,3 +677,54 @@ define('W_CREATE_MODULE', 3);
|
|||
define('W_CREATE_ALERT', 4);
|
||||
define('W_CREATE_TASK', 5);
|
||||
define('WELCOME_FINISHED', -1);
|
||||
|
||||
// Fixed tnetwork_component values.
|
||||
define('MODULE_TYPE_NUMERIC', 1);
|
||||
define('MODULE_TYPE_INCREMENTAL', 2);
|
||||
define('MODULE_TYPE_BOOLEAN', 3);
|
||||
define('MODULE_TYPE_ALPHANUMERIC', 4);
|
||||
define('SCAN_TYPE_FIXED', 1);
|
||||
define('SCAN_TYPE_DYNAMIC', 2);
|
||||
define('EXECUTION_TYPE_NETWORK', 1);
|
||||
define('EXECUTION_TYPE_PLUGIN', 2);
|
||||
|
||||
// Id of component type.
|
||||
define('COMPONENT_TYPE_NETWORK', 2);
|
||||
define('COMPONENT_TYPE_PLUGIN', 4);
|
||||
define('COMPONENT_TYPE_WMI', 6);
|
||||
define('COMPONENT_TYPE_WIZARD', 9);
|
||||
|
||||
// Wizard Internal Plugins.
|
||||
define('PLUGIN_WIZARD_SNMP_MODULE', 1);
|
||||
define('PLUGIN_WIZARD_SNMP_PROCESS', 2);
|
||||
define('PLUGIN_WIZARD_WMI_MODULE', 3);
|
||||
|
||||
// Module Types.
|
||||
define('MODULE_TYPE_GENERIC_DATA', 1);
|
||||
define('MODULE_TYPE_GENERIC_PROC', 2);
|
||||
define('MODULE_TYPE_GENERIC_DATA_STRING', 3);
|
||||
define('MODULE_TYPE_GENERIC_DATA_INC', 4);
|
||||
define('MODULE_TYPE_GENERIC_DATA_INC_ABS', 5);
|
||||
define('MODULE_TYPE_REMOTE_ICMP_PROC', 6);
|
||||
define('MODULE_TYPE_REMOTE_ICMP', 7);
|
||||
define('MODULE_TYPE_REMOTE_TCP', 8);
|
||||
define('MODULE_TYPE_REMOTE_TCP_PROC', 9);
|
||||
define('MODULE_TYPE_REMOTE_TCP_STRING', 10);
|
||||
define('MODULE_TYPE_REMOTE_TCP_INC', 11);
|
||||
define('MODULE_TYPE_REMOTE_SNMP', 15);
|
||||
define('MODULE_TYPE_REMOTE_SNMP_INC', 16);
|
||||
define('MODULE_TYPE_REMOTE_SNMP_STRING', 17);
|
||||
define('MODULE_TYPE_REMOTE_SNMP_PROC', 18);
|
||||
define('MODULE_TYPE_ASYNC_PROC', 21);
|
||||
define('MODULE_TYPE_ASYNC_DATA', 22);
|
||||
define('MODULE_TYPE_ASYNC_STRING', 23);
|
||||
define('MODULE_TYPE_WEB_ANALYSIS', 25);
|
||||
define('MODULE_TYPE_WEB_DATA', 30);
|
||||
define('MODULE_TYPE_WEB_PROC', 31);
|
||||
define('MODULE_TYPE_WEB_CONTENT_DATA', 32);
|
||||
define('MODULE_TYPE_WEB_CONTENT_STRING', 33);
|
||||
define('MODULE_TYPE_REMOTE_CMD', 34);
|
||||
define('MODULE_TYPE_REMOTE_CMD_PROC', 35);
|
||||
define('MODULE_TYPE_REMOTE_CMD_STRING', 36);
|
||||
define('MODULE_TYPE_REMOTE_CMD_INC', 37);
|
||||
define('MODULE_TYPE_KEEP_ALIVE', 100);
|
||||
|
|
|
@ -1797,6 +1797,7 @@ function html_print_div($options, $return=false)
|
|||
'id',
|
||||
'style',
|
||||
'class',
|
||||
'title',
|
||||
];
|
||||
|
||||
if (isset($options['hidden'])) {
|
||||
|
@ -2224,21 +2225,36 @@ function html_print_input_image($name, $src, $value, $style='', $return=false, $
|
|||
*
|
||||
* The element will have an id like: "hidden-$name"
|
||||
*
|
||||
* @param string $name Input name.
|
||||
* @param string $value Input value.
|
||||
* @param boolean $return Whether to return an output string or echo now (optional, echo by default).
|
||||
* @param string $class Set the class of input.
|
||||
* @param string $name Input name.
|
||||
* @param string $value Input value.
|
||||
* @param boolean $return Whether to return an output string or echo now
|
||||
* (optional, echo by default).
|
||||
* @param string $class Set the class of input.
|
||||
* @param string $attributes String with the needed attributes to add.
|
||||
* @param string $id Specific id.
|
||||
*
|
||||
* @return string HTML code if return parameter is true.
|
||||
*/
|
||||
function html_print_input_hidden($name, $value, $return=false, $class=false)
|
||||
{
|
||||
function html_print_input_hidden(
|
||||
$name,
|
||||
$value,
|
||||
$return=false,
|
||||
$class=false,
|
||||
$attributes=false,
|
||||
$id=''
|
||||
) {
|
||||
if ($class !== false) {
|
||||
$classText = 'class="'.$class.'"';
|
||||
} else {
|
||||
$classText = '';
|
||||
}
|
||||
|
||||
if ($attributes !== false) {
|
||||
$otherAttributes = $attributes;
|
||||
} else {
|
||||
$otherAttributes = '';
|
||||
}
|
||||
|
||||
$separator = '"';
|
||||
|
||||
if (is_string($value)) {
|
||||
|
@ -2247,7 +2263,12 @@ function html_print_input_hidden($name, $value, $return=false, $class=false)
|
|||
}
|
||||
}
|
||||
|
||||
$output = '<input id="hidden-'.$name.'" '.'name="'.$name.'" '.'type="hidden" '.$classText.' '.'value='.$separator.$value.$separator.' />';
|
||||
$idInput = 'hidden-'.$name;
|
||||
if (empty($id) === false) {
|
||||
$idInput = $id;
|
||||
}
|
||||
|
||||
$output = '<input id="'.$idInput.'" name="'.$name.'" type="hidden" '.$classText.' value='.$separator.$value.$separator.' '.$otherAttributes.'/>';
|
||||
|
||||
if ($return) {
|
||||
return $output;
|
||||
|
@ -3042,34 +3063,53 @@ function html_print_checkbox(
|
|||
|
||||
|
||||
/**
|
||||
* Render a checkbox button input switch type. Extended version, use html_print_checkbox_switch() to simplify.
|
||||
* Render a checkbox button input switch type.
|
||||
* Extended version, use html_print_checkbox_switch() to simplify.
|
||||
*
|
||||
* @param string Input name.
|
||||
* @param string Input value.
|
||||
* @param string Set the button to be marked (optional, unmarked by default).
|
||||
* @param bool Disable the button (optional, button enabled by default).
|
||||
* @param string Script to execute when onClick event is triggered (optional).
|
||||
* @param string Optional HTML attributes. It's a free string which will be
|
||||
* @param bool Whether to return an output string or echo now (optional, echo by default).
|
||||
* @param string $name Input name.
|
||||
* @param integer $value Input value.
|
||||
* @param integer $checked Input checked.
|
||||
* @param boolean $disabled Disable the button (optional,
|
||||
* button enabled by default).
|
||||
* @param string $script Script to execute when onClick event
|
||||
* is triggered (optional).
|
||||
* @param string $attributes Optional HTML attributes.
|
||||
* It's a free string which will be.
|
||||
* @param boolean $return Whether to return an output string or echo now
|
||||
* (optional, echo by default).
|
||||
* @param string $id Input id.
|
||||
* @param string $classParent Class for label.
|
||||
*
|
||||
* @return string HTML code if return parameter is true.
|
||||
* @return string Input html.
|
||||
*/
|
||||
|
||||
|
||||
function html_print_checkbox_switch_extended($name, $value, $checked, $disabled, $script, $attributes, $return=false, $id='')
|
||||
{
|
||||
function html_print_checkbox_switch_extended(
|
||||
$name,
|
||||
$value,
|
||||
$checked,
|
||||
$disabled=false,
|
||||
$script='',
|
||||
$attributes='',
|
||||
$return=false,
|
||||
$id='',
|
||||
$classParent=''
|
||||
) {
|
||||
static $idcounter = [];
|
||||
|
||||
// If duplicate names exist, it will start numbering. Otherwise it won't
|
||||
// If duplicate names exist, it will start numbering. Otherwise it won't.
|
||||
if (isset($idcounter[$name])) {
|
||||
$idcounter[$name]++;
|
||||
} else {
|
||||
$idcounter[$name] = 0;
|
||||
}
|
||||
|
||||
$id_aux = preg_replace('/[^a-z0-9\:\;\-\_]/i', '', $name.($idcounter[$name] ? $idcounter[$name] : ''));
|
||||
$id_aux = preg_replace(
|
||||
'/[^a-z0-9\:\;\-\_]/i',
|
||||
'',
|
||||
$name.($idcounter[$name] ? $idcounter[$name] : '')
|
||||
);
|
||||
|
||||
$output = '<label class="p-switch"><input name="'.$name.'" type="checkbox" value="'.$value.'" '.($checked ? 'checked="checked"' : '');
|
||||
$output = '<label class="p-switch '.$classParent.'">';
|
||||
$output .= '<input name="'.$name.'" type="checkbox" value="'.$value.'" '.($checked ? 'checked="checked"' : '');
|
||||
if ($id == '') {
|
||||
$output .= ' id="checkbox-'.$id_aux.'"';
|
||||
} else {
|
||||
|
@ -3903,7 +3943,9 @@ function html_print_input($data, $wrapper='div', $input_only=false)
|
|||
$data['name'],
|
||||
$data['value'],
|
||||
((isset($data['return']) === true) ? $data['return'] : false),
|
||||
((isset($data['class']) === true) ? $data['class'] : false)
|
||||
((isset($data['class']) === true) ? $data['class'] : false),
|
||||
false,
|
||||
((isset($data['id']) === true) ? $data['id'] : '')
|
||||
);
|
||||
break;
|
||||
|
||||
|
@ -4004,6 +4046,21 @@ function html_print_input($data, $wrapper='div', $input_only=false)
|
|||
);
|
||||
break;
|
||||
|
||||
case 'select_for_unit':
|
||||
$output .= html_print_extended_select_for_unit(
|
||||
$data['name'],
|
||||
((isset($data['selected']) === true) ? $data['selected'] : ''),
|
||||
((isset($data['script']) === true) ? $data['script'] : ''),
|
||||
((isset($data['nothing']) === true) ? $data['nothing'] : ''),
|
||||
((isset($data['nothing_value']) === true) ? $data['nothing_value'] : '0'),
|
||||
((isset($data['size']) === true) ? $data['size'] : false),
|
||||
((isset($data['return']) === true) ? $data['return'] : false),
|
||||
((isset($data['select_style']) === true) ? $data['select_style'] : false),
|
||||
((isset($data['unique_name']) === true) ? $data['unique_name'] : true),
|
||||
((isset($data['disabled']) === true) ? $data['disabled'] : false),
|
||||
((isset($data['disabled']) === true) ? $data['disabled'] : 0)
|
||||
);
|
||||
|
||||
case 'submit':
|
||||
$width = (isset($data['width']) === true) ? 'width: '.$data['width'] : 'width: 100%';
|
||||
$output .= '<'.$wrapper.' class="action-buttons" style="'.$width.'">'.html_print_submit_button(
|
||||
|
|
|
@ -769,7 +769,7 @@ function netflow_get_relationships_raw_data(
|
|||
$command = netflow_get_command($options, $filter);
|
||||
|
||||
// Execute nfdump.
|
||||
#$command .= ' -q -o csv -n 10000 -s record/bytes -t '.date($nfdump_date_format, $start_date).'-'.date($nfdump_date_format, $end_date);
|
||||
// $command .= ' -q -o csv -n 10000 -s record/bytes -t '.date($nfdump_date_format, $start_date).'-'.date($nfdump_date_format, $end_date);
|
||||
exec($command, $result);
|
||||
|
||||
if (! is_array($result)) {
|
||||
|
|
|
@ -321,7 +321,7 @@ function ui_print_message($message, $class='', $attributes='', $return=false, $t
|
|||
$output = '<table cellspacing="0" cellpadding="0" id="'.$id.'" '.$attributes.'
|
||||
class="info_box '.$id.' '.$class.' textodialogo" style="'.$force_style.'">
|
||||
<tr>
|
||||
<td class="icon" rowspan="2" style="padding-right: 10px; padding-top: 3px;">'.html_print_image($icon_image, true, false, false, false, false).'</td>
|
||||
<td class="icon" rowspan="2" style="padding-right: 10px; padding-top: 3px; vertical-align: top;">'.html_print_image($icon_image, true, false, false, false, false).'</td>
|
||||
<td class="title" style="text-transform: uppercase; padding-top: 10px;"><b>'.$text_title.'</b></td>
|
||||
<td class="icon" style="text-align: right; padding-right: 3px;">';
|
||||
if (!$no_close_bool) {
|
||||
|
@ -3749,13 +3749,27 @@ function ui_toggle(
|
|||
$main_class='box-shadow white_table_graph',
|
||||
$img_a='images/arrow_down_green.png',
|
||||
$img_b='images/arrow_right_green.png',
|
||||
$clean=false
|
||||
$clean=false,
|
||||
$reverseImg=false,
|
||||
$switch=false,
|
||||
$attributes_switch=''
|
||||
) {
|
||||
// Generate unique Id.
|
||||
$uniqid = uniqid('');
|
||||
|
||||
$image_a = html_print_image($img_a, true, [ 'style' => 'object-fit: contain;' ], true);
|
||||
$image_b = html_print_image($img_b, true, [ 'style' => 'object-fit: contain;' ], true);
|
||||
$image_a = html_print_image(
|
||||
$img_a,
|
||||
true,
|
||||
[ 'style' => 'object-fit: contain;' ],
|
||||
true
|
||||
);
|
||||
$image_b = html_print_image(
|
||||
$img_b,
|
||||
true,
|
||||
[ 'style' => 'object-fit: contain;' ],
|
||||
true
|
||||
);
|
||||
|
||||
// Options.
|
||||
if ($hidden_default) {
|
||||
$style = 'display:none';
|
||||
|
@ -3775,18 +3789,71 @@ function ui_toggle(
|
|||
|
||||
// Link to toggle.
|
||||
$output = '<div class="'.$main_class.'" id="'.$id.'">';
|
||||
$output .= '<div class="'.$header_class.'" style="cursor: pointer;" id="tgl_ctrl_'.$uniqid.'">'.html_print_image(
|
||||
$original,
|
||||
true,
|
||||
[
|
||||
'style' => 'object-fit: contain;',
|
||||
'title' => $title,
|
||||
'id' => 'image_'.$uniqid,
|
||||
]
|
||||
).' <b>'.$name.'</b></div>';
|
||||
// $output .= '<br />';
|
||||
// if (!defined("METACONSOLE"))
|
||||
// $output .= '<br />';
|
||||
$output .= '<div class="'.$header_class.'" style="cursor: pointer;" id="tgl_ctrl_'.$uniqid.'">';
|
||||
if ($reverseImg === false) {
|
||||
if ($switch === true) {
|
||||
$output .= html_print_div(
|
||||
[
|
||||
'class' => 'float-left',
|
||||
'content' => html_print_checkbox_switch_extended(
|
||||
'box_enable_toggle'.$uniqid,
|
||||
1,
|
||||
($hidden_default === true) ? 0 : 1,
|
||||
false,
|
||||
'',
|
||||
$attributes_switch,
|
||||
true
|
||||
),
|
||||
],
|
||||
true
|
||||
);
|
||||
} else {
|
||||
$output .= html_print_image(
|
||||
$original,
|
||||
true,
|
||||
[
|
||||
'style' => 'object-fit: contain; float:right; margin-right:10px;',
|
||||
'title' => $title,
|
||||
'id' => 'image_'.$uniqid,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
$output .= '  ';
|
||||
$output .= '<b>'.$name.'</b>';
|
||||
} else {
|
||||
$output .= $name;
|
||||
if ($switch === true) {
|
||||
$output .= html_print_div(
|
||||
[
|
||||
'class' => 'float-left',
|
||||
'content' => html_print_checkbox_switch_extended(
|
||||
'box_enable_toggle'.$uniqid,
|
||||
1,
|
||||
($hidden_default === true) ? 0 : 1,
|
||||
false,
|
||||
'',
|
||||
'',
|
||||
true
|
||||
),
|
||||
],
|
||||
true
|
||||
);
|
||||
} else {
|
||||
$output .= html_print_image(
|
||||
$original,
|
||||
true,
|
||||
[
|
||||
'style' => 'object-fit: contain; float:right; margin-right:10px;',
|
||||
'title' => $title,
|
||||
'id' => 'image_'.$uniqid,
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$output .= '</div>';
|
||||
|
||||
// Code into a div
|
||||
$output .= "<div id='tgl_div_".$uniqid."' style='".$style.";margin-top: -1px;' class='".$toggle_class."'>\n";
|
||||
$output .= '<div class="'.$container_class.'">';
|
||||
|
@ -3799,16 +3866,28 @@ function ui_toggle(
|
|||
$output .= ' var hide_tgl_ctrl_'.$uniqid.' = '.(int) $hidden_default.";\n";
|
||||
$output .= ' /* <![CDATA[ */'."\n";
|
||||
$output .= " $(document).ready (function () {\n";
|
||||
$output .= " $('#checkbox-box_enable_toggle".$uniqid."').click(function() {\n";
|
||||
$output .= ' if (hide_tgl_ctrl_'.$uniqid.") {\n";
|
||||
$output .= ' hide_tgl_ctrl_'.$uniqid." = 0;\n";
|
||||
$output .= " $('#tgl_div_".$uniqid."').toggle();\n";
|
||||
$output .= " }\n";
|
||||
$output .= " else {\n";
|
||||
$output .= ' hide_tgl_ctrl_'.$uniqid." = 1;\n";
|
||||
$output .= " $('#tgl_div_".$uniqid."').toggle();\n";
|
||||
$output .= " }\n";
|
||||
$output .= " });\n";
|
||||
$output .= " $('#tgl_ctrl_".$uniqid."').click(function() {\n";
|
||||
$output .= ' if (hide_tgl_ctrl_'.$uniqid.") {\n";
|
||||
$output .= ' hide_tgl_ctrl_'.$uniqid." = 0;\n";
|
||||
$output .= " $('#tgl_div_".$uniqid."').toggle();\n";
|
||||
$output .= " $('#image_".$uniqid."').attr({src: '".$image_a."'});\n";
|
||||
$output .= " $('#checkbox-box_enable_toggle".$uniqid."').prop('checked', true);\n";
|
||||
$output .= " }\n";
|
||||
$output .= " else {\n";
|
||||
$output .= ' hide_tgl_ctrl_'.$uniqid." = 1;\n";
|
||||
$output .= " $('#tgl_div_".$uniqid."').toggle();\n";
|
||||
$output .= " $('#image_".$uniqid."').attr({src: '".$image_b."'});\n";
|
||||
$output .= " $('#checkbox-box_enable_toggle".$uniqid."').prop('checked', false);\n";
|
||||
$output .= " }\n";
|
||||
$output .= " });\n";
|
||||
$output .= " });\n";
|
||||
|
|
|
@ -1322,3 +1322,308 @@ function filterByText(selectbox, textbox, textNoData) {
|
|||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Manage network component oid field generation.
|
||||
function manageComponentFields(action, type) {
|
||||
var fieldLines = $("tr[id*=network_component-" + type + "]").length;
|
||||
var protocol = $("#module_protocol").val();
|
||||
if (action === "add") {
|
||||
let lineNumber = fieldLines + 1;
|
||||
let textForAdd =
|
||||
type === "oid-list-pluginRow-snmpRow"
|
||||
? "_oid_" + lineNumber + "_"
|
||||
: lineNumber;
|
||||
|
||||
$("#network_component-manage-" + type).before(
|
||||
$("#network_component-" + type + "-row-1")
|
||||
.clone()
|
||||
.attr("id", "network_component-" + type + "-row-" + lineNumber)
|
||||
);
|
||||
|
||||
$("#network_component-" + type + "-row-" + lineNumber + " input")
|
||||
.attr("name", "extra_field_" + protocol + "_" + lineNumber)
|
||||
.attr("id", "extra_field_" + protocol + "_" + lineNumber);
|
||||
|
||||
$("#network_component-" + type + "-row-" + lineNumber + " td div").html(
|
||||
textForAdd
|
||||
);
|
||||
|
||||
$("#del_field_button")
|
||||
.attr("style", "opacity: 1;")
|
||||
.addClass("clickable");
|
||||
} else if (action === "del") {
|
||||
if (fieldLines >= 2) {
|
||||
$("#network_component-" + type + "-row-" + fieldLines).remove();
|
||||
}
|
||||
|
||||
if (fieldLines == 2) {
|
||||
$("#del_field_button")
|
||||
.attr("style", "opacity: 0.5;")
|
||||
.removeClass("clickable");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Change module type and show/hide the fields needed.
|
||||
function changeModuleType() {
|
||||
var executionType = $("#execution_type").val();
|
||||
var moduleSelected = $("#module_type").val();
|
||||
var moduleProtocol = $("#module_protocol").val();
|
||||
var typeField, toNone, toBlock;
|
||||
|
||||
switch (moduleSelected) {
|
||||
case MODULE_TYPE_NUMERIC:
|
||||
typeField =
|
||||
executionType === EXECUTION_TYPE_PLUGIN || moduleProtocol === "wmi"
|
||||
? MODULE_TYPE_GENERIC_DATA
|
||||
: MODULE_TYPE_REMOTE_SNMP;
|
||||
|
||||
toNone = "string_values";
|
||||
toBlock = "minmax_values";
|
||||
|
||||
break;
|
||||
case MODULE_TYPE_INCREMENTAL:
|
||||
typeField =
|
||||
executionType === EXECUTION_TYPE_PLUGIN || moduleProtocol === "wmi"
|
||||
? MODULE_TYPE_GENERIC_DATA_INC
|
||||
: MODULE_TYPE_REMOTE_SNMP_INC;
|
||||
|
||||
toNone = "string_values";
|
||||
toBlock = "minmax_values";
|
||||
break;
|
||||
case MODULE_TYPE_BOOLEAN:
|
||||
typeField =
|
||||
executionType === EXECUTION_TYPE_PLUGIN || moduleProtocol === "wmi"
|
||||
? MODULE_TYPE_GENERIC_PROC
|
||||
: MODULE_TYPE_REMOTE_SNMP_PROC;
|
||||
|
||||
toNone = "string_values";
|
||||
toBlock = "minmax_values";
|
||||
break;
|
||||
case MODULE_TYPE_ALPHANUMERIC:
|
||||
typeField =
|
||||
executionType === EXECUTION_TYPE_PLUGIN || moduleProtocol === "wmi"
|
||||
? MODULE_TYPE_GENERIC_DATA_STRING
|
||||
: MODULE_TYPE_REMOTE_SNMP_STRING;
|
||||
|
||||
toNone = "minmax_values";
|
||||
toBlock = "string_values";
|
||||
break;
|
||||
default:
|
||||
typeField = "";
|
||||
toNone = "string_values";
|
||||
toBlock = "minmax_values";
|
||||
break;
|
||||
}
|
||||
|
||||
// Show and hide the proper fields.
|
||||
$("." + toNone).css("display", "none");
|
||||
$("." + toBlock).css("display", "block");
|
||||
// Set value to module type.
|
||||
$("#hidden-type").val(typeField);
|
||||
}
|
||||
|
||||
// Manage of the visibility fields for various options
|
||||
// for remote components wizard
|
||||
function manageVisibleFields() {
|
||||
var executionType = $("#execution_type").val();
|
||||
var protocolSelected = $("#module_protocol").val();
|
||||
var symbolName = $("#module_protocol_symbol")
|
||||
.attr("src")
|
||||
.split("/")
|
||||
.pop();
|
||||
var changePath = $("#module_protocol_symbol")
|
||||
.attr("src")
|
||||
.replace(symbolName, protocolSelected + ".png");
|
||||
$("#module_protocol_symbol")
|
||||
.attr("src", changePath)
|
||||
.attr("data-title", protocolSelected.toUpperCase() + " protocol");
|
||||
// Visibility of protocol type.
|
||||
if (protocolSelected === "wmi") {
|
||||
$("tr[id*=wmiRow]").css("display", "table-row");
|
||||
$("tr[id*=snmpRow]").css("display", "none");
|
||||
} else if (protocolSelected === "snmp") {
|
||||
$("tr[id*=wmiRow]").css("display", "none");
|
||||
$("tr[id*=snmpRow]").css("display", "table-row");
|
||||
}
|
||||
// Visibility of execution type.
|
||||
if (executionType === EXECUTION_TYPE_NETWORK) {
|
||||
$("tr[id*=networkRow-" + protocolSelected + "]").css(
|
||||
"display",
|
||||
"table-row"
|
||||
);
|
||||
$("tr[id*=pluginRow]").css("display", "none");
|
||||
} else if (executionType === EXECUTION_TYPE_PLUGIN) {
|
||||
$("tr[id*=networkRow]").css("display", "none");
|
||||
$("tr[id*=pluginRow-" + protocolSelected + "]").css("display", "table-row");
|
||||
// Only row WMI type execution plugin.
|
||||
$("tr#network_component-query-filter-execution-wmiRow").css(
|
||||
"display",
|
||||
"none"
|
||||
);
|
||||
}
|
||||
// Must update the module type.
|
||||
changeModuleType();
|
||||
// Must update the plugin macros.
|
||||
changePlugin();
|
||||
}
|
||||
|
||||
// Plugin managing for wizard components.
|
||||
function changePlugin() {
|
||||
var moduleProtocol = $("#module_protocol").val();
|
||||
var executionType = $("#execution_type").val();
|
||||
var pluginSelected = $("#server_plugin_" + moduleProtocol).val();
|
||||
var pluginAllData = JSON.parse(
|
||||
$("#hidden-server_plugin_data_" + pluginSelected).val()
|
||||
);
|
||||
|
||||
var pluginDescription = pluginAllData.description;
|
||||
var pluginMacros = pluginAllData.macros;
|
||||
console.log(pluginAllData.macrosElement);
|
||||
var pluginMacrosElement = JSON.parse(atob(pluginAllData.macrosElement));
|
||||
console.log(pluginMacrosElement);
|
||||
|
||||
var displayShow = "none";
|
||||
if (executionType == EXECUTION_TYPE_NETWORK) {
|
||||
displayShow = "none";
|
||||
} else {
|
||||
displayShow = "table-row";
|
||||
}
|
||||
|
||||
var cntMacrosToGo = 4;
|
||||
var cntMacrosLine = 0;
|
||||
var thisIdLine = "";
|
||||
// Clear older macros rows.
|
||||
$("tr[id*=dynamicMacroRow-pluginRow-" + moduleProtocol + "Row-N-]").remove();
|
||||
// Hide the template.
|
||||
$(
|
||||
"#network_component-plugin-" +
|
||||
moduleProtocol +
|
||||
"-fields-dynamicMacroRow-pluginRow-" +
|
||||
moduleProtocol +
|
||||
"Row-0"
|
||||
).attr("style", "display: none;");
|
||||
// For each macro.
|
||||
$.each(pluginMacros, function() {
|
||||
let description = this.desc;
|
||||
let macro = this.macro;
|
||||
let value = this.value;
|
||||
|
||||
if (pluginMacrosElement["server_plugin"] == pluginSelected) {
|
||||
if (pluginMacrosElement[macro + "_" + moduleProtocol + "_field"]) {
|
||||
value = pluginMacrosElement[macro + "_" + moduleProtocol + "_field"];
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
typeof description == "undefined" ||
|
||||
description === null ||
|
||||
description == ""
|
||||
) {
|
||||
description = "unknown";
|
||||
}
|
||||
|
||||
if (cntMacrosToGo == 4) {
|
||||
cntMacrosToGo = 0;
|
||||
cntMacrosLine++;
|
||||
thisIdLine =
|
||||
"network_component-plugin-" +
|
||||
moduleProtocol +
|
||||
"-fields-dynamicMacroRow-pluginRow-" +
|
||||
moduleProtocol +
|
||||
"Row-N-" +
|
||||
cntMacrosLine;
|
||||
$(
|
||||
"#network_component-server-plugin-pluginRow-" + moduleProtocol + "Row"
|
||||
).after(
|
||||
$(
|
||||
"#network_component-plugin-" +
|
||||
moduleProtocol +
|
||||
"-fields-dynamicMacroRow-pluginRow-" +
|
||||
moduleProtocol +
|
||||
"Row-0"
|
||||
)
|
||||
.clone()
|
||||
.attr("id", thisIdLine)
|
||||
.css("display", displayShow)
|
||||
);
|
||||
// Clear the template.
|
||||
$("#" + thisIdLine).empty();
|
||||
}
|
||||
|
||||
$(
|
||||
"#network_component-plugin-" +
|
||||
moduleProtocol +
|
||||
"-fields-dynamicMacroRow-pluginRow-" +
|
||||
moduleProtocol +
|
||||
"Row-0-0"
|
||||
)
|
||||
.clone()
|
||||
.attr(
|
||||
"id",
|
||||
"network_component-plugin-" +
|
||||
moduleProtocol +
|
||||
"-fields-dynamicMacroRow-pluginRow-" +
|
||||
moduleProtocol +
|
||||
"Row-N-" +
|
||||
cntMacrosLine +
|
||||
"-" +
|
||||
cntMacrosToGo
|
||||
)
|
||||
.html(description)
|
||||
.appendTo("#" + thisIdLine);
|
||||
cntMacrosToGo++;
|
||||
|
||||
$(
|
||||
"#network_component-plugin-" +
|
||||
moduleProtocol +
|
||||
"-fields-dynamicMacroRow-pluginRow-" +
|
||||
moduleProtocol +
|
||||
"Row-0-1"
|
||||
)
|
||||
.clone()
|
||||
.attr(
|
||||
"id",
|
||||
"network_component-plugin-" +
|
||||
moduleProtocol +
|
||||
"-fields-dynamicMacroRow-pluginRow-" +
|
||||
moduleProtocol +
|
||||
"Row-N-" +
|
||||
cntMacrosLine +
|
||||
"-" +
|
||||
cntMacrosToGo
|
||||
)
|
||||
.appendTo("#" + thisIdLine);
|
||||
|
||||
$(
|
||||
"#network_component-plugin-" +
|
||||
moduleProtocol +
|
||||
"-fields-dynamicMacroRow-pluginRow-" +
|
||||
moduleProtocol +
|
||||
"Row-N-" +
|
||||
cntMacrosLine +
|
||||
"-" +
|
||||
cntMacrosToGo
|
||||
)
|
||||
.children("input")
|
||||
.val(value);
|
||||
|
||||
$(
|
||||
"#network_component-plugin-" +
|
||||
moduleProtocol +
|
||||
"-fields-dynamicMacroRow-pluginRow-" +
|
||||
moduleProtocol +
|
||||
"Row-N-" +
|
||||
cntMacrosLine +
|
||||
"-" +
|
||||
cntMacrosToGo
|
||||
)
|
||||
.children("#field0_" + moduleProtocol + "_fields")
|
||||
.attr("id", this.macro + "_" + moduleProtocol + "_fields")
|
||||
.attr("name", this.macro + "_" + moduleProtocol + "_field");
|
||||
|
||||
cntMacrosToGo++;
|
||||
});
|
||||
|
||||
$("#selected_plugin_description_" + moduleProtocol).html(pluginDescription);
|
||||
}
|
||||
|
|
|
@ -390,15 +390,31 @@ function load_modal(settings) {
|
|||
function confirmDialog(settings) {
|
||||
var randomStr = uniqId();
|
||||
|
||||
$("body").append(
|
||||
'<div id="confirm_' + randomStr + '">' + settings.message + "</div>"
|
||||
);
|
||||
if (settings.size == undefined) {
|
||||
settings.size = 350;
|
||||
}
|
||||
|
||||
if (settings.maxHeight == undefined) {
|
||||
settings.maxHeight = 1000;
|
||||
}
|
||||
|
||||
if (typeof settings.message == "function") {
|
||||
$("body").append(
|
||||
'<div id="confirm_' + randomStr + '">' + settings.message() + "</div>"
|
||||
);
|
||||
} else {
|
||||
$("body").append(
|
||||
'<div id="confirm_' + randomStr + '">' + settings.message + "</div>"
|
||||
);
|
||||
}
|
||||
|
||||
$("#confirm_" + randomStr);
|
||||
$("#confirm_" + randomStr)
|
||||
.dialog({
|
||||
title: settings.title,
|
||||
close: false,
|
||||
width: 350,
|
||||
width: settings.size,
|
||||
maxHeight: settings.maxHeight,
|
||||
modal: true,
|
||||
buttons: [
|
||||
{
|
||||
|
@ -417,8 +433,8 @@ function confirmDialog(settings) {
|
|||
"ui-widget ui-state-default ui-corner-all ui-button-text-only sub ok submit-next",
|
||||
click: function() {
|
||||
$(this).dialog("close");
|
||||
$(this).remove();
|
||||
if (typeof settings.onAccept == "function") settings.onAccept();
|
||||
$(this).remove();
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
|
@ -30,6 +30,9 @@
|
|||
// Begin.
|
||||
namespace PandoraFMS;
|
||||
|
||||
|
||||
use PandoraFMS\ModuleType;
|
||||
|
||||
/**
|
||||
* PandoraFMS agent entity.
|
||||
*/
|
||||
|
@ -43,6 +46,28 @@ class Module extends Entity
|
|||
*/
|
||||
private $status;
|
||||
|
||||
/**
|
||||
* Module type matching id_tipo_modulo.
|
||||
*
|
||||
* @var PandoraFMS\ModuleType
|
||||
*/
|
||||
private $moduleType;
|
||||
|
||||
/**
|
||||
* Configuration data (only local modules).
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $configurationData;
|
||||
|
||||
/**
|
||||
* Configuration data (before updates) (only local modules).
|
||||
* Compatibility with classic functions.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $configurationDataOld;
|
||||
|
||||
|
||||
/**
|
||||
* Search a module in db.
|
||||
|
@ -123,6 +148,24 @@ class Module extends Entity
|
|||
|
||||
// Customize certain fields.
|
||||
$obj->status = new ModuleStatus($obj->id_agente_modulo());
|
||||
$obj->moduleType = new ModuleType($obj->id_tipo_modulo());
|
||||
|
||||
// Include some enterprise dependencies.
|
||||
enterprise_include_once('include/functions_config_agents.php');
|
||||
|
||||
// Load configuration data from agent configuration if available.
|
||||
$obj->configuration_data(
|
||||
\enterprise_hook(
|
||||
'config_agents_get_module_from_conf',
|
||||
[
|
||||
$obj->id_agente(),
|
||||
\io_safe_output($obj->nombre()),
|
||||
]
|
||||
)
|
||||
);
|
||||
|
||||
// Classic compat.
|
||||
$obj->configurationDataOld = $obj->configurationData;
|
||||
|
||||
return $obj;
|
||||
}
|
||||
|
@ -153,6 +196,144 @@ class Module extends Entity
|
|||
|
||||
// Customize certain fields.
|
||||
$this->status = new ModuleStatus($this->fields['id_agente_modulo']);
|
||||
$this->moduleType = new ModuleType($this->id_tipo_modulo());
|
||||
|
||||
// Include some enterprise dependencies.
|
||||
enterprise_include_once('include/functions_config_agents.php');
|
||||
|
||||
// Load configuration data from agent configuration if available.
|
||||
$this->configuration_data(
|
||||
\enterprise_hook(
|
||||
'config_agents_get_module_from_conf',
|
||||
[
|
||||
$this->id_agente(),
|
||||
\io_safe_output($this->nombre()),
|
||||
]
|
||||
)
|
||||
);
|
||||
|
||||
// Backup. Classic compat.
|
||||
$this->configurationDataOld = $this->configurationData;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Dynamically call methods in this object.
|
||||
*
|
||||
* @param string $methodName Name of target method or attribute.
|
||||
* @param array $params Arguments for target method.
|
||||
*
|
||||
* @return mixed Return of method.
|
||||
* @throws \Exception On error.
|
||||
*/
|
||||
public function __call(string $methodName, ?array $params=null)
|
||||
{
|
||||
// Prioritize written methods over dynamic ones.
|
||||
if (method_exists($this, $methodName) === true) {
|
||||
return $this->{$methodName}($params);
|
||||
}
|
||||
|
||||
if (array_key_exists($methodName, $this->fields) === true) {
|
||||
if (empty($params) === false) {
|
||||
if ($this->is_local() === true) {
|
||||
$keyName = $methodName;
|
||||
if ($methodName === 'nombre') {
|
||||
$keyName = 'name';
|
||||
}
|
||||
|
||||
if ($methodName === 'descripcion') {
|
||||
$keyName = 'description';
|
||||
}
|
||||
|
||||
if ($methodName === 'post_process') {
|
||||
$keyName = 'postprocess';
|
||||
}
|
||||
|
||||
if ($methodName === 'max_timeout') {
|
||||
$keyName = 'timeout';
|
||||
}
|
||||
|
||||
if ($methodName === 'max_retries') {
|
||||
$keyName = 'retries';
|
||||
}
|
||||
|
||||
if (in_array(
|
||||
'module_'.$keyName,
|
||||
[
|
||||
'module_name',
|
||||
'module_description',
|
||||
'module_type',
|
||||
'module_max',
|
||||
'module_min',
|
||||
'module_postprocess',
|
||||
'module_interval',
|
||||
'module_timeout',
|
||||
'module_retries',
|
||||
'module_min_critical',
|
||||
'module_max_critical',
|
||||
'module_min_warning',
|
||||
'module_max_warning',
|
||||
]
|
||||
) === true
|
||||
) {
|
||||
$this->updateConfigurationData(
|
||||
'module_'.$methodName,
|
||||
$params[0]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$this->fields[$methodName] = $params[0];
|
||||
return null;
|
||||
} else {
|
||||
return $this->fields[$methodName];
|
||||
}
|
||||
}
|
||||
|
||||
throw new \Exception(
|
||||
get_class($this).' error, method '.$methodName.' does not exist'
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets or retrieves value of id_tipo_modulo (complex).
|
||||
*
|
||||
* @param integer|null $id_tipo_modulo Id module type.
|
||||
*
|
||||
* @return PandoraFMS\ModuleType corresponding to this module type.
|
||||
* @throws \Exception On error.
|
||||
*/
|
||||
public function moduleType(?int $id_tipo_modulo=null)
|
||||
{
|
||||
if ($id_tipo_modulo === null) {
|
||||
return $this->moduleType;
|
||||
}
|
||||
|
||||
if (is_numeric($id_tipo_modulo) === true && $id_tipo_modulo > 0) {
|
||||
$this->moduleType = new ModuleType($id_tipo_modulo);
|
||||
$this->fields['id_tipo_modulo'] = $this->moduleType->id_tipo();
|
||||
} else {
|
||||
throw new \Exception('Invalid id_tipo_modulo '.$id_tipo_modulo);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets or retrieves value of id_tipo_modulo (complex).
|
||||
*
|
||||
* @param integer|null $id_tipo_modulo Id module type.
|
||||
*
|
||||
* @return integer corresponding to this module type.
|
||||
* @throws \Exception On error.
|
||||
*/
|
||||
public function id_tipo_modulo(?int $id_tipo_modulo=null)
|
||||
{
|
||||
if ($id_tipo_modulo === null) {
|
||||
return $this->fields['id_tipo_modulo'];
|
||||
}
|
||||
|
||||
return $this->moduleType($id_tipo_modulo);
|
||||
}
|
||||
|
||||
|
||||
|
@ -187,10 +368,14 @@ class Module extends Entity
|
|||
);
|
||||
}
|
||||
|
||||
// Include some enterprise dependencies.
|
||||
enterprise_include_once('include/functions_config_agents.php');
|
||||
|
||||
$updates = $this->fields;
|
||||
$updates['id_tipo_modulo'] = $this->moduleType()->id_tipo();
|
||||
|
||||
if ($this->fields['id_agente_modulo'] > 0) {
|
||||
// Update.
|
||||
$updates = $this->fields;
|
||||
|
||||
$rs = \db_process_sql_update(
|
||||
'tagente_modulo',
|
||||
$updates,
|
||||
|
@ -203,10 +388,20 @@ class Module extends Entity
|
|||
__METHOD__.' error: '.$config['dbconnection']->error
|
||||
);
|
||||
}
|
||||
|
||||
// Save configuration data if needed.
|
||||
if ($this->configurationData !== null) {
|
||||
\enterprise_hook(
|
||||
'config_agents_update_module_in_conf',
|
||||
[
|
||||
$this->id_agente(),
|
||||
$this->configurationDataOld,
|
||||
$this->configurationData,
|
||||
]
|
||||
);
|
||||
}
|
||||
} else {
|
||||
// Creation.
|
||||
$updates = $this->fields;
|
||||
|
||||
// Clean null fields.
|
||||
foreach ($updates as $k => $v) {
|
||||
if ($v === null) {
|
||||
|
@ -220,20 +415,139 @@ class Module extends Entity
|
|||
$updates
|
||||
);
|
||||
|
||||
if ($rs === false) {
|
||||
if ($rs === false || $rs < 0) {
|
||||
global $config;
|
||||
if ($rs === ERR_EXIST) {
|
||||
throw new \Exception(
|
||||
__METHOD__.': '.__(
|
||||
'Module already exists: "%s"',
|
||||
$updates['nombre']
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
throw new \Exception(
|
||||
__METHOD__.' error: '.$config['dbconnection']->error
|
||||
);
|
||||
}
|
||||
|
||||
$this->fields['id_agente_modulo'] = $rs;
|
||||
|
||||
\enterprise_hook(
|
||||
'config_agents_add_module_in_conf',
|
||||
[
|
||||
$this->id_agente(),
|
||||
$this->configurationData,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Verifies if module is local or not.
|
||||
*
|
||||
* @return boolean Is local, or not (false).
|
||||
*/
|
||||
public function is_local()
|
||||
{
|
||||
if ($this->moduleType()->is_local_datatype() === true) {
|
||||
if ($this->fields['id_modulo'] === MODULE_DATA) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Transforms configuration data into an array.
|
||||
*
|
||||
* @return array Configuration data in array format.
|
||||
*/
|
||||
protected function configurationDataToArray()
|
||||
{
|
||||
$rr = explode("\n", $this->configurationData);
|
||||
|
||||
$configuration = [];
|
||||
|
||||
foreach ($rr as $line) {
|
||||
if (empty($line) === true) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (preg_match('/module_begin/', $line) === 1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (preg_match('/module_end/', $line) === 1) {
|
||||
break;
|
||||
}
|
||||
|
||||
$_tmp = explode(' ', $line, 2);
|
||||
|
||||
$key = $_tmp[0];
|
||||
$value = $_tmp[1];
|
||||
|
||||
$configuration[$key] = $value;
|
||||
}
|
||||
|
||||
return $configuration;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Updates remote configuration.
|
||||
*
|
||||
* @param string $key Left side (module_XXX).
|
||||
* @param string $value Value, could be empty.
|
||||
*
|
||||
* @return boolean True - configurationData updated, false if not.
|
||||
*/
|
||||
public function updateConfigurationData(string $key, ?string $value=null)
|
||||
{
|
||||
if ($this->is_local() !== true) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$cnf = $this->configurationDataToArray();
|
||||
|
||||
$cnf[$key] = $value;
|
||||
|
||||
$str = "module_begin\n";
|
||||
foreach ($cnf as $k => $v) {
|
||||
$str .= $k.' '.$v."\n";
|
||||
}
|
||||
|
||||
$str .= "module_end\n";
|
||||
|
||||
$this->configuration_data($str);
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get/set configuration data for current module.
|
||||
*
|
||||
* @param string|null $conf Configuration data (block).
|
||||
*
|
||||
* @return mixed Content or void if set.
|
||||
*/
|
||||
public function configuration_data(?string $conf=null)
|
||||
{
|
||||
if ($conf === null) {
|
||||
return $this->configurationData;
|
||||
}
|
||||
|
||||
$this->configurationData = $conf;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Erases this module.
|
||||
*
|
||||
|
|
|
@ -0,0 +1,94 @@
|
|||
<?php
|
||||
// phpcs:disable Squiz.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||
/**
|
||||
* Module Type entity class.
|
||||
*
|
||||
* @category Class
|
||||
* @package Pandora FMS
|
||||
* @subpackage OpenSource
|
||||
* @version 1.0.0
|
||||
* @license See below
|
||||
*
|
||||
* ______ ___ _______ _______ ________
|
||||
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
|
||||
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
|
||||
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
|
||||
*
|
||||
* ============================================================================
|
||||
* Copyright (c) 2005-2019 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.
|
||||
namespace PandoraFMS;
|
||||
|
||||
/**
|
||||
* PandoraFMS agent entity.
|
||||
*/
|
||||
class ModuleType extends Entity
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* Builds a PandoraFMS\ModuleType object from given id.
|
||||
*
|
||||
* @param integer $id_tipo_modulo Id tipo modulo.
|
||||
*/
|
||||
public function __construct(?int $id_tipo_modulo=null)
|
||||
{
|
||||
if (is_numeric($id_tipo_modulo) === true
|
||||
&& $id_tipo_modulo > 0
|
||||
) {
|
||||
parent::__construct(
|
||||
'ttipo_modulo',
|
||||
['id_tipo' => $id_tipo_modulo]
|
||||
);
|
||||
} else {
|
||||
// Create empty skel.
|
||||
parent::__construct('ttipo_modulo');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Verifies if module type is local or not.
|
||||
* Beware, plugins also use this kind of modules..
|
||||
*
|
||||
* @return boolean Is a local candidate! or not (false).
|
||||
*/
|
||||
public function is_local_datatype()
|
||||
{
|
||||
if ((int) $this->id_tipo() === MODULE_TYPE_GENERIC_DATA
|
||||
|| (int) $this->id_tipo() === MODULE_TYPE_GENERIC_PROC
|
||||
|| (int) $this->id_tipo() === MODULE_TYPE_GENERIC_DATA_STRING
|
||||
|| (int) $this->id_tipo() === MODULE_TYPE_GENERIC_DATA_INC
|
||||
|| (int) $this->id_tipo() === MODULE_TYPE_GENERIC_DATA_INC_ABS
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Saves current definition to database.
|
||||
*
|
||||
* @return void No return.
|
||||
* @throws \Exception On error.
|
||||
*/
|
||||
public function save()
|
||||
{
|
||||
throw new \Exception('Read only component');
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -4571,6 +4571,7 @@ div#dialog_messages table th:last-child {
|
|||
display: inline-block;
|
||||
width: 30px;
|
||||
height: 17px;
|
||||
margin-right: 1em;
|
||||
}
|
||||
|
||||
.p-switch input {
|
||||
|
@ -6040,3 +6041,29 @@ form#modal_form_feedback ul.wizard li > textarea {
|
|||
#controls_table > tbody > tr > td input {
|
||||
margin-left: 3px;
|
||||
}
|
||||
|
||||
form#form-filter-interfaces {
|
||||
margin-left: -30px;
|
||||
}
|
||||
|
||||
form#form-filter-interfaces ul {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: flex-start;
|
||||
flex-wrap: wrap;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
form#form-filter-interfaces ul li {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-direction: row;
|
||||
justify-content: flex-start;
|
||||
max-width: 35%;
|
||||
}
|
||||
|
||||
form#form-filter-interfaces ul li.select-interfaces {
|
||||
flex-direction: row-reverse;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
/*
|
||||
* Discovery > Wizard css global style
|
||||
*/
|
||||
|
||||
#main > form.discovery.wizard > .white_box {
|
||||
min-width: 1024px;
|
||||
}
|
||||
|
|
|
@ -923,6 +923,20 @@ CREATE TABLE IF NOT EXISTS `tnetwork_component` (
|
|||
`dynamic_min` int(4) default '0',
|
||||
`dynamic_next` bigint(20) NOT NULL default '0',
|
||||
`dynamic_two_tailed` tinyint(1) unsigned default '0',
|
||||
`module_type` tinyint(1) unsigned NOT NULL DEFAULT 1,
|
||||
`protocol` tinytext NOT NULL,
|
||||
`manufacturer_id` varchar(200) NOT NULL,
|
||||
`execution_type` tinyint(1) unsigned NOT NULL DEFAULT 1,
|
||||
`scan_type` tinyint(1) unsigned NOT NULL DEFAULT 1,
|
||||
`value` text NOT NULL,
|
||||
`value_operations` text NOT NULL,
|
||||
`module_enabled` tinyint(1) unsigned DEFAULT 0,
|
||||
`name_oid` varchar(255) NOT NULL,
|
||||
`query_class` varchar(200) NOT NULL,
|
||||
`query_key_field` varchar(200) NOT NULL,
|
||||
`scan_filters` text NOT NULL,
|
||||
`query_filters` text NOT NULL,
|
||||
`enabled` tinyint(1) UNSIGNED DEFAULT 1,
|
||||
PRIMARY KEY (`id_nc`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -344,6 +344,9 @@ return array(
|
|||
'PandoraFMS\\Dashboard\\WuxWidget' => $baseDir . '/include/lib/Dashboard/Widgets/wux_transaction.php',
|
||||
'PandoraFMS\\Entity' => $baseDir . '/include/lib/Entity.php',
|
||||
'PandoraFMS\\Group' => $baseDir . '/include/lib/Group.php',
|
||||
'PandoraFMS\\Module' => $baseDir . '/include/lib/Module.php',
|
||||
'PandoraFMS\\ModuleStatus' => $baseDir . '/include/lib/ModuleStatus.php',
|
||||
'PandoraFMS\\ModuleType' => $baseDir . '/include/lib/ModuleType.php',
|
||||
'PandoraFMS\\User' => $baseDir . '/include/lib/User.php',
|
||||
'PandoraFMS\\View' => $baseDir . '/include/lib/View.php',
|
||||
'PandoraFMS\\WebSockets\\WSManager' => $baseDir . '/include/lib/WSManager.php',
|
||||
|
|
|
@ -426,6 +426,9 @@ class ComposerStaticInitfdecadadce22e6dde51e9535fe4ad7aa
|
|||
'PandoraFMS\\Dashboard\\WuxWidget' => __DIR__ . '/../..' . '/include/lib/Dashboard/Widgets/wux_transaction.php',
|
||||
'PandoraFMS\\Entity' => __DIR__ . '/../..' . '/include/lib/Entity.php',
|
||||
'PandoraFMS\\Group' => __DIR__ . '/../..' . '/include/lib/Group.php',
|
||||
'PandoraFMS\\Module' => __DIR__ . '/../..' . '/include/lib/Module.php',
|
||||
'PandoraFMS\\ModuleStatus' => __DIR__ . '/../..' . '/include/lib/ModuleStatus.php',
|
||||
'PandoraFMS\\ModuleType' => __DIR__ . '/../..' . '/include/lib/ModuleType.php',
|
||||
'PandoraFMS\\User' => __DIR__ . '/../..' . '/include/lib/User.php',
|
||||
'PandoraFMS\\View' => __DIR__ . '/../..' . '/include/lib/View.php',
|
||||
'PandoraFMS\\WebSockets\\WSManager' => __DIR__ . '/../..' . '/include/lib/WSManager.php',
|
||||
|
|
|
@ -24,6 +24,7 @@ use Encode;
|
|||
use Encode::Locale;
|
||||
use Getopt::Long;
|
||||
use Net::SNMP;
|
||||
use Net::SNMP::Security::USM;
|
||||
|
||||
my $HELP=<<EO_HELP;
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ use Encode;
|
|||
use Encode::Locale;
|
||||
use Getopt::Long;
|
||||
use Net::SNMP;
|
||||
use Net::SNMP::Security::USM;
|
||||
|
||||
my $HELP=<<EO_HELP;
|
||||
|
||||
|
|
Loading…
Reference in New Issue