2013-03-05 Miguel de Dios <miguel.dedios@artica.es>

* include/functions_netflow.php, include/functions_graph.php,
	include/functions_config.php, include/functions_groups.php: improved
	source code style.




git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7780 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
mdtrooper 2013-03-05 11:00:40 +00:00
parent 4a4fc60f21
commit fb2c412a9f
5 changed files with 76 additions and 57 deletions

View File

@ -1,3 +1,9 @@
2013-03-05 Miguel de Dios <miguel.dedios@artica.es>
* include/functions_netflow.php, include/functions_graph.php,
include/functions_config.php, include/functions_groups.php: improved
source code style.
2013-03-05 Miguel de Dios <miguel.dedios@artica.es> 2013-03-05 Miguel de Dios <miguel.dedios@artica.es>
* godmode/agentes/module_manager_editor.php, * godmode/agentes/module_manager_editor.php,

View File

@ -994,7 +994,8 @@ function config_process_config () {
//If current user is editing himself or if the user has UM (User Management) rights on any groups the user is part of AND the authorization scheme allows for users/admins to update info //If current user is editing himself or if the user has UM (User Management) rights on any groups the user is part of AND the authorization scheme allows for users/admins to update info
if (($config["id_user"] == $id || check_acl ($config["id_user"], users_get_groups ($id), "UM")) && $config["user_can_update_info"]) { if (($config["id_user"] == $id || check_acl ($config["id_user"], users_get_groups ($id), "UM")) && $config["user_can_update_info"]) {
$view_mode = false; $view_mode = false;
} else { }
else {
$view_mode = true; $view_mode = true;
} }

View File

@ -1029,7 +1029,8 @@ function graphic_combined_module ($module_list, $weight_list, $period, $width, $
$nextData = modules_get_next_data ($agent_module_id, $date); $nextData = modules_get_next_data ($agent_module_id, $date);
if ($nextData !== false) { if ($nextData !== false) {
array_push ($data, $nextData); array_push ($data, $nextData);
} else if (count ($data) > 0) { }
else if (count ($data) > 0) {
// Propagate the last known data to the end of the interval // Propagate the last known data to the end of the interval
$nextData = array_pop ($data); $nextData = array_pop ($data);
array_push ($data, $nextData); array_push ($data, $nextData);

View File

@ -841,7 +841,7 @@ function groups_create_group($group_name, $rest_values){
$check = db_get_value('nombre', 'tgrupo', 'nombre', $group_name); $check = db_get_value('nombre', 'tgrupo', 'nombre', $group_name);
if (!$check){ if (!$check) {
$result = db_process_sql_insert('tgrupo', $values); $result = db_process_sql_insert('tgrupo', $values);
} }
else { else {
@ -860,10 +860,11 @@ function groups_agent_not_init ($group_array) {
if (empty ($group_array)) { if (empty ($group_array)) {
return 0; return 0;
} else if (!is_array ($group_array)){ }
else if (!is_array ($group_array)) {
$group_array = array($group_array); $group_array = array($group_array);
} }
$group_clause = implode (",", $group_array); $group_clause = implode (",", $group_array);
$group_clause = "(" . $group_clause . ")"; $group_clause = "(" . $group_clause . ")";
@ -896,7 +897,7 @@ function groups_agent_ok ($group_array) {
return 0; return 0;
} }
else if (!is_array ($group_array)){ else if (!is_array ($group_array)) {
$group_array = array($group_array); $group_array = array($group_array);
} }
@ -913,10 +914,11 @@ function groups_agent_critical ($group_array) {
if (empty ($group_array)) { if (empty ($group_array)) {
return 0; return 0;
} else if (!is_array ($group_array)){ }
else if (!is_array ($group_array)) {
$group_array = array($group_array); $group_array = array($group_array);
} }
$group_clause = implode (",", $group_array); $group_clause = implode (",", $group_array);
$group_clause = "(" . $group_clause . ")"; $group_clause = "(" . $group_clause . ")";
@ -928,14 +930,15 @@ function groups_agent_critical ($group_array) {
// Get warning agents by using the status code in modules. // Get warning agents by using the status code in modules.
function groups_agent_warning ($group_array) { function groups_agent_warning ($group_array) {
if (empty ($group_array)) { if (empty ($group_array)) {
return 0; return 0;
} else if (!is_array ($group_array)){ }
else if (!is_array ($group_array)) {
$group_array = array($group_array); $group_array = array($group_array);
} }
$group_clause = implode (",", $group_array); $group_clause = implode (",", $group_array);
$group_clause = "(" . $group_clause . ")"; $group_clause = "(" . $group_clause . ")";
@ -946,36 +949,38 @@ function groups_agent_warning ($group_array) {
// Get monitor NOT INIT, except disabled AND async modules // Get monitor NOT INIT, except disabled AND async modules
function groups_monitor_not_init ($group_array) { function groups_monitor_not_init ($group_array) {
// If there are not groups to query, we jump to nextone // If there are not groups to query, we jump to nextone
if (empty ($group_array)) { if (empty ($group_array)) {
return 0; return 0;
} else if (!is_array ($group_array)){ }
else if (!is_array ($group_array)) {
$group_array = array($group_array); $group_array = array($group_array);
} }
$group_clause = implode (",", $group_array); $group_clause = implode (",", $group_array);
$group_clause = "(" . $group_clause . ")"; $group_clause = "(" . $group_clause . ")";
//TODO REVIEW ORACLE AND POSTGRES //TODO REVIEW ORACLE AND POSTGRES
return db_get_sql ("SELECT SUM(notinit_count) FROM tagente WHERE disabled = 0 AND id_grupo IN $group_clause"); return db_get_sql ("SELECT SUM(notinit_count) FROM tagente WHERE disabled = 0 AND id_grupo IN $group_clause");
} }
// Get monitor OK, except disabled and non-init // Get monitor OK, except disabled and non-init
function groups_monitor_ok ($group_array) { function groups_monitor_ok ($group_array) {
// If there are not groups to query, we jump to nextone // If there are not groups to query, we jump to nextone
if (empty ($group_array)) { if (empty ($group_array)) {
return 0; return 0;
} else if (!is_array ($group_array)){ }
else if (!is_array ($group_array)) {
$group_array = array($group_array); $group_array = array($group_array);
} }
$group_clause = implode (",", $group_array); $group_clause = implode (",", $group_array);
$group_clause = "(" . $group_clause . ")"; $group_clause = "(" . $group_clause . ")";
@ -986,16 +991,17 @@ function groups_monitor_ok ($group_array) {
// Get monitor CRITICAL, except disabled and non-init // Get monitor CRITICAL, except disabled and non-init
function groups_monitor_critical ($group_array) { function groups_monitor_critical ($group_array) {
// If there are not groups to query, we jump to nextone // If there are not groups to query, we jump to nextone
if (empty ($group_array)) { if (empty ($group_array)) {
return 0; return 0;
} else if (!is_array ($group_array)){ }
else if (!is_array ($group_array)) {
$group_array = array($group_array); $group_array = array($group_array);
} }
$group_clause = implode (",", $group_array); $group_clause = implode (",", $group_array);
$group_clause = "(" . $group_clause . ")"; $group_clause = "(" . $group_clause . ")";
@ -1012,30 +1018,32 @@ function groups_monitor_warning ($group_array) {
if (empty ($group_array)) { if (empty ($group_array)) {
return 0; return 0;
} else if (!is_array ($group_array)){ }
else if (!is_array ($group_array)) {
$group_array = array($group_array); $group_array = array($group_array);
} }
$group_clause = implode (",", $group_array); $group_clause = implode (",", $group_array);
$group_clause = "(" . $group_clause . ")"; $group_clause = "(" . $group_clause . ")";
//TODO REVIEW ORACLE AND POSTGRES //TODO REVIEW ORACLE AND POSTGRES
return db_get_sql ("SELECT SUM(warning_count) FROM tagente WHERE disabled = 0 AND id_grupo IN $group_clause"); return db_get_sql ("SELECT SUM(warning_count) FROM tagente WHERE disabled = 0 AND id_grupo IN $group_clause");
} }
// Get monitor UNKNOWN, except disabled and non-init // Get monitor UNKNOWN, except disabled and non-init
function groups_monitor_unknown ($group_array) { function groups_monitor_unknown ($group_array) {
// If there are not groups to query, we jump to nextone // If there are not groups to query, we jump to nextone
if (empty ($group_array)) { if (empty ($group_array)) {
return 0; return 0;
} else if (!is_array ($group_array)){ }
else if (!is_array ($group_array)) {
$group_array = array($group_array); $group_array = array($group_array);
} }
$group_clause = implode (",", $group_array); $group_clause = implode (",", $group_array);
$group_clause = "(" . $group_clause . ")"; $group_clause = "(" . $group_clause . ")";
@ -1046,58 +1054,58 @@ function groups_monitor_unknown ($group_array) {
// Get alerts defined for a given group, except disabled // Get alerts defined for a given group, except disabled
function groups_monitor_alerts ($group_array) { function groups_monitor_alerts ($group_array) {
// If there are not groups to query, we jump to nextone // If there are not groups to query, we jump to nextone
if (empty ($group_array)) { if (empty ($group_array)) {
return 0; return 0;
} else if (!is_array ($group_array)){ }
else if (!is_array ($group_array)) {
$group_array = array($group_array); $group_array = array($group_array);
} }
$group_clause = implode (",", $group_array); $group_clause = implode (",", $group_array);
$group_clause = "(" . $group_clause . ")"; $group_clause = "(" . $group_clause . ")";
//TODO REVIEW ORACLE AND POSTGRES //TODO REVIEW ORACLE AND POSTGRES
return db_get_sql ("SELECT COUNT(talert_template_modules.id) return db_get_sql ("SELECT COUNT(talert_template_modules.id)
FROM talert_template_modules, tagente_modulo, tagente_estado, tagente FROM talert_template_modules, tagente_modulo, tagente_estado, tagente
WHERE tagente.id_grupo IN $group_clause AND tagente_modulo.id_agente = tagente.id_agente WHERE tagente.id_grupo IN $group_clause AND tagente_modulo.id_agente = tagente.id_agente
AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo
AND tagente_modulo.disabled = 0 AND tagente.disabled = 0 AND tagente_modulo.disabled = 0 AND tagente.disabled = 0
AND talert_template_modules.disabled = 0 AND talert_template_modules.disabled = 0
AND talert_template_modules.id_agent_module = tagente_modulo.id_agente_modulo"); AND talert_template_modules.id_agent_module = tagente_modulo.id_agente_modulo");
} }
// Get alert configured currently FIRED, except disabled // Get alert configured currently FIRED, except disabled
function groups_monitor_fired_alerts ($group_array) { function groups_monitor_fired_alerts ($group_array) {
// If there are not groups to query, we jump to nextone // If there are not groups to query, we jump to nextone
if (empty ($group_array)) { if (empty ($group_array)) {
return 0; return 0;
} else if (!is_array ($group_array)){ }
else if (!is_array ($group_array)){
$group_array = array($group_array); $group_array = array($group_array);
} }
$group_clause = implode (",", $group_array); $group_clause = implode (",", $group_array);
$group_clause = "(" . $group_clause . ")"; $group_clause = "(" . $group_clause . ")";
//TODO REVIEW ORACLE AND POSTGRES //TODO REVIEW ORACLE AND POSTGRES
return db_get_sql ("SELECT COUNT(talert_template_modules.id) return db_get_sql ("SELECT COUNT(talert_template_modules.id)
FROM talert_template_modules, tagente_modulo, tagente_estado, tagente FROM talert_template_modules, tagente_modulo, tagente_estado, tagente
WHERE tagente.id_grupo IN $group_clause AND tagente_modulo.id_agente = tagente.id_agente WHERE tagente.id_grupo IN $group_clause AND tagente_modulo.id_agente = tagente.id_agente
AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo
AND tagente_modulo.disabled = 0 AND tagente.disabled = 0 AND tagente_modulo.disabled = 0 AND tagente.disabled = 0
AND talert_template_modules.disabled = 0 AND talert_template_modules.disabled = 0
AND talert_template_modules.id_agent_module = tagente_modulo.id_agente_modulo AND talert_template_modules.id_agent_module = tagente_modulo.id_agente_modulo
AND times_fired > 0"); AND times_fired > 0");
} }
/** /**
@ -1114,10 +1122,11 @@ function groups_total_agents ($group_array, $disabled = false) {
if (empty ($group_array)) { if (empty ($group_array)) {
return 0; return 0;
} else if (!is_array ($group_array)){ }
else if (!is_array ($group_array)){
$group_array = array($group_array); $group_array = array($group_array);
} }
$group_clause = implode (",", $group_array); $group_clause = implode (",", $group_array);
$group_clause = "(" . $group_clause . ")"; $group_clause = "(" . $group_clause . ")";
@ -1125,9 +1134,8 @@ function groups_total_agents ($group_array, $disabled = false) {
if (!$disabled) if (!$disabled)
$sql .= " AND disabled = 0"; $sql .= " AND disabled = 0";
return db_get_sql ($sql); return db_get_sql ($sql);
} }
/** /**
@ -1143,16 +1151,17 @@ function groups_agent_disabled ($group_array) {
if (empty ($group_array)) { if (empty ($group_array)) {
return 0; return 0;
} else if (!is_array ($group_array)){ }
else if (!is_array ($group_array)){
$group_array = array($group_array); $group_array = array($group_array);
} }
$group_clause = implode (",", $group_array); $group_clause = implode (",", $group_array);
$group_clause = "(" . $group_clause . ")"; $group_clause = "(" . $group_clause . ")";
$sql = "SELECT COUNT(*) FROM tagente WHERE id_grupo IN $group_clause AND disabled = 1"; $sql = "SELECT COUNT(*) FROM tagente WHERE id_grupo IN $group_clause AND disabled = 1";
return db_get_sql ($sql); return db_get_sql ($sql);
} }

View File

@ -597,7 +597,8 @@ function netflow_get_stats ($start_date, $end_date, $filter, $aggregate, $max, $
$values[$i]['datetime'] = $end_date; $values[$i]['datetime'] = $end_date;
if ($aggregate == 'proto') { if ($aggregate == 'proto') {
$values[$i]['agg'] = $val[3]; $values[$i]['agg'] = $val[3];
} else { }
else {
$values[$i]['agg'] = $val[4]; $values[$i]['agg'] = $val[4];
} }
if (! isset ($val[9])) { if (! isset ($val[9])) {
@ -1002,7 +1003,8 @@ function netflow_draw_item ($start_date, $end_date, $interval_length, $type, $fi
if ($output == 'HTML' || $output == 'PDF') { if ($output == 'HTML' || $output == 'PDF') {
$html = netflow_stat_table ($data, $start_date, $end_date, $aggregate, $unit); $html = netflow_stat_table ($data, $start_date, $end_date, $aggregate, $unit);
return $html; return $html;
} else if ($output == 'XML') { }
else if ($output == 'XML') {
return netflow_stat_xml ($data); return netflow_stat_xml ($data);
} }
break; break;