2010-04-22 Miguel de Dios <miguel.dedios@artica.es>

* include/ajax/reporting.ajax.php: added ajax respond to delete_sla_item and
	add_sla actions.
	
	* include/functions.php: added in the function "get_report_types" new types
	of items/contents for reporting.

	* pandoradb.sql: added columns custom_logo, header, first_page, footer,
	custom_font into the table treport. And in the table treport_content have
	new columns text, external_source, treport_custom_sql_id, header_definition,
	row_separator, line_separator. Added new table treport_custom_sql.
	
	* extras/pandoradb_migrate_v3.0_to_v3.1.sql: added changes for DB that it
	same to pandoradb.sql. 

	* images/sort_none.png, images/sort_down.png, images/sort_up.png: added the
	images for order list items for reports.

	* godmode/reporting/reporting_builder.list_items.php,
	godmode/reporting/reporting_builder.main.php,
	godmode/reporting/reporting_builder.php,
	godmode/reporting/reporting_builder.item_editor.php: made new forms to
	manage the reporting, now Pandora have tabs and list of items. In the list
	of items, you can order manually or automatically the items.



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2595 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
mdtrooper 2010-04-22 19:01:47 +00:00
parent ccf3ef7205
commit 008b908ebd
12 changed files with 1437 additions and 696 deletions

View File

@ -1,3 +1,29 @@
2010-04-22 Miguel de Dios <miguel.dedios@artica.es>
* include/ajax/reporting.ajax.php: added ajax respond to delete_sla_item and
add_sla actions.
* include/functions.php: added in the function "get_report_types" new types
of items/contents for reporting.
* pandoradb.sql: added columns custom_logo, header, first_page, footer,
custom_font into the table treport. And in the table treport_content have
new columns text, external_source, treport_custom_sql_id, header_definition,
row_separator, line_separator. Added new table treport_custom_sql.
* extras/pandoradb_migrate_v3.0_to_v3.1.sql: added changes for DB that it
same to pandoradb.sql.
* images/sort_none.png, images/sort_down.png, images/sort_up.png: added the
images for order list items for reports.
* godmode/reporting/reporting_builder.list_items.php,
godmode/reporting/reporting_builder.main.php,
godmode/reporting/reporting_builder.php,
godmode/reporting/reporting_builder.item_editor.php: made new forms to
manage the reporting, now Pandora have tabs and list of items. In the list
of items, you can order manually or automatically the items.
2010-04-22 Miguel de Dios <miguel.dedios@artica.es>
* include/javascript/pandora.js: added function

View File

