2014-06-10 Alejandro Gallardo <alejandro.gallardo@artica.es>
* include/functions_graph.php: Added the function "graph_snmp_traps_treemap". * include/functions_netflow.php: Fixed a little error. * operation/snmpconsole/snmp_view.php: Fixed the pagination. Now is possible to see a treemap graph of oid per agent with the snmptraps received. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@10156 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
01c0086c1a
commit
c747b15a32
|
@ -1,3 +1,14 @@
|
|||
2014-06-10 Alejandro Gallardo <alejandro.gallardo@artica.es>
|
||||
|
||||
* include/functions_graph.php: Added the function
|
||||
"graph_snmp_traps_treemap".
|
||||
|
||||
* include/functions_netflow.php: Fixed a little error.
|
||||
|
||||
* operation/snmpconsole/snmp_view.php: Fixed the pagination.
|
||||
Now is possible to see a treemap graph of oid per agent with
|
||||
the snmptraps received.
|
||||
|
||||
2014-06-10 Miguel de Dios <miguel.dedios@artica.es>
|
||||
|
||||
* extensions/update_manager.php, extensions/update_manager/*,
|
||||
|
|
|
@ -3246,7 +3246,7 @@ function graph_netflow_circular_mesh ($data, $unit, $radius = 700) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Print a rescangular graph with the traffic of the ports for each IP
|
||||
* Print a rectangular graph with the traffic of the ports for each IP
|
||||
*/
|
||||
function graph_netflow_host_traffic ($data, $unit, $width = 700, $height = 700) {
|
||||
global $config;
|
||||
|
@ -4082,4 +4082,21 @@ function get_criticity_pie_colors ($data_graph) {
|
|||
|
||||
return $colors;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Print a rectangular graph with the snmptraps received
|
||||
*/
|
||||
function graph_snmp_traps_treemap ($data, $width = 700, $height = 700) {
|
||||
global $config;
|
||||
|
||||
if (empty ($data)) {
|
||||
return fs_error_image ();
|
||||
}
|
||||
|
||||
include_once($config['homedir'] . "/include/graphs/functions_d3.php");
|
||||
|
||||
return d3_tree_map_graph ($data, $width, $height, true);
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
@ -1362,6 +1362,8 @@ function netflow_draw_item ($start_date, $end_date, $interval_length, $type, $fi
|
|||
$id = -1;
|
||||
|
||||
$data = array();
|
||||
|
||||
if (! empty($netflow_data)) {
|
||||
$data['name'] = __("Host detailed traffic") . ": " . $type;
|
||||
$data['children'] = array();
|
||||
|
||||
|
@ -1380,6 +1382,7 @@ function netflow_draw_item ($start_date, $end_date, $interval_length, $type, $fi
|
|||
}
|
||||
$data['children'][] = $children;
|
||||
}
|
||||
}
|
||||
|
||||
return graph_netflow_host_traffic ($data, netflow_format_unit($unit), 'auto', 400);
|
||||
break;
|
||||
|
|
|
@ -40,6 +40,7 @@ $offset = (int) get_parameter ('offset',0);
|
|||
$trap_type = (int) get_parameter ('trap_type', -1);
|
||||
$group_by = (int)get_parameter('group_by', 0);
|
||||
$refr = (int)get_parameter("refr", 0);
|
||||
$tab = (string) get_parameter("tab");
|
||||
|
||||
$user_groups = users_get_groups ($config['id_user'],"AR", false);
|
||||
$str_user_groups = '';
|
||||
|
@ -63,18 +64,34 @@ $url = "index.php?sec=estado&" .
|
|||
"trap_type=" . $trap_type . "&" .
|
||||
"group_by=" .$group_by;
|
||||
|
||||
switch ($tab) {
|
||||
case 'statistics':
|
||||
$statistics['active'] = true;
|
||||
break;
|
||||
|
||||
default:
|
||||
$list['active'] = true;
|
||||
break;
|
||||
}
|
||||
$statistics['text'] = '<a href="' . $url . '&pure=' . $config["pure"] . '&refr=' . $refr . '&tab=statistics">' .
|
||||
html_print_image("images/op_reporting.png", true, array ("title" => __('Statistics'))) .'</a>';
|
||||
$list['text'] = '<a href="' . $url . '&pure=' . $config["pure"] . '&refr=' . $refr . '">' .
|
||||
html_print_image("images/op_snmp.png", true, array ("title" => __('List'))) .'</a>';
|
||||
|
||||
if ($tab)
|
||||
$url .= "&tab=$tab";
|
||||
|
||||
if ($config["pure"]) {
|
||||
$link['text'] = '<a target="_top" href="'.$url.'&pure=0&refr=' . $refr . '">' . html_print_image("images/normal_screen.png", true, array("title" => __('Normal screen'))) . '</a>';
|
||||
$fullscreen['text'] = '<a target="_top" href="'.$url.'&pure=0&refr=' . $refr . '">' . html_print_image("images/normal_screen.png", true, array("title" => __('Normal screen'))) . '</a>';
|
||||
}
|
||||
else {
|
||||
// Fullscreen
|
||||
$link['text'] = '<a target="_top" href="'.$url.'&pure=1&refr=' . $refr . '">' . html_print_image("images/full_screen.png", true, array("title" => __('Full screen'))) . '</a>';
|
||||
$fullscreen['text'] = '<a target="_top" href="'.$url.'&pure=1&refr=' . $refr . '">' . html_print_image("images/full_screen.png", true, array("title" => __('Full screen'))) . '</a>';
|
||||
}
|
||||
|
||||
// Header
|
||||
ui_print_page_header(__("SNMP Console"), "images/op_snmp.png", false,
|
||||
"", false, array($link));
|
||||
"", false, array($fullscreen, $list, $statistics));
|
||||
|
||||
// OPERATIONS
|
||||
|
||||
|
@ -142,11 +159,6 @@ if (isset ($_POST["updatebt"])) {
|
|||
}
|
||||
}
|
||||
|
||||
$table->width = '90%';
|
||||
$table->size = array ();
|
||||
$table->size[0] = '120px';
|
||||
$table->data = array ();
|
||||
|
||||
// All traps
|
||||
$all_traps = db_get_all_rows_sql ("SELECT DISTINCT source FROM ttrap");
|
||||
if (empty($all_traps))
|
||||
|
@ -180,6 +192,7 @@ switch ($config["dbtype"]) {
|
|||
LIMIT %d,%d";
|
||||
break;
|
||||
case "postgresql":
|
||||
case "oracle":
|
||||
$sql = "SELECT *
|
||||
FROM ttrap
|
||||
WHERE (source IN (
|
||||
|
@ -189,18 +202,22 @@ switch ($config["dbtype"]) {
|
|||
ORDER BY timestamp DESC
|
||||
LIMIT %d OFFSET %d";
|
||||
break;
|
||||
case "oracle":
|
||||
$sql = "SELECT *
|
||||
}
|
||||
$sql_all = "SELECT *
|
||||
FROM ttrap
|
||||
WHERE (source IN (
|
||||
SELECT direccion FROM tagente
|
||||
WHERE id_grupo IN ($str_user_groups)
|
||||
)
|
||||
OR source='' OR source NOT IN (SELECT direccion FROM tagente)) %s
|
||||
ORDER BY timestamp DESC
|
||||
LIMIT %d OFFSET %d";
|
||||
break;
|
||||
}
|
||||
ORDER BY timestamp DESC";
|
||||
$sql_count = "SELECT COUNT(id_trap)
|
||||
FROM ttrap
|
||||
WHERE (source IN (
|
||||
SELECT direccion FROM tagente
|
||||
WHERE id_grupo IN ($str_user_groups)
|
||||
)
|
||||
OR source='' OR source NOT IN (SELECT direccion FROM tagente)) %s";
|
||||
//$whereSubquery = 'WHERE 1=1';
|
||||
$whereSubquery = '';
|
||||
|
||||
|
@ -276,21 +293,13 @@ switch ($config["dbtype"]) {
|
|||
$sql = oracle_recode_query ($sql, $set);
|
||||
break;
|
||||
}
|
||||
$sql_all = sprintf($sql_all, $whereSubquery);
|
||||
$sql_count = sprintf($sql_count, $whereSubquery);
|
||||
|
||||
$traps = db_get_all_rows_sql($sql);
|
||||
|
||||
// No traps
|
||||
if (empty ($traps)) {
|
||||
echo '<div class="nf">'.__('There are no SNMP traps in database').'</div>';
|
||||
return;
|
||||
}
|
||||
|
||||
if (($config['dbtype'] == 'oracle') && ($traps !== false)) {
|
||||
for ($i=0; $i < count($traps); $i++) {
|
||||
unset($traps[$i]['rnum']);
|
||||
}
|
||||
}
|
||||
|
||||
$table->width = '90%';
|
||||
$table->size = array ();
|
||||
$table->size[0] = '120px';
|
||||
$table->data = array ();
|
||||
|
||||
// Alert status select
|
||||
$table->data[1][0] = '<strong>'.__('Alert').'</strong>';
|
||||
|
@ -330,7 +339,7 @@ $table->data[3][3] = '<strong>'.__('Group by OID/IP').'</strong>';
|
|||
$table->data[3][4] .= __('Yes').' '.html_print_radio_button ('group_by', 1, '', $group_by, true).' ';
|
||||
$table->data[3][4] .= __('No').' '.html_print_radio_button ('group_by', 0, '', $group_by, true);
|
||||
|
||||
$filter = '<form method="POST" action="index.php?sec=snmpconsole&sec2=operation/snmpconsole/snmp_view&refr='.((int)get_parameter('refr', 0)).'&pure='.$config["pure"].'">';
|
||||
$filter = '<form method="POST" action="index.php?sec=snmpconsole&sec2=operation/snmpconsole/snmp_view&refr='.((int)get_parameter('refr', 0)).'&pure='.$config["pure"].'&tab='.$tab.'">';
|
||||
$filter .= html_print_table($table, true);
|
||||
$filter .= '<div style="width: ' . $table->width . '; text-align: right;">';
|
||||
$filter .= html_print_submit_button(__('Update'), 'search', false, 'class="sub upd"', true);
|
||||
|
@ -341,8 +350,22 @@ ui_toggle($filter, __('Toggle filter(s)'));
|
|||
|
||||
unset ($table);
|
||||
|
||||
// Prepare index for pagination
|
||||
$trapcount = count($traps);
|
||||
if ($tab == '') {
|
||||
|
||||
$traps = db_get_all_rows_sql($sql);
|
||||
$trapcount = (int) db_get_value_sql($sql_count);
|
||||
|
||||
// No traps
|
||||
if (empty ($traps)) {
|
||||
echo '<div class="nf">'.__('There are no SNMP traps in database').'</div>';
|
||||
return;
|
||||
}
|
||||
|
||||
if (($config['dbtype'] == 'oracle') && ($traps !== false)) {
|
||||
for ($i=0; $i < count($traps); $i++) {
|
||||
unset($traps[$i]['rnum']);
|
||||
}
|
||||
}
|
||||
|
||||
$url_snmp = "index.php?" .
|
||||
"sec=snmpconsole&" .
|
||||
|
@ -693,6 +716,75 @@ foreach (get_priorities () as $num => $name) {
|
|||
}
|
||||
echo '</div>';
|
||||
echo '<div style="clear:both;"> </div>';
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
$traps = db_get_all_rows_sql($sql_all);
|
||||
$trapcount = (int) db_get_value_sql($sql_count);
|
||||
|
||||
// No traps
|
||||
if (empty ($traps)) {
|
||||
echo '<div class="nf">'.__('There are no SNMP traps in database').'</div>';
|
||||
return;
|
||||
}
|
||||
|
||||
if (($config['dbtype'] == 'oracle') && ($traps !== false)) {
|
||||
for ($i=0; $i < count($traps); $i++) {
|
||||
unset($traps[$i]['rnum']);
|
||||
}
|
||||
}
|
||||
|
||||
include_once($config['homedir'] . '/include/functions_graph.php');
|
||||
|
||||
$data_aux = array();
|
||||
foreach ($traps as $trap) {
|
||||
$source = $trap['source'];
|
||||
$oid = $trap['oid'];
|
||||
|
||||
if (!isset($data_aux[$source]))
|
||||
$data_aux[$source] = array();
|
||||
|
||||
if (!isset($data_aux[$source][$oid]))
|
||||
$data_aux[$source][$oid] = array('num' => 1, 'text' => '');
|
||||
else {
|
||||
$data_aux[$source][$oid]['num']++;
|
||||
if (empty($data_aux[$source][$oid]['text']))
|
||||
$data_aux[$source][$oid]['text'] = $trap['text'];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$id = -1;
|
||||
$data = array();
|
||||
|
||||
if (!empty($traps)) {
|
||||
$data['name'] = __("Traps received by source");
|
||||
$data['children'] = array();
|
||||
|
||||
foreach ($data_aux as $source => $oid_data) {
|
||||
$children = array();
|
||||
$children['id'] = $id++;
|
||||
$children['name'] = $source;
|
||||
$children['children'] = array();
|
||||
foreach ($oid_data as $oid => $values) {
|
||||
$children_data = array();
|
||||
$children_data['id'] = $id++;
|
||||
$children_data['name'] = $oid;
|
||||
$children_data['value'] = $values['num'];
|
||||
$children_data['tooltip_content'] = '';
|
||||
if (!empty($values['text']))
|
||||
$children_data['tooltip_content'] .= "<b>" . $values['text'] . "</b><br>";
|
||||
$children_data['tooltip_content'] .= sprintf(__('%d traps received from this source with this oid'), $values['num']);
|
||||
$children['children'][] = $children_data;
|
||||
}
|
||||
$data['children'][] = $children;
|
||||
}
|
||||
}
|
||||
|
||||
echo graph_snmp_traps_treemap($data, 'auto', 500);
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<script language="JavaScript" type="text/javascript">
|
||||
|
|
Loading…
Reference in New Issue