Merge branch '845-Mejoras-en-SNMP-Browser-dev' into 'develop'

845 mejoras en snmp browser dev

See merge request !602
This commit is contained in:
vgilc 2017-07-13 12:07:46 +02:00
commit 38b42a26a2
5 changed files with 285 additions and 2 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

@ -0,0 +1,126 @@
<?php
//Pandora FMS- http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2017 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation; version 2
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
include_once($config['homedir'] . "/include/functions_config.php");
include_once($config['homedir'] . "/include/functions_snmp_browser.php");
require_once ($config['homedir'] . '/include/functions_network_components.php');
global $config;
if(is_ajax()){
ob_clean();
$action = (string) get_parameter ("action", "");
$target_ip = (string) get_parameter ("target_ip", '');
$community = (string) get_parameter ("community", '');
$snmp_version = (string) get_parameter ("snmp_browser_version", '');
$snmp3_auth_user = get_parameter('snmp3_browser_auth_user');
$snmp3_security_level = get_parameter('snmp3_browser_security_level');
$snmp3_auth_method = get_parameter('snmp3_browser_auth_method');
$snmp3_auth_pass = get_parameter('snmp3_browser_auth_pass');
$snmp3_privacy_method = get_parameter('snmp3_browser_privacy_method');
$snmp3_privacy_pass = get_parameter('snmp3_browser_privacy_pass');
$targets_oids = get_parameter ("oids", "");
$targets_oids = explode(",", $targets_oids);
$custom_action = get_parameter ("custom_action", "");
if ($custom_action != "") {
$custom_action = urldecode (base64_decode ($custom_action));
}
if($action == 'create_modules_snmp'){
$fail_modules = array();
foreach ($targets_oids as $key => $target_oid) {
$oid = snmp_browser_get_oid ($target_ip, $community,
htmlspecialchars_decode($target_oid), $snmp_version, $snmp3_auth_user,
$snmp3_security_level, $snmp3_auth_method, $snmp3_auth_pass,
$snmp3_privacy_method, $snmp3_privacy_pass);
$name_check = db_get_value ('name', 'tnetwork_component',
'name', $oid['oid']);
if(empty($oid['description'])) {
$description = '';
} else {
$description = io_safe_input($oid['description']);
}
if(!$name_check){
$id = network_components_create_network_component ($oid['oid'],17,1,
array ('description' => $description,
'module_interval' => 300,
'max' => 0,
'min' => 0,
'tcp_send' => $snmp_version,
'tcp_rcv' => '',
'tcp_port' => 0,
'snmp_oid' => $oid['numeric_oid'],
'snmp_community' => $community,
'id_module_group' => 3,
'id_modulo' => 2,
'id_plugin' => 0,
'plugin_user' => '',
'plugin_pass' => '',
'plugin_parameter' => '',
'macros' => '',
'max_timeout' => 0,
'max_retries' => 0,
'history_data' => '',
'dynamic_interval' => 0,
'dynamic_max' => 0,
'dynamic_min' => 0,
'dynamic_two_tailed' => 0,
'min_warning' => 0,
'max_warning' => 0,
'str_warning' => '',
'min_critical' => 0,
'max_critical' => 0,
'str_critical' => '',
'min_ff_event' => 0,
'custom_string_1' => '',
'custom_string_2' => '',
'custom_string_3' => '',
'post_process' => 0,
'unit' => '',
'wizard_level' => 'nowizard',
'macros' => '',
'critical_instructions' => '',
'warning_instructions' => '',
'unknown_instructions' => '',
'critical_inverse' => 0,
'warning_inverse' => 0,
'id_category' => 0,
'tags' => '',
'disabled_types_event' => '{"going_unknown":1}',
'min_ff_event_normal' => 0,
'min_ff_event_warning' => 0,
'min_ff_event_critical' => 0,
'each_ff' => 0));
}
if(empty($id)) {
array_push($fail_modules,$name_check);
}
}
}
echo json_encode($fail_modules);
return;
}
?>

View File

