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,13 +52,14 @@ $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')));
ui_meta_print_page_header($nav_bar);
}
$delete = (bool) get_parameter ('delete');
$multiple_delete = (bool)get_parameter('multiple_delete', 0);
$order = get_parameter('order');
@ -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

@ -215,7 +215,7 @@ function modules_change_disabled($id_agent_module, $new_value = 1) {
function modules_delete_agent_module ($id_agent_module) {
if (!$id_agent_module)
return false;
// Read module data
$module = db_get_row_sql ('SELECT * FROM tagente_modulo, tagente_estado WHERE tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo AND tagente_modulo.id_agente_modulo=' . (int)$id_agent_module);
@ -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;
}
@ -368,14 +384,15 @@ function modules_create_agent_module ($id_agent, $name, $values = false, $disabl
if ($return_tag === false){
db_process_sql_delete ('tagente_modulo',
array ('id_agente_modulo' => $id_agent_module));
return ERR_DB;
}
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;
}
@ -427,16 +444,17 @@ function modules_create_agent_module ($id_agent, $name, $values = false, $disabl
return ERR_DB;
}
// Update module status count if the module is not created disabled
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);
}
}
return $id_agent_module;
}

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;
@ -5873,10 +5874,11 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
$modules = agents_get_modules ($agent['id_agente']);
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);
$data = array();
$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['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'];
$sql = "SELECT *
FROM tagente_modulo
WHERE id_agente_modulo=$id_agent_module";
$data_module = db_get_row_sql($sql);
$data = array();
$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['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'];
$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);
$data[8] = $data_module['unit'];
$data[10] = $tags;
array_push ($table->data, $data);
$i++;
}
$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);
$data[10] = $tags;
array_push ($table->data, $data);
$i++;
}
}
break;
@ -5970,7 +5974,7 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
case 'netflow_data':
case 'netflow_statistics':
case 'netflow_summary':
// Read the report item
$report_id = $report['id_report'];
$content_id = $content['id_rc'];
@ -5984,13 +5988,13 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
// Calculate the start and end dates
$end_date = $report['datetime'];
$start_date = $end_date - $period;
// Get item filters
$filter = db_get_row_sql("SELECT * FROM tnetflow_filter WHERE id_sg = '" . (int)$content['text'] . "'", false, true);
if ($description == '') {
$description = $filter['id_name'];
}
$table->colspan[0][0] = 4;
$table->data[0][0] = '<h4>' . $description . '</h4>';
$table->colspan[1][0] = 4;

View File

@ -66,11 +66,12 @@ 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;">';
}
}
// Branch
if (! empty ($sub_level['__LEAVES__'])) {
echo "<a id='anchor_$sub_id' onfocus='javascript: this.blur();' href='javascript: toggleTreeNode(\"$sub_id\", \"$id\");'>";

View File

@ -801,53 +801,54 @@ foreach ($contents as $content) {
fclose($file);
}
}
///
break;
case 'event_report_module':
$data["title"] = __('Agents detailed event');
$data["objdata"] = array();
$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.
" GROUP BY id_agentmodule, evento) t1";
$data_count = db_get_value_sql($sql_count);
$temp_file = $config['attachment_store'] . '/event_report_module_' . $time.'_'.$content['id_rc'] . '.tmp';
$file = fopen ($temp_file, 'a+');
$buffer_file["objdata"] = $config['attachment_store'] . '/event_report_module_' . $time.'_'.$content['id_rc'] . '.tmp';
$limit = 1000;
$offset = 0;
if ($data_count == false) {
$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);
xml_file_event ($events, $temp_file, 0, $content['id_agent']);
$file = fopen ($temp_file, 'a+');
$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,10 +857,10 @@ 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);
$position = xml_file_event ($events, $temp_file, $position, $content['id_agent']);
@ -875,7 +876,7 @@ foreach ($contents as $content) {
case 'alert_report_module':
$data["title"] = __('Alert report module');
$data["objdata"]["alert_report_module"] = array();
$alerts = reporting_alert_reporting_module ($content['id_agent_module'], $content['period'], $report["datetime"], true, false);
foreach ($alerts->data as $row) {
@ -1200,8 +1201,9 @@ foreach ($contents as $content) {
$content_report = " </module_configuration>\n";
$content_report .= " </configuration_report_agent>\n";
$result = fwrite($file, $content_report);
} else {
}
else {
$content_report = " <module_configuration>\n";
$file = fopen ($temp_file, 'a+');
@ -1369,8 +1371,9 @@ foreach ($contents as $content) {
$content_report .= " </agent_data>\n";
$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,8 +542,9 @@ 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\';';
}
?>