From 2cbd2b69bf2227e65f444ccf761bf4a564a2ca22 Mon Sep 17 00:00:00 2001 From: mdtrooper Date: Tue, 10 Jul 2012 11:03:00 +0000 Subject: [PATCH] 2012-07-10 Miguel de Dios * include/functions_networkmap.php, include/functions_netflow.php, extensions/snmp_explorer.php, operation/netflow/nf_live_view.php, operation/agentes/estado_monitores.php, operation/agentes/networkmap.php, godmode/netflow/nf_report_form.php, godmode/netflow/nf_edit_form.php: cleaned source code style. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6760 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 9 + pandora_console/extensions/snmp_explorer.php | 671 +++++++++--------- .../godmode/netflow/nf_edit_form.php | 60 +- .../godmode/netflow/nf_report_form.php | 64 +- pandora_console/include/functions_netflow.php | 7 +- .../include/functions_networkmap.php | 91 +-- .../operation/agentes/estado_monitores.php | 20 +- .../operation/agentes/networkmap.php | 57 +- .../operation/netflow/nf_live_view.php | 80 +-- 9 files changed, 539 insertions(+), 520 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index bd54e0802f..fb2cb7e972 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,12 @@ +2012-07-10 Miguel de Dios + + * include/functions_networkmap.php, include/functions_netflow.php, + extensions/snmp_explorer.php, operation/netflow/nf_live_view.php, + operation/agentes/estado_monitores.php, + operation/agentes/networkmap.php, + godmode/netflow/nf_report_form.php, + godmode/netflow/nf_edit_form.php: cleaned source code style. + 2012-07-10 Miguel de Dios * install.php, operation/reporting/reporting_xml.php, diff --git a/pandora_console/extensions/snmp_explorer.php b/pandora_console/extensions/snmp_explorer.php index f1d51de02e..2baf4ccab5 100755 --- a/pandora_console/extensions/snmp_explorer.php +++ b/pandora_console/extensions/snmp_explorer.php @@ -22,194 +22,194 @@ require_once ('include/functions_reporting.php'); require_once ('include/graphs/functions_utils.php'); function snmp_explorer() { - - $idAgent = (int) get_parameter('id_agente', 0); - $ipAgent = db_get_value('direccion', 'tagente', 'id_agente', $idAgent); - - // Load global vars - global $config; - - - check_login (); - - $ip_target = (string) get_parameter ('ip_target', $ipAgent); - $snmp_community = (string) get_parameter ('snmp_community', 'public'); - $snmp_version = get_parameter('snmp_version', '1'); - $snmp3_auth_user = get_parameter('snmp3_auth_user'); - $snmp3_security_level = get_parameter('snmp3_security_level'); - $snmp3_auth_method = get_parameter('snmp3_auth_method'); - $snmp3_auth_pass = get_parameter('snmp3_auth_pass'); - $snmp3_privacy_method = get_parameter('snmp3_privacy_method'); - $snmp3_privacy_pass = 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 = array(); - - if($snmpwalk) { - - $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", $tcp_port); - - if($snmpis === false) { - $snmpis = array(); - } - $interfaces = array(); - - // We get here only the interface part of the MIB, not full mib - foreach($snmpis as $key => $snmp) { - - $data = explode(': ',$snmp); - $keydata = explode('::',$key); - $keydata2 = explode('.',$keydata[1]); + $idAgent = (int) get_parameter('id_agente', 0); + $ipAgent = db_get_value('direccion', 'tagente', 'id_agente', $idAgent); + + // Load global vars + global $config; + + + check_login (); + + $ip_target = (string) get_parameter ('ip_target', $ipAgent); + $snmp_community = (string) get_parameter ('snmp_community', 'public'); + $snmp_version = get_parameter('snmp_version', '1'); + $snmp3_auth_user = get_parameter('snmp3_auth_user'); + $snmp3_security_level = get_parameter('snmp3_security_level'); + $snmp3_auth_method = get_parameter('snmp3_auth_method'); + $snmp3_auth_pass = get_parameter('snmp3_auth_pass'); + $snmp3_privacy_method = get_parameter('snmp3_privacy_method'); + $snmp3_privacy_pass = 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 = array(); + + if($snmpwalk) { - if(!isset($keydata2[1])) { - continue; - } + $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", $tcp_port); - 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]; - } + if($snmpis === false) { + $snmpis = array(); + } - $interfaces[$keydata2[1]][$keydata2[0]]['oid'] = $key; - $interfaces[$keydata2[1]][$keydata2[0]]['checked'] = 0; - } + $interfaces = array(); - unset($interfaces[0]); - } - - if($create_modules) { - $id_snmp_serialize = get_parameter_post('id_snmp_serialize'); - $interfaces = unserialize_in_temp($id_snmp_serialize); - - if(!$interfaces) { + // We get here only the interface part of the MIB, not full mib + foreach($snmpis as $key => $snmp) { + + $data = explode(': ',$snmp); + $keydata = explode('::',$key); + $keydata2 = explode('.',$keydata[1]); + + if(!isset($keydata2[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); + + if(!$interfaces) { $interfaces = array(); } - $values = array(); - - if($tcp_port != ''){ - $values['tcp_port'] = $tcp_port; - } - $values['snmp_community'] = $snmp_community; - $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 = array(); - 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', array()); - $id_snmp = get_parameter('id_snmp'); - - if($id_snmp == false) { - ui_print_error_message (__('No modules selected')); - $id_snmp = array(); - } - - if(agents_get_name($id_agent) == false) { - ui_print_error_message (__('No agent selected or the agent does not exist')); - $id_snmp = array(); - } - - $result = false; - + $values = array(); + + if($tcp_port != '') { + $values['tcp_port'] = $tcp_port; + } + $values['snmp_community'] = $snmp_community; + $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 = array(); + 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', array()); + $id_snmp = get_parameter('id_snmp'); + + if($id_snmp == false) { + ui_print_error_message (__('No modules selected')); + $id_snmp = array(); + } + + if(agents_get_name($id_agent) == false) { + ui_print_error_message (__('No agent selected or the agent does not exist')); + $id_snmp = array(); + } + + $result = false; + $errors = array(); $done = 0; - - foreach($id_snmp as $id) { + + foreach($id_snmp as $id) { if (isset($interfaces[$id]['ifName']) && $interfaces[$id]['ifName']['value'] != ""){ - $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']; + $ifname = $interfaces[$id]['ifDescr']['value']; } - 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 = $name_array[1] . "_" . $ifname; - - // Clean the name - $name = str_replace ( "\"" , "" , $name); - - // Proc moduletypes - if (preg_match ( "/Status/", $name_array[1])) - $module_type = 18; - - elseif (preg_match ( "/Present/", $name_array[1])) - $module_type = 18; - - elseif (preg_match ( "/PromiscuousMode/", $name_array[1])) - $module_type = 18; - - // String moduletypes - elseif (preg_match ( "/Alias/", $name_array[1])) - $module_type = 17; - - elseif (preg_match ( "/Address/", $name_array[1])) - $module_type = 17; - - elseif (preg_match ( "/Name/", $name_array[1])) - $module_type = 17; - - elseif (preg_match ( "/Specific/", $name_array[1])) - $module_type = 17; - - elseif (preg_match ( "/Descr/", $name_array[1])) - $module_type = 17; - - // Specific counters (ends in s) - elseif (preg_match ( "/s$/", $name_array[1])) - $module_type = 16; - - // Otherwise, numeric - else - $module_type = 15; - - $values['id_tipo_modulo'] = $module_type; - $values['descripcion'] = io_safe_input("(" . $ip_target." - ".$name . ") " . $interfaces[$id]['ifDescr']['value']); - - $values['snmp_oid'] = $oid; - $values['id_modulo'] = 2; - - $result = modules_create_agent_module ($id_agent, io_safe_input($name), $values); - - if(is_error($result)) { + 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 = $name_array[1] . "_" . $ifname; + + // Clean the name + $name = str_replace ( "\"" , "" , $name); + + // Proc moduletypes + if (preg_match ( "/Status/", $name_array[1])) + $module_type = 18; + + elseif (preg_match ( "/Present/", $name_array[1])) + $module_type = 18; + + elseif (preg_match ( "/PromiscuousMode/", $name_array[1])) + $module_type = 18; + + // String moduletypes + elseif (preg_match ( "/Alias/", $name_array[1])) + $module_type = 17; + + elseif (preg_match ( "/Address/", $name_array[1])) + $module_type = 17; + + elseif (preg_match ( "/Name/", $name_array[1])) + $module_type = 17; + + elseif (preg_match ( "/Specific/", $name_array[1])) + $module_type = 17; + + elseif (preg_match ( "/Descr/", $name_array[1])) + $module_type = 17; + + // Specific counters (ends in s) + elseif (preg_match ( "/s$/", $name_array[1])) + $module_type = 16; + + // Otherwise, numeric + else + $module_type = 15; + + $values['id_tipo_modulo'] = $module_type; + $values['descripcion'] = io_safe_input("(" . $ip_target." - ".$name . ") " . $interfaces[$id]['ifDescr']['value']); + + $values['snmp_oid'] = $oid; + $values['id_modulo'] = 2; + + $result = modules_create_agent_module ($id_agent, io_safe_input($name), $values); + + if (is_error($result)) { if(!isset($errors[$result])) { $errors[$result] = 0; } @@ -218,19 +218,19 @@ function snmp_explorer() { else { $done++; } - } - } - - if($done > 0) { + } + } + + if ($done > 0) { ui_print_success_message(__('Successfully modules created')." ($done)"); } - if(!empty($errors)) { + if (!empty($errors)) { $msg = __('Could not be created').':'; - - - foreach($errors as $code => $number) { - switch($code) { + + + foreach ($errors as $code => $number) { + switch ($code) { case ERR_EXIST: $msg .= '
'.__('Another module already exists with the same name')." ($number)"; break; @@ -243,171 +243,169 @@ function snmp_explorer() { $msg .= '
'.__('Processing error')." ($number)"; break; } - } ui_print_error_message($msg); } - } - - // Create the interface list for the interface - $interfaces_list = array(); - foreach($interfaces as $interface){ - // Get the interface name, removing " " characters and avoid "blank" interfaces - if (isset($interface['ifName']) && $interface['ifName']['value'] != ""){ - $ifname = $interface['ifName']['value']; - } - else if (isset($interface['ifDescr']) && $interface['ifDescr']['value'] != ""){ - $ifname = $interface['ifDescr']['value']; - } - else { - continue; - } - - $interfaces_list[$interface['ifIndex']['value']] = str_replace ( "\"" , "" , $ifname); - - } - - echo ''; - echo "
"; - - $table->width = '98%'; - - $table->valign[0] = 'top'; - $table->valign[1] = 'top'; - - $table->data[0][0] = '' . __('Target IP') . ''; - $table->data[0][1] = html_print_input_text ('ip_target', $ip_target, '', 15, 60, true); - - $table->data[0][2] = '' . __('Port') . ''; - $table->data[0][3] = html_print_input_text ('tcp_port', $tcp_port, '', 5, 20, true); - - $snmp_versions['1'] = 'v. 1'; - $snmp_versions['2'] = 'v. 2'; - $snmp_versions['2c'] = 'v. 2c'; - $snmp_versions['3'] = 'v. 3'; - - $table->data[1][0] = '' . __('SNMP community') . ''; - $table->data[1][1] = html_print_input_text ('snmp_community', $snmp_community, '', 15, 60, true); - - $table->data[1][2] = '' . _('SNMP version') . ''; - $table->data[1][3] = html_print_select ($snmp_versions, 'snmp_version', $snmp_version, '', '', '', true, false, false, ''); - - $table->data[1][3] .= ''; - html_print_input_hidden('snmpwalk', 1); - - html_print_table($table); - - unset($table); - - //SNMP3 OPTIONS - $table->width = '98%'; - - $table->valign[0] = 'top'; - $table->valign[1] = 'top'; - - $table->data[2][1] = ''.__('Auth user').''; - $table->data[2][2] = html_print_input_text ('snmp3_auth_user', $snmp3_auth_user, '', 15, 60, true); - $table->data[2][3] = ''.__('Auth password').''; - $table->data[2][4] = html_print_input_text ('snmp3_auth_pass', $snmp3_auth_pass, '', 15, 60, true); - $table->data[2][4] .= html_print_input_hidden('active_snmp_v3', 0, true); - - $table->data[5][0] = ''.__('Privacy method').''; - $table->data[5][1] = html_print_select(array('DES' => __('DES'), 'AES' => __('AES')), 'snmp3_privacy_method', $snmp3_privacy_method, '', '', '', true); - $table->data[5][2] = ''.__('privacy pass').''; - $table->data[5][3] = html_print_input_text ('snmp3_privacy_pass', $snmp3_privacy_pass, '', 15, 60, true); - - $table->data[6][0] = ''.__('Auth method').''; - $table->data[6][1] = html_print_select(array('MD5' => __('MD5'), 'SHA' => __('SHA')), 'snmp3_auth_method', $snmp3_auth_method, '', '', '', true); - $table->data[6][2] = ''.__('Security level').''; - $table->data[6][3] = html_print_select(array('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 '
'; - }else { - echo ''; - - echo "
"; - echo ''; - html_print_submit_button(__('SNMP Walk'), 'snmp_walk', false, array('class' => 'sub next')); - echo "
"; - - if($snmpwalk && !$snmpis) { - echo ''.__('Unable to do SNMP walk').''; - } - - unset($table); - - echo ""; - - //echo ""; - //echo ""; - - if(!empty($interfaces_list)){ - 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('create_modules', 1); - html_print_input_hidden('ip_target', $ip_target); - 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); - - $table->width = '98%'; - - $table->valign[0] = 'top'; - $table->valign[1] = 'top'; - - //Agent selector - $table->data[0][0] = ''.__('Interfaces').''; - $table->data[0][1] = ''; - $table->data[0][2] = ''.__('Modules').''; - - $table->data[1][0] = html_print_select ($interfaces_list, 'id_snmp[]', 0, false, '', '', true, true, true, '', false, 'width:200px;'); - $table->data[1][1] = html_print_image('images/darrowright.png', true); - $table->data[1][2] = html_print_select (array (), '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 "
"; - html_print_submit_button(__('Create modules'), '', false, array('class' => 'sub add')); + // Create the interface list for the interface + $interfaces_list = array(); + foreach($interfaces as $interface){ + // Get the interface name, removing " " characters and avoid "blank" interfaces + if (isset($interface['ifName']) && $interface['ifName']['value'] != ""){ + $ifname = $interface['ifName']['value']; + } + else if (isset($interface['ifDescr']) && $interface['ifDescr']['value'] != ""){ + $ifname = $interface['ifDescr']['value']; + } + else { + continue; + } + + $interfaces_list[$interface['ifIndex']['value']] = str_replace ( "\"" , "" , $ifname); + } + + echo ''; + echo ""; + + $table->width = '98%'; + + $table->valign[0] = 'top'; + $table->valign[1] = 'top'; + + $table->data[0][0] = '' . __('Target IP') . ''; + $table->data[0][1] = html_print_input_text ('ip_target', $ip_target, '', 15, 60, true); + + $table->data[0][2] = '' . __('Port') . ''; + $table->data[0][3] = html_print_input_text ('tcp_port', $tcp_port, '', 5, 20, true); + + $snmp_versions['1'] = 'v. 1'; + $snmp_versions['2'] = 'v. 2'; + $snmp_versions['2c'] = 'v. 2c'; + $snmp_versions['3'] = 'v. 3'; + + $table->data[1][0] = '' . __('SNMP community') . ''; + $table->data[1][1] = html_print_input_text ('snmp_community', $snmp_community, '', 15, 60, true); + + $table->data[1][2] = '' . _('SNMP version') . ''; + $table->data[1][3] = html_print_select ($snmp_versions, 'snmp_version', $snmp_version, '', '', '', true, false, false, ''); + + $table->data[1][3] .= ''; + html_print_input_hidden('snmpwalk', 1); + + html_print_table($table); + + unset($table); + + //SNMP3 OPTIONS + $table->width = '98%'; + + $table->valign[0] = 'top'; + $table->valign[1] = 'top'; + + $table->data[2][1] = ''.__('Auth user').''; + $table->data[2][2] = html_print_input_text ('snmp3_auth_user', $snmp3_auth_user, '', 15, 60, true); + $table->data[2][3] = ''.__('Auth password').''; + $table->data[2][4] = html_print_input_text ('snmp3_auth_pass', $snmp3_auth_pass, '', 15, 60, true); + $table->data[2][4] .= html_print_input_hidden('active_snmp_v3', 0, true); + + $table->data[5][0] = ''.__('Privacy method').''; + $table->data[5][1] = html_print_select(array('DES' => __('DES'), 'AES' => __('AES')), 'snmp3_privacy_method', $snmp3_privacy_method, '', '', '', true); + $table->data[5][2] = ''.__('privacy pass').''; + $table->data[5][3] = html_print_input_text ('snmp3_privacy_pass', $snmp3_privacy_pass, '', 15, 60, true); + + $table->data[6][0] = ''.__('Auth method').''; + $table->data[6][1] = html_print_select(array('MD5' => __('MD5'), 'SHA' => __('SHA')), 'snmp3_auth_method', $snmp3_auth_method, '', '', '', true); + $table->data[6][2] = ''.__('Security level').''; + $table->data[6][3] = html_print_select(array('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 '
'; + } + else { + echo ''; + + echo "
"; + echo ''; + html_print_submit_button(__('SNMP Walk'), 'snmp_walk', false, array('class' => 'sub next')); + echo "
"; + + if ($snmpwalk && !$snmpis) { + echo ''.__('Unable to do SNMP walk').''; + } + + unset($table); + + echo ""; + + //echo ""; + //echo ""; + + if (!empty($interfaces_list)) { + 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('create_modules', 1); + html_print_input_hidden('ip_target', $ip_target); + 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); + + $table->width = '98%'; + + $table->valign[0] = 'top'; + $table->valign[1] = 'top'; + + //Agent selector + $table->data[0][0] = ''.__('Interfaces').''; + $table->data[0][1] = ''; + $table->data[0][2] = ''.__('Modules').''; + + $table->data[1][0] = html_print_select ($interfaces_list, 'id_snmp[]', 0, false, '', '', true, true, true, '', false, 'width:200px;'); + $table->data[1][1] = html_print_image('images/darrowright.png', true); + $table->data[1][2] = html_print_select (array (), '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 "
"; + html_print_submit_button(__('Create modules'), '', false, array('class' => 'sub add')); echo "
"; - unset($table); - - echo "
"; - echo '
'; - } - - ui_require_jquery_file ('pandora.controls'); - ui_require_jquery_file ('ajaxqueue'); - ui_require_jquery_file ('bgiframe'); + unset($table); + + echo ""; + echo '
'; + } + + ui_require_jquery_file ('pandora.controls'); + ui_require_jquery_file ('ajaxqueue'); + ui_require_jquery_file ('bgiframe'); //ui_require_jquery_file ('autocomplete'); - ?> - - - + \ No newline at end of file diff --git a/pandora_console/godmode/netflow/nf_report_form.php b/pandora_console/godmode/netflow/nf_report_form.php index 90a420e218..dd9906982d 100644 --- a/pandora_console/godmode/netflow/nf_report_form.php +++ b/pandora_console/godmode/netflow/nf_report_form.php @@ -36,19 +36,19 @@ $create = (string)get_parameter('create', 0); $buttons['report_list']['active'] = false; $buttons['report_list'] = '' - . html_print_image ("images/edit.png", true, array ("title" => __('Report list'))) - . ''; - + . html_print_image ("images/edit.png", true, array ("title" => __('Report list'))) + . ''; + $buttons['report_items']['active'] = false; $buttons['report_items']['text'] = '' - . html_print_image ("images/god6.png", true, array ("title" => __('Report items'))) - . ''; - + . html_print_image ("images/god6.png", true, array ("title" => __('Report items'))) + . ''; + $buttons['edit_report']['active'] = true; $buttons['edit_report']['text'] = '' - . html_print_image ("images/config.png", true, array ("title" => __('Edit report'))) - . ''; - + . html_print_image ("images/config.png", true, array ("title" => __('Edit report'))) + . ''; + //Header ui_print_page_header (__('Netflow Report'), "images/networkmap/so_cisco_new.png", false, "", true, $buttons); @@ -66,7 +66,8 @@ if ($id) { $description = $report['description']; $group = $report['id_group']; -} else { +} +else { $name = ''; $group = ''; $description = ''; @@ -77,10 +78,11 @@ if ($update) { $name = (string) get_parameter ('name'); $description = get_parameter ('description'); $group = get_parameter('id_group'); - + if ($name == '') { - ui_print_error_message (__('Not updated. Blank name')); - } else { + ui_print_error_message (__('Not updated. Blank name')); + } + else { $result = db_process_sql_update ('tnetflow_report', array ( 'id_name' => $name, @@ -88,26 +90,28 @@ if ($update) { 'description' => $description, ), array ('id_report' => $id)); - ui_print_result_message ($result, __('Report updated successfully'), __('Error updating report')); - } + ui_print_result_message ($result, __('Report updated successfully'), __('Error updating report')); + } } if ($create){ $name = (string) get_parameter ('name'); $group = (int) get_parameter ('id_group'); $description = get_parameter('description',''); - + $values = array ( - 'id_name' => $name, - 'id_group' => $group, - 'description' => $description, + 'id_name' => $name, + 'id_group' => $group, + 'description' => $description, ); + $id = db_process_sql_insert('tnetflow_report', $values); - if ($id === false) { - ui_print_error_message ('Error creating report'); - } else { - ui_print_success_message ('Report created successfully'); - } + if ($id === false) { + ui_print_error_message ('Error creating report'); + } + else { + ui_print_success_message ('Report created successfully'); + } } $table->width = '80%'; @@ -118,15 +122,15 @@ $table->class = "databox_color"; $table->style[0] = 'vertical-align: top;'; $table->data = array (); - + $table->data[0][0] = ''.__('Name').''; $table->data[0][1] = html_print_input_text ('name', $name, false, 30, 80, true); $own_info = get_user_info ($config['id_user']); $table->data[1][0] = ''.__('Group').''; $table->data[1][1] = html_print_select_groups($config['id_user'], "IW", - $own_info['is_admin'], 'id_group', $group, '','', -1, true, - false, false); + $own_info['is_admin'], 'id_group', $group, '','', -1, true, + false, false); $table->data[2][0] = ''.__('Description').''; $table->data[2][1] = html_print_textarea ('description', 2, 65, $description, '', true); @@ -140,11 +144,11 @@ if ($id) { html_print_input_hidden ('update', 1); html_print_input_hidden ('id', $id); html_print_submit_button (__('Update'), 'crt', false, 'class="sub upd"'); -} else { +} +else { html_print_input_hidden ('create', 1); html_print_submit_button (__('Create'), 'crt', false, 'class="sub wand"'); } echo '
'; echo ''; - -?> +?> \ No newline at end of file diff --git a/pandora_console/include/functions_netflow.php b/pandora_console/include/functions_netflow.php index c5330a37e3..24f856f3e9 100644 --- a/pandora_console/include/functions_netflow.php +++ b/pandora_console/include/functions_netflow.php @@ -182,7 +182,7 @@ function compare_flows ($a, $b) { * */ function sort_netflow_data (&$netflow_data) { - usort($netflow_data, "compare_flows"); + usort($netflow_data, "compare_flows"); } function netflow_stat_table ($data, $start_date, $end_date, $aggregate, $unit){ @@ -207,7 +207,8 @@ function netflow_stat_table ($data, $start_date, $end_date, $aggregate, $unit){ $values[$agg] = $data[$j]['data']; $table->data[$x][0] = $agg; $table->data[$x][1] = format_numeric ($data[$j]['data']); - } else { + } + else { $values[$agg] += $data[$j]['data']; $table->data[$x][0] = $agg; $table->data[$x][1] = format_numeric ($data[$j]['data']); @@ -215,7 +216,7 @@ function netflow_stat_table ($data, $start_date, $end_date, $aggregate, $unit){ $j++; $x++; } - + html_print_table($table); } diff --git a/pandora_console/include/functions_networkmap.php b/pandora_console/include/functions_networkmap.php index 82e89dee3b..0e6f60512f 100644 --- a/pandora_console/include/functions_networkmap.php +++ b/pandora_console/include/functions_networkmap.php @@ -42,9 +42,10 @@ function networkmap_is_descendant ($node, $ascendant, $parents) { } // Generate a dot graph definition for graphviz -function networkmap_generate_dot ($pandora_name, $group = 0, $simple = 0, $font_size = 12, - $layout = 'radial', $nooverlap = 0, $zoom = 1, $ranksep = 2.5, $center = 0, - $regen = 1, $pure = 0, $id_networkmap = 0, $show_snmp_modules = 0, $cut_names = true, +function networkmap_generate_dot ($pandora_name, $group = 0, $simple = 0, + $font_size = 12, $layout = 'radial', $nooverlap = 0, $zoom = 1, + $ranksep = 2.5, $center = 0, $regen = 1, $pure = 0, + $id_networkmap = 0, $show_snmp_modules = 0, $cut_names = true, $relative = false) { $parents = array(); @@ -136,7 +137,7 @@ function networkmap_generate_dot ($pandora_name, $group = 0, $simple = 0, $font_ continue; } - switch($node['type']){ + switch ($node['type']) { case 'agent': $graph .= networkmap_create_agent_node ($node , $simple, $font_size, $cut_names, $relative)."\n\t\t"; $stats['agents'][] = $node['id_agente']; @@ -195,7 +196,7 @@ function networkmap_generate_dot_groups ($pandora_name, $group = 0, $simple = 0, $groups[] = db_get_row ('tgrupo', 'id_grupo', $id_group); } } - + $filter['id_grupo'] = $id_groups; } else { @@ -231,18 +232,19 @@ function networkmap_generate_dot_groups ($pandora_name, $group = 0, $simple = 0, // Save node parent information to define edges later if ($node_group['parent'] != "0" && $node_group['id_grupo'] != $group) { $parents[$node_count] = $nodes_groups[$node_group['parent']]['id_node']; - } else { + } + else { $orphans[$node_count] = 1; } - $nodes[$node_count] = $node_group; + $nodes[$node_count] = $node_group; } - if($depth != 'group') { + if ($depth != 'group') { // Get agents data $agents = agents_get_agents ($filter, array ('id_grupo, nombre, id_os, id_agente')); - + if ($agents === false) $agents = array(); @@ -252,13 +254,13 @@ function networkmap_generate_dot_groups ($pandora_name, $group = 0, $simple = 0, $node_count ++; // Save node parent information to define edges later $parents[$node_count] = $agent['parent'] = $nodes_groups[$agent['id_grupo']]['id_node']; - + $agent['id_node'] = $node_count; $agent['type'] = 'agent'; // Add node $nodes[$node_count] = $nodes_agents[$agent['id_agente']] = $agent; - if($depth == 'agent'){ + if ($depth == 'agent') { continue; } @@ -269,35 +271,37 @@ function networkmap_generate_dot_groups ($pandora_name, $group = 0, $simple = 0, $node_count ++; $agent_module = modules_get_agentmodule($key); $alerts_module = db_get_sql('SELECT count(*) as num - FROM talert_template_modules WHERE id_agent_module = '.$key); + FROM talert_template_modules + WHERE id_agent_module = ' . $key); - if($alerts_module == 0 && $modwithalerts){ + if ($alerts_module == 0 && $modwithalerts) { continue; } - if($agent_module['id_module_group'] != $module_group && $module_group != 0){ + if ($agent_module['id_module_group'] != $module_group && + $module_group != 0) { continue; } - if($hidepolicymodules && $config['enterprise_installed']){ + if ($hidepolicymodules && $config['enterprise_installed']) { enterprise_include_once('include/functions_policies.php'); - if(policies_is_module_in_policy($key)) { + if (policies_is_module_in_policy($key)) { continue; } } - + // Save node parent information to define edges later $parents[$node_count] = $agent_module['parent'] = $agent['id_node']; - + $agent_module['id_node'] = $node_count; - + $agent_module['type'] = 'module'; // Add node $nodes[$node_count] = $agent_module; } } } - + if (empty ($nodes)) { return false; } @@ -309,7 +313,7 @@ function networkmap_generate_dot_groups ($pandora_name, $group = 0, $simple = 0, unset ($nodes[$node_id]); continue; } - switch($node['type']){ + switch ($node['type']) { case 'group': $graph .= networkmap_create_group_node ($node , $simple, $font_size)."\n\t\t"; $stats['groups'][] = $node['id_grupo']; @@ -329,16 +333,17 @@ function networkmap_generate_dot_groups ($pandora_name, $group = 0, $simple = 0, // Verify that the parent is in the graph if (isset ($nodes[$parent_id])) { $graph .= networkmap_create_edge ($node, $parent_id, $layout, $nooverlap, $pure, $zoom, $ranksep, $simple, $regen, $font_size, $group, 'operation/agentes/networkmap', 'groups', $id_networkmap); - } else { + } + else { $orphans[$node] = 1; } } - + // Create a central node if orphan nodes exist if (count ($orphans)) { $graph .= networkmap_create_pandora_node ($pandora_name, $font_size, $simple, $stats); } - + // Define edges for orphan nodes foreach (array_keys($orphans) as $node) { $graph .= networkmap_create_edge ('0', $node, $layout, $nooverlap, $pure, $zoom, $ranksep, $simple, $regen, $font_size, $group, 'operation/agentes/networkmap', 'groups', $id_networkmap); @@ -550,7 +555,7 @@ function networkmap_open_graph ($layout, $nooverlap, $pure, $zoom, $ranksep, $fo $size_y = 5.4; $size = ''; - + if ($layout == 'radial') { $overlap = 'true'; } @@ -560,7 +565,7 @@ function networkmap_open_graph ($layout, $nooverlap, $pure, $zoom, $ranksep, $fo $overlap = 'scalexy'; } } - + if ($zoom > 0) { $size_x *= $zoom; $size_y *= $zoom; @@ -577,7 +582,7 @@ function networkmap_open_graph ($layout, $nooverlap, $pure, $zoom, $ranksep, $fo $head .= "ratio=fill;"; $head .= "root=0;"; $head .= "size=\"$size\";"; - + return $head; } @@ -588,19 +593,25 @@ function networkmap_close_graph () { // Returns the filter used to achieve the desired layout function networkmap_get_filter ($layout) { - switch($layout) { - case 'flat': - return 'dot'; - case 'radial': - return 'twopi'; - case 'circular': - return 'circo'; - case 'spring1': - return 'neato'; - case 'spring2': - return 'fdp'; - default: - return 'twopi'; + switch ($layout) { + case 'flat': + return 'dot'; + break; + case 'radial': + return 'twopi'; + break; + case 'circular': + return 'circo'; + break; + case 'spring1': + return 'neato'; + break; + case 'spring2': + return 'fdp'; + break; + default: + return 'twopi'; + break; } } diff --git a/pandora_console/operation/agentes/estado_monitores.php b/pandora_console/operation/agentes/estado_monitores.php index 5ab71c7df6..863cf556b6 100644 --- a/pandora_console/operation/agentes/estado_monitores.php +++ b/pandora_console/operation/agentes/estado_monitores.php @@ -300,11 +300,11 @@ foreach ($modules as $module) { } else { $data[1] = ""; - } + } } - + $data[2] = servers_show_type ($module['id_modulo']) . ' '; - + if (check_acl ($config['id_user'], $id_grupo, "AW")) $data[2] .= '' . html_print_image("images/config.png", true, array("alt" => '0', "border" => "")) . ''; @@ -340,7 +340,7 @@ foreach ($modules as $module) { else { if (is_numeric($module["datos"])){ $salida = format_numeric($module["datos"]); - + // Show units ONLY in numeric data types if (isset($module["unit"])){ $salida .= " " . ''. io_safe_output($module["unit"]) . ''; @@ -361,21 +361,21 @@ foreach ($modules as $module) { } } } - + $data[6] = ui_print_module_warn_value ($module["max_warning"], $module["min_warning"], $module["str_warning"], $module["max_critical"], $module["min_critical"], $module["str_critical"]); - + $data[7] = $salida; $graph_type = return_graphtype ($module["id_tipo_modulo"]); - + $data[8] = " "; if ($module['history_data'] == 1){ $nombre_tipo_modulo = modules_get_moduletype_name ($module["id_tipo_modulo"]); $handle = "stat".$nombre_tipo_modulo."_".$module["id_agente_modulo"]; $url = 'include/procesos.php?agente='.$module["id_agente_modulo"]; $win_handle=dechex(crc32($module["id_agente_modulo"].$module["nombre"])); - + $link ="winopeng('operation/agentes/stat_win.php?type=$graph_type&period=86400&id=".$module["id_agente_modulo"]."&label=".base64_encode($module["nombre"])."&refresh=600','day_".$win_handle."')"; - + // if ($nombre_tipo_modulo != "log4x") $data[8] .= '' . html_print_image("images/chart_curve.png", true, array("border" => '0', "alt" => "")) . '   '; $data[8] .= "" . html_print_image('images/binary.png', true, array("border" => '0', "alt" => "")) . ""; @@ -432,4 +432,4 @@ ui_require_jquery_file ('cluetip'); }); /* ]]> */ - + \ No newline at end of file diff --git a/pandora_console/operation/agentes/networkmap.php b/pandora_console/operation/agentes/networkmap.php index e19e588d4a..6f78716b47 100644 --- a/pandora_console/operation/agentes/networkmap.php +++ b/pandora_console/operation/agentes/networkmap.php @@ -223,31 +223,31 @@ if (!$nomaps && $id_networkmap != 0) { } $title = ''; -switch($activeTab){ +switch ($activeTab) { case 'topology': - $title = __('Topology view'); - break; + $title = __('Topology view'); + break; case 'groups': - $title = __('Groups view'); - break; + $title = __('Groups view'); + break; case 'policies': - $title = __('Policies view'); - break; + $title = __('Policies view'); + break; } -if(!empty($name)) { +if (!empty($name)) { $title .= " » ". mb_substr($name, 0, 25); } ui_print_page_header (__('Network map')." - ".$title, "images/bricks.png", false, "network_map", false, $buttons); -if($delete_networkmap || $add_networkmap || $save_networkmap) { +if ($delete_networkmap || $add_networkmap || $save_networkmap) { echo $message; } -if($id_networkmap == 0) { - echo "
".__('There are no defined maps in this view')."
"; - return; +if ($id_networkmap == 0) { + echo "
".__('There are no defined maps in this view')."
"; + return; } // CONFIGURATION FORM @@ -256,11 +256,11 @@ echo "
"; // Layout selection $layout_array = array ( - 'circular' => 'circular', - 'radial' => 'radial', - 'spring1' => 'spring 1', - 'spring2' => 'spring 2', - 'flat' => 'flat'); + 'circular' => 'circular', + 'radial' => 'radial', + 'spring1' => 'spring 1', + 'spring2' => 'spring 2', + 'flat' => 'flat'); $options_form = '
'; $options_form .= ''; @@ -274,13 +274,13 @@ $options_form .= ''; $options_form .= ''; -if($activeTab == 'groups' || $activeTab == 'policies'){ +if ($activeTab == 'groups' || $activeTab == 'policies') { $options_form .= ''; } -if($activeTab == 'topology') { +if ($activeTab == 'topology') { $options_form .= ''; @@ -290,14 +290,14 @@ $options_form .= ''; -if($activeTab == 'groups'){ +if ($activeTab == 'groups') { $options_form .= ''; } -if($activeTab == 'policies'){ +if ($activeTab == 'policies') { $options_form .= ''; -if(($activeTab == 'groups' || $activeTab == 'policies') && $depth == 'all') { +if (($activeTab == 'groups' || $activeTab == 'policies') && + $depth == 'all') { $options_form .= ''; - - if($activeTab == 'groups') { + + if ($activeTab == 'groups') { if($config['enterprise_installed']) { $options_form .= ''; - } -if ($nooverlap == 1){ +if ($nooverlap == 1) { $options_form .= "
' . __('Group') . '
'; $options_form .= html_print_select_groups(false, 'AR', false, 'group', $group, '', 'All', 0, true); $options_form .= '
' . __('Module group') . '
'; $options_form .= html_print_select_from_sql ('SELECT id_mg, name FROM tmodule_group', 'module_group', $module_group, '', 'All', 0, true); $options_form .= '
' . __('Show interfaces') . '
'; $options_form .= html_print_checkbox ('show_snmp_modules', '1', $show_snmp_modules, true); $options_form .= '
' . __('Layout') . '
'; $options_form .= html_print_select ($layout_array, 'layout', $layout, '', '', '', true); $options_form .= '
' . __('Depth') . '
'; $depth_levels = array('all' => __('All'), 'agent' => __('Agents'), 'group' => __('Groups')); $options_form .= html_print_select ($depth_levels, 'depth', $depth, '', '', '', true, false, false); $options_form .= '
' . __('Depth') . '
'; $depth_levels = array('all' => __('All'), 'agent' => __('Agents'), 'policy' => __('Policies')); $options_form .= html_print_select ($depth_levels, 'depth', $depth, '', '', '', true, false, false); @@ -311,12 +311,13 @@ $options_form .= '
' . __('No Overlap') . '
'; $options_form .= html_print_checkbox ('nooverlap', '1', $nooverlap, true); $options_form .= '
' . __('Only modules with alerts') . '
'; $options_form .= html_print_checkbox ('modwithalerts', '1', $modwithalerts, true); $options_form .= '
' . __('Hide policy modules') . '
'; $options_form .= html_print_checkbox ('hidepolicymodules', '1', $hidepolicymodules, true); @@ -343,14 +344,13 @@ if ($pure == "1") { '2.5' => 'x5', '5' => 'x10', ); - + $options_form .= '
' . __('Zoom') . '
'; $options_form .= html_print_select ($zoom_array, 'zoom', $zoom, '', '', '', true, false, false, false); $options_form .= '
"; $options_form .= __('Distance between nodes') . '
'; $options_form .= html_print_input_text ('ranksep', $ranksep, __('Separation between elements in the map (in Non-overlap mode)'), 3, 4, true); @@ -385,5 +385,4 @@ if($id_networkmap != 0) { break; } } - -?> +?> \ No newline at end of file diff --git a/pandora_console/operation/netflow/nf_live_view.php b/pandora_console/operation/netflow/nf_live_view.php index 53e7aeefdc..9b2578efc0 100644 --- a/pandora_console/operation/netflow/nf_live_view.php +++ b/pandora_console/operation/netflow/nf_live_view.php @@ -180,7 +180,8 @@ echo 'data[2][3] = html_print_select_from_sql ($sql, 'filter_id', $filter_id, '', __('none'), 0, true); - + $table->data[3][0] = __('Dst Ip'). ui_print_help_tip (__("Destination IP. A comma separated list of destination ip. If we leave the field blank, will show all ip. Example filter by ip:
25.46.157.214,160.253.135.249"), true); $table->data[3][1] = html_print_input_text ('ip_dst', $filter['ip_dst'], false, 40, 80, true); $table->data[3][2] = __('Src Ip'). ui_print_help_tip (__("Source IP. A comma separated list of source ip. If we leave the field blank, will show all ip. Example filter by ip:
25.46.157.214,160.253.135.249"), true); $table->data[3][3] = html_print_input_text ('ip_src', $filter['ip_src'], false, 40, 80, true); - + $table->data[4][0] = __('Dst Port'). ui_print_help_tip (__("Destination port. A comma separated list of destination ports. If we leave the field blank, will show all ports. Example filter by ports 80 and 22:
80,22"), true); $table->data[4][1] = html_print_input_text ('dst_port', $filter['dst_port'], false, 40, 80, true); $table->data[4][2] = __('Src Port'). ui_print_help_tip (__("Source port. A comma separated list of source ports. If we leave the field blank, will show all ports. Example filter by ports 80 and 22:
80,22"), true); @@ -206,94 +207,91 @@ echo 'colspan[5][1] = 3; - + $table->data[6][0] = ''.__('Aggregate by').''. ui_print_help_icon ('aggregate_by', true); - + $aggregate_list = array(); $aggregate_list = array ('none' => __('None'), 'proto' => __('Protocol'), 'srcip' =>__('Src Ip Address'), 'dstip' =>__('Dst Ip Address'), 'srcport' =>__('Src Port'), 'dstport' =>__('Dst Port') ); $table->data[6][1] = html_print_select ($aggregate_list, "aggregate", $filter['aggregate'], '', '', 0, true, false, true, '', false); - + $table->data[6][2] = ''.__('Output format').''; $show_output = array(); $show_output = array ('packets' => __('Packets'), 'bytes' => __('Bytes'), 'flows' =>__('Flows')); $table->data[6][3] = html_print_select ($show_output, 'output', $filter['output'], '', '', 0, true, false, true, '', false); - + html_print_table ($table); - + html_print_submit_button (__('Draw'), 'draw_button', false, 'class="sub upd"'); if (check_acl ($config["id_user"], 0, "AW")) { html_print_submit_button (__('Save as new filter'), 'save_button', false, 'class="sub upd" onClick="return defineFilterName();"'); - - html_print_submit_button (__('Update current filter'), 'update_button', false, 'class="sub upd"'); - + + html_print_submit_button (__('Update current filter'), 'update_button', false, 'class="sub upd"'); } echo''; if ($draw != '') { - // Get the command to call nfdump $command = netflow_get_command ($filter); - + // Build a unique id for the cache $unique_id = 'live_view__' . ($end_date - $start_date); - + // Draw netflow_draw_item ($start_date, $end_date, $chart_type, $filter, $command, $filter, $max_aggregates, $unique_id); } - ?> + \ No newline at end of file