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; global $config;
include_once($config['homedir']."/include/functions_servers.php"); include_once($config['homedir']."/include/functions_servers.php");
include_once($config['homedir']."/include/functions_modules.php");
if (defined("METACONSOLE")) if (defined("METACONSOLE"))
enterprise_include_once("meta/include/functions_ui_meta.php"); enterprise_include_once("meta/include/functions_ui_meta.php");
@ -1306,31 +1307,35 @@ class Tree {
$module['serverTypeHTML'] = servers_show_type($module['server_type']); $module['serverTypeHTML'] = servers_show_type($module['server_type']);
// Link to the Module graph // Link to the Module graph
$graphType = return_graphtype($module['id_module_type']); $group_id = (int) modules_get_agent_group($module['id']);
$winHandle = dechex(crc32($module['id'] . $module['name'])); $module["showGraphs"] = 0;
if (!defined('METACONSOLE')) { // ACL
$moduleGraphURL = $config['homeurl'] . if (!empty($group_id) {
"/operation/agentes/stat_win.php?" . $module["showGraphs"] = (int) check_acl($config['id_user'], $group_id, "RR");
"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");
} }
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( $module['moduleGraph'] = array(
'url' => $moduleGraphURL, 'url' => $moduleGraphURL,
'handle' => $winHandle 'handle' => $winHandle

View File

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

View File

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

View File

@ -1197,11 +1197,11 @@ foreach ($result as $row) {
$data[7] = ""; $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"]); $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"])); $handle = dechex(crc32($row["id_agente_modulo"].$row["module_name"]));
$win_handle = "day_$handle"; $win_handle = "day_$handle";
@ -1214,8 +1214,6 @@ foreach ($result as $row) {
); );
if (defined('METACONSOLE') && isset($row["server_id"])) { 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 // Set the server id
$graph_params["server"] = $row["server_id"]; $graph_params["server"] = $row["server_id"];
} }