From 9df2277efb7af09bf6546def61d00a5a13a79e75 Mon Sep 17 00:00:00 2001 From: zarzuelo Date: Thu, 29 Sep 2011 14:39:19 +0000 Subject: [PATCH] 2011-09-29 Sergio Martin * extensions/snmp_explorer.php godmode/agentes/agent_manager.php: Fixed timeout problem with big machines changing the transfer to ajax data mode to serialize way. Fixed little bugs as None option when are data and few checks to avoid errors when try create modules without select any OID. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@5023 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 9 +++ pandora_console/extensions/snmp_explorer.php | 55 +++++++++++-------- .../godmode/agentes/agent_manager.php | 8 ++- 3 files changed, 46 insertions(+), 26 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 32ac65bd3c..8f0b0b6d31 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,12 @@ +2011-09-29 Sergio Martin + + * extensions/snmp_explorer.php + godmode/agentes/agent_manager.php: Fixed timeout problem + with big machines changing the transfer to ajax data mode + to serialize way. Fixed little bugs as None option when + are data and few checks to avoid errors when try create + modules without select any OID. + 2011-09-28 Sergio Martin * godmode/setup/setup_auth.php: Fixed LDAP jquery problem diff --git a/pandora_console/extensions/snmp_explorer.php b/pandora_console/extensions/snmp_explorer.php index 7090718879..534ab8ec67 100755 --- a/pandora_console/extensions/snmp_explorer.php +++ b/pandora_console/extensions/snmp_explorer.php @@ -19,6 +19,7 @@ include_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'); function snmp_explorer() { @@ -91,6 +92,10 @@ function snmp_explorer() { if($create_modules) { $interfaces = json_decode(html_entity_decode(get_parameter_post("snmp_json")), true); + if(is_null($interfaces)) { + $interfaces = array(); + } + $values = array(); if($tcp_port != ''){ @@ -122,7 +127,7 @@ function snmp_explorer() { } } } - $modules = get_parameter('module'); + $modules = get_parameter('module', array()); $id_snmp = get_parameter('id_snmp'); if($id_snmp == false) { @@ -201,10 +206,6 @@ function snmp_explorer() { // Create the interface list for the interface $interfaces_list = array(); foreach($interfaces as $interface){ - /*foreach($interface as $key => $interf) { - echo $key.": ".$interf['value']."
"; - }*/ - // Get the interface name, removing " " characters and avoid "blank" interfaces if (!isset($interface['ifName']) || $interface['ifName']['value'] == "") continue; @@ -296,8 +297,10 @@ function snmp_explorer() { echo ''; echo ''; echo "
"; + + $id_snmp_serialize = serialize_in_temp($interfaces, $config['id_user']."_snmp"); + html_print_input_hidden('id_snmp_serialize', $id_snmp_serialize); - html_print_input_hidden('snmp_json', htmlentities(json_encode($interfaces))); html_print_input_hidden('create_modules', 1); html_print_input_hidden('ip_target', $ip_target); html_print_input_hidden('tcp_port', $tcp_port); @@ -383,32 +386,36 @@ function snmp_changed_by_multiple_snmp (event, id_snmp, selected) { {"page" : "godmode/agentes/agent_manager", "get_modules_json_for_multiple_snmp": 1, "id_snmp[]": idSNMP, - "snmp_json": $("#hidden-snmp_json").val() + "id_snmp_serialize": $("#hidden-id_snmp_serialize").val() }, function (data) { $('#module').empty (); - if (typeof($(document).data('text_for_module')) != 'undefined') { - $('#module').append ($('').html ($(document).data('text_for_module')).attr("value", 0).attr('selected', true)); - } - else { - if (typeof(data['any_text']) != 'undefined') { - $('#module').append ($('').html (data['any_text']).attr ("value", 0).attr('selected', true)); - } - else { - var anyText = $("#any_text").html(); //Trick for catch the translate text. - - if (anyText == null) { - anyText = 'Any'; - } - - $('#module').append ($('').html (anyText).attr ("value", 0).attr('selected', true)); - } - } + c = 0; jQuery.each (data, function (i, val) { s = js_html_entity_decode(val); $('#module').append ($('').html (s).attr ("value", i)); $('#module').fadeIn ('normal'); + c++; }); + if(c == 0){ + if (typeof($(document).data('text_for_module')) != 'undefined') { + $('#module').append ($('').html ($(document).data('text_for_module')).attr("value", 0).attr('selected', true)); + } + else { + if (typeof(data['any_text']) != 'undefined') { + $('#module').append ($('').html (data['any_text']).attr ("value", 0).attr('selected', true)); + } + else { + var anyText = $("#any_text").html(); //Trick for catch the translate text. + + if (anyText == null) { + anyText = 'Any'; + } + + $('#module').append ($('').html (anyText).attr ("value", 0).attr('selected', true)); + } + } + } if (selected != undefined) $('#module').attr ('value', selected); $('#module').attr ('disabled', 0); diff --git a/pandora_console/godmode/agentes/agent_manager.php b/pandora_console/godmode/agentes/agent_manager.php index f6d3bf1573..bc5c352de9 100644 --- a/pandora_console/godmode/agentes/agent_manager.php +++ b/pandora_console/godmode/agentes/agent_manager.php @@ -51,9 +51,13 @@ if (is_ajax ()) { $get_modules_json_for_multiple_snmp = (bool) get_parameter("get_modules_json_for_multiple_snmp", 0); if ($get_modules_json_for_multiple_snmp) { + require_once ('include/graphs/functions_utils.php'); + $idSNMP = get_parameter('id_snmp'); - $snmp = json_decode(html_entity_decode(get_parameter('snmp_json')),true); - + + $id_snmp_serialize = get_parameter('id_snmp_serialize'); + $snmp = unserialize_in_temp($id_snmp_serialize, false); + $oid_snmp = array(); $out = false; foreach($idSNMP as $id) {