@ -116,7 +116,7 @@ function snmp_browser_print_tree ($tree, $id = 0, $depth = 0, $last = 0, $last_a
echo "</a>";
}
echo '&nbsp;<span>' . $level . '</span>';
echo html_print_checkbox("create_$sub_id", 0, false, true, false, '') .'&nbsp;<span>' . $level . '</span>';
if (isset ($sub_level['__VALUE__'])) {
echo '<span class="value" style="display: none;">&nbsp;=&nbsp;' . $sub_level['__VALUE__'] . '</span>';
}
@ -618,3 +618,137 @@ function snmp_browser_print_container ($return = false, $width = '100%', $height
}
?>
<script type="text/javascript">
$(document).ready(function () {
$('input[name*=create_network_component]').click(function () {
var id_check = $('#ul_0').find('input').map(function(){
if(this.id.indexOf('checkbox-create_')!=-1){
if($(this).is(':checked')){
return this.id;
}
} }).get();
$('input[name*=create_network_component]').removeClass("sub add");
$('input[name*=create_network_component]').addClass("sub spinn");
var target_ip = $('#text-target_ip').val();
var community = $('#text-community').val();
var snmp_version = $('#snmp_browser_version').val();
var snmp3_auth_user = $('#text-snmp3_browser_auth_user').val();
var snmp3_security_level = $('#snmp3_browser_security_level').val();
var snmp3_auth_method = $('#snmp3_browser_auth_method').val();
var snmp3_auth_pass = $('#password-snmp3_browser_auth_pass').val();
var snmp3_privacy_method = $('#snmp3_browser_privacy_method').val();
var snmp3_privacy_pass = $('#password-snmp3_browser_privacy_pass').val();
var custom_action = $('#hidden-custom_action').val();
if (custom_action == undefined) {
custom_action = '';
}
var oids = [];
id_check.forEach(function(product, index) {
var oid = $("#"+product).siblings('a').attr('href');
if(oid.indexOf('javascript: snmpGet("')!=-1) {
oid = oid.replace('javascript: snmpGet("',"");
oid = oid.replace('");',"");
oids.push(oid);
}
});
// Prepare the AJAX call
var params = [
"target_ip=" + target_ip,
"community=" + community,
"oids=" + oids,
"snmp_browser_version=" + snmp_version,
"snmp3_browser_auth_user=" + snmp3_auth_user,
"snmp3_browser_security_level=" + snmp3_security_level,
"snmp3_browser_auth_method=" + snmp3_auth_method,
"snmp3_browser_auth_pass=" + snmp3_auth_pass,
"snmp3_browser_privacy_method=" + snmp3_privacy_method,
"snmp3_browser_privacy_pass=" + snmp3_privacy_pass,
"action=" + "create_modules_snmp",
"custom_action=" + custom_action,
"page=include/ajax/snmp_browser.ajax"
];
$.ajax({
type: "GET",
url: "ajax.php",
data: params.join ("&"),
dataType: "json",
success: function(data) {
$('input[name*=create_network_component]').removeClass("sub spinn");
$('input[name*=create_network_component]').addClass("sub add");
if(data.length !== 0){
$('#error_text').text("");
data.forEach( function(valor, indice, array) {
console.log(valor);
$('#error_text').append('<br/>'+ valor );
});
$("#dialog_error")
.dialog({
resizable: true,
draggable: true,
modal: true,
height: 300,
width: 500,
overlay: {
opacity: 0.5,
background: "black"
}
});
} else {
$("#dialog_success")
.dialog({
resizable: true,
draggable: true,
modal: true,
height: 250,
width: 500,
overlay: {
opacity: 0.5,
background: "black"
}
});
}
}
});
});
$('input[id^=checkbox-create]').change(function () {
if ($(this).is(':checked') ) {
$('input[name*=create_network_component]').show();
var id_input = $(this).attr("id");
id_input = id_input.split("checkbox-create_");
var checks = $('#ul_'+id_input[1]).find('input').map(function(){
if(this.id.indexOf('checkbox-create_')!=-1){
return this.id;
} }).get();
checks.forEach(function(product, index) {
$("#"+product).prop('checked', "true");
});
} else {
var id_input = $(this).attr("id");
id_input = id_input.split("checkbox-create_");
var checks = $('#ul_'+id_input[1]).find('input').map(function(){
if(this.id.indexOf('checkbox-create_')!=-1){
return this.id;
} }).get();
checks.forEach(function(product, index) {
$("#"+product).prop('checked', false);
});
}
});
});
</script>

View File

@ -656,7 +656,7 @@ input.sub[disabled] {
input.next, input.upd, input.ok, input.wand, input.delete, input.cog,
input.target, input.search, input.copy, input.add, input.graph,
input.percentile, input.binary, input.camera, input.config,
input.cancel, input.default, input.filter, input.pdf {
input.cancel, input.default, input.filter, input.pdf,input.spinn {
padding-right: 30px;
height: 23px;
@ -741,6 +741,9 @@ input.pdf:disabled {
input.camera {
background-image: url(../../images/input_camera.png) !important;
}
input.spinn {
background-image: url(../../images/spinner_green.gif) !important;
}
#toolbox #auto_save {
padding-top: 5px;

View File

@ -47,6 +47,26 @@ if (is_ajax()) {
}
else {
snmp_browser_print_tree ($snmp_tree);
echo html_print_submit_button(__('Create network components'),'create_network_component',
false, array('style' => 'display: none', 'class' => 'sub add'), true);
echo '<div id="dialog_error" style="display: none" title="Network components">';
echo "<div>";
echo "<div style='width:25%; float:left'><img style='padding-left:20px; padding-top:20px;' src='images/icono_error_mr.png'></div>";
echo "<div style='width:75%; float:left;'><h3><strong style='font-family:Verdana; font-size:13pt;'>ERROR</strong></h3>";
echo "<p style='font-family:Verdana; font-size:12pt;margin-bottom: 0px'>".__('Error creating the following modules:')."</p>";
echo "<p id='error_text' style='font-family:Verdana; font-size:12pt;'></p>";
echo "</div>";
echo '</div>';
echo '<div id="dialog_success" style="display: none" title="Network components">';
echo "<div>";
echo "<div style='width:25%; float:left'><img style='padding-left:20px; padding-top:20px;' src='images/icono_exito_mr.png'></div>";
echo "<div style='width:75%; float:left;'><h3><strong style='font-family:Verdana; font-size:13pt;'>SUCCESS</strong></h3>";
echo "<p style='font-family:Verdana; font-size:12pt;'>".__('Modules successfully created')."</p>";
echo "</div>";
echo '</div>';
}
return;
}