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

* godmode/agentes/module_manager_editor.php,
	godmode/netflow/nf_item_list.php, include/functions_reporting.php,
	include/functions_modules.php, include/functions_snmp_browser.php,
	include/functions_agents.php, operation/tree.php,
	operation/reporting/reporting_xml.php: improved source code style.




git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7778 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
mdtrooper 2013-03-05 10:34:29 +00:00
parent e5adb86b98
commit ae38902834
9 changed files with 158 additions and 108 deletions

View File

@ -1,3 +1,11 @@
2013-03-05 Miguel de Dios <miguel.dedios@artica.es>
* godmode/agentes/module_manager_editor.php,
godmode/netflow/nf_item_list.php, include/functions_reporting.php,
include/functions_modules.php, include/functions_snmp_browser.php,
include/functions_agents.php, operation/tree.php,
operation/reporting/reporting_xml.php: improved source code style.
2013-03-05 Sergio Martin <sergio.martin@artica.es>
* include/functions_reporting.php

View File

@ -214,7 +214,8 @@ if ($id_agent_module) {
$mday = $cron_interval[2];
$month = $cron_interval[3];
$wday = $cron_interval[4];
} else {
}
else {
$minute = '*';
$hour = '*';
$mday = '*';
@ -396,7 +397,7 @@ switch ($moduletype) {
}
if($config['enterprise_installed'] && $id_agent_module) {
if ($config['enterprise_installed'] && $id_agent_module) {
if (policies_is_module_in_policy($id_agent_module)) {
policies_add_policy_linkation($id_agent_module);
}

View File

@ -52,7 +52,8 @@ $buttons['edit_report']['text'] = '<a href="' . $config['homeurl'] . 'index.php?
//Header
if (! defined ('METACONSOLE')) {
ui_print_page_header (__('Report items'), "images/networkmap/so_cisco_new.png", false, "", true, $buttons);
} else {
}
else {
$nav_bar = array(array('link' => 'index.php?sec=main', 'text' => __('Main')),
array('link' => 'index.php?sec=netf&sec2=' . $config['homedir'] . '/operation/netflow/nf_reporting', 'text' => __('Netflow reports')),
array('link' => 'index.php?sec=netf&sec2=' . $config['homedir'] . '/godmode/netflow/nf_item_list&id=' . $id, 'text' => __('Item list')));
@ -169,15 +170,23 @@ $total_reports_item = $total_reports_item[0]['total'];
//ui_pagination ($total_reports_item, $url);
$sql = "SELECT id_rc FROM tnetflow_report_content where `order`= (select min(`order`)
from tnetflow_report_content
where id_report=$id) and id_report=$id";
$sql = "SELECT id_rc
FROM tnetflow_report_content
WHERE `order`= (
SELECT min(`order`)
FROM tnetflow_report_content
WHERE id_report=$id)
AND id_report=$id";
$item_min = db_get_row_sql($sql);
$first_item = $item_min['id_rc'];
$sql = "SELECT id_rc FROM tnetflow_report_content where `order`= (select max(`order`)
from tnetflow_report_content
where id_report=$id) and id_report=$id";
$sql = "SELECT id_rc
FROM tnetflow_report_content
WHERE `order`= (
SELECT max(`order`)
FROM tnetflow_report_content
WHERE id_report=$id)
AND id_report=$id";
$item_max = db_get_row_sql($sql);
$last_item = $item_max['id_rc'];

View File

@ -705,7 +705,8 @@ function agents_common_modules_with_alerts ($id_agent, $filter = false, $indexed
array_push ($fields, $field.'="'.$value.'"');
}
$where .= implode (' AND ', $fields);
} else {
}
else {
$where .= $filter;
}
}

View File

