2013-07-30 Miguel de Dios <miguel.dedios@artica.es>

* mobile/operation/networkmap.php, godmode/users/user_list.php,
	include/javascript/pandora.js,
	include/javascript/openlayers.pandora.js,
	include/functions_snmp_browser.php, include/api.php,
	include/functions_api.php, operation/snmpconsole/snmp_browser.php,
	operation/agentes/networkmap.dinamic.php: improved the source code
	style.




git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@8596 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
mdtrooper 2013-07-30 10:25:49 +00:00
parent 9b18352767
commit c7e78e0190
10 changed files with 275 additions and 265 deletions

View File

@ -1,3 +1,13 @@
2013-07-30 Miguel de Dios <miguel.dedios@artica.es>
* mobile/operation/networkmap.php, godmode/users/user_list.php,
include/javascript/pandora.js,
include/javascript/openlayers.pandora.js,
include/functions_snmp_browser.php, include/api.php,
include/functions_api.php, operation/snmpconsole/snmp_browser.php,
operation/agentes/networkmap.dinamic.php: improved the source code
style.
2013-07-30 Sergio Martin <sergio.martin@artica.es> 2013-07-30 Sergio Martin <sergio.martin@artica.es>
* include/functions_users.php * include/functions_users.php

View File

@ -80,11 +80,11 @@ if ($correctLogin) {
// The extension API file must exist and the extension must be enabled // The extension API file must exist and the extension must be enabled
if (file_exists($extension_api_url) && !in_array($ext_name,extensions_get_disabled_extensions())) { if (file_exists($extension_api_url) && !in_array($ext_name,extensions_get_disabled_extensions())) {
include_once($extension_api_url); include_once($extension_api_url);
$function_name = 'apiextension_'.$op.'_'.$ext_function; $function_name = 'apiextension_' . $op .'_' . $ext_function;
} }
} }
else { else {
$function_name = 'api_'.$op.'_'.$op2; $function_name = 'api_' . $op . '_' . $op2;
} }
// Check if the function exists // Check if the function exists

View File

