Added support to show the interface traffic graphs through the metaconsole and improved the ACL

This commit is contained in:
Alejandro Gallardo Escobar 2015-03-23 20:51:44 +01:00
parent 9b9a3797cd
commit da8570d3b9
4 changed files with 104 additions and 93 deletions

View File

@ -46,6 +46,7 @@ class Tree {
global $config;
include_once($config['homedir']."/include/functions_servers.php");
include_once($config['homedir']."/include/functions_modules.php");
if (defined("METACONSOLE"))
enterprise_include_once("meta/include/functions_ui_meta.php");
@ -1306,31 +1307,35 @@ class Tree {
$module['serverTypeHTML'] = servers_show_type($module['server_type']);
// Link to the Module graph
$graphType = return_graphtype($module['id_module_type']);
$winHandle = dechex(crc32($module['id'] . $module['name']));
$group_id = (int) modules_get_agent_group($module['id']);
$module["showGraphs"] = 0;
if (!defined('METACONSOLE')) {
$moduleGraphURL = $config['homeurl'] .
"/operation/agentes/stat_win.php?" .
"type=$graphType&" .
"period=" . SECONDS_1DAY . "&" .
"id=" . $module['id'] . "&" .
"label=" . rawurlencode(urlencode(base64_encode($module['name']))) . "&" .
"refresh=" . SECONDS_10MINUTES;
}
else if (!empty($server)) {
$moduleGraphURL = ui_meta_get_url_console_child(
$server, null, null, null, null,
"operation/agentes/stat_win.php?" .
"type=$graphType&" .
"period=" . SECONDS_1DAY . "&" .
"id=" . $module["id"] . "&" .
"label=" . rawurlencode(urlencode(base64_encode($module['name']))) . "&" .
"refresh=" . SECONDS_10MINUTES . "&" .
"avg_only=1");
// ACL
if (!empty($group_id) {
$module["showGraphs"] = (int) check_acl($config['id_user'], $group_id, "RR");
}
if (!empty($moduleGraphURL)) {
if ($module["showGraphs"]) {
$graphType = return_graphtype($module['id_module_type']);
$url = ui_get_full_url("operation/agentes/stat_win.php", false, false, false);
$winHandle = dechex(crc32($module['id'].$module['name']));
$graph_params = array(
"type" => $graphType,
"period" => SECONDS_1DAY,
"id" => $module['id'],
"label" => rawurlencode(urlencode(base64_encode($module['name']))),
"refresh" => SECONDS_10MINUTES
);
if (defined('METACONSOLE') && !empty($server)) {
// Set the server id
$graph_params["server"] = $module['serverID'];
}
$graph_params_str = http_build_query($graph_params);
$moduleGraphURL = "$url?$graph_params_str";
$module['moduleGraph'] = array(
'url' => $moduleGraphURL,
'handle' => $winHandle

View File

@ -2033,35 +2033,41 @@ function events_page_details ($event, $server = "") {
}
$table_details->data[] = $data;
$data = array();
$data[0] = '<div style="font-weight:normal; margin-left: 20px;">'.__('Graph').'</div>';
$module_module_type = -1;
if (isset($module["module_type"])) {
$module_module_type = $module["module_type"];
}
$graph_type = return_graphtype ($module_module_type);
$win_handle=dechex(crc32($module["id_agente_modulo"] .
$module["nombre"]));
$module_module_name = '';
if (isset($module["module_name"])) {
$module_module_name = $module["module_name"];
}
$link ="winopeng('" . $serverstring .
"operation/agentes/stat_win.php?type=" . $graph_type."&" .
"period=" . SECONDS_1DAY . "&" .
"id=" . $module["id_agente_modulo"] . "&" .
"label=" . rawurlencode(
urlencode(
base64_encode($module_module_name))) . $hashstring . "&" .
(!empty($server) ? "avg_only=1&" : "") .
"refresh=" . SECONDS_10MINUTES . "','day_".$win_handle."')";
$data[1] = '<a href="javascript:'.$link.'">';
$data[1] .= html_print_image('images/chart_curve.png',true);
$data[1] .= '</a>';
$table_details->data[] = $data;
if (check_acl($config['id_user'], $agent['id_grupo'], "RR")) {
$data = array();
$data[0] = '<div style="font-weight:normal; margin-left: 20px;">'.__('Graph').'</div>';
$module_type = -1;
if (isset($module["module_type"])) {
$module_type = $module["module_type"];
}
$graph_type = return_graphtype ($module_type);
$url = ui_get_full_url("operation/agentes/stat_win.php", false, false, false);
$handle = dechex(crc32($module["id_agente_modulo"].$module["nombre"]));
$win_handle = "day_$handle";
$graph_params = array(
"type" => $graph_type,
"period" => SECONDS_1DAY,
"id" => $module["id_agente_modulo"],
"label" => rawurlencode(urlencode(base64_encode($module["nombre"]))),
"refresh" => SECONDS_10MINUTES
);
if (defined('METACONSOLE')) {
// Set the server id
$graph_params["server"] = $server["id"];
}
$graph_params_str = http_build_query($graph_params);
$link = "winopeng('$url?$graph_params_str','$win_handle')";
$data[1] = '<a href="javascript:'.$link.'">';
$data[1] .= html_print_image('images/chart_curve.png',true);
$data[1] .= '</a>';
$table_details->data[] = $data;
}
}
$data = array();

View File

@ -355,48 +355,50 @@ TreeController = {
$content.append($serverTypeImage);
}
// Graph pop-up
if (typeof element.moduleGraph != 'undefined') {
var $graphImage = $('<img src="'+(controller.baseURL.length > 0 ? controller.baseURL : '')
+'images/chart_curve.png" /> ');
$graphImage
.addClass('module-graph')
.click(function (e) {
e.preventDefault();
try {
winopeng(element.moduleGraph.url, element.moduleGraph.handle);
}
catch (error) {
// console.log(error);
}
});
$content.append($graphImage);
}
// Data pop-up
if (typeof element.id != 'undefined' && !isNaN(element.id)) {
if (typeof element.showGraphs != 'undefined' && element.showGraphs != 0) {
// Graph pop-up
if (typeof element.moduleGraph != 'undefined') {
var $graphImage = $('<img src="'+(controller.baseURL.length > 0 ? controller.baseURL : '')
+'images/chart_curve.png" /> ');
$graphImage
.addClass('module-graph')
.click(function (e) {
e.preventDefault();
var $dataImage = $('<img src="'+(controller.baseURL.length > 0 ? controller.baseURL : '')
+'images/binary.png" /> ');
$dataImage
.addClass('module-data')
.click(function (e) {
e.preventDefault();
try {
winopeng(element.moduleGraph.url, element.moduleGraph.handle);
}
catch (error) {
// console.log(error);
}
});
try {
var serverName = element.serverName.length > 0 ? element.serverName : '';
if ($("#module_details_window").length > 0)
show_module_detail_dialog(element.id, '', serverName, 0, 86400);
}
catch (error) {
// console.log(error);
}
});
$content.append($graphImage);
}
// Data pop-up
if (typeof element.id != 'undefined' && !isNaN(element.id)) {
$content.append($dataImage);
var $dataImage = $('<img src="'+(controller.baseURL.length > 0 ? controller.baseURL : '')
+'images/binary.png" /> ');
$dataImage
.addClass('module-data')
.click(function (e) {
e.preventDefault();
try {
var serverName = element.serverName.length > 0 ? element.serverName : '';
if ($("#module_details_window").length > 0)
show_module_detail_dialog(element.id, '', serverName, 0, 86400);
}
catch (error) {
// console.log(error);
}
});
$content.append($dataImage);
}
}
// Alerts

View File

@ -1197,11 +1197,11 @@ foreach ($result as $row) {
$data[7] = "";
if ($row['history_data'] == 1) {
if ($row['history_data'] == 1 && check_acl($config['id_user'], $row['id_group'], "RR") {
$graph_type = return_graphtype ($row["module_type"]);
$url = "operation/agentes/stat_win.php";
$url = ui_get_full_url("operation/agentes/stat_win.php", false, false, false);
$handle = dechex(crc32($row["id_agente_modulo"].$row["module_name"]));
$win_handle = "day_$handle";
@ -1214,8 +1214,6 @@ foreach ($result as $row) {
);
if (defined('METACONSOLE') && isset($row["server_id"])) {
// Force the search of this url from the pandora_console's root homeurl
$url = "../../$url";
// Set the server id
$graph_params["server"] = $row["server_id"];
}