@ -46,6 +46,21 @@ CREATE INDEX idx_utimestamp USING BTREE ON tagent_access(utimestamp);
ALTER TABLE tusuario ADD `timezone` varchar(50) default '';
-- New report data
ALTER TABLE `treport` ADD `custom_logo` varchar(200) default NULL;
ALTER TABLE `treport` ADD `header` MEDIUMTEXT default NULL;
ALTER TABLE `treport` ADD `first_page` MEDIUMTEXT default NULL;
ALTER TABLE `treport` ADD `footer` MEDIUMTEXT default NULL;
ALTER TABLE `treport` ADD `custom_font` varchar(200) default NULL;
-- New report content data
ALTER TABLE `treport_content` ADD `text` TEXT default NULL;
ALTER TABLE `treport_content` ADD `external_source` TinyText default NULL;
ALTER TABLE `treport_content` ADD `treport_custom_sql_id` INTEGER UNSIGNED default 0;
ALTER TABLE `treport_content` ADD `header_definition` TinyText default NULL;
ALTER TABLE `treport_content` ADD `row_separator` TinyText default NULL;
ALTER TABLE `treport_content` ADD `line_separator` TinyText default NULL;
-- Realtime statistics on/off and interval
INSERT INTO tconfig (`token`, `value`) VALUES ('realtimestats', '1');
INSERT INTO tconfig (`token`, `value`) VALUES ('stats_interval', '300');
@ -60,6 +75,16 @@ INSERT INTO ttipo_modulo (`id_tipo`, `nombre`, `categoria`, `descripcion`, `icon
-- GIS is disabled by default
INSERT INTO tconfig (`token`, `value`) VALUES ('activate_gis', '1');
-- -----------------------------------------------------
-- Table `treport_custom_sql`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `treport_custom_sql` (
`id` INTEGER UNSIGNED NOT NULL auto_increment,
`name` varchar(150) NOT NULL default '',
`sql` TEXT default NULL,
PRIMARY KEY(`id`)
) ENGINE = InnoDB DEFAULT CHARSET = utf8;
-- -----------------------------------------------------
-- Table `tgis_data_history`
-- -----------------------------------------------------

View File

@ -0,0 +1,651 @@
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2010 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation for version 2.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
global $config;
// Login check
check_login ();
if (! give_acl ($config['id_user'], 0, "IW")) {
audit_db ($config['id_user'], $_SERVER['REMOTE_ADDR'], "ACL Violation",
"Trying to access report builder");
require ("general/noaccess.php");
exit;
}
switch ($action) {
case 'new':
$actionParameter = 'save';
$type = get_parameter('type', 'SLA');
$period = 86400;
$idAgent = null;
$idCustomGraph = null;
$text = null;
$header = null;
$idCustom = null;
$url = null;
$field = null;
$line = null;
$description = null;
$sql = null;
break;
default:
$actionParameter = 'update';
$item = get_db_row_filter('treport_content', array('id_rc' => $idItem));
print_input_hidden('id_item', $idItem);
//debugPrint($item);
$type = $item['type'];
switch ($type) {
case 'avg_value':
$period = $item['period'];
$description = $item['description'];
$idAgentModule = $item['id_agent_module'];
$idAgent = get_db_value_filter('id_agente', 'tagente_modulo', array('id_agente_modulo' => $idAgentModule));
break;
case 'simple_graph':
$description = $item['description'];
$idAgentModule = $item['id_agent_module'];
$idAgent = get_db_value_filter('id_agente', 'tagente_modulo', array('id_agente_modulo' => $idAgentModule));
$period = $item['period'];
break;
case 'custom_graph':
$description = $item['description'];
$period = $item['period'];
$idCustomGraph = $item['id_gs'];
break;
case 'SLA':
$description = $item['description'];
$period = $item['period'];
break;
case 'monitor_report':
$description = $item['description'];
$idAgent = get_db_value_filter('id_agente', 'tagente_modulo', array('id_agente_modulo' => $idAgentModule));
$idAgentModule = $item['id_agent_module'];
$period = $item['period'];
break;
case 'avg_value':
$description = $item['description'];
$idAgent = get_db_value_filter('id_agente', 'tagente_modulo', array('id_agente_modulo' => $idAgentModule));
$idAgentModule = $item['id_agent_module'];
$period = $item['period'];
break;
case 'max_value':
$description = $item['description'];
$idAgent = get_db_value_filter('id_agente', 'tagente_modulo', array('id_agente_modulo' => $idAgentModule));
$idAgentModule = $item['id_agent_module'];
$period = $item['period'];
break;
case 'min_value':
$description = $item['description'];
$idAgent = get_db_value_filter('id_agente', 'tagente_modulo', array('id_agente_modulo' => $idAgentModule));
$idAgentModule = $item['id_agent_module'];
$period = $item['period'];
break;
case 'sumatory':
$description = $item['description'];
$idAgent = get_db_value_filter('id_agente', 'tagente_modulo', array('id_agente_modulo' => $idAgentModule));
$idAgentModule = $item['id_agent_module'];
$period = $item['period'];
break;
case 'agent_detailed':
$description = $item['description'];
$idAgent = get_db_value_filter('id_agente', 'tagente_modulo', array('id_agente_modulo' => $idAgentModule));
$period = $item['period'];
break;
// case 'agent_detailed_event':
// $description = $item['description'];
// $idAgent = get_db_value_filter('id_agente', 'tagente_modulo', array('id_agente_modulo' => $idAgentModule));
// $idAgentModule = $item['id_agent_module'];
// $period = $item['period'];
// break;
case 'text':
$description = $item['description'];
$text = $item['text'];
break;
case 'sql':
$description = $item['description'];
$sql = $item['external_source'];
$idCustom = $item['treport_custom_sql_id'];
$header = $item['header_definition'];
break;
case 'url':
$description = $item['description'];
$url = $item['row_separator'];
break;
case 'database_serialized':
$description = $item['description'];
$idAgent = get_db_value_filter('id_agente', 'tagente_modulo', array('id_agente_modulo' => $idAgentModule));
$idAgentModule = $item['id_agent_module'];
$header = $item['header_definition'];
$field = $item['row_separator'];
$line = $item['line_separator'];
break;
case 'TTRT':
$description = $item['description'];
$idAgent = get_db_value_filter('id_agente', 'tagente_modulo', array('id_agente_modulo' => $idAgentModule));
$idAgentModule = $item['id_agent_module'];
$period = $item['period'];
break;
case 'TTO':
$description = $item['description'];
$idAgent = get_db_value_filter('id_agente', 'tagente_modulo', array('id_agente_modulo' => $idAgentModule));
$idAgentModule = $item['id_agent_module'];
$period = $item['period'];
break;
case 'MTBF':
$description = $item['description'];
$idAgent = get_db_value_filter('id_agente', 'tagente_modulo', array('id_agente_modulo' => $idAgentModule));
$idAgentModule = $item['id_agent_module'];
$period = $item['period'];
break;
case 'MTTR':
$description = $item['description'];
$idAgent = get_db_value_filter('id_agente', 'tagente_modulo', array('id_agente_modulo' => $idAgentModule));
$idAgentModule = $item['id_agent_module'];
$period = $item['period'];
break;
case 'alert_report_module':
$description = $item['description'];
$idAgent = get_db_value_filter('id_agente', 'tagente_modulo', array('id_agente_modulo' => $idAgentModule));
$idAgentModule = $item['id_agent_module'];
$period = $item['period'];
break;
case 'alert_report_agent':
$description = $item['description'];
$idAgent = get_db_value_filter('id_agente', 'tagente_modulo', array('id_agente_modulo' => $idAgentModule));
$period = $item['period'];
break;
case 'event_report_agent':
$description = $item['description'];
$idAgent = get_db_value_filter('id_agente', 'tagente_modulo', array('id_agente_modulo' => $idAgentModule));
$period = $item['period'];
break;
case 'event_report_module':
$description = $item['description'];
$idAgent = get_db_value_filter('id_agente', 'tagente_modulo', array('id_agente_modulo' => $idAgentModule));
$idAgentModule = $item['id_agent_module'];
$period = $item['period'];
break;
// case 'list_events_module':
// $description = $item['description'];
// $idAgent = get_db_value_filter('id_agente', 'tagente_modulo', array('id_agente_modulo' => $idAgentModule));
// $idAgentModule = $item['id_agent_module'];
// break;
// case 'list_events_agent':
// $description = $item['description'];
// $idAgent = get_db_value_filter('id_agente', 'tagente_modulo', array('id_agente_modulo' => $idAgentModule));
// break;
// case 'list_alerts_agent':
// $description = $item['description'];
// $idAgent = get_db_value_filter('id_agente', 'tagente_modulo', array('id_agente_modulo' => $idAgentModule));
// break;
// case 'list_alerts_module':
// $description = $item['description'];
// $idAgent = get_db_value_filter('id_agente', 'tagente_modulo', array('id_agente_modulo' => $idAgentModule));
// $idAgentModule = $item['id_agent_module'];
// break;
}
break;
}
$intervals = array ();
$intervals[30] = human_time_description_raw (30);
$intervals[60] = human_time_description_raw (60);
$intervals[300] = human_time_description_raw (300);
$intervals[600] = human_time_description_raw (600);
$intervals[1200] = human_time_description_raw (1200);
$intervals[1800] = human_time_description_raw (1800);
$intervals[3600] = human_time_description_raw (3600);
$intervals[7200] = human_time_description_raw (7200);
$urlForm = 'index.php?sec=greporting&sec2=godmode/reporting/reporting_builder&tab=item_editor&action=' . $actionParameter . '&id_report=' . $idReport;
echo '<form action="' . $urlForm . '" method="post">';
?>
<table style="" class="databox" id="" border="0" cellpadding="4" cellspacing="4" width="90%">
<tbody>
<tr id="row_type" style="" class="datos">
<td style="vertical-align: top;"><?php echo __('Type'); ?></td>
<td style="">
<?php
if ($action == 'new') {
print_select(get_report_types(), 'type', $type, 'chooseType();', '', '');
}
else {
echo get_report_name($type);
echo '<input type="hidden" id="type" name="type" value="' . $type . '" />';
}
?>
</td>
</tr>
<tr id="row_description" style="" class="datos">
<td style="vertical-align: top;"><?php echo __('Description'); ?></td>
<td style=""><?php echo print_textarea('description', 3, 25, $description); ?></td>
</tr>
<tr id="row_period" style="" class="datos">
<td style="vertical-align: top;"><?php echo __('Period'); ?></td>
<td style=""><?php print_extended_select_for_time ($intervals, 'period', $period, '', '', '0', 10); echo __(" seconds."); ?></td>
</tr>
<tr id="row_agent" style="" class="datos">
<td style="vertical-align: top;"><?php echo __('Agent'); ?></td>
<td style="">
<?php
print_input_hidden('id_agent', $idAgent) .
print_input_text_extended ('agent', get_agent_name ($idAgent), 'text-agent', '', 30, 100, false, '',
array('style' => 'background: url(images/lightning.png) no-repeat right;'))
. '<a href="#" class="tip">&nbsp;<span>' . __("Type at least two characters to search") . '</span></a>';
?>
</td>
</tr>
<tr id="row_module" style="" class="datos">
<td style="vertical-align: top;"><?php echo __('Module'); ?></td>
<td style="">
<?php
if($idAgent) {
$sql = "SELECT id_agente_modulo, nombre FROM tagente_modulo WHERE id_agente = " . $idAgent;
print_select_from_sql($sql, 'id_agent_module', $idAgentModule, '', '', '0');
}
else {
?>
<select id="id_agent_module" name="id_agente_modulo" disabled="disabled">
<option value="0"><?php echo __('Select an Agent first'); ?></option>
</select>
<?php
}
?>
</td>
</tr>
<tr id="row_custom_graph" style="" class="datos">
<td style="vertical-align: top;"><?php echo __('Custom graph'); ?></td>
<td style="">
<?php
print_select_from_sql ('SELECT id_graph, name FROM tgraph WHERE private = 0 OR (private = 1 AND id_user = "'.$config["id_user"].'")', 'id_custom_graph', $idCustomGraph, '', '--', 0);
?>
</td>
</tr>
<tr id="row_text" style="" class="datos">
<td style="vertical-align: top;"><?php echo __('Text'); ?></td>
<td style=""><?php print_textarea('text', 5, 25, $text); ?></td>
</tr>
<tr id="row_query" style="" class="datos">
<td style="vertical-align: top;"><?php echo __('Query SQL'); ?></td>
<td style=""><?php print_textarea('sql', 5, 25, $sql); ?></td>
</tr>
<tr id="row_header" style="" class="datos">
<td style="vertical-align: top;"><?php echo __('Serialized header'); ?></td>
<td style=""><?php print_input_text('header', $header, '', 40, 90); ?></td>
</tr>
<tr id="row_custom" style="" class="datos">
<td style="vertical-align: top;"><?php echo __('Custom SQL template'); ?></td>
<td style=""><?php print_select_from_sql('SELECT id, name FROM treport_custom_sql', 'id_custom', $idCustom, '', '--', '0'); ?></td>
</tr>
<tr id="row_url" style="" class="datos">
<td style="vertical-align: top;"><?php echo __('URL'); ?></td>
<td style=""><?php print_input_text('url', $url, '', 40, 90); ?></td>
</tr>
<tr id="row_field_separator" style="" class="datos">
<td style="vertical-align: top;"><?php echo __('Field separator'); ?></td>
<td style=""><?php print_input_text('field', $field, '', 2, 4); ?></td>
</tr>
<tr id="row_line_separator" style="" class="datos">
<td style="vertical-align: top;"><?php echo __('Line separator'); ?></td>
<td style=""><?php print_input_text('line', $line, '', 2, 4); ?></td>
</tr>
</tbody>
</table>
<?php
print_SLA_list('90%', $action, $idItem);
echo '<div class="action-buttons" style="width: 90%">';
if ($action == 'new') {
print_submit_button(__('Create item'), 'create_item', false, 'class="sub next"');
}
else {
print_submit_button(__('Edit item'), 'edit_item', false, 'class="sub upd"');
}
echo '</div>';
echo '</form>';
require_javascript_file('pandora');
if ($enterpriseEnable) {
enterpriseTextBox();
}
function print_SLA_list($width, $action, $idItem = null) {
?>
<table class="databox" id="sla_list" border="0" cellpadding="4" cellspacing="4" width="90%">
<thead>
<tr>
<th class="header" scope="col"><?php echo __('Agent');?></th>
<th class="header" scope="col"><?php echo __('Module');?></th>
<th class="header" scope="col"><?php echo __('SLA Min. (value)');?></th>
<th class="header" scope="col"><?php echo __('SLA Max. (value)');?></th>
<th class="header" scope="col"><?php echo __('SLA Limit (%)');?></th>
<th class="header" scope="col"><?php echo __('Action');?></th>
</tr>
</thead>
<?php
switch ($action) {
case 'new':
?>
<tr id="sla_template" style="" class="datos">
<td colspan="6"><?php echo __('Please save the SLA for start to add items in this list.');?></td>
</tr>
<?php
break;
case 'save':
case 'update':
case 'edit':
echo '<tbody id="list_sla">';
$itemsSLA = get_db_all_rows_filter('treport_content_sla_combined', array('id_report_content' => $idItem));
if ($itemsSLA === false) {
$itemsSLA = array();
}
foreach ($itemsSLA as $item) {
$idAgent = get_db_value_filter('id_agente', 'tagente_modulo', array('id_agente_modulo' => $item['id_agent_module']));
$nameAgent = get_agent_name ($idAgent);
$nameModule = get_db_value_filter('nombre', 'tagente_modulo', array('id_agente_modulo' => $item['id_agent_module']));
echo '<tr id="sla_' . $item['id'] . '" style="" class="datos">
<td>' . $nameAgent . '</td>
<td>' . $nameModule . '</td>
<td>' . $item['sla_min'] . '</td>
<td>' . $item['sla_max'] . '</td>
<td>' . $item['sla_limit'] . '</td>
<td style="text-align: center;">
<a href="javascript: deleteSLARow(' . $item['id'] . ');"><img src="images/cross.png" /></a>
</td>
</tr>';
}
echo '</tbody>';
?>
<tbody id="sla_template">
<tr id="row" style="display: none;" class="datos">
<td class="agent_name"></td>
<td class="module_name"></td>
<td class="sla_min"></td>
<td class="sla_max"></td>
<td class="sla_limit"></td>
<td style="text-align: center;"><a class="delete_button" href="javascript: deleteSLARow(0);"><img src="images/cross.png"></a></td>
</tr>
</tbody>
<tbody>
<tr id="sla_form" style="" class="datos">
<td><input id="hidden-id_agent_sla" name="id_agent_sla" value="" type="hidden"><input class="ac_input" autocomplete="off" style="background: transparent url(images/lightning.png) no-repeat scroll right center; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" name="agent_sla" id="text-agent_sla" size="15" maxlength="20" type="text"><a href="#" class="tip">&nbsp;<span>Type at least two characters to search</span></a></td>
<td><select id="id_agent_module_sla" name="id_agente_modulo_sla" disabled="disabled"><option value="0"><?php echo __('Select an Agent first'); ?></option></select></td>
<td><input name="sla_min" id="text-sla_min" size="10" maxlength="10" type="text"></td>
<td><input name="sla_max" id="text-sla_max" size="10" maxlength="10" type="text"></td>
<td><input name="sla_limit" id="text-sla_limit" size="10" maxlength="10" type="text"></td>
<td style="text-align: center;"><a href="javascript: addSLARow();"><img src="images/disk.png"></a></td>
</tr>
</tbody>
<?php
break;
default:
break;
}
?>
</table>
<span style="display: none" id="module_sla_text"><?php echo __('Select an Agent first'); ?></span>
<?php
}
?>
<script>
$(document).ready (function () {
agent_module_autocomplete('#text-agent', '#hidden-id_agent', '#id_agent_module');
agent_module_autocomplete('#text-agent_sla', '#hidden-id_agent_sla', '#id_agent_module_sla');
chooseType();
});
function deleteSLARow(id_row) {
//ajax to delete
var params = [];
params.push("delete_sla_item=1");
params.push("id=" + id_row);
params.push("page=include/ajax/reporting.ajax");
jQuery.ajax ({
data: params.join ("&"),
type: 'POST',
url: action="ajax.php",
timeout: 10000,
dataType: 'json',
success: function (data) {
if (data['correct']) {
$("#sla_" + id_row).remove();
}
}
});
}
function addSLARow() {
var nameAgent = $("input[name=agent_sla]").val();
var idAgent = $("input[name=id_agent_sla]").val();
var idModule = $("#id_agent_module_sla").val();
var nameModule = $("#id_agent_module_sla :selected").text();
var slaMin = $("input[name=sla_min]").val();
var slaMax = $("input[name=sla_min]").val();
var slaLimit = $("input[name=sla_limit]").val();
if ((idAgent != '') && (slaMin != '') && (slaMax != '')
&& (slaLimit != '')) {
var params = [];
params.push("add_sla=1");
params.push("id=" + $("input[name=id_item]").val());
params.push("id_module=" + idModule);
params.push("sla_min=" + slaMin);
params.push("sla_max=" + slaMax);
params.push("sla_limit=" + slaLimit);
params.push("page=include/ajax/reporting.ajax");
jQuery.ajax ({
data: params.join ("&"),
type: 'POST',
url: action="ajax.php",
timeout: 10000,
dataType: 'json',
success: function (data) {
if (data['correct']) {
row = $("#sla_template").clone();
$("#row", row).css('display', '');
$("#row", row).attr('id', 'sla_' + data['id']);
$(".agent_name", row).html(nameAgent);
$(".module_name", row).html(nameModule);
$(".sla_min", row).html(slaMin);
$(".sla_max", row).html(slaMax);
$(".sla_limit", row).html(slaLimit);
$(".delete_button", row).attr('href', 'javascript: deleteSLARow(' + data['id'] + ');');
$("#list_sla").append($(row).html());
$("input[name=id_agent_sla]").val('');
$("input[name=agent_sla]").val('');
$("#id_agent_module_sla").empty();
$("#id_agent_module_sla").attr('disabled', 'true');
$("#id_agent_module_sla").append(
$("<option></option>")
.attr ("value", 0)
.html ($("#module_sla_text").html()));
$("input[name=sla_min]").val('');
$("input[name=sla_max]").val('');
$("input[name=sla_limit]").val('');
}
}
});
}
}
function chooseType() {
type = $("#type").val();
$("#row_description").css('display', 'none');
$("#row_period").css('display', 'none');
$("#row_agent").css('display', 'none');
$("#row_module").css('display', 'none');
$("#row_period").css('display', 'none');
$("#row_custom_graph").css('display', 'none');
$("#row_text").css('display', 'none');
$("#row_query").css('display', 'none');
$("#row_header").css('display', 'none');
$("#row_custom").css('display', 'none');
$("#row_url").css('display', 'none');
$("#row_field_separator").css('display', 'none');
$("#row_line_separator").css('display', 'none');
$("#sla_list").css('display', 'none');
switch (type) {
case 'simple_graph':
$("#row_description").css('display', '');
$("#row_agent").css('display', '');
$("#row_module").css('display', '');
$("#row_period").css('display', '');
break;
case 'custom_graph':
$("#row_description").css('display', '');
$("#row_period").css('display', '');
$("#row_custom_graph").css('display', '');
break;
case 'SLA':
$("#row_description").css('display', '');
$("#row_period").css('display', '');
$("#sla_list").css('display', '');
break;
case 'monitor_report':
$("#row_description").css('display', '');
$("#row_agent").css('display', '');
$("#row_module").css('display', '');
$("#row_period").css('display', '');
break;
case 'avg_value':
$("#row_description").css('display', '');
$("#row_agent").css('display', '');
$("#row_module").css('display', '');
$("#row_period").css('display', '');
break;
case 'max_value':
$("#row_description").css('display', '');
$("#row_agent").css('display', '');
$("#row_module").css('display', '');
$("#row_period").css('display', '');
break;
case 'min_value':
$("#row_description").css('display', '');
$("#row_agent").css('display', '');
$("#row_module").css('display', '');
$("#row_period").css('display', '');
break;
case 'sumatory':
$("#row_description").css('display', '');
$("#row_agent").css('display', '');
$("#row_module").css('display', '');
$("#row_period").css('display', '');
break;
case 'agent_detailed':
$("#row_description").css('display', '');
$("#row_agent").css('display', '');
$("#row_period").css('display', '');
break;
// case 'agent_detailed_event':
// $("#row_description").css('display', '');
// $("#row_agent").css('display', '');
// $("#row_module").css('display', '');
// $("#row_period").css('display', '');
// break;
case 'text':
$("#row_description").css('display', '');
$("#row_text").css('display', '');
break;
case 'sql':
$("#row_description").css('display', '');
$("#row_query").css('display', '');
$("#row_header").css('display', '');
$("#row_custom").css('display', '');
break;
case 'url':
$("#row_description").css('display', '');
$("#row_url").css('display', '');
break;
case 'database_serialized':
$("#row_description").css('display', '');
$("#row_agent").css('display', '');
$("#row_module").css('display', '');
$("#row_header").css('display', '');
$("#row_field_separator").css('display', '');
$("#row_line_separator").css('display', '');
break;
case 'TTRT':
$("#row_description").css('display', '');
$("#row_agent").css('display', '');
$("#row_module").css('display', '');
$("#row_period").css('display', '');
break;
case 'TTO':
$("#row_description").css('display', '');
$("#row_agent").css('display', '');
$("#row_module").css('display', '');
$("#row_period").css('display', '');
break;
case 'MTBF':
$("#row_description").css('display', '');
$("#row_agent").css('display', '');
$("#row_module").css('display', '');
$("#row_period").css('display', '');
break;
case 'MTTR':
$("#row_description").css('display', '');
$("#row_agent").css('display', '');
$("#row_module").css('display', '');
$("#row_period").css('display', '');
break;
case 'alert_report_module':
$("#row_description").css('display', '');
$("#row_agent").css('display', '');
$("#row_module").css('display', '');
$("#row_period").css('display', '');
break;
case 'alert_report_agent':
$("#row_description").css('display', '');
$("#row_agent").css('display', '');
$("#row_period").css('display', '');
break;
case 'event_report_agent':
$("#row_description").css('display', '');
$("#row_agent").css('display', '');
$("#row_period").css('display', '');
break;
case 'event_report_module':
$("#row_description").css('display', '');
$("#row_agent").css('display', '');
$("#row_module").css('display', '');
$("#row_period").css('display', '');
break;
// case 'list_events_module':
// $("#row_description").css('display', '');
// $("#row_agent").css('display', '');
// $("#row_module").css('display', '');
// break;
// case 'list_events_agent':
// $("#row_description").css('display', '');
// $("#row_agent").css('display', '');
// break;
// case 'list_alerts_agent':
// $("#row_description").css('display', '');
// $("#row_agent").css('display', '');
// break;
// case 'list_alerts_module':
// $("#row_description").css('display', '');
// $("#row_agent").css('display', '');
// $("#row_module").css('display', '');
// break;
}
}
</script>

View File

@ -0,0 +1,255 @@
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2010 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation for version 2.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
global $config;
// Login check
check_login ();
if (! give_acl ($config['id_user'], 0, "IW")) {
audit_db ($config['id_user'], $_SERVER['REMOTE_ADDR'], "ACL Violation",
"Trying to access report builder");
require ("general/noaccess.php");
exit;
}
//FORM FILTER
$rows = get_db_all_rows_sql('
SELECT t5.nombre, t5.id_agente
FROM
(
SELECT t1.*, id_agente
FROM treport_content AS t1
LEFT JOIN tagente_modulo AS t2
ON t1.id_agent_module = id_agente_modulo
) AS t4
INNER JOIN tagente AS t5
ON (t4.id_agent = t5.id_agente OR t4.id_agente = t5.id_agente)
WHERE t4.id_report = ' . $idReport);
if ($rows === false) {
$rows = array();
}
$agents = array();
foreach ($rows as $row) {
$agents[$row['id_agente']] = $row['nombre'];
}
$agents[0] = __('None');
$rows = get_db_all_rows_sql('
SELECT t1.id_agent_module, t2.nombre
FROM treport_content AS t1
INNER JOIN tagente_modulo AS t2
ON t1.id_agent_module = t2.id_agente_modulo
WHERE t1.id_report = ' . $idReport);
if ($rows === false) {
$rows = array();
}
$modules = array();
foreach ($rows as $row) {
$modules[$row['id_agent_module']] = $row['nombre'];
}
$modules[0] = __('None');
$rows = get_db_all_rows_sql('
SELECT DISTINCT(type)
FROM treport_content
WHERE id_report = ' . $idReport);
if ($rows === false) {
$rows = array();
}
$types = array();
foreach ($rows as $row) {
$types[$row['type']] = get_report_name($row['type']);
}
$types[0] = __('None');
$agentFilter = get_parameter('agent_filter', 0);
$moduleFilter = get_parameter('module_filter', 0);
$typeFilter = get_parameter('type_filter', '');
$filterEnable = true;
if (($agentFilter == 0) && ($moduleFilter == 0) && ($typeFilter == '')) {
$filterEnable = false;
}
$urlFilter = '&agent_filter=' . $agentFilter . '&module_filter=' . $moduleFilter . '&type_filter=' . $typeFilter;
echo '<a href="javascript: toggleFormFilter();"><b>'.__('Items filter').'</b> <img id="image_form_filter" src="images/down.png" "title"=' . __('Toggle filter(s)') . ' /></a>';
$table = null;
$table->width = '80%';
$table->data[0][0] = __('Agents');
$table->data[0][1] = print_select($agents, 'agent_filter', $agentFilter, '', 0, '', true);
$table->data[0][2] = __('Modules');
$table->data[0][3] = print_select($modules, 'module_filter', $moduleFilter, '', '', 0, true);
$table->data[1][0] = __('Type');
$table->data[1][1] = print_select($types, 'type_filter', $typeFilter, '', '', 0, true);
echo '<div id="form_filter" style="display: none;">';
echo '<form method="post" action ="index.php?sec=greporting&sec2=godmode/reporting/reporting_builder&tab=list_items&action=filter&&id_report=' . $idReport . '">';
print_table ($table);
echo '<div class="action-buttons" style="width: '.$table->width.'">';
print_submit_button(__('Filter'), 'filter', false, 'class="sub upd"');
print_input_hidden('action', 'filter');
echo '</div>';
echo '</form>';
echo '</div>';
$where = '1=1';
if ($typeFilter != '') {
$where .= ' AND type LIKE "' . $typeFilter . '"';
}
$items = get_db_all_rows_sql('SELECT * FROM treport_content WHERE ' . $where . ' AND id_report = ' . $idReport . ' ORDER BY `order` LIMIT ' . $offset . ', ' . $config["block_size"]);
$countItems = get_db_sql('SELECT COUNT(id_rc) FROM treport_content WHERE ' . $where . ' AND id_report = ' . $idReport);
if ($items === false) {
$items = array();
}
$table = null;
$table->width = '100%';
$table->head[0] = '<span title="' . __('Sort') . '">' . __('S.') . '</span>';
$table->head[1] = __('Type');
if (!$filterEnable) {
$table->head[1] .= ' <a href="index.php?sec=greporting&sec2=godmode/reporting/reporting_builder&tab=list_items&action=order&dir=up&field=type&id_report=' . $idReport . $urlFilter . '"><img src="images/sort_up.png" title="' . __('Ascendent') . '" /></a>' .
'<a href="index.php?sec=greporting&sec2=godmode/reporting/reporting_builder&tab=list_items&action=order&dir=down&field=type&id_report=' . $idReport . $urlFilter . '"><img src="images/sort_down.png" title="' . __('Descent') . '" /></a>';
}
$table->head[2] = __('Agent');
if (!$filterEnable) {
$table->head[2] .= ' <a href="index.php?sec=greporting&sec2=godmode/reporting/reporting_builder&tab=list_items&action=order&dir=up&field=agent&id_report=' . $idReport . $urlFilter . '"><img src="images/sort_up.png" title="' . __('Ascendent') . '" /></a>' .
'<a href="index.php?sec=greporting&sec2=godmode/reporting/reporting_builder&tab=list_items&action=order&dir=down&field=agent&id_report=' . $idReport . $urlFilter . '"><img src="images/sort_down.png" title="' . __('Descent') . '" /></a>';
}
$table->head[3] = __('Module');
if (!$filterEnable) {
$table->head[3] .= ' <a href="index.php?sec=greporting&sec2=godmode/reporting/reporting_builder&tab=list_items&action=order&dir=up&field=module&id_report=' . $idReport . $urlFilter . '"><img src="images/sort_up.png" title="' . __('Ascendent') . '" /></a>' .
'<a href="index.php?sec=greporting&sec2=godmode/reporting/reporting_builder&tab=list_items&action=order&dir=down&field=module&id_report=' . $idReport . $urlFilter . '"><img src="images/sort_down.png" title="' . __('Descent') . '" /></a>';
}
$table->head[4] = __('Period');
$table->head[5] = __('Description');
$table->head[6] = '<span title="' . __('Options') . '">' . __('O.') . '</span>';
$table->align[6] = 'center';
$lastPage = true;
if (((($offset == 0) && ($config["block_size"] > $countItems)) ||
($countItems >= ($config["block_size"] + $offset))) &&
($countItems > $config["block_size"])) {
$lastPage = false;
}
$count = 0;
$rowPair = true;
//debugPrint($items);
foreach ($items as $item) {
if ($rowPair)
$table->rowclass[$count] = 'rowPair';
else
$table->rowclass[$count] = 'rowOdd';
$rowPair = !$rowPair;
$row = array();
if ((reset($items) == $item) && ($offset == 0)) {
$row[0] = '<span style="display: block; float: left; width: 16px;">&nbsp;</span>';
}
else {
$row[0] = '<a href="index.php?sec=greporting&sec2=godmode/reporting/reporting_builder&tab=list_items&action=order&dir=up&id_report=' . $idReport . '&id_item=' . $item['id_rc'] . $urlFilter . '"><img src="images/up.png" title="' . __('Move to up') . '" /></a>';
}
if ((end($items) == $item) && $lastPage) {
$row[0] .= '<span style="width: 16px;">&nbsp;</span>';
}
else {
$row[0] .= '<a href="index.php?sec=greporting&sec2=godmode/reporting/reporting_builder&tab=list_items&action=order&dir=down&id_report=' . $idReport . '&id_item=' . $item['id_rc'] . $urlFilter . '"><img src="images/down.png" title="' . __('Move to down') . '" /></a>';
}
if ($filterEnable) {
$row[0] = '';
}
$row[1] = get_report_name($item['type']);
if ($item['id_agent'] == 0) {
if ($item['id_agent_module'] == '') {
$row[2] = '-';
$row[3] = '-';
}
else {
$row[2] = get_agent_name(get_agent_module_id($item['id_agent_module']));
$row[3] = get_db_value_filter('nombre', 'tagente_modulo', array('id_agente_modulo' => $item['id_agent_module']));
}
}
else {
$row[2] = get_agent_name($item['id_agent']);
if ($item['id_agent_module'] == '') {
$row [3] = '-';
}
else {
$row[3] = get_db_value_filter('nombre', 'tagente_modulo', array('id_agente_modulo' => $item['id_agent_module']));
}
}
$row[4] = human_time_description_raw($item['period']);
//. '<a href="#" class="tip">&nbsp;<span>' . __("Type at least two<br><br><br>characters to search") . '</span></a>';
if ($item['description'] == '') {
$row[5] = '-';
}
else {
if (strlen($item['description']) > 25) {
$row[5] = substr($item['description'], 0, 25) . '&hellip;' . '<a href="#" class="tip">&nbsp;<span>' . $item['description'] . '</span></a>';
}
else {
$row[5] = substr($item['description'], 0, 25);
}
}
// if ($item['id_gs'] == null) {
// $row[5] = '-';
// }
// else {
// $row[5] = get_db_value_filter('name', 'tgraph', array('id_graph' => $item['id_gs']));
// }
$row[6] = '<a href="index.php?sec=greporting&sec2=godmode/reporting/reporting_builder&tab=item_editor&action=edit&id_report=' . $idReport . '&id_item=' . $item['id_rc'] . '"><img src="images/wrench_orange.png" title="' . __('Edit') . '" /></a>';
$row[6] .= '&nbsp;';
$row[6] .= '<a href="index.php?sec=greporting&sec2=godmode/reporting/reporting_builder&tab=list_items&action=delete&id_report=' . $idReport . '&id_item=' . $item['id_rc'] . $urlFilter . '"><img src="images/cross.png" title="' . __('Delete') . '" /></a>';
$table->data[] = $row;
$count++;
}
pagination ($countItems, 'index.php?sec=greporting&sec2=godmode/reporting/reporting_builder&tab=list_items&action=edit&id_report=' . $idReport . $urlFilter);
print_table($table);
pagination ($countItems, 'index.php?sec=greporting&sec2=godmode/reporting/reporting_builder&tab=list_items&action=edit&id_report=' . $idReport . $urlFilter);
?>
<script type="text/javascript">
function toggleFormFilter() {
if ($("#form_filter").css('display') == 'none') {
$("#image_form_filter").attr('src', 'images/up.png');
$("#form_filter").css('display','');
}
else {
$("#image_form_filter").attr('src', 'images/down.png');
$("#form_filter").css('display','none');
}
}
</script>

View File

@ -0,0 +1,68 @@
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2010 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation for version 2.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
global $config;
// Login check
check_login ();
if (! give_acl ($config['id_user'], 0, "IW")) {
audit_db ($config['id_user'], $_SERVER['REMOTE_ADDR'], "ACL Violation",
"Trying to access report builder");
require ("general/noaccess.php");
exit;
}
$groups = get_user_groups ();
switch ($action) {
case 'new':
$actionButtonHtml = print_submit_button(__('Add'), 'add', false, 'class="sub next"', true);
$hiddenFieldAction = 'save';
break;
case 'update':
case 'edit':
$actionButtonHtml = print_submit_button(__('Edit'), 'edit', false, 'class="sub upd"', true);
$hiddenFieldAction = 'update';
break;
}
$table->width = '80%';
$table->id = 'add_alert_table';
$table->class = 'databox';
$table->head = array ();
$table->data = array ();
$table->size = array ();
$table->size = array ();
$table->size[0] = '10%';
$table->size[1] = '90%';
$table->style[0] = 'font-weight: bold; vertical-align: top;';
$table->data['name'][0] = __('Name');
$table->data['name'][1] = print_input_text('name', $reportName, __('Name'), 20, 40, true);
$table->data['group'][0] = __('Group');
$table->data['group'][1] = print_select ($groups, 'id_group', $idGroupReport, false, '', '', true);
$table->data['description'][0] = __('Description');
$table->data['description'][1] = print_textarea('description', 5, 15, $description, '', true);
echo '<form class="" method="post">';
print_table ($table);
echo '<div class="action-buttons" style="width: '.$table->width.'">';
echo $actionButtonHtml;
print_input_hidden('action', $hiddenFieldAction);
print_input_hidden('id_report', $idReport);
echo '</div></form>';
?>

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 247 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 250 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 242 B

View File

@ -0,0 +1,69 @@
<?php
//Pandora FMS- http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2010 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation; version 2
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
global $config;
// Login check
check_login ();
if (! give_acl ($config['id_user'], 0, "IW")) {
audit_db ($config['id_user'], $_SERVER['REMOTE_ADDR'], "ACL Violation",
"Trying to access report builder");
require ("general/noaccess.php");
exit;
}
$delete_sla_item = get_parameter('delete_sla_item', 0);
$add_sla = get_parameter('add_sla', 0);
$id = get_parameter('id', 0);
if ($delete_sla_item) {
$result = process_sql_delete('treport_content_sla_combined', array('id' => (int)$id));
$data['correct'] = 1;
if ($result === false) {
$data['correct'] = 0;
}
echo json_encode($data);
return;
}
if ($add_sla) {
$id_module = get_parameter('id_module', 0);
$sla_limit = get_parameter('sla_limit', 0);
$sla_max = get_parameter('sla_max', 0);
$sla_min = get_parameter('sla_min', 0);
$result = process_sql_insert('treport_content_sla_combined', array(
'id_report_content' => $id,
'id_agent_module' => $id_module,
'sla_max' => $sla_max,
'sla_min' => $sla_min,
'sla_limit' => $sla_limit));
if ($result === false) {
$data['correct'] = 0;
}
else {
$data['correct'] = 1;
$data['id'] = $result;
}
echo json_encode($data);
return;
}
?>

View File

@ -613,17 +613,34 @@ function get_report_types () {
$types['simple_graph'] = __('Simple graph');
$types['custom_graph'] = __('Custom graph');
$types['SLA'] = __('S.L.A.');
$types['event_report'] = __('Event report');
$types['alert_report'] = __('Alert report');
$types['monitor_report'] = __('Monitor report');
$types['avg_value'] = __('Avg. Value');
$types['max_value'] = __('Max. Value');
$types['min_value'] = __('Min. Value');
$types['sumatory'] = __('Sumatory');
$types['general_group_report'] = __('General group report');
$types['monitor_health'] = __('Monitor health');
$types['agents_detailed'] = __('Agents detailed view');
$types['agent_detailed_event'] = __('Agent detailed event');
$types['agent_detailed'] = __('Agent detailed view');
// $types['agent_detailed_event'] = __('Agent detailed event');
// $types['list_events_module'] = __('List events of module');
// $types['list_events_agent'] = __('List events of agent');
// $types['list_alerts_agent'] = __('List alerts of agent');
// $types['list_alerts_module'] = __('List alerts of module');
$types['text'] = __('Text');
$types['sql'] = __('SQL query');
$types['url'] = __('Import text from URL');
$types['database_serialized'] = __('Serialize data');
$types['TTRT'] = __('TTRT');
$types['TTO'] = __('TTO');
$types['MTBF'] = __('MTBF');
$types['MTTR'] = __('MTTR');
// $types['agent_detailed_event_pie_char'] = __('Agent detailed pie chart events');
// $types['agent_detailed_event_last_hours'] = __('Agent detailed event in last hours');
// $types['agent_detailed_alert_last_hours'] = __('Agent detailed alerts in last hours');
// $types['agent_detailed_num_modules'] = __('Agent detailed num modules');
// $types['agent_detailed_num_alerts'] = __('Agent detailed num alerts');
$types['alert_report_module'] = __('Alert report module');
$types['alert_report_agent'] = __('Alert report agent');
$types['event_report_agent'] = __('Event report agent');
$types['event_report_module'] = __('Event report module');
return $types;
}

View File

@ -751,6 +751,12 @@ CREATE TABLE IF NOT EXISTS `treport` (
`description` TEXT NOT NULL,
`private` tinyint(1) UNSIGNED NOT NULL default 0,
`id_group` mediumint(8) unsigned NULL default NULL,
`custom_logo` varchar(200) default NULL,
`header` MEDIUMTEXT default NULL,
`first_page` MEDIUMTEXT default NULL,
`footer` MEDIUMTEXT default NULL,
`custom_font` varchar(200) default NULL,
PRIMARY KEY(`id_report`),
FOREIGN KEY (`id_group`) REFERENCES tgrupo(`id_grupo`)
ON UPDATE CASCADE ON DELETE CASCADE
@ -766,6 +772,12 @@ CREATE TABLE IF NOT EXISTS `treport_content` (
`order` int (11) NOT NULL default 0,
`description` mediumtext,
`id_agent` int(10) unsigned NOT NULL default 0,
`text` TEXT default NULL,
`external_source` TinyText default NULL,
`treport_custom_sql_id` INTEGER UNSIGNED default 0,
`header_definition` TinyText default NULL,
`row_separator` TinyText default NULL,
`line_separator` TinyText default NULL,
PRIMARY KEY(`id_rc`),
FOREIGN KEY (`id_report`) REFERENCES treport(`id_report`)
ON UPDATE CASCADE ON DELETE CASCADE
@ -785,6 +797,13 @@ CREATE TABLE IF NOT EXISTS `treport_content_sla_combined` (
ON UPDATE CASCADE ON DELETE CASCADE
) ENGINE = InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `treport_custom_sql` (
`id` INTEGER UNSIGNED NOT NULL auto_increment,
`name` varchar(150) NOT NULL default '',
`sql` TEXT default NULL,
PRIMARY KEY(`id`)
) ENGINE = InnoDB DEFAULT CHARSET = utf8;
CREATE TABLE IF NOT EXISTS `tlayout` (
`id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
`name` varchar(50) NOT NULL,