@ -266,7 +266,9 @@ function api_get_agent_module_name_last_value($agentName, $moduleName, $other =
function api_get_module_last_value($idAgentModule, $trash1, $other = ';', $returnType) function api_get_module_last_value($idAgentModule, $trash1, $other = ';', $returnType)
{ {
$sql = sprintf('SELECT datos FROM tagente_estado WHERE id_agente_modulo = %d', $idAgentModule); $sql = sprintf('SELECT datos
FROM tagente_estado
WHERE id_agente_modulo = %d', $idAgentModule);
$value = db_get_value_sql($sql); $value = db_get_value_sql($sql);
if ($value === false) { if ($value === false) {
switch ($other['type']) { switch ($other['type']) {
@ -471,8 +473,7 @@ function api_get_tree_agents($trash1, $trahs2, $other, $returnType)
'alert_templates_field3', 'alert_templates_field3',
'alert_actions_field3', 'alert_actions_field3',
'alert_templates_id_group', 'alert_templates_id_group',
'alert_actions_id_group' 'alert_actions_id_group');
);
/* agent related field mappings (output field => column designation for 'tagente') */ /* agent related field mappings (output field => column designation for 'tagente') */
@ -493,8 +494,7 @@ function api_get_tree_agents($trash1, $trahs2, $other, $returnType)
'agent_id_parent' => 'id_parent as agent_id_parent', 'agent_id_parent' => 'id_parent as agent_id_parent',
'agent_custom_id' => 'custom_id as agent_custom_id', 'agent_custom_id' => 'custom_id as agent_custom_id',
'agent_server_name' => 'server_name as agent_server_name', 'agent_server_name' => 'server_name as agent_server_name',
'agent_cascade_protection' => 'cascade_protection as agent_cascade_protection', 'agent_cascade_protection' => 'cascade_protection as agent_cascade_protection');
);
/* module related field mappings 1/2 (output field => column for 'tagente_modulo') */ /* module related field mappings 1/2 (output field => column for 'tagente_modulo') */
@ -535,8 +535,7 @@ function api_get_tree_agents($trash1, $trahs2, $other, $returnType)
'module_max_critical' => 'max_critical as module_max_critical', 'module_max_critical' => 'max_critical as module_max_critical',
'module_str_critical' => 'str_critical as module_str_critical', 'module_str_critical' => 'str_critical as module_str_critical',
'module_min_ff_event' => 'min_ff_event as module_min_ff_event', 'module_min_ff_event' => 'min_ff_event as module_min_ff_event',
'module_delete_pending' => 'delete_pending as module_delete_pending', 'module_delete_pending' => 'delete_pending as module_delete_pending');
);
/* module related field mappings 2/2 (output field => column for 'tagente_estado') */ /* module related field mappings 2/2 (output field => column for 'tagente_estado') */
@ -552,8 +551,7 @@ function api_get_tree_agents($trash1, $trahs2, $other, $returnType)
'module_running_by' => 'running_by as module_running_by', 'module_running_by' => 'running_by as module_running_by',
'module_last_execution_try' => 'last_execution_try as module_last_execution_try', 'module_last_execution_try' => 'last_execution_try as module_last_execution_try',
'module_status_changes' => 'status_changes as module_status_changes', 'module_status_changes' => 'status_changes as module_status_changes',
'module_last_status' => 'last_status as module_last_status', 'module_last_status' => 'last_status as module_last_status');
);
/* alert related field mappings (output field => column for 'talert_template_modules', ... ) */ /* alert related field mappings (output field => column for 'talert_template_modules', ... ) */
@ -616,8 +614,7 @@ function api_get_tree_agents($trash1, $trahs2, $other, $returnType)
'alert_internal' => 't5.internal as alert_internal', 'alert_internal' => 't5.internal as alert_internal',
'alert_commands_id' => 't5.id as alert_commands_id', 'alert_commands_id' => 't5.id as alert_commands_id',
'alert_commands_name' => 't5.name as alert_commands_name', 'alert_commands_name' => 't5.name as alert_commands_name',
'alert_commands_description' => 't5.description as alert_commands_description', 'alert_commands_description' => 't5.description as alert_commands_description');
);
if ($fields == false) { if ($fields == false) {
@ -631,17 +628,17 @@ function api_get_tree_agents($trash1, $trahs2, $other, $returnType)
$estado_additional_columns = ""; $estado_additional_columns = "";
$alert_additional_columns = ""; $alert_additional_columns = "";
foreach( $fields as $fld ) { foreach ($fields as $fld ) {
if( array_key_exists ($fld, $agent_field_column_mapping ) ) { if (array_key_exists ($fld, $agent_field_column_mapping ) ) {
$agent_additional_columns .= (", " . $agent_field_column_mapping[$fld] ); $agent_additional_columns .= (", " . $agent_field_column_mapping[$fld] );
} }
if( array_key_exists ($fld, $module_field_column_mampping ) ) { if (array_key_exists ($fld, $module_field_column_mampping ) ) {
$module_additional_columns .= (", " . $module_field_column_mampping[$fld]); $module_additional_columns .= (", " . $module_field_column_mampping[$fld]);
} }
if( array_key_exists ($fld, $estado_fields_to_columns_mapping ) ) { if (array_key_exists ($fld, $estado_fields_to_columns_mapping ) ) {
$estado_additional_columns .= (", " . $estado_fields_to_columns_mapping[$fld]); $estado_additional_columns .= (", " . $estado_fields_to_columns_mapping[$fld]);
} }
if( array_key_exists ($fld, $alert_fields_to_columns_mapping ) ) { if (array_key_exists ($fld, $alert_fields_to_columns_mapping ) ) {
$alert_additional_columns .= (", " . $alert_fields_to_columns_mapping[$fld]); $alert_additional_columns .= (", " . $alert_fields_to_columns_mapping[$fld]);
} }
} }
@ -653,7 +650,8 @@ function api_get_tree_agents($trash1, $trahs2, $other, $returnType)
if ($groups === false) $groups = array(); if ($groups === false) $groups = array();
$groups = str_replace('\n', $returnReplace, $groups); $groups = str_replace('\n', $returnReplace, $groups);
$agents = db_get_all_rows_sql('SELECT id_agente as agent_id, id_grupo as agent_id_group ' . $agent_additional_columns . ' FROM tagente'); $agents = db_get_all_rows_sql('
SELECT id_agente AS agent_id, id_grupo AS agent_id_group ' . $agent_additional_columns . ' FROM tagente');
if ($agents === false) $agents = array(); if ($agents === false) $agents = array();
$agents = str_replace('\n', $returnReplace, $agents); $agents = str_replace('\n', $returnReplace, $agents);
@ -667,10 +665,9 @@ function api_get_tree_agents($trash1, $trahs2, $other, $returnType)
$agent['type_row'] = 'agent'; $agent['type_row'] = 'agent';
$returnVar[] = $agent; $returnVar[] = $agent;
if( strlen($module_additional_columns) <= 0 if ( strlen($module_additional_columns) <= 0
&& strlen($estado_additional_columns) <= 0 && strlen($estado_additional_columns) <= 0
&& strlen($alert_additional_columns) <= 0 ) && strlen($alert_additional_columns) <= 0 ) {
{
continue; /** SKIP collecting MODULES and ALERTS **/ continue; /** SKIP collecting MODULES and ALERTS **/
} }
@ -690,8 +687,7 @@ function api_get_tree_agents($trash1, $trahs2, $other, $returnType)
$module['type_row'] = 'module'; $module['type_row'] = 'module';
$returnVar[] = $module; $returnVar[] = $module;
if( strlen($alert_additional_columns) <= 0 ) if ( strlen($alert_additional_columns) <= 0 ) {
{
continue; /** SKIP collecting ALERTS info **/ continue; /** SKIP collecting ALERTS info **/
} }

View File

@ -165,7 +165,8 @@ function snmp_browser_get_tree ($target_ip, $community, $starting_oid = '.', $ve
$oid_tree = array('__LEAVES__' => array()); $oid_tree = array('__LEAVES__' => array());
if ($version == "3") { if ($version == "3") {
exec ($snmpwalk_bin . ' -m ALL -v 3 -u ' . escapeshellarg($snmp3_auth_user) . ' -A ' . escapeshellarg($snmp3_auth_pass) . ' -l ' . escapeshellarg($snmp3_security_level) . ' -a ' . escapeshellarg($snmp3_auth_method) . ' -x ' . escapeshellarg($snmp3_privacy_method) . ' -X ' . escapeshellarg($snmp3_privacy_pass) . ' ' . escapeshellarg($target_ip) . ' ' . escapeshellarg($starting_oid) . ' 2>/dev/null', $output, $rc); exec ($snmpwalk_bin . ' -m ALL -v 3 -u ' . escapeshellarg($snmp3_auth_user) . ' -A ' . escapeshellarg($snmp3_auth_pass) . ' -l ' . escapeshellarg($snmp3_security_level) . ' -a ' . escapeshellarg($snmp3_auth_method) . ' -x ' . escapeshellarg($snmp3_privacy_method) . ' -X ' . escapeshellarg($snmp3_privacy_pass) . ' ' . escapeshellarg($target_ip) . ' ' . escapeshellarg($starting_oid) . ' 2>/dev/null', $output, $rc);
} else { }
else {
exec ($snmpwalk_bin . ' -m ALL -M +' . escapeshellarg($config['homedir'] . '/attachment/mibs') . ' -Cc -c ' . escapeshellarg($community) . ' -v ' . escapeshellarg($version) . ' ' . escapeshellarg($target_ip) . ' ' . escapeshellarg($starting_oid) . ' 2>/dev/null', $output, $rc); exec ($snmpwalk_bin . ' -m ALL -M +' . escapeshellarg($config['homedir'] . '/attachment/mibs') . ' -Cc -c ' . escapeshellarg($community) . ' -v ' . escapeshellarg($version) . ' ' . escapeshellarg($target_ip) . ' ' . escapeshellarg($starting_oid) . ' 2>/dev/null', $output, $rc);
} }
//if ($rc != 0) { //if ($rc != 0) {
@ -265,7 +266,8 @@ function snmp_browser_get_oid ($target_ip, $community, $target_oid, $version = '
} }
if ($version == "3") { if ($version == "3") {
exec ($snmpget_bin . ' -m ALL -v 3 -u ' . escapeshellarg($snmp3_auth_user) . ' -A ' . escapeshellarg($snmp3_auth_pass) . ' -l ' . escapeshellarg($snmp3_security_level) . ' -a ' . escapeshellarg($snmp3_auth_method) . ' -x ' . escapeshellarg($snmp3_privacy_method) . ' -X ' . escapeshellarg($snmp3_privacy_pass) . ' ' . escapeshellarg($target_ip) . ' ' . escapeshellarg($target_oid) . ' 2>/dev/null', $output, $rc); exec ($snmpget_bin . ' -m ALL -v 3 -u ' . escapeshellarg($snmp3_auth_user) . ' -A ' . escapeshellarg($snmp3_auth_pass) . ' -l ' . escapeshellarg($snmp3_security_level) . ' -a ' . escapeshellarg($snmp3_auth_method) . ' -x ' . escapeshellarg($snmp3_privacy_method) . ' -X ' . escapeshellarg($snmp3_privacy_pass) . ' ' . escapeshellarg($target_ip) . ' ' . escapeshellarg($target_oid) . ' 2>/dev/null', $output, $rc);
} else { }
else {
exec ($snmpget_bin . ' -m ALL -M +' . escapeshellarg($config['homedir'] . '/attachment/mibs') . ' -On -c ' . escapeshellarg($community) . ' -v ' . escapeshellarg($version) . ' ' . escapeshellarg($target_ip) . ' ' . escapeshellarg($target_oid) . ' 2>/dev/null', $output, $rc); exec ($snmpget_bin . ' -m ALL -M +' . escapeshellarg($config['homedir'] . '/attachment/mibs') . ' -On -c ' . escapeshellarg($community) . ' -v ' . escapeshellarg($version) . ' ' . escapeshellarg($target_ip) . ' ' . escapeshellarg($target_oid) . ' 2>/dev/null', $output, $rc);
} }

View File

@ -40,7 +40,7 @@ $graph = networkmap_generate_hash(__('Pandora FMS'), $group, $simple,
$font_size, $layout, $nooverlap, $zoom, $ranksep, $center, $regen, $font_size, $layout, $nooverlap, $zoom, $ranksep, $center, $regen,
$pure, $id_networkmap, $show_snmp_modules, true, true, $pure, $id_networkmap, $show_snmp_modules, true, true,
$text_filter); $text_filter);
html_debug_print($graph, true);
networkmap_print_jsdata($graph); networkmap_print_jsdata($graph);
$zoom_default = file($config['homedir'] . '/images/zoom_default.svg'); $zoom_default = file($config['homedir'] . '/images/zoom_default.svg');
@ -176,7 +176,7 @@ var node = svg.selectAll(".node")
//.on("click", click) //.on("click", click)
.call(force.drag); .call(force.drag);
svg.style("opacity", 1e-6) svg.style("opacity", 1e-6)
.transition() .transition()
.duration(1000) .duration(1000)
.style("opacity", 1); .style("opacity", 1);

View File

@ -56,8 +56,10 @@ if (is_ajax()) {
$custom_action = urldecode (base64_decode ($custom_action)); $custom_action = urldecode (base64_decode ($custom_action));
} }
$oid = snmp_browser_get_oid ($target_ip, $community, $target_oid, $snmp_version, $oid = snmp_browser_get_oid ($target_ip, $community,
$snmp3_auth_user, $snmp3_security_level, $snmp3_auth_method, $snmp3_auth_pass, $snmp3_privacy_method, $snmp3_privacy_pass); $target_oid, $snmp_version, $snmp3_auth_user,
$snmp3_security_level, $snmp3_auth_method, $snmp3_auth_pass,
$snmp3_privacy_method, $snmp3_privacy_pass);
snmp_browser_print_oid ($oid, $custom_action); snmp_browser_print_oid ($oid, $custom_action);
return; return;
} }