mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-31 01:35:36 +02:00
Added the 'automatic custom graphs' in the template reports in metaconsole.
This commit is contained in:
parent
b689f05ec3
commit
8d54a6762a
@ -182,6 +182,7 @@ ALTER TABLE tagente_estado ADD COLUMN `last_dynamic_update` bigint(20) NOT NULL
|
|||||||
-- Table `tgraph_source`
|
-- Table `tgraph_source`
|
||||||
-- ---------------------------------------------------------------------
|
-- ---------------------------------------------------------------------
|
||||||
ALTER TABLE tgraph_source ADD COLUMN `label` varchar(150) DEFAULT '';
|
ALTER TABLE tgraph_source ADD COLUMN `label` varchar(150) DEFAULT '';
|
||||||
|
ALTER TABLE tgraph_source ADD COLUMN `id_server` int(11) NOT NULL default 0;
|
||||||
|
|
||||||
-- ---------------------------------------------------------------------
|
-- ---------------------------------------------------------------------
|
||||||
-- Table `tevent_filter`
|
-- Table `tevent_filter`
|
||||||
|
@ -130,3 +130,4 @@ ALTER TABLE tevent_filter ADD COLUMN id_agent int(25) DEFAULT 0;
|
|||||||
-- Table `tgraph_source`
|
-- Table `tgraph_source`
|
||||||
-- ---------------------------------------------------------------------
|
-- ---------------------------------------------------------------------
|
||||||
ALTER TABLE tgraph_source ADD COLUMN label VARCHAR2(150) DEFAULT '';
|
ALTER TABLE tgraph_source ADD COLUMN label VARCHAR2(150) DEFAULT '';
|
||||||
|
ALTER TABLE tgraph_source ADD COLUMN "id_server" BIGINT NOT NULL default 0;
|
||||||
|
@ -120,4 +120,10 @@ UPDATE `tnetwork_component` set `tcp_port`=0 WHERE id_nc=219;
|
|||||||
-- Table `tnetwork_component`
|
-- Table `tnetwork_component`
|
||||||
-- ---------------------------------------------------------------------
|
-- ---------------------------------------------------------------------
|
||||||
ALTER TABLE tevent_filter ADD COLUMN id_agent_module int(25) DEFAULT 0;
|
ALTER TABLE tevent_filter ADD COLUMN id_agent_module int(25) DEFAULT 0;
|
||||||
ALTER TABLE tevent_filter ADD COLUMN id_agent int(25) DEFAULT 0;
|
ALTER TABLE tevent_filter ADD COLUMN id_agent int(25) DEFAULT 0;
|
||||||
|
|
||||||
|
-- ---------------------------------------------------------------------
|
||||||
|
-- Table `tgraph_source`
|
||||||
|
-- ---------------------------------------------------------------------
|
||||||
|
ALTER TABLE tgraph_source ADD COLUMN label VARCHAR2(150) DEFAULT '';
|
||||||
|
ALTER TABLE tgraph_source ADD COLUMN id_graph NUMBER(19, 0) DEFAULT 0;
|
@ -1009,7 +1009,7 @@ function graphic_combined_module ($module_list, $weight_list, $period,
|
|||||||
if ($date == 0)
|
if ($date == 0)
|
||||||
$date = get_system_time();
|
$date = get_system_time();
|
||||||
$datelimit = $date - $period;
|
$datelimit = $date - $period;
|
||||||
$search_in_history_db = db_search_in_history_db($datelimit);
|
|
||||||
$resolution = $config['graph_res'] * 50; //Number of points of the graph
|
$resolution = $config['graph_res'] * 50; //Number of points of the graph
|
||||||
$interval = (int) ($period / $resolution);
|
$interval = (int) ($period / $resolution);
|
||||||
|
|
||||||
@ -1079,16 +1079,36 @@ function graphic_combined_module ($module_list, $weight_list, $period,
|
|||||||
|
|
||||||
// Calculate data for each module
|
// Calculate data for each module
|
||||||
for ($i = 0; $i < $module_number; $i++) {
|
for ($i = 0; $i < $module_number; $i++) {
|
||||||
// If its a projection graph, first module will be data and second will be the projection
|
$automatic_custom_graph_meta = false;
|
||||||
|
if ($config['metaconsole']) {
|
||||||
|
// Automatic custom graph from the report template in metaconsole
|
||||||
|
if (is_array($module_list[$i])) {
|
||||||
|
$server = metaconsole_get_connection_by_id ($module_list[$i]['server']);
|
||||||
|
metaconsole_connect($server);
|
||||||
|
$automatic_custom_graph_meta = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$search_in_history_db = db_search_in_history_db($datelimit);
|
||||||
|
|
||||||
|
// If its a projection graph,
|
||||||
|
// first module will be data and second will be the projection
|
||||||
if ($projection != false && $i != 0) {
|
if ($projection != false && $i != 0) {
|
||||||
$agent_module_id = $module_list[0];
|
if ($automatic_custom_graph_meta)
|
||||||
|
$agent_module_id = $module_list[0]['module'];
|
||||||
|
else
|
||||||
|
$agent_module_id = $module_list[0];
|
||||||
|
|
||||||
$id_module_type = modules_get_agentmodule_type ($agent_module_id);
|
$id_module_type = modules_get_agentmodule_type ($agent_module_id);
|
||||||
$module_type = modules_get_moduletype_name ($id_module_type);
|
$module_type = modules_get_moduletype_name ($id_module_type);
|
||||||
$uncompressed_module = is_module_uncompressed ($module_type);
|
$uncompressed_module = is_module_uncompressed ($module_type);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$agent_module_id = $module_list[$i];
|
if ($automatic_custom_graph_meta)
|
||||||
|
$agent_module_id = $module_list[$i]['module'];
|
||||||
|
else
|
||||||
|
$agent_module_id = $module_list[$i];
|
||||||
|
|
||||||
|
|
||||||
$id_module_type = modules_get_agentmodule_type ($agent_module_id);
|
$id_module_type = modules_get_agentmodule_type ($agent_module_id);
|
||||||
$module_type = modules_get_moduletype_name ($id_module_type);
|
$module_type = modules_get_moduletype_name ($id_module_type);
|
||||||
@ -1365,6 +1385,13 @@ function graphic_combined_module ($module_list, $weight_list, $period,
|
|||||||
//unset($graph_values[$i]);
|
//unset($graph_values[$i]);
|
||||||
|
|
||||||
//$graph_values[$i] = $graph_values[$i];
|
//$graph_values[$i] = $graph_values[$i];
|
||||||
|
|
||||||
|
if ($config['metaconsole']) {
|
||||||
|
// Automatic custom graph from the report template in metaconsole
|
||||||
|
if (is_array($module_list[0])) {
|
||||||
|
metaconsole_restore_db();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$temp = array();
|
$temp = array();
|
||||||
@ -1372,7 +1399,24 @@ function graphic_combined_module ($module_list, $weight_list, $period,
|
|||||||
switch ($stacked) {
|
switch ($stacked) {
|
||||||
case CUSTOM_GRAPH_BULLET_CHART:
|
case CUSTOM_GRAPH_BULLET_CHART:
|
||||||
$datelimit = $date - $period;
|
$datelimit = $date - $period;
|
||||||
foreach ($module_list as $module) {
|
foreach ($module_list as $module_item) {
|
||||||
|
$automatic_custom_graph_meta = false;
|
||||||
|
if ($config['metaconsole']) {
|
||||||
|
// Automatic custom graph from the report template in metaconsole
|
||||||
|
if (is_array($module_list[$i])) {
|
||||||
|
$server = metaconsole_get_connection_by_id ($module_item['server']);
|
||||||
|
metaconsole_connect($server);
|
||||||
|
$automatic_custom_graph_meta = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($automatic_custom_graph_meta)
|
||||||
|
$module = $module_item['module'];
|
||||||
|
else
|
||||||
|
$module = $module_item;
|
||||||
|
|
||||||
|
$search_in_history_db = db_search_in_history_db($datelimit);
|
||||||
|
|
||||||
$temp[$module] = modules_get_agentmodule($module);
|
$temp[$module] = modules_get_agentmodule($module);
|
||||||
$temp_data = db_get_value_sql('SELECT datos
|
$temp_data = db_get_value_sql('SELECT datos
|
||||||
FROM tagente_datos
|
FROM tagente_datos
|
||||||
@ -1396,6 +1440,13 @@ function graphic_combined_module ($module_list, $weight_list, $period,
|
|||||||
$temp[$module]['max'] = reporting_get_agentmodule_data_max($module,$period,$date);
|
$temp[$module]['max'] = reporting_get_agentmodule_data_max($module,$period,$date);
|
||||||
$temp[$module]['min'] = reporting_get_agentmodule_data_min($module,$period,$date);
|
$temp[$module]['min'] = reporting_get_agentmodule_data_min($module,$period,$date);
|
||||||
|
|
||||||
|
if ($config['metaconsole']) {
|
||||||
|
// Automatic custom graph from the report template in metaconsole
|
||||||
|
if (is_array($module_list[0])) {
|
||||||
|
metaconsole_restore_db();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -1404,7 +1455,23 @@ function graphic_combined_module ($module_list, $weight_list, $period,
|
|||||||
$datelimit = $date - $period;
|
$datelimit = $date - $period;
|
||||||
|
|
||||||
$label = '';
|
$label = '';
|
||||||
foreach ($module_list as $module) {
|
foreach ($module_list as $module_item) {
|
||||||
|
$automatic_custom_graph_meta = false;
|
||||||
|
if ($config['metaconsole']) {
|
||||||
|
// Automatic custom graph from the report template in metaconsole
|
||||||
|
if (is_array($module_list[$i])) {
|
||||||
|
$server = metaconsole_get_connection_by_id ($module_item['server']);
|
||||||
|
metaconsole_connect($server);
|
||||||
|
$automatic_custom_graph_meta = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($automatic_custom_graph_meta)
|
||||||
|
$module = $module_item['module'];
|
||||||
|
else
|
||||||
|
$module = $module_item;
|
||||||
|
|
||||||
|
|
||||||
$module_data = modules_get_agentmodule($module);
|
$module_data = modules_get_agentmodule($module);
|
||||||
$temp_data = db_get_value_sql('SELECT datos
|
$temp_data = db_get_value_sql('SELECT datos
|
||||||
FROM tagente_datos
|
FROM tagente_datos
|
||||||
@ -1421,12 +1488,31 @@ function graphic_combined_module ($module_list, $weight_list, $period,
|
|||||||
$label = $agent_name . " - " .$module_data['nombre'];
|
$label = $agent_name . " - " .$module_data['nombre'];
|
||||||
$temp[$label]['g'] = round($temp_data,4);
|
$temp[$label]['g'] = round($temp_data,4);
|
||||||
|
|
||||||
|
|
||||||
|
if ($config['metaconsole']) {
|
||||||
|
// Automatic custom graph from the report template in metaconsole
|
||||||
|
if (is_array($module_list[0])) {
|
||||||
|
metaconsole_restore_db();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CUSTOM_GRAPH_PIE:
|
case CUSTOM_GRAPH_PIE:
|
||||||
$datelimit = $date - $period;
|
$datelimit = $date - $period;
|
||||||
$total_modules = 0;
|
$total_modules = 0;
|
||||||
foreach ($module_list as $module) {
|
foreach ($module_list as $module_item) {
|
||||||
|
$automatic_custom_graph_meta = false;
|
||||||
|
if ($config['metaconsole']) {
|
||||||
|
// Automatic custom graph from the report template in metaconsole
|
||||||
|
if (is_array($module_list[$i])) {
|
||||||
|
$server = metaconsole_get_connection_by_id ($module_item['server']);
|
||||||
|
metaconsole_connect($server);
|
||||||
|
$automatic_custom_graph_meta = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$data_module = modules_get_agentmodule($module);
|
$data_module = modules_get_agentmodule($module);
|
||||||
$temp_data = db_get_value_sql('SELECT datos
|
$temp_data = db_get_value_sql('SELECT datos
|
||||||
FROM tagente_datos
|
FROM tagente_datos
|
||||||
@ -1450,15 +1536,35 @@ function graphic_combined_module ($module_list, $weight_list, $period,
|
|||||||
$label = $data_module['nombre'];
|
$label = $data_module['nombre'];
|
||||||
|
|
||||||
$label = io_safe_output($label);
|
$label = io_safe_output($label);
|
||||||
$temp[$label] = array('value'=>$value,
|
$temp[$label] = array(
|
||||||
'unit'=>$data_module['unit']);
|
'value'=>$value,
|
||||||
|
'unit'=>$data_module['unit']);
|
||||||
|
|
||||||
|
|
||||||
|
if ($config['metaconsole']) {
|
||||||
|
// Automatic custom graph from the report template in metaconsole
|
||||||
|
if (is_array($module_list[0])) {
|
||||||
|
metaconsole_restore_db();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$temp['total_modules'] = $total_modules;
|
$temp['total_modules'] = $total_modules;
|
||||||
break;
|
break;
|
||||||
case CUSTOM_GRAPH_GAUGE:
|
case CUSTOM_GRAPH_GAUGE:
|
||||||
$datelimit = $date - $period;
|
$datelimit = $date - $period;
|
||||||
$i = 0;
|
$i = 0;
|
||||||
foreach ($module_list as $module) {
|
foreach ($module_list as $module_item) {
|
||||||
|
$automatic_custom_graph_meta = false;
|
||||||
|
if ($config['metaconsole']) {
|
||||||
|
// Automatic custom graph from the report template in metaconsole
|
||||||
|
if (is_array($module_list[$i])) {
|
||||||
|
$server = metaconsole_get_connection_by_id ($module_item['server']);
|
||||||
|
metaconsole_connect($server);
|
||||||
|
$automatic_custom_graph_meta = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$temp[$module] = modules_get_agentmodule($module);
|
$temp[$module] = modules_get_agentmodule($module);
|
||||||
$temp_data = db_get_value_sql('SELECT datos
|
$temp_data = db_get_value_sql('SELECT datos
|
||||||
FROM tagente_datos
|
FROM tagente_datos
|
||||||
@ -1494,6 +1600,14 @@ function graphic_combined_module ($module_list, $weight_list, $period,
|
|||||||
}
|
}
|
||||||
$temp[$module]['gauge'] = "gauge_" . $i;
|
$temp[$module]['gauge'] = "gauge_" . $i;
|
||||||
$i++;
|
$i++;
|
||||||
|
|
||||||
|
|
||||||
|
if ($config['metaconsole']) {
|
||||||
|
// Automatic custom graph from the report template in metaconsole
|
||||||
|
if (is_array($module_list[0])) {
|
||||||
|
metaconsole_restore_db();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -160,14 +160,22 @@ function reporting_make_reporting_data($report = null, $id_report,
|
|||||||
$content);
|
$content);
|
||||||
break;
|
break;
|
||||||
case 'custom_graph':
|
case 'custom_graph':
|
||||||
case 'automatic_custom_graph':
|
|
||||||
$report['contents'][] =
|
$report['contents'][] =
|
||||||
reporting_custom_graph(
|
reporting_custom_graph(
|
||||||
$report,
|
$report,
|
||||||
$content,
|
$content,
|
||||||
$type,
|
$type,
|
||||||
$force_width_chart,
|
$force_width_chart,
|
||||||
$force_height_chart);
|
$force_height_chart, 'custom_graph');
|
||||||
|
break;
|
||||||
|
case 'automatic_graph':
|
||||||
|
$report['contents'][] =
|
||||||
|
reporting_custom_graph(
|
||||||
|
$report,
|
||||||
|
$content,
|
||||||
|
$type,
|
||||||
|
$force_width_chart,
|
||||||
|
$force_height_chart, 'automatic_graph');
|
||||||
break;
|
break;
|
||||||
case 'text':
|
case 'text':
|
||||||
$report['contents'][] = reporting_text(
|
$report['contents'][] = reporting_text(
|
||||||
@ -4272,18 +4280,23 @@ function reporting_general($report, $content) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function reporting_custom_graph($report, $content, $type = 'dinamic',
|
function reporting_custom_graph($report, $content, $type = 'dinamic',
|
||||||
$force_width_chart = null, $force_height_chart = null) {
|
$force_width_chart = null, $force_height_chart = null, $type_report = "custom_graph") {
|
||||||
|
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
require_once ($config["homedir"] . '/include/functions_graph.php');
|
require_once ($config["homedir"] . '/include/functions_graph.php');
|
||||||
|
|
||||||
if ($config['metaconsole']) {
|
if ($type_report == 'automatic_graph') {
|
||||||
$id_meta = metaconsole_get_id_server($content["server_name"]);
|
// Do none
|
||||||
|
}
|
||||||
|
else {
|
||||||
$server = metaconsole_get_connection_by_id ($id_meta);
|
if ($config['metaconsole']) {
|
||||||
metaconsole_connect($server);
|
$id_meta = metaconsole_get_id_server($content["server_name"]);
|
||||||
|
|
||||||
|
|
||||||
|
$server = metaconsole_get_connection_by_id ($id_meta);
|
||||||
|
metaconsole_connect($server);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$graph = db_get_row ("tgraph", "id_graph", $content['id_gs']);
|
$graph = db_get_row ("tgraph", "id_graph", $content['id_gs']);
|
||||||
@ -4310,7 +4323,15 @@ function reporting_custom_graph($report, $content, $type = 'dinamic',
|
|||||||
$graphs = array();
|
$graphs = array();
|
||||||
|
|
||||||
foreach ($graphs as $graph_item) {
|
foreach ($graphs as $graph_item) {
|
||||||
array_push ($modules, $graph_item['id_agent_module']);
|
if ($type_report == 'automatic_graph') {
|
||||||
|
array_push ($modules, array(
|
||||||
|
'module' => $graph_item['id_agent_module'],
|
||||||
|
'server' => $graph_item['id_server']));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
array_push ($modules, $graph_item['id_agent_module']);
|
||||||
|
}
|
||||||
|
|
||||||
array_push ($weights, $graph_item["weight"]);
|
array_push ($weights, $graph_item["weight"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4344,8 +4365,13 @@ function reporting_custom_graph($report, $content, $type = 'dinamic',
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($config['metaconsole']) {
|
if ($type_report == 'automatic_graph') {
|
||||||
metaconsole_restore_db();
|
// Do none
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if ($config['metaconsole']) {
|
||||||
|
metaconsole_restore_db();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return reporting_check_structure_content($return);
|
return reporting_check_structure_content($return);
|
||||||
|
@ -514,7 +514,7 @@ function reports_get_report_types ($template = false, $not_editor = false) {
|
|||||||
$types['sql_graph_hbar'] = array('optgroup' => __('Graphs'),
|
$types['sql_graph_hbar'] = array('optgroup' => __('Graphs'),
|
||||||
'name' => __('SQL horizonal bar graph'));
|
'name' => __('SQL horizonal bar graph'));
|
||||||
}
|
}
|
||||||
if ($template && !defined('METACONSOLE')) {
|
if ($template) {
|
||||||
$types['automatic_graph'] = array('optgroup' => __('Graphs'),
|
$types['automatic_graph'] = array('optgroup' => __('Graphs'),
|
||||||
'name' => __('Automatic combined Graph'));
|
'name' => __('Automatic combined Graph'));
|
||||||
}
|
}
|
||||||
|
@ -1194,6 +1194,7 @@ CREATE OR REPLACE TRIGGER tgraph_inc BEFORE INSERT ON tgraph REFERENCING NEW AS
|
|||||||
CREATE TABLE tgraph_source (
|
CREATE TABLE tgraph_source (
|
||||||
id_gs NUMBER(10, 0) PRIMARY KEY,
|
id_gs NUMBER(10, 0) PRIMARY KEY,
|
||||||
id_graph NUMBER(19, 0) DEFAULT 0,
|
id_graph NUMBER(19, 0) DEFAULT 0,
|
||||||
|
id_server NUMBER(19, 0) DEFAULT 0,
|
||||||
id_agent_module NUMBER(19, 0) DEFAULT 0,
|
id_agent_module NUMBER(19, 0) DEFAULT 0,
|
||||||
weight BINARY_DOUBLE DEFAULT 0,
|
weight BINARY_DOUBLE DEFAULT 0,
|
||||||
label VARCHAR2(150) DEFAULT ''
|
label VARCHAR2(150) DEFAULT ''
|
||||||
|
@ -984,9 +984,11 @@ CREATE TABLE "tgraph" (
|
|||||||
-- -----------------------------------------------------
|
-- -----------------------------------------------------
|
||||||
CREATE TABLE "tgraph_source" (
|
CREATE TABLE "tgraph_source" (
|
||||||
"id_gs" SERIAL NOT NULL PRIMARY KEY,
|
"id_gs" SERIAL NOT NULL PRIMARY KEY,
|
||||||
|
"id_server" BIGINT NOT NULL default 0,
|
||||||
"id_graph" BIGINT NOT NULL default 0,
|
"id_graph" BIGINT NOT NULL default 0,
|
||||||
"id_agent_module" BIGINT NOT NULL default 0,
|
"id_agent_module" BIGINT NOT NULL default 0,
|
||||||
"weight" DOUBLE PRECISION default 0
|
"weight" DOUBLE PRECISION default 0,
|
||||||
|
"label" VARCHAR2(150) DEFAULT ''
|
||||||
);
|
);
|
||||||
|
|
||||||
-- -----------------------------------------------------
|
-- -----------------------------------------------------
|
||||||
|
@ -1071,6 +1071,7 @@ CREATE TABLE IF NOT EXISTS `tgraph` (
|
|||||||
CREATE TABLE IF NOT EXISTS `tgraph_source` (
|
CREATE TABLE IF NOT EXISTS `tgraph_source` (
|
||||||
`id_gs` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
|
`id_gs` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||||
`id_graph` int(11) NOT NULL default 0,
|
`id_graph` int(11) NOT NULL default 0,
|
||||||
|
`id_server` int(11) NOT NULL default 0,
|
||||||
`id_agent_module` int(11) NOT NULL default 0,
|
`id_agent_module` int(11) NOT NULL default 0,
|
||||||
`weight` float(8,3) NOT NULL DEFAULT 0,
|
`weight` float(8,3) NOT NULL DEFAULT 0,
|
||||||
`label` varchar(150) DEFAULT '',
|
`label` varchar(150) DEFAULT '',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user