@ -237,20 +237,36 @@ function modules_delete_agent_module ($id_agent_module) {
db_process_sql_delete('ttag_module', $where);
// Update module status count only if the module is not disabled
if($module['disabled'] == 0) {
if ($module['estado'] == 0) {
db_process_sql ('UPDATE tagente SET normal_count=normal_count-1 WHERE id_agente=' . $module['id_agente']);
} else if ($module['estado'] == 1) {
db_process_sql ('UPDATE tagente SET critical_count=critical_count-1 WHERE id_agente=' . $module['id_agente']);
} else if ($module['estado'] == 2) {
db_process_sql ('UPDATE tagente SET warning_count=warning_count-1 WHERE id_agente=' . $module['id_agente']);
} else if ($module['estado'] == 3) {
db_process_sql ('UPDATE tagente SET unknown_count=unknown_count-1 WHERE id_agente=' . $module['id_agente']);
} else if ($module['estado'] == 4) {
db_process_sql ('UPDATE tagente SET notinit_count=notinit_count-1 WHERE id_agente=' . $module['id_agente']);
if ($module['disabled'] == 0) {
if ($module['estado'] == AGENT_MODULE_STATUS_NORMAL) {
db_process_sql ('UPDATE tagente
SET normal_count=normal_count-1
WHERE id_agente=' . $module['id_agente']);
}
else if ($module['estado'] == AGENT_MODULE_STATUS_CRITICAL_BAD) {
db_process_sql ('UPDATE tagente
SET critical_count=critical_count-1
WHERE id_agente=' . $module['id_agente']);
}
else if ($module['estado'] == AGENT_MODULE_STATUS_WARNING) {
db_process_sql ('UPDATE tagente
SET warning_count=warning_count-1
WHERE id_agente=' . $module['id_agente']);
}
else if ($module['estado'] == AGENT_MODULE_STATUS_UNKNOW) {
db_process_sql ('UPDATE tagente
SET unknown_count=unknown_count-1
WHERE id_agente=' . $module['id_agente']);
}
else if ($module['estado'] == AGENT_MODULE_STATUS_NO_DATA) {
db_process_sql ('UPDATE tagente
SET notinit_count=notinit_count-1
WHERE id_agente=' . $module['id_agente']);
}
db_process_sql ('UPDATE tagente SET total_count=total_count-1 WHERE id_agente=' . $module['id_agente']);
db_process_sql ('UPDATE tagente
SET total_count=total_count-1
WHERE id_agente=' . $module['id_agente']);
}
return true;
}
@ -375,7 +391,8 @@ function modules_create_agent_module ($id_agent, $name, $values = false, $disabl
if (isset ($values['id_tipo_modulo']) && ($values['id_tipo_modulo'] == 21 || $values['id_tipo_modulo'] == 22 || $values['id_tipo_modulo'] == 23)) {
// Async modules start in normal status
$status = 0;
} else {
}
else {
// Sync modules start in unknown status
$status = 4;
}
@ -432,7 +449,8 @@ function modules_create_agent_module ($id_agent, $name, $values = false, $disabl
if(!isset ($values['disabled']) || $values['disabled'] == 0) {
if ($status == 0) {
db_process_sql ('UPDATE tagente SET total_count=total_count+1, normal_count=normal_count+1 WHERE id_agente=' . (int)$id_agent);
} else {
}
else {
db_process_sql ('UPDATE tagente SET total_count=total_count+1, notinit_count=notinit_count+1 WHERE id_agente=' . (int)$id_agent);
}
}

View File

@ -5733,7 +5733,8 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
//Agent's modules
if ($modules == null) {
$modules = array();
} else {
}
else {
$data[0] = '';
$data[1] = '<b>'.agents_get_name ($content['id_agent'], 'upper').__(' MODULES').'</b>';
$table->colspan[3][1] = 10;
@ -5876,7 +5877,8 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
if ($modules == null) {
$modules = array();
} else {
}
else {
//Agent's modules
$data[0] = '';
@ -5918,50 +5920,52 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
}
foreach ($modules as $id_agent_module=>$module) {
$sql = "SELECT * FROM tagente_modulo WHERE id_agente_modulo=$id_agent_module";
$data_module = db_get_row_sql($sql);
$sql = "SELECT *
FROM tagente_modulo
WHERE id_agente_modulo=$id_agent_module";
$data_module = db_get_row_sql($sql);
$data = array();
$data = array();
$data[0] = '';
$data[0] = '';
if ($data_module['disabled'] == 0)
$disabled = '';
else
$disabled = ' (Disabled)';
$data[1] = $data_module['nombre'].$disabled;
$data[2] = ui_print_moduletype_icon ($data_module['id_tipo_modulo'], true);
$data[3] = $data_module['max_warning'].'/'.$data_module['min_warning'].' <br> '.$data_module['max_critical'].'/'.$data_module['min_critical'];
$data[4] = $data_module['module_ff_interval'];
$data[5] = groups_get_name ($content['id_group'], true);
$data[6] = $data_module['descripcion'];
if ($data_module['disabled'] == 0)
$disabled = '';
else
$disabled = ' (Disabled)';
$data[1] = $data_module['nombre'].$disabled;
$data[2] = ui_print_moduletype_icon ($data_module['id_tipo_modulo'], true);
$data[3] = $data_module['max_warning'].'/'.$data_module['min_warning'].' <br> '.$data_module['max_critical'].'/'.$data_module['min_critical'];
$data[4] = $data_module['module_ff_interval'];
$data[5] = groups_get_name ($content['id_group'], true);
$data[6] = $data_module['descripcion'];
if (($data_module['module_interval'] == 0) || ($data_module['module_interval'] == ''))
$data[7] = db_get_value('intervalo', 'tagente', 'id_agente', $content['id_agent']);
else
$data[7] = $data_module['module_interval'];
if (($data_module['module_interval'] == 0) || ($data_module['module_interval'] == ''))
$data[7] = db_get_value('intervalo', 'tagente', 'id_agente', $content['id_agent']);
else
$data[7] = $data_module['module_interval'];
$data[8] = $data_module['unit'];
$data[8] = $data_module['unit'];
$module_status = db_get_row('tagente_estado', 'id_agente_modulo', $id_agent_module);
modules_get_status($id_agent_module, $module_status['estado'], $module_status['datos'], $status, $title);
$data[9] = ui_print_status_image($status, $title, true);
$module_status = db_get_row('tagente_estado', 'id_agente_modulo', $id_agent_module);
modules_get_status($id_agent_module, $module_status['estado'], $module_status['datos'], $status, $title);
$data[9] = ui_print_status_image($status, $title, true);
$sql_tag = "SELECT name FROM ttag WHERE id_tag IN (
SELECT id_tag FROM ttag_module
WHERE id_agente_modulo=$id_agent_module)";
$tags = db_get_all_rows_sql($sql_tag);
if ($tags === false)
$tags = '';
else
$tags = implode (",", $tags);
$sql_tag = "SELECT name FROM ttag WHERE id_tag IN (
SELECT id_tag FROM ttag_module
WHERE id_agente_modulo=$id_agent_module)";
$tags = db_get_all_rows_sql($sql_tag);
if ($tags === false)
$tags = '';
else
$tags = implode (",", $tags);
$data[10] = $tags;
array_push ($table->data, $data);
$data[10] = $tags;
array_push ($table->data, $data);
$i++;
}
$i++;
}
}
break;

View File

@ -66,7 +66,8 @@ function snmp_browser_print_tree ($tree, $id = 0, $depth = 0, $last = 0, $last_a
for ($i = 1; $i <= $depth; $i++) {
if ($last_array[$i] == 1) {
echo '<img src="' . $url . '/no_branch.png" style="vertical-align: middle;">';
} else {
}
else {
echo '<img src="' . $url . '/branch.png" style="vertical-align: middle;">';
}
}

View File

@ -801,7 +801,6 @@ foreach ($contents as $content) {
fclose($file);
}
}
///
break;
case 'event_report_module':
@ -810,7 +809,7 @@ foreach ($contents as $content) {
$date = get_system_time ();
$datelimit = $date - $content['period'];
///
$sql_count = "SELECT count(*) FROM (SELECT count(*)
FROM tevento
WHERE id_agente =".$content['id_agent']." AND utimestamp > $datelimit AND utimestamp <=". $date.
@ -829,15 +828,16 @@ foreach ($contents as $content) {
$content_report = " <event_report_module/>\n";
$result = fwrite($file, $content_report);
fclose($file);
} else if ($data_count <= $limit) {
}
else if ($data_count <= $limit) {
$content_report = " <event_report_module>\n";
$result = fwrite($file, $content_report);
fclose($file);
$sql = "SELECT evento, event_type, criticity, count(*) as count_rep, max(timestamp) AS time2, id_agentmodule, estado, user_comment, tags, source, id_extra, owner_user
FROM tevento
WHERE id_agente =".$content['id_agent']." AND utimestamp > $datelimit AND utimestamp <=". $date.
" GROUP BY id_agentmodule, evento";
FROM tevento
WHERE id_agente =".$content['id_agent']." AND utimestamp > $datelimit AND utimestamp <=". $date.
" GROUP BY id_agentmodule, evento";
$events = db_get_all_rows_sql($sql);
@ -847,7 +847,8 @@ foreach ($contents as $content) {
$content_report = " </event_report_module>\n";
$result = fwrite($file, $content_report);
} else {
}
else {
$content_report = " <event_report_module>\n";
$result = fwrite($file, $content_report);
fclose($file);
@ -856,9 +857,9 @@ foreach ($contents as $content) {
while ($offset < $data_count) {
$sql = sprintf ('SELECT evento, event_type, criticity, count(*) as count_rep, max(timestamp) AS time2, id_agentmodule, estado, user_comment, tags, source, id_extra, owner_user
FROM tevento
WHERE id_agentmodule = %d AND utimestamp > %d AND utimestamp <= %d
GROUP BY id_agentmodule, evento ORDER BY time2 DESC LIMIT %d,%d', $content['id_agent_module'], $datelimit, $date, $offset,$limit);
FROM tevento
WHERE id_agentmodule = %d AND utimestamp > %d AND utimestamp <= %d
GROUP BY id_agentmodule, evento ORDER BY time2 DESC LIMIT %d,%d', $content['id_agent_module'], $datelimit, $date, $offset,$limit);
$events = db_get_all_rows_sql($sql);
@ -1201,7 +1202,8 @@ foreach ($contents as $content) {
$content_report .= " </configuration_report_agent>\n";
$result = fwrite($file, $content_report);
} else {
}
else {
$content_report = " <module_configuration>\n";
$file = fopen ($temp_file, 'a+');
@ -1370,7 +1372,8 @@ foreach ($contents as $content) {
$result = fwrite($file, $content_report);
} else {
}
else {
$content_report = " <module_configuration>\n";
$file = fopen ($temp_file, 'a+');

View File

@ -124,10 +124,12 @@ if (is_ajax ())
$sql = treeview_getFirstBranchSQL ($type, $id, $avariableGroupsIds, $statusSel, $search_free);
if ($sql === false) {
$rows = array ();
} else {
}
else {
$rows = db_get_all_rows_sql($sql);
}
} else {
}
else {
$rows = array ();
foreach ($servers as $server) {
if (metaconsole_connect($server) != NOERR) {
@ -138,7 +140,8 @@ if (is_ajax ())
$sql = treeview_getFirstBranchSQL ($type, $id, $avariableGroupsIds, $statusSel, $search_free);
if ($sql === false) {
$server_rows = array ();
} else {
}
else {
$server_rows = db_get_all_rows_sql($sql);
if ($server_rows === false) {
$server_rows = array ();
@ -539,7 +542,8 @@ switch ($activeTab) {
if (! defined ('METACONSOLE')) {
$onheader = array('tag' => $tags_tab, 'os' => $os_tab, 'group' => $group_tab, 'module_group' => $module_group_tab, 'policies' => $policies_tab, 'module' => $module_tab);
ui_print_page_header (__('Tree view')." - ".__('Sort the agents by ') .$order, "images/extensions.png", false, "", false, $onheader);
} else {
}
else {
ui_meta_add_breadcrumb(array('link' => 'index.php?sec=monitoring&sec2=operation/tree', 'text' => __('Tree View')));
ui_meta_print_page_header($nav_bar);
@ -652,7 +656,8 @@ treeview_printTree($activeTab);
//change image of tree [+] to [-]
<?php if (! defined ('METACONSOLE')) {
echo 'var icon_path = \'operation/tree\';';
} else {
}
else {
echo 'var icon_path = \'../../operation/tree\';';
}
?>