Skip to content

Commit

Permalink
Merge branch 'feature/ticket#1319-CombinedGraph' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
alexgallardo committed Sep 22, 2014
2 parents 0bc05e7 + 87b7126 commit 016a353
Show file tree
Hide file tree
Showing 3 changed files with 342 additions and 21 deletions.
4 changes: 2 additions & 2 deletions pandora_console/include/functions_custom_graphs.php
Expand Up @@ -152,7 +152,7 @@ function custom_graphs_get_user ($id_user = 0, $only_names = false, $returnAllGr

function custom_graphs_print($id_graph, $height, $width, $period,
$stacked = null, $return = false, $date = 0, $only_image = false,
$background_color = 'white', $modules_param = array()) {
$background_color = 'white', $modules_param = array(), $homeurl = '') {

global $config;

Expand Down Expand Up @@ -210,7 +210,7 @@ function custom_graphs_print($id_graph, $height, $width, $period,
$stacked,
$date,
$only_image,
'',
$homeurl,
1,
false,
false,
Expand Down
87 changes: 68 additions & 19 deletions pandora_console/operation/agentes/estado_generalagente.php
Expand Up @@ -379,15 +379,16 @@
"id_agente" => $id_agente,
"id_tipo_modulo" => (int)db_get_value("id_tipo", "ttipo_modulo", "nombre", "remote_snmp_proc")
);
$modules = agents_get_modules ($id_agente, $columns, $filter);
$modules = agents_get_modules($id_agente, $columns, $filter);

if (! empty($modules)) {
$table_interface = new stdClass();
$table_interface->id = 'agent_interface_info';
$table_interface->class = 'databox';
$table_interface->width = '100%';
$table_interface->style = array();
$table_interface->style[1] = 'width: 30px;';
$table_interface->style['interface_status'] = 'width: 30px;';
$table_interface->style['interface_graph'] = 'width: 20px;';
$table_interface->head = array();
$options = array(
"class" => "closed",
Expand All @@ -396,7 +397,7 @@
$table_interface->head[0] = html_print_image("images/go.png", true, $options) . "  ";
$table_interface->head[0] .= '<span style="vertical-align: middle;">' . __('Interface information') .' (SNMP)</span>';
$table_interface->head_colspan = array();
$table_interface->head_colspan[0] = 4;
$table_interface->head_colspan[0] = 5;
$table_interface->data = array();

foreach ($modules as $key => $module) {
Expand All @@ -405,7 +406,7 @@
if (preg_match ("/_(.+)$/", (string)$module['nombre'], $matches)) {
if ($matches[1]) {
$interface_name = $matches[1];

$module_id = $module['id_agente_modulo'];
$db_status = modules_get_agentmodule_status($module_id);
$module_value = modules_get_last_value ($module_id);
Expand All @@ -428,12 +429,59 @@
$description = $matches[0];
}
}

// Get the ifInOctets and ifOutOctets modules of the interface
$columns = array(
"id_agente_modulo",
"nombre"
);
$interface_traffic_modules = agents_get_modules($id_agente, $columns, "nombre LIKE 'if%Octets_$interface_name'");
if (!empty($interface_traffic_modules) && count($interface_traffic_modules) >= 2) {
$interface_traffic_modules_aux = array('in' => '', 'out' => '');
foreach ($interface_traffic_modules as $interface_traffic_module) {
if (preg_match ("/if(.+)Octets_$interface_name$/i", (string)$interface_traffic_module['nombre'], $matches)) {
if (strtolower($matches[1]) == 'in') {
$interface_traffic_modules_aux['in'] = $interface_traffic_module['id_agente_modulo'];
}
elseif (strtolower($matches[1]) == 'out') {
$interface_traffic_modules_aux['out'] = $interface_traffic_module['id_agente_modulo'];
}
}
}
if (!empty($interface_traffic_modules_aux['in']) && !empty($interface_traffic_modules_aux['out'])) {
$interface_traffic_modules = $interface_traffic_modules_aux;
}
else {
$interface_traffic_modules = false;
}
}
else {
$interface_traffic_modules = false;
}

if ($interface_traffic_modules != false) {
$params = array(
'interface_name' => $interface_name,
'agent_id' => $id_agente,
'traffic_module_in' => $interface_traffic_modules_aux['in'],
'traffic_module_out' => $interface_traffic_modules_aux['out']
);
$params_json = json_encode($params);
$params_encoded = base64_encode($params_json);
$win_handle = dechex(crc32($module_id.$interface_name));
$graph_link = "<a href=\"javascript:winopeng('operation/agentes/interface_traffic_graph_win.php?params=$params_encoded','$win_handle')\">" .
html_print_image("images/chart_curve.png", true, array("title" => __('Interface traffic'))) . "</a>";
}
else {
$graph_link = "";
}

$data = array();
$data[0] = "<strong>" . $interface_name . "</strong>";
$data[1] = $status;
$data[2] = $ip_target;
$data[3] = $description;
$data['interface_name'] = "<strong>" . $interface_name . "</strong>";
$data['interface_status'] = $status;
$data['interface_graph'] = $graph_link;
$data['interface_ip'] = $ip_target;
$data['interface_mac'] = $description;
$table_interface->data[] = $data;
}
}
Expand All @@ -446,17 +494,18 @@
$(document).ready (function () {
$("#agent_interface_info").find("tbody").hide();
$("#agent_interface_info").find("thead").click (function () {
var arrow = $("#agent_interface_info").find("thead").find("img");
if (arrow.hasClass("closed")) {
arrow.removeClass("closed");
arrow.prop("src", "images/down.png");
$("#agent_interface_info").find("tbody").show();
} else {
arrow.addClass("closed");
arrow.prop("src", "images/go.png");
$("#agent_interface_info").find("tbody").hide();
}
});
var arrow = $("#agent_interface_info").find("thead").find("img");
if (arrow.hasClass("closed")) {
arrow.removeClass("closed");
arrow.prop("src", "images/down.png");
$("#agent_interface_info").find("tbody").show();
} else {
arrow.addClass("closed");
arrow.prop("src", "images/go.png");
$("#agent_interface_info").find("tbody").hide();
}
})
.css('cursor', 'pointer');
});
</script>
<?php
Expand Down

0 comments on commit 016a353

Please sign in to comment.