Fixed oid for getting x64 interfaces module. Fixed visual (module order) bug
This commit is contained in:
parent
4e67371967
commit
25de1b686a
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Agent Wizard for SNMP and WMI
|
||||
*
|
||||
|
@ -273,7 +274,7 @@ class AgentWizard extends HTML
|
|||
// Check access.
|
||||
check_login();
|
||||
|
||||
if (! check_acl($config['id_user'], 0, 'AR')) {
|
||||
if (!check_acl($config['id_user'], 0, 'AR')) {
|
||||
db_pandora_audit(
|
||||
'ACL Violation',
|
||||
'Trying to access event viewer'
|
||||
|
@ -865,7 +866,6 @@ class AgentWizard extends HTML
|
|||
],
|
||||
true
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -992,10 +992,51 @@ class AgentWizard extends HTML
|
|||
}
|
||||
|
||||
if ($this->wizardSection === 'snmp_interfaces_explorer') {
|
||||
// First, try x64 interfaces.
|
||||
$this->interfacesx64 = true;
|
||||
// Check if thereis x64 counters.
|
||||
$snmp_tmp = '.1.3.6.1.2.1.31.1.1.1.6';
|
||||
$check_x64 = get_snmpwalk(
|
||||
$this->targetIp,
|
||||
$this->version,
|
||||
$this->community,
|
||||
$this->authUserV3,
|
||||
$this->securityLevelV3,
|
||||
$this->authMethodV3,
|
||||
$this->authPassV3,
|
||||
$this->privacyMethodV3,
|
||||
$this->privacyPassV3,
|
||||
0,
|
||||
$snmp_tmp,
|
||||
$this->targetPort,
|
||||
$this->server,
|
||||
$this->extraArguments
|
||||
);
|
||||
|
||||
if ($check_x64) {
|
||||
$this->interfacesx64 = true;
|
||||
$oidExplore = '.1.3.6.1.2.1.31.1.1.1.1';
|
||||
} else {
|
||||
$this->interfacesx64 = false;
|
||||
$oidExplore = '1.3.6.1.2.1.2.2.1.2';
|
||||
}
|
||||
|
||||
// Explore interface names.
|
||||
$oidExplore = '.1.3.6.1.2.1.31.1.1.1.1';
|
||||
$receivedOid = get_snmpwalk(
|
||||
$this->targetIp,
|
||||
$this->version,
|
||||
$this->community,
|
||||
$this->authUserV3,
|
||||
$this->securityLevelV3,
|
||||
$this->authMethodV3,
|
||||
$this->authPassV3,
|
||||
$this->privacyMethodV3,
|
||||
$this->privacyPassV3,
|
||||
0,
|
||||
$oidExplore,
|
||||
$this->targetPort,
|
||||
$this->server,
|
||||
$this->extraArguments
|
||||
);
|
||||
} else {
|
||||
// Get the device PEN.
|
||||
$oidExplore = '.1.3.6.1.2.1.1.2.0';
|
||||
|
@ -1310,7 +1351,7 @@ class AgentWizard extends HTML
|
|||
*
|
||||
* @return array
|
||||
*/
|
||||
public function candidateModuleToCreate(array $data):array
|
||||
public function candidateModuleToCreate(array $data): array
|
||||
{
|
||||
$modulesActivated = [];
|
||||
$generalInterface = false;
|
||||
|
@ -1560,8 +1601,8 @@ class AgentWizard extends HTML
|
|||
if ($this->securityLevelV3 === 'authNoPriv'
|
||||
|| $this->securityLevelV3 === 'authPriv'
|
||||
) {
|
||||
$values['plugin_parameter'] = $this->authMethodV3;
|
||||
$values['plugin_pass'] = $this->authPassV3;
|
||||
$values['plugin_parameter'] = $this->authMethodV3;
|
||||
$values['plugin_pass'] = $this->authPassV3;
|
||||
if ($this->securityLevelV3 === 'authPriv') {
|
||||
$values['custom_string_1'] = $this->privacyMethodV3;
|
||||
$values['custom_string_2'] = $this->privacyPassV3;
|
||||
|
@ -2261,7 +2302,7 @@ class AgentWizard extends HTML
|
|||
private function replacementMacrosPlugin(
|
||||
string $text,
|
||||
array $macros
|
||||
):string {
|
||||
): string {
|
||||
// Only agents.
|
||||
if (empty($this->idPolicy) === true) {
|
||||
// Common.
|
||||
|
@ -2308,7 +2349,7 @@ class AgentWizard extends HTML
|
|||
?string $value,
|
||||
?string $unit='',
|
||||
?int $moduleType=0
|
||||
):string {
|
||||
): string {
|
||||
if ($moduleType !== MODULE_TYPE_REMOTE_SNMP_INC
|
||||
&& $moduleType !== MODULE_TYPE_GENERIC_DATA_INC
|
||||
&& $moduleType !== MODULE_TYPE_REMOTE_TCP_INC
|
||||
|
@ -2562,7 +2603,7 @@ class AgentWizard extends HTML
|
|||
// Unpack the extra fields
|
||||
// and include with key field in a field set.
|
||||
$macros = json_decode($module['macros'], true);
|
||||
$fieldSet = [ '0' => $module['query_key_field'] ];
|
||||
$fieldSet = ['0' => $module['query_key_field']];
|
||||
foreach ($macros as $fieldKey => $fieldMacro) {
|
||||
if (preg_match('/extra_field_/', $fieldKey) !== 0) {
|
||||
$tmpKey = explode('_', $fieldKey);
|
||||
|
@ -3100,7 +3141,6 @@ class AgentWizard extends HTML
|
|||
// Add Create Modules form.
|
||||
$this->createModulesForm();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -3209,7 +3249,6 @@ class AgentWizard extends HTML
|
|||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -3306,7 +3345,7 @@ class AgentWizard extends HTML
|
|||
*
|
||||
* @return array Inputs for common data.
|
||||
*/
|
||||
private function getCommonDataInputs():array
|
||||
private function getCommonDataInputs(): array
|
||||
{
|
||||
$inputs[] = [
|
||||
'id' => 'create-modules-action',
|
||||
|
@ -4116,13 +4155,13 @@ class AgentWizard extends HTML
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* This function return the definition of modules for SNMP Interfaces
|
||||
*
|
||||
* @param array $data Data.
|
||||
*
|
||||
* @return array Return modules for defect.
|
||||
*/
|
||||
/**
|
||||
* This function return the definition of modules for SNMP Interfaces
|
||||
*
|
||||
* @param array $data Data.
|
||||
*
|
||||
* @return array Return modules for defect.
|
||||
*/
|
||||
private function getInterfacesModules(array $data=[])
|
||||
{
|
||||
$moduleDescription = '';
|
||||
|
@ -4207,6 +4246,34 @@ class AgentWizard extends HTML
|
|||
],
|
||||
];
|
||||
|
||||
// Get x86 or x64 modules.
|
||||
if ($this->interfacesx64 === true) {
|
||||
$definition_temp = $this->getInterfacesModulesx64($data);
|
||||
} else {
|
||||
$definition_temp = $this->getInterfacesModulesx86($data);
|
||||
}
|
||||
|
||||
// General monitoring names.
|
||||
$general_module_names = [
|
||||
'ifInOctets / ifHCInOctets',
|
||||
'ifOutOctets / ifHCOutOctets',
|
||||
'ifInUcastPkts / ifHCInUcastPkts',
|
||||
'ifOutUcastPkts / ifHCOutUcastPkts',
|
||||
'ifInNUcastPkts / ifHCInNUcastPkts',
|
||||
'ifOutNUcastPkts / ifHCOutNUcastPkts',
|
||||
];
|
||||
|
||||
if ($name == '') {
|
||||
foreach ($definition_temp as $module => $module_def) {
|
||||
$definition_temp[$module]['module_name'] = array_shift($general_module_names);
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($definition_temp) === false) {
|
||||
$definition = array_merge($definition, $definition_temp);
|
||||
}
|
||||
|
||||
// Continue with common x86 and x84 modules.
|
||||
// IfAdminStatus.
|
||||
$moduleName = $name.'ifAdminStatus';
|
||||
$definition['ifAdminStatus'] = [
|
||||
|
@ -4333,19 +4400,6 @@ class AgentWizard extends HTML
|
|||
],
|
||||
];
|
||||
|
||||
// Get x86 or x64 modules.
|
||||
if ($this->interfacesx64 === true) {
|
||||
$definitionx64 = $this->getInterfacesModulesx64($data);
|
||||
if (empty($definitionx64) === false) {
|
||||
$definition = array_merge($definition, $definitionx64);
|
||||
}
|
||||
} else {
|
||||
$definitionx86 = $this->getInterfacesModulesx86($data);
|
||||
if (empty($definitionx86) === false) {
|
||||
$definition = array_merge($definition, $definitionx86);
|
||||
}
|
||||
}
|
||||
|
||||
return $definition;
|
||||
}
|
||||
|
||||
|
@ -4815,7 +4869,7 @@ class AgentWizard extends HTML
|
|||
try {
|
||||
exec($execution, $output);
|
||||
} catch (Exception $ex) {
|
||||
$output = [ '0' => 'ERROR: Failed execution: '.(string) $ex];
|
||||
$output = ['0' => 'ERROR: Failed execution: '.(string) $ex];
|
||||
}
|
||||
|
||||
return $output;
|
||||
|
@ -4913,7 +4967,7 @@ class AgentWizard extends HTML
|
|||
// Meta.
|
||||
var meta = "<?php echo is_metaconsole(); ?>";
|
||||
var hack_meta = '';
|
||||
if(meta){
|
||||
if (meta) {
|
||||
hack_meta = '../../';
|
||||
}
|
||||
|
||||
|
@ -4921,15 +4975,15 @@ class AgentWizard extends HTML
|
|||
showV3Form();
|
||||
|
||||
// Filter search interfaces snmp.
|
||||
$('#text-filter-search').keyup(function () {
|
||||
$('#text-filter-search').keyup(function() {
|
||||
var string = $('#text-filter-search').val();
|
||||
var regex = new RegExp(string);
|
||||
var interfaces = $('.interfaces_search');
|
||||
interfaces.each(function(){
|
||||
if(string == ''){
|
||||
interfaces.each(function() {
|
||||
if (string == '') {
|
||||
$(this).removeClass('hidden');
|
||||
} else {
|
||||
if(this.id.match(regex)) {
|
||||
if (this.id.match(regex)) {
|
||||
$(this).removeClass('hidden');
|
||||
} else {
|
||||
$(this).addClass('hidden');
|
||||
|
@ -4939,12 +4993,12 @@ class AgentWizard extends HTML
|
|||
});
|
||||
|
||||
// Loading.
|
||||
$('#submit-sub-protocol').click(function () {
|
||||
$('#submit-sub-protocol').click(function() {
|
||||
$('.wizard-result').remove();
|
||||
$('#form-create-modules').remove();
|
||||
$('.textodialogo').remove();
|
||||
$('.loading-wizard')
|
||||
.html('<center><span style="font-size:25px;">Loading...</span><img style="width:25px;heigth:25px;" src="'+hack_meta+'images/spinner.gif"></center>');
|
||||
.html('<center><span style="font-size:25px;">Loading...</span><img style="width:25px;heigth:25px;" src="' + hack_meta + 'images/spinner.gif"></center>');
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -4962,17 +5016,17 @@ class AgentWizard extends HTML
|
|||
|
||||
function showSecurityLevelForm() {
|
||||
var selector = $('#securityLevelV3').val();
|
||||
if(selector === 'authNoPriv' || selector === 'authPriv'){
|
||||
if (selector === 'authNoPriv' || selector === 'authPriv') {
|
||||
$('#txt-authMethodV3').removeClass('invisible');
|
||||
$('#txt-authPassV3').removeClass('invisible');
|
||||
if(selector === 'authPriv'){
|
||||
if (selector === 'authPriv') {
|
||||
$('#txt-privacyMethodV3').removeClass('invisible');
|
||||
$('#txt-privacyPassV3').removeClass('invisible');
|
||||
} else {
|
||||
$('#txt-privacyMethodV3').addClass('invisible');
|
||||
$('#txt-privacyPassV3').addClass('invisible');
|
||||
}
|
||||
} else {
|
||||
} else {
|
||||
$('#txt-authMethodV3').addClass('invisible');
|
||||
$('#txt-authPassV3').addClass('invisible');
|
||||
$('#txt-privacyMethodV3').addClass('invisible');
|
||||
|
@ -4986,45 +5040,42 @@ class AgentWizard extends HTML
|
|||
var text = "";
|
||||
var failed = 0;
|
||||
try {
|
||||
data = JSON.parse(data);
|
||||
text = data["result"];
|
||||
data = JSON.parse(data);
|
||||
text = data["result"];
|
||||
} catch (err) {
|
||||
title = "<?php echo __('Failed'); ?>";
|
||||
text = err.message;
|
||||
failed = 1;
|
||||
title = "<?php echo __('Failed'); ?>";
|
||||
text = err.message;
|
||||
failed = 1;
|
||||
}
|
||||
if (!failed && data["error"] != undefined) {
|
||||
title = "<?php echo __('Failed'); ?>";
|
||||
text = data["error"];
|
||||
failed = 1;
|
||||
title = "<?php echo __('Failed'); ?>";
|
||||
text = data["error"];
|
||||
failed = 1;
|
||||
}
|
||||
if (data["report"] != undefined) {
|
||||
data["report"].forEach(function(item) {
|
||||
text += "<br>" + item;
|
||||
});
|
||||
data["report"].forEach(function(item) {
|
||||
text += "<br>" + item;
|
||||
});
|
||||
}
|
||||
|
||||
$("#msg").empty();
|
||||
$("#msg").html(text);
|
||||
$("#msg").dialog({
|
||||
width: 450,
|
||||
position: {
|
||||
my: "center",
|
||||
at: "center",
|
||||
of: window,
|
||||
collision: "fit"
|
||||
},
|
||||
title: title,
|
||||
buttons: [
|
||||
{
|
||||
class:
|
||||
"ui-widget ui-state-default ui-corner-all ui-button-text-only sub ok submit-next",
|
||||
width: 450,
|
||||
position: {
|
||||
my: "center",
|
||||
at: "center",
|
||||
of: window,
|
||||
collision: "fit"
|
||||
},
|
||||
title: title,
|
||||
buttons: [{
|
||||
class: "ui-widget ui-state-default ui-corner-all ui-button-text-only sub ok submit-next",
|
||||
text: "OK",
|
||||
click: function(e) {
|
||||
$("#msg").close();
|
||||
}
|
||||
}
|
||||
]
|
||||
}]
|
||||
});
|
||||
|
||||
}
|
||||
|
@ -5044,8 +5095,8 @@ class AgentWizard extends HTML
|
|||
var markedCount = 0;
|
||||
if (type == 'block') {
|
||||
selectedBlock
|
||||
.parent()
|
||||
.removeClass("alpha50");
|
||||
.parent()
|
||||
.removeClass("alpha50");
|
||||
if (selectedBlock.prop("checked")) {
|
||||
// Set to active the values of fields.
|
||||
$("[id*=hidden-module-active-"+blockNumber+"]")
|
||||
|
@ -5054,9 +5105,9 @@ class AgentWizard extends HTML
|
|||
});
|
||||
// Set checked.
|
||||
$("[id*=checkbox-sel_module_" + blockNumber + "]")
|
||||
.each(function(){
|
||||
$(this).prop("checked", true);
|
||||
});
|
||||
.each(function() {
|
||||
$(this).prop("checked", true);
|
||||
});
|
||||
imageInfoModules.removeClass('hidden');
|
||||
} else {
|
||||
// Set to inactive the values of fields.
|
||||
|
@ -5066,15 +5117,15 @@ class AgentWizard extends HTML
|
|||
});
|
||||
// Set unchecked.
|
||||
$("[id*=checkbox-sel_module_" + blockNumber + "]")
|
||||
.each(function(){
|
||||
$(this).prop("checked", false);
|
||||
});
|
||||
.each(function() {
|
||||
$(this).prop("checked", false);
|
||||
});
|
||||
imageInfoModules.addClass('hidden');
|
||||
}
|
||||
} else if (type == 'module') {
|
||||
// Getting the element.
|
||||
var thisModuleHidden = document.getElementById("hidden-module-active-"+switchName[2]+"_"+moduleNumber);
|
||||
var thisModule = $("#checkbox-sel_module_"+blockNumber+"_"+moduleNumber);
|
||||
var thisModuleHidden = document.getElementById("hidden-module-active-" + switchName[2] + "_" + moduleNumber);
|
||||
var thisModule = $("#checkbox-sel_module_" + blockNumber + "_" + moduleNumber);
|
||||
// Setting the individual field
|
||||
if (thisModule.prop('checked')) {
|
||||
thisModuleHidden.value = '1';
|
||||
|
@ -5084,12 +5135,12 @@ class AgentWizard extends HTML
|
|||
|
||||
// Get the list of selected modules.
|
||||
$("[id*=checkbox-sel_module_" + blockNumber + "]")
|
||||
.each(function() {
|
||||
if ($(this).prop("checked")) {
|
||||
markedCount++;
|
||||
}
|
||||
totalCount++;
|
||||
});
|
||||
.each(function() {
|
||||
if ($(this).prop("checked")) {
|
||||
markedCount++;
|
||||
}
|
||||
totalCount++;
|
||||
});
|
||||
|
||||
if (totalCount == markedCount) {
|
||||
selectedBlock.prop("checked", true);
|
||||
|
@ -5118,7 +5169,7 @@ class AgentWizard extends HTML
|
|||
*/
|
||||
function switchBlockControlInterfaces(e) {
|
||||
var string = $('#text-filter-search').val();
|
||||
if(string == ''){
|
||||
if (string == '') {
|
||||
if (e.checked) {
|
||||
$(".interfaz_select").prop("checked", true);
|
||||
} else {
|
||||
|
@ -5127,15 +5178,15 @@ class AgentWizard extends HTML
|
|||
} else {
|
||||
var regex = new RegExp(string);
|
||||
var interfaces = $('.interfaces_search');
|
||||
interfaces.each(function(){
|
||||
if(this.id.match(regex)) {
|
||||
interfaces.each(function() {
|
||||
if (this.id.match(regex)) {
|
||||
$(this).removeClass('hidden');
|
||||
if (e.checked) {
|
||||
$("input[name='interfaz_select_"+this.id+"']")
|
||||
$("input[name='interfaz_select_" + this.id + "']")
|
||||
.prop("checked", true);
|
||||
} else {
|
||||
$("input[name='interfaz_select_"+this.id+"']")
|
||||
.prop("checked", false);
|
||||
$("input[name='interfaz_select_" + this.id + "']")
|
||||
.prop("checked", false);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -5143,13 +5194,13 @@ class AgentWizard extends HTML
|
|||
}
|
||||
|
||||
/**
|
||||
* Show the modal with modules for create.
|
||||
*/
|
||||
* Show the modal with modules for create.
|
||||
*/
|
||||
function processListModules() {
|
||||
confirmDialog({
|
||||
title: "<?php echo __('Modules about to be created'); ?>",
|
||||
message: function() {
|
||||
var id = "div-"+uniqId();
|
||||
var id = "div-" + uniqId();
|
||||
var loading = "<?php echo __('Loading'); ?>" + "...";
|
||||
$.ajax({
|
||||
method: "post",
|
||||
|
@ -5165,22 +5216,22 @@ class AgentWizard extends HTML
|
|||
},
|
||||
datatype: "html",
|
||||
success: function(data) {
|
||||
$('#'+id).empty().append(data);
|
||||
$('#' + id).empty().append(data);
|
||||
},
|
||||
error: function(e) {
|
||||
showMsg(e);
|
||||
}
|
||||
});
|
||||
|
||||
return "<div id ='"+id+"'>"+loading+"</div>";
|
||||
return "<div id ='" + id + "'>" + loading + "</div>";
|
||||
},
|
||||
ok: "<?php echo __('OK'); ?>",
|
||||
cancel: "<?php echo __('Cancel'); ?>",
|
||||
onAccept: function() {
|
||||
$('#reviewed-modules').submit();
|
||||
$('#reviewed-modules').submit();
|
||||
},
|
||||
size:750,
|
||||
maxHeight:500
|
||||
size: 750,
|
||||
maxHeight: 500
|
||||
});
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue