From b2c0ec28a9855e771d83598b0b58ae0b362942d1 Mon Sep 17 00:00:00 2001 From: mdtrooper Date: Tue, 30 Apr 2013 22:20:22 +0000 Subject: [PATCH] 2013-05-01 Miguel de Dios * extensions/system_info.php, extensions/agents_modules.php, extensions/vnc_view.php, extensions/users_connected.php, extensions/update_manager/lib/libupdate_manager.php, extensions/update_manager/lib/libupdate_manager_updates.php, extensions/snmp_explorer.php, extensions/insert_data.php, operation/agentes/tactical.php: improved the source code. * include/functions_reporting.php: fixed the links of list modules. Fixes: #3612243 git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@8091 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 13 +++++++++++ pandora_console/extensions/agents_modules.php | 6 ++--- pandora_console/extensions/insert_data.php | 10 ++++----- pandora_console/extensions/snmp_explorer.php | 22 +++++++++---------- pandora_console/extensions/system_info.php | 10 ++++----- .../update_manager/lib/libupdate_manager.php | 4 ++-- .../lib/libupdate_manager_updates.php | 6 ++--- .../extensions/users_connected.php | 2 +- pandora_console/extensions/vnc_view.php | 2 +- .../include/functions_reporting.php | 20 ++++++++++++----- .../operation/agentes/tactical.php | 10 +++++---- 11 files changed, 65 insertions(+), 40 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 9067f4bf85..9852ee04f7 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,16 @@ +2013-05-01 Miguel de Dios + + * extensions/system_info.php, extensions/agents_modules.php, + extensions/vnc_view.php, extensions/users_connected.php, + extensions/update_manager/lib/libupdate_manager.php, + extensions/update_manager/lib/libupdate_manager_updates.php, + extensions/snmp_explorer.php, extensions/insert_data.php, + operation/agentes/tactical.php: improved the source code. + + * include/functions_reporting.php: fixed the links of list modules. + + Fixes: #3612243 + 2013-04-30 Sergio Martin * godmode/agentes/agent_template.php: Add tags creation diff --git a/pandora_console/extensions/agents_modules.php b/pandora_console/extensions/agents_modules.php index 83e3cbf638..eee788ae5d 100644 --- a/pandora_console/extensions/agents_modules.php +++ b/pandora_console/extensions/agents_modules.php @@ -248,10 +248,10 @@ function mainAgentsModules() { $nmodules = 0; - foreach($modules_by_name as $module) { + foreach ($modules_by_name as $module) { $nmodules++; - if($nmodules <= $hor_offset || $nmodules > ($hor_offset+$block)) { + if ($nmodules <= $hor_offset || $nmodules > ($hor_offset+$block)) { continue; } @@ -288,7 +288,7 @@ function mainAgentsModules() { } } - if(!$match) { + if (!$match) { echo ""; } } diff --git a/pandora_console/extensions/insert_data.php b/pandora_console/extensions/insert_data.php index 4b72fca785..8cb04468b1 100644 --- a/pandora_console/extensions/insert_data.php +++ b/pandora_console/extensions/insert_data.php @@ -100,7 +100,7 @@ function mainInsertData() { $result = createXMLData($agent, $agentModule, trim($tokens[0]), trim($tokens[1])); - if($result) { + if ($result) { $done++; } else { @@ -111,7 +111,7 @@ function mainInsertData() { else { $result = createXMLData($agent, $agentModule, $date_xml, $data); - if($result) { + if ($result) { $done++; } else { @@ -120,16 +120,16 @@ function mainInsertData() { } } - if($errors > 0) { + if ($errors > 0) { $msg = sprintf(__('Can\'t save agent (%s), module (%s) data xml.'), $agent['nombre'], $agentModule['nombre']); - if($errors > 1) { + if ($errors > 1) { $msg .= " ($errors)"; } ui_print_error_message($msg); } if ($done > 0) { $msg = sprintf(__('Save agent (%s), module (%s) data xml.'), $agent['nombre'], $agentModule['nombre']); - if($done > 1) { + if ($done > 1) { $msg .= " ($done)"; } ui_print_success_message($msg); diff --git a/pandora_console/extensions/snmp_explorer.php b/pandora_console/extensions/snmp_explorer.php index 3d5d9eb4e0..9a7c6d66b2 100755 --- a/pandora_console/extensions/snmp_explorer.php +++ b/pandora_console/extensions/snmp_explorer.php @@ -71,11 +71,11 @@ function snmp_explorer() { $keydata = explode('::',$key); $keydata2 = explode('.',$keydata[1]); - if(!isset($keydata2[1])) { + if (!isset($keydata2[1])) { continue; } - if(array_key_exists(1,$data)) { + if (array_key_exists(1,$data)) { $interfaces[$keydata2[1]][$keydata2[0]]['type'] = $data[0]; $interfaces[$keydata2[1]][$keydata2[0]]['value'] = $data[1]; } @@ -95,20 +95,20 @@ function snmp_explorer() { $id_snmp_serialize = get_parameter_post('id_snmp_serialize'); $interfaces = unserialize_in_temp($id_snmp_serialize); - if(!$interfaces) { + if (!$interfaces) { $interfaces = array(); } $values = array(); - if($tcp_port != '') { + 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') { + if ($snmp_version == '3') { $values['plugin_user'] = $snmp3_auth_user; $values['plugin_pass'] = $snmp3_auth_pass; $values['plugin_parameter'] = $snmp3_auth_method; @@ -118,10 +118,10 @@ function snmp_explorer() { } $oids = array(); - foreach($interfaces as $key => $interface) { - foreach($interface as $key2 => $module) { + foreach ($interfaces as $key => $interface) { + foreach ($interface as $key2 => $module) { $oid = get_parameter($key."-".$key2, ''); - if($oid != '') { + if ($oid != '') { $interfaces[$key][$key2]['checked'] = 1; $oids[$key][] = $interfaces[$key][$key2]['oid']; } @@ -133,12 +133,12 @@ function snmp_explorer() { $modules = get_parameter('module', array()); $id_snmp = get_parameter('id_snmp'); - if($id_snmp == false) { + if ($id_snmp == false) { ui_print_error_message (__('No modules selected')); $id_snmp = array(); } - if(agents_get_name($id_agent) == false) { + if (agents_get_name($id_agent) == false) { ui_print_error_message (__('No agent selected or the agent does not exist')); $id_snmp = array(); } @@ -210,7 +210,7 @@ function snmp_explorer() { $result = modules_create_agent_module ($id_agent, io_safe_input($name), $values); if (is_error($result)) { - if(!isset($errors[$result])) { + if (!isset($errors[$result])) { $errors[$result] = 0; } $errors[$result]++; diff --git a/pandora_console/extensions/system_info.php b/pandora_console/extensions/system_info.php index 63dea7038d..008fda5186 100644 --- a/pandora_console/extensions/system_info.php +++ b/pandora_console/extensions/system_info.php @@ -36,7 +36,7 @@ function getPandoraDiagnostic(&$systemInfo) { $systemInfo['talert_commands'] = db_get_sql("SELECT COUNT(*) FROM tagente"); $systemInfo['talert_template_modules'] = db_get_sql("SELECT COUNT(*) FROM talert_template_modules"); $systemInfo['tlayout'] = db_get_sql("SELECT COUNT(*) FROM tlayout"); - if($config['enterprise_installed']) + if ($config['enterprise_installed']) $systemInfo['tlocal_component'] = db_get_sql("SELECT COUNT(*) FROM tlocal_component"); $systemInfo['tserver'] = db_get_sql("SELECT COUNT(*) FROM tserver"); $systemInfo['treport'] = db_get_sql("SELECT COUNT(*) FROM treport"); @@ -324,10 +324,10 @@ function mainSystemInfo() { @unlink($zipArchive); $url_zip = ui_get_full_url(false); - + $url = '' . __('download here') . ''; - - if($log_info || $system_info || $pandora_diag) { + + if ($log_info || $system_info || $pandora_diag) { echo '' . __('File:') . ' ' . $url . '
'; echo '' . __('Location:') . ' ' . $zipArchive; } @@ -488,7 +488,7 @@ function consoleMode() { fclose($file); } } - + if ($pandoraSystemInfo) { $systemInfo = array(); getSystemInfo($systemInfo, true); diff --git a/pandora_console/extensions/update_manager/lib/libupdate_manager.php b/pandora_console/extensions/update_manager/lib/libupdate_manager.php index b6d2cdc508..2b3fe65586 100644 --- a/pandora_console/extensions/update_manager/lib/libupdate_manager.php +++ b/pandora_console/extensions/update_manager/lib/libupdate_manager.php @@ -106,7 +106,7 @@ function um_db_get_latest_package_by_status ($id_package = '0', $status = 'publi WHERE status = "'.$status.'" AND id > ' . $id_package . ' ORDER BY id DESC LIMIT 1'); - if($result === false) { + if ($result === false) { echo 'Error reading latest package with status ' . $status . '
'; return false; } @@ -145,7 +145,7 @@ function um_db_update_package ($id_package, $description = '', $status = 'disabl $result = db_process_sql_update(DB_PREFIX.'tupdate_package', $values, $where); - if($result === false) { + if ($result === false) { echo 'Error updating package
'; return false; } diff --git a/pandora_console/extensions/update_manager/lib/libupdate_manager_updates.php b/pandora_console/extensions/update_manager/lib/libupdate_manager_updates.php index 1cbf53d750..d52b0a177b 100644 --- a/pandora_console/extensions/update_manager/lib/libupdate_manager_updates.php +++ b/pandora_console/extensions/update_manager/lib/libupdate_manager_updates.php @@ -87,9 +87,9 @@ function um_db_get_orphan_updates () { $cont = 0; $updates = array(); - while(true) { + while (true) { $update = um_std_from_result($result, $cont); - if($update === false) { + if ($update === false) { break; } $updates[$update['id']] = $update; @@ -101,7 +101,7 @@ function um_db_get_orphan_updates () { function um_db_get_update ($id_update) { $result = db_process_sql('SELECT * FROM '.DB_PREFIX.'tupdate WHERE id = "'.$id_update.'" LIMIT 1'); - + if ($result === false) { echo 'Error getting update
'; return NULL; diff --git a/pandora_console/extensions/users_connected.php b/pandora_console/extensions/users_connected.php index c44cfbec83..276b272e8c 100644 --- a/pandora_console/extensions/users_connected.php +++ b/pandora_console/extensions/users_connected.php @@ -27,7 +27,7 @@ function users_extension_main_god ($god = true) { } } - if($god) { + if ($god) { $image = "images/gm_users.png"; } else { diff --git a/pandora_console/extensions/vnc_view.php b/pandora_console/extensions/vnc_view.php index bca0ceab47..20ed151478 100644 --- a/pandora_console/extensions/vnc_view.php +++ b/pandora_console/extensions/vnc_view.php @@ -27,7 +27,7 @@ $id_agente = get_parameter ("id_agente"); // This extension is usefull only if the agent has associated IP $address = agents_get_address($id_agente); -if(!empty($address) || empty($id_agente)) { +if (!empty($address) || empty($id_agente)) { extensions_add_opemode_tab_agent('vnc_view', __('VNC view'), 'images/vnc.png', 'vnc_view', "v1r1"); } ?> diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index b8a9afe83f..ec2c1adeb4 100644 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -990,11 +990,21 @@ function reporting_get_stats_modules_status($data, $graph_width = 250, $graph_he // Link URLS if ($links === false) { $urls = array(); - $urls['monitor_critical'] = "index.php?sec=estado&sec2=operation/agentes/status_monitor&refr=60&status=2"; - $urls['monitor_warning'] = "index.php?sec=estado&sec2=operation/agentes/status_monitor&refr=60&status=1"; - $urls['monitor_ok'] = "index.php?sec=estado&sec2=operation/agentes/status_monitor&refr=60&status=0"; - $urls['monitor_unknown'] = "index.php?sec=estado&sec2=operation/agentes/status_monitor&refr=60&status=3"; - $urls['monitor_not_init'] = "index.php?sec=estado&sec2=operation/agentes/status_monitor&refr=60&status=5"; + $urls['monitor_critical'] = "index.php?" . + "sec=estado&sec2=operation/agentes/status_monitor&" . + "refr=60&status=" . AGENT_MODULE_STATUS_CRITICAL_BAD; + $urls['monitor_warning'] = "index.php?" . + "sec=estado&sec2=operation/agentes/status_monitor&" . + "refr=60&status=" . AGENT_MODULE_STATUS_WARNING; + $urls['monitor_ok'] = "index.php?" . + "sec=estado&sec2=operation/agentes/status_monitor&" . + "refr=60&status=" . AGENT_MODULE_STATUS_NORMAL; + $urls['monitor_unknown'] = "index.php?" . + "sec=estado&sec2=operation/agentes/status_monitor&" . + "refr=60&status=" . AGENT_MODULE_STATUS_UNKNOW; + $urls['monitor_not_init'] = "index.php?" . + "sec=estado&sec2=operation/agentes/status_monitor&" . + "refr=60&status=" . AGENT_MODULE_STATUS_NOT_INIT; } else { $urls = array(); diff --git a/pandora_console/operation/agentes/tactical.php b/pandora_console/operation/agentes/tactical.php index 7e5e0d4b8e..44e19ca3a1 100644 --- a/pandora_console/operation/agentes/tactical.php +++ b/pandora_console/operation/agentes/tactical.php @@ -51,7 +51,7 @@ else { ui_print_page_header (__("Tactical view"), "images/op_monitoring.png", false, "", false, $updated_time); $data = reporting_get_group_stats(); -if(tags_has_user_acl_tags()) { +if (tags_has_user_acl_tags()) { ui_print_tags_warning(); } @@ -74,7 +74,7 @@ $table->rowclass[] = ''; html_print_table ($table); -unset ($table); +unset($table); // --------------------------------------------------------------------- // Monitor checks @@ -94,6 +94,8 @@ $table->data[0][0] .= reporting_get_stats_agents_monitors($data); $table->rowclass[] = ''; html_print_table($table); + + // --------------------------------------------------------------------- // Server performance // --------------------------------------------------------------------- @@ -106,10 +108,10 @@ if ($is_admin) { $table->head = array (); $table->data = array (); $table->style = array (); - + $table->data[0][0] = reporting_get_stats_servers(false); $table->rowclass[] = ''; - + html_print_table($table); }