2012-02-20 Vanessa Gil <vanessa.gil@artica.es>
* pandoradb.sql pandoradb.oracle.sql pandoradb.postgreSQL.sql extras/pandoradb_migrate_4.0.x_to_4.1.mysql.sql extras/pandoradb_migrate_4.0.x_to_4.1.oracle.sql extras/pandoradb_migrate_4.0.x_to_4.1.postgreSQL.sql: Added 'tgraph_template' and 'tgraph_source_template' tables. * godmode/reporting/graphs.php include/functions_reporting.php: Added templates for combined graphs. * godmode/reporting/graph_template_editor.php godmode/reporting/graph_template_item_editor.php godmode/reporting/graph_template_list.php: Added files. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@5622 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
46599e8f95
commit
d0149da3e5
|
@ -1,3 +1,20 @@
|
|||
2012-02-20 Vanessa Gil <vanessa.gil@artica.es>
|
||||
* pandoradb.sql
|
||||
pandoradb.oracle.sql
|
||||
pandoradb.postgreSQL.sql
|
||||
extras/pandoradb_migrate_4.0.x_to_4.1.mysql.sql
|
||||
extras/pandoradb_migrate_4.0.x_to_4.1.oracle.sql
|
||||
extras/pandoradb_migrate_4.0.x_to_4.1.postgreSQL.sql: Added
|
||||
'tgraph_template' and 'tgraph_source_template' tables.
|
||||
|
||||
* godmode/reporting/graphs.php
|
||||
include/functions_reporting.php: Added templates for combined
|
||||
graphs.
|
||||
|
||||
* godmode/reporting/graph_template_editor.php
|
||||
godmode/reporting/graph_template_item_editor.php
|
||||
godmode/reporting/graph_template_list.php: Added files.
|
||||
|
||||
2012-02-16 Vanessa Gil <vanessa.gil@artica.es>
|
||||
* operation/events/events_list: Changed extended info
|
||||
to event list.
|
||||
|
|
|
@ -158,3 +158,35 @@ INSERT INTO tconfig (token, `value`) SELECT 'list_ACL_IPs_for_API', GROUP_CONCAT
|
|||
INSERT INTO `tconfig` (`token`, `value`) VALUES ('event_fields', 'evento,id_agente,estado,timestamp');
|
||||
DELETE FROM tconfig WHERE token LIKE "list_ACL_IPs_for_API_%";
|
||||
|
||||
-- -----------------------------------------------------
|
||||
-- Table `tgraph_template`
|
||||
-- -----------------------------------------------------
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `tgraph_template` (
|
||||
`id_graph_template` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`id_user` TEXT NOT NULL,
|
||||
`name` TEXT NOT NULL,
|
||||
`description` TEXT NOT NULL,
|
||||
`period` int(11) NOT NULL default '0',
|
||||
`width` smallint(5) UNSIGNED NOT NULL DEFAULT 0,
|
||||
`height` smallint(5) UNSIGNED NOT NULL DEFAULT 0,
|
||||
`private` tinyint(1) UNSIGNED NOT NULL default 0,
|
||||
`events` tinyint(1) UNSIGNED NOT NULL default 0,
|
||||
`stacked` tinyint(1) UNSIGNED NOT NULL default 0,
|
||||
`id_group` mediumint(8) unsigned NULL default 0,
|
||||
PRIMARY KEY(`id_graph_template`)
|
||||
) ENGINE = InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
-- -----------------------------------------------------
|
||||
-- Table `tgraph_source_template`
|
||||
-- -----------------------------------------------------
|
||||
CREATE TABLE IF NOT EXISTS `tgraph_source_template` (
|
||||
`id_gs_template` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`id_template` int(11) NOT NULL default 0,
|
||||
`agent` TEXT,
|
||||
`module` TEXT,
|
||||
`weight` FLOAT(5,3) NOT NULL DEFAULT 2,
|
||||
`exact_match` tinyint(1) default 0,
|
||||
PRIMARY KEY(`id_gs_template`)
|
||||
) ENGINE = InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
|
|
|
@ -148,3 +148,37 @@ CREATE TABLE tevent_filter (
|
|||
-- -----------------------------------------------------
|
||||
ALTER TABLE tconfig MODIFY value TEXT NOT NULL;
|
||||
INSERT INTO tconfig (token, value) VALUES ('event_fields', 'evento,id_agente,estado,timestamp');
|
||||
|
||||
-- -----------------------------------------------------
|
||||
-- Table `tgraph_template`
|
||||
-- -----------------------------------------------------
|
||||
|
||||
CREATE TABLE tgraph_template (
|
||||
id_graph_template NUMBER(10, 0) NOT NULL PRIMARY KEY,
|
||||
id_user VARCHAR2(255) NOT NULL,
|
||||
name VARCHAR2(255) NOT NULL,
|
||||
description CLOB default '',
|
||||
period NUMBER(11, 0) default 0 NOT NULL,
|
||||
width SMALLINT default 0 NOT NULL,
|
||||
height SMALLINT default 0 NOT NULL,
|
||||
private SMALLINT default 0 NOT NULL,
|
||||
events SMALLINT default 0 NOT NULL,
|
||||
stacked SMALLINT default 0 NOT NULL,
|
||||
id_group NUMBER(8, 0) default 0
|
||||
);
|
||||
|
||||
CREATE SEQUENCE tgraph_template_s INCREMENT BY 1 START WITH 1;
|
||||
|
||||
-- -----------------------------------------------------
|
||||
-- Table `tgraph_source_template`
|
||||
-- -----------------------------------------------------
|
||||
CREATE tgraph_source_template (
|
||||
id_gs_template NUMBER(10, 0) NOT NULL PRIMARY KEY,
|
||||
id_template NUMBER(10, 0) default 0 NOT NULL,
|
||||
agent VARCHAR2(255),
|
||||
module VARCHAR2(255),
|
||||
weight FLOAT(5) DEFAULT 2 NOT NULL;
|
||||
exact_match SMALLINT default 0 NOT NULL
|
||||
);
|
||||
|
||||
CREATE SEQUENCE tgraph_source_template_s INCREMENT BY 1 START WITH 1;
|
||||
|
|
|
@ -135,3 +135,35 @@ ALTER TABLE "tconfig" ALTER COLUMN "value" TYPE TEXT;
|
|||
|
||||
INSERT INTO tconfig ("token", "value") SELECT 'list_ACL_IPs_for_API', array_to_string(ARRAY(SELECT value FROM tconfig WHERE token LIKE 'list_ACL_IPs_for_API%'), ';') AS "value";
|
||||
INSERT INTO "tconfig" ("token", "value") VALUES ('event_fields', 'evento,id_agente,estado,timestamp');
|
||||
|
||||
-- -----------------------------------------------------
|
||||
-- Table `tgraph_template`
|
||||
-- -----------------------------------------------------
|
||||
|
||||
CREATE TABLE IF NOT EXISTS "tgraph_template" (
|
||||
"id_graph_template" SERIAL NOT NULL PRIMARY KEY,
|
||||
"id_user" TEXT NOT NULL default '',
|
||||
"name" TEXT NOT NULL default '',
|
||||
"description" TEXT NOT NULL default '',
|
||||
"period" INTEGER NOT NULL default 0,
|
||||
"width" SMALLINT NOT NULL default 0,
|
||||
"height" SMALLINT NOT NULL default 0,
|
||||
"private" SMALLINT NOT NULL default 0,
|
||||
"events" SMALLINT NOT NULL default 0,
|
||||
"stacked" SMALLINT NOT NULL default 0,
|
||||
"id_group" INTEGER NOT NULL default 0
|
||||
);
|
||||
|
||||
-- -----------------------------------------------------
|
||||
-- Table `tgraph_source_template`
|
||||
-- -----------------------------------------------------
|
||||
|
||||
CREATE TABLE IF NOT EXISTS "tgraph_source_template" (
|
||||
"id_gs_template" SERIAL NOT NULL PRIMARY KEY,
|
||||
"id_template" INTEGER NOT NULL default 0,
|
||||
"agent" TEXT NOT NULL default '',
|
||||
"module" TEXT NOT NULL default '',
|
||||
"period" INTEGER NOT NULL default 0,
|
||||
"weight" DOUBLE PRECISION default 2.0,
|
||||
"exact_match" SMALLINT NOT NULL default 0
|
||||
);
|
||||
|
|
|
@ -0,0 +1,217 @@
|
|||
<?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;
|
||||
|
||||
check_login ();
|
||||
|
||||
if (! check_acl ($config['id_user'], 0, "IW")) {
|
||||
db_pandora_audit("ACL Violation",
|
||||
"Trying to access graph builder");
|
||||
include ("general/noaccess.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
$update = get_parameter('edit_template', 0);
|
||||
$create = get_parameter('create_template', 0);
|
||||
$id_template = get_parameter('id', 0);
|
||||
|
||||
|
||||
if ($create){
|
||||
$stacked = get_parameter('stacked');
|
||||
$events = get_parameter('events');
|
||||
$period = get_parameter('period');
|
||||
$name = get_parameter('name');
|
||||
$description = get_parameter('description');
|
||||
$id_group = get_parameter('id_group');
|
||||
$width = get_parameter('width');
|
||||
$height = get_parameter('height');
|
||||
|
||||
$values = array (
|
||||
'name' => $name,
|
||||
'id_user' => $config['id_user'],
|
||||
'period' => $period,
|
||||
'width' => $width,
|
||||
'height' => $height,
|
||||
'id_group' => $id_group,
|
||||
'stacked' => $stacked,
|
||||
'private' => 0,
|
||||
'events' => $events,
|
||||
'description' => $description
|
||||
);
|
||||
$id_template = db_process_sql_insert('tgraph_template', $values);
|
||||
}
|
||||
|
||||
$buttons['graph_list'] = '<a href="index.php?sec=greporting&sec2=godmode/reporting/graph_template_list">'
|
||||
. html_print_image ("images/god6.png", true, array ("title" => __('Template list')))
|
||||
. '</a>';
|
||||
|
||||
$buttons['template_editor'] = '<a href="index.php?sec=greporting&sec2=godmode/reporting/graph_template_item_editor&id='.$id_template.'">'
|
||||
. html_print_image ("images/config.png", true, array ("title" => __('Template editor')))
|
||||
. '</a>';
|
||||
|
||||
// Header
|
||||
ui_print_page_header (__('Graph template editor'), "", false, "", true, $buttons);
|
||||
|
||||
if ($create) {
|
||||
if ($id_template === false) {
|
||||
ui_print_error_message ('Error creating template');
|
||||
} else {
|
||||
ui_print_success_message ('Template created successfully');
|
||||
}
|
||||
}
|
||||
|
||||
if ($id_template) {
|
||||
$template_data = db_get_row_sql("SELECT * FROM tgraph_template WHERE id_graph_template = " . $id_template);
|
||||
$stacked = $template_data['stacked'];
|
||||
$events = $template_data['events'];
|
||||
$period = $template_data['period'];
|
||||
$name = $template_data['name'];
|
||||
$description = $template_data['description'];
|
||||
$id_group = $template_data['id_group'];
|
||||
$width = $template_data['width'];
|
||||
$height = $template_data['height'];
|
||||
} else {
|
||||
$id_agent = 0;
|
||||
$id_module = 0;
|
||||
$id_group = 0;
|
||||
$name = "";
|
||||
$description = "";
|
||||
$width = 550;
|
||||
$height = 210;
|
||||
$period = 86400;
|
||||
$events = 0;
|
||||
$factor = 1;
|
||||
$stacked = 0;
|
||||
}
|
||||
|
||||
if ($update) {
|
||||
$stacked = get_parameter('stacked');
|
||||
$events = get_parameter('events');
|
||||
$period = get_parameter('period');
|
||||
$name = get_parameter('name');
|
||||
$description = get_parameter('description');
|
||||
$id_group = get_parameter('id_group');
|
||||
$width = get_parameter('width');
|
||||
$height = get_parameter('height');
|
||||
|
||||
if ($name == '') {
|
||||
ui_print_error_message (__('Not updated. Blank name'));
|
||||
} else {
|
||||
$result = db_process_sql_update ('tgraph_template',
|
||||
array (
|
||||
'name' => $name,
|
||||
'period' => $period,
|
||||
'width' => $width,
|
||||
'height' => $height,
|
||||
'id_group' => $id_group,
|
||||
'stacked' => $stacked,
|
||||
'events' => $events,
|
||||
'description' => $description
|
||||
),
|
||||
array ('id_graph_template' => $id_template));
|
||||
ui_print_result_message ($result, __('Template updated successfully'), __('Error updating template'));
|
||||
}
|
||||
}
|
||||
|
||||
// -----------------------
|
||||
// CREATE/EDIT GRAPH TEMPLATE FORM
|
||||
// -----------------------
|
||||
|
||||
echo "<table width='98%' cellpadding=4 cellspacing=4 class='databox_color'>";
|
||||
|
||||
if ($id_template)
|
||||
echo "<form method='post' action='index.php?sec=greporting&sec2=godmode/reporting/graph_template_editor&edit_template=1&id=" . $id_template . "'>";
|
||||
else
|
||||
echo "<form method='post' action='index.php?sec=greporting&sec2=godmode/reporting/graph_template_editor&create_template=1&id=" . $id_template . "'>";
|
||||
|
||||
echo "<tr>";
|
||||
echo "<td class='datos'><b>".__('Name')."</b></td>";
|
||||
echo "<td class='datos'><input type='text' name='name' size='25' ";
|
||||
|
||||
echo "value='" . $name . "'>";
|
||||
|
||||
$own_info = get_user_info ($config['id_user']);
|
||||
if ($own_info['is_admin'] || check_acl ($config['id_user'], 0, "PM"))
|
||||
$return_all_groups = true;
|
||||
else
|
||||
$return_all_groups = false;
|
||||
|
||||
echo "<td><b>".__('Group')."</b></td><td>" .
|
||||
html_print_select_groups($config['id_user'], "AR", $return_all_groups, 'graph_id_group', $id_group, '', '', '', true) .
|
||||
"</td></tr>";
|
||||
echo "<tr>";
|
||||
|
||||
echo "<td class='datos2'><b>".__('Description')."</b></td>";
|
||||
echo "<td class='datos2' colspan=3><textarea name='description' style='height:45px;' cols=55 rows=2>";
|
||||
|
||||
echo $description;
|
||||
|
||||
echo "</textarea>";
|
||||
echo "</td></tr>";
|
||||
echo "<tr>";
|
||||
echo "<td class='datos'>";
|
||||
echo "<b>".__('Width')."</b></td>";
|
||||
echo "<td class='datos'>";
|
||||
echo "<input type='text' name='width' value='$width' size=6></td>";
|
||||
echo "<td class='datos2'>";
|
||||
echo "<b>".__('Height')."</b></td>";
|
||||
echo "<td class='datos2'>";
|
||||
echo "<input type='text' name='height' value='$height' size=6></td></tr>";
|
||||
|
||||
$periods = array(3600 => "1 ".__('hour'), 7200 => "2 ".__('hours'), 10800 => "3 ".__('hours'),
|
||||
21600 => "6 ".__('hours'), 43200 => "12 ".__('hours'), 86400 => "1 ".__('day'),
|
||||
172800 => "2 ".__('days'), 345600 => "4 ".__('days'), 604800 => __('Last week'),
|
||||
1296000 => "15 ".__('days'), 2592000 => __('Last month'), 5184000 => "2 ".__('months'),
|
||||
15552000 => "6 ".__('months'), 31104000 => __('1 year'), 31104000 => __('1 year'));
|
||||
|
||||
echo "<tr>";
|
||||
echo "<td class='datos'>";
|
||||
echo "<b>".__('Period')."</b></td>";
|
||||
echo "<td class='datos'>";
|
||||
html_print_select ($periods, 'period', $period);
|
||||
echo "</td><td class='datos2'>";
|
||||
echo "<b>".__('Stacked')."</b></td>";
|
||||
echo "<td class='datos2'>";
|
||||
|
||||
include_once($config["homedir"] . "/include/functions_graph.php");
|
||||
|
||||
$stackeds = array(
|
||||
GRAPH_AREA => __('Area'),
|
||||
GRAPH_STACKED_AREA => __('Stacked area'),
|
||||
GRAPH_LINE => __('Line'),
|
||||
GRAPH_STACKED_LINE => __('Stacked line'));
|
||||
html_print_select ($stackeds, 'stacked', $stacked);
|
||||
echo "</td>";
|
||||
|
||||
echo "<tr>";
|
||||
echo "<td class='datos'>";
|
||||
echo "<b>".__('View events')."</b></td>";
|
||||
echo "<td class='datos'>";
|
||||
html_print_checkbox('events', 1, $events);
|
||||
echo "</td>";
|
||||
|
||||
echo "<td></td><td></td>";
|
||||
|
||||
echo "</tr>";
|
||||
echo "<tr><td colspan='4' align='right'>";
|
||||
if ($id_template) {
|
||||
echo "<input type=submit class='sub upd' value='".__('Update')."'>";
|
||||
}
|
||||
else {
|
||||
echo "<input type=submit class='sub next' value='".__('Create')."'>";
|
||||
}
|
||||
echo "</td></tr></table>";
|
||||
echo "</form>";
|
|
@ -0,0 +1,151 @@
|
|||
<?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;
|
||||
|
||||
check_login ();
|
||||
|
||||
if (! check_acl ($config['id_user'], 0, "IW")) {
|
||||
db_pandora_audit("ACL Violation",
|
||||
"Trying to access graph builder");
|
||||
include ("general/noaccess.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
$id_template = get_parameter('id',0);
|
||||
$delete = get_parameter('delete',0);
|
||||
|
||||
$create = get_parameter('add',0);
|
||||
|
||||
$buttons['template_list'] = '<a href="index.php?sec=greporting&sec2=godmode/reporting/graph_template_list">'
|
||||
. html_print_image ("images/god6.png", true, array ("title" => __('Template list')))
|
||||
. '</a>';
|
||||
// Header
|
||||
ui_print_page_header (__('Graph template editor'), "", false, "", true, $buttons);
|
||||
|
||||
if ($create) {
|
||||
if (!$id_template) {
|
||||
ui_print_error_message ('Not created. Blank template.');
|
||||
} else {
|
||||
$agent = get_parameter('agent', '');
|
||||
$module = get_parameter('module', '');
|
||||
$match = get_parameter('match', 0);
|
||||
$weight = get_parameter('weight', 1);
|
||||
|
||||
if ($module != '') {
|
||||
$values = array (
|
||||
'id_template' => $id_template,
|
||||
'agent' => $agent,
|
||||
'module' => $module,
|
||||
'exact_match' => $match,
|
||||
'weight' => $weight
|
||||
);
|
||||
$id_gs_template = db_process_sql_insert('tgraph_source_template', $values);
|
||||
if ($id_gs_template === false) {
|
||||
ui_print_error_message ('Error creating template');
|
||||
} else {
|
||||
ui_print_success_message ('Template created successfully');
|
||||
}
|
||||
} else {
|
||||
ui_print_error_message ('Not created. Blank module');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($delete) {
|
||||
$id_gs_template = get_parameter('id_gs_template');
|
||||
$id_template = get_parameter('id_template');
|
||||
|
||||
$result = db_process_sql_delete ('tgraph_source_template',
|
||||
array ('id_gs_template' => $id_gs_template));
|
||||
|
||||
if ($result !== false) {
|
||||
$result = true;
|
||||
} else {
|
||||
$result = false;
|
||||
}
|
||||
|
||||
ui_print_result_message ($result,
|
||||
__('Successfully deleted'),
|
||||
__('Not deleted. Error deleting data'));
|
||||
}
|
||||
|
||||
if ($id_template) {
|
||||
$sql = "SELECT * FROM tgraph_source_template where id_template=$id_template";
|
||||
$templates = db_get_all_rows_sql($sql);
|
||||
if ($templates != false) {
|
||||
$table_aux->width = '90%';
|
||||
|
||||
$table_aux->size = array();
|
||||
$table_aux->size[0] = '40%';
|
||||
$table_aux->size[1] = '30%';
|
||||
$table_aux->size[2] = '20%';
|
||||
$table_aux->size[3] = '30px';
|
||||
|
||||
$table_aux->head[0] = __('Agent');
|
||||
$table_aux->align[0] = 'center';
|
||||
$table_aux->head[1] = __('Module');
|
||||
$table_aux->align[1] = 'center';
|
||||
$table_aux->head[2] = __('Weight');
|
||||
$table_aux->align[2] = 'center';
|
||||
$table_aux->head[3] = __('Delete');
|
||||
$table_aux->align[3] = 'center';
|
||||
|
||||
$table_aux->data = array();
|
||||
|
||||
foreach ($templates as $template) {
|
||||
$data = array();
|
||||
|
||||
$data[0] = $template['agent'];
|
||||
$data[1] = $template['module'];
|
||||
$data[2] = $template['weight'];
|
||||
$data[3] = "<a onclick='if(confirm(\"" . __('Are you sure?') . "\")) return true; else return false;'
|
||||
href='index.php?sec=greporting&sec2=godmode/reporting/graph_template_item_editor&delete=1&id_gs_template=".$template['id_gs_template']."&id_template=".$template['id_template']."&offset=0'>" .
|
||||
html_print_image('images/cross.png', true, array('title' => __('Delete'))) . "</a>";
|
||||
|
||||
array_push ($table_aux->data, $data);
|
||||
}
|
||||
|
||||
html_print_table($table_aux);
|
||||
}
|
||||
}
|
||||
|
||||
//Configuration form
|
||||
$table->width = '90%';
|
||||
|
||||
$table->size = array();
|
||||
$table->size[0] = '40%';
|
||||
$table->size[1] = '40%';
|
||||
|
||||
$table->data = array();
|
||||
|
||||
$table->data[0][0] = '<b>'.__('Agent').'</b>';
|
||||
$table->data[1][0] = html_print_input_text('agent', '', '', 30, 255, true);
|
||||
$table->data[0][1] = '<b>'.__('Module').'</b>';
|
||||
$table->data[1][1] = html_print_input_text('module', '', '', 30, 255, true);
|
||||
$table->data[2][0] = '<b>'.__('Weight').'</b>';
|
||||
$table->data[2][0] .= ' '.html_print_input_text('weight', 2, '', 3, 5, true);
|
||||
$table->data[2][1] = __('Exact match');
|
||||
$table->data[2][1] .= html_print_checkbox('match', 1, 0, true);
|
||||
|
||||
echo '<form method="post" action="index.php?sec=greporting&sec2=godmode/reporting/graph_template_item_editor&add=1&id='.$id_template.'">';
|
||||
html_print_table($table);
|
||||
echo '<div class="action-buttons" style="width: '.$table->width.'">';
|
||||
|
||||
html_print_submit_button (__('Add'), 'crt', false, 'class="sub add"');
|
||||
|
||||
echo '</div>';
|
||||
echo '</form>';
|
||||
?>
|
|
@ -0,0 +1,108 @@
|
|||
<?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.
|
||||
|
||||
// Load global variables
|
||||
global $config;
|
||||
|
||||
require_once ('include/functions_reporting.php');
|
||||
|
||||
// Check user credentials
|
||||
check_login ();
|
||||
|
||||
if (! check_acl ($config['id_user'], 0, "IW")) {
|
||||
db_pandora_audit("ACL Violation",
|
||||
"Trying to access Inventory Module Management");
|
||||
require ("general/noaccess.php");
|
||||
return;
|
||||
}
|
||||
|
||||
$buttons['graph_list'] = '<a href="index.php?sec=greporting&sec2=godmode/reporting/graphs">'
|
||||
. html_print_image ("images/god6.png", true, array ("title" => __('Graph list')))
|
||||
. '</a>';
|
||||
|
||||
// Header
|
||||
ui_print_page_header (__('Graph template management'), "", false, "", true, $buttons);
|
||||
|
||||
$delete = get_parameter ('delete_template', 0);
|
||||
$id_template = get_parameter('id', 0);
|
||||
|
||||
if ($delete) {
|
||||
$result = db_process_sql_delete ('tgraph_template',
|
||||
array ('id_graph_template' => $id_template));
|
||||
|
||||
if ($result !== false)
|
||||
$result = true;
|
||||
else
|
||||
$result = false;
|
||||
|
||||
ui_print_result_message ($result,
|
||||
__('Successfully deleted'),
|
||||
__('Not deleted. Error deleting data'));
|
||||
}
|
||||
|
||||
$own_info = get_user_info ($config['id_user']);
|
||||
if ($own_info['is_admin'] || check_acl ($config['id_user'], 0, "PM"))
|
||||
$return_all_group = true;
|
||||
else
|
||||
$return_all_group = false;
|
||||
|
||||
$templates = reporting_template_graphs_get_user ($config['id_user'], false, $return_all_group, "IW");
|
||||
|
||||
if (! empty ($templates)) {
|
||||
$table->width = '98%';
|
||||
$tale->class = 'databox_frame';
|
||||
$table->align = array ();
|
||||
$table->align[3] = 'center';
|
||||
$table->head = array ();
|
||||
$table->head[0] = __('Template name');
|
||||
$table->head[1] = __('Description');
|
||||
$table->head[3] = __('Group');
|
||||
$table->size[3] = '50px';
|
||||
if (check_acl ($config['id_user'], 0, "AW")) {
|
||||
$table->align[4] = 'center';
|
||||
$table->head[4] = __('Delete');
|
||||
$table->size[4] = '50px';
|
||||
}
|
||||
$table->data = array ();
|
||||
|
||||
foreach ($templates as $template) {
|
||||
$data = array ();
|
||||
|
||||
$data[0] = '<a href="index.php?sec=greporting&sec2=godmode/reporting/graph_template_editor&id='.
|
||||
$template['id_graph_template'].'">'.$template['name'].'</a>';
|
||||
$data[1] = $template["description"];
|
||||
|
||||
$data[3] = ui_print_group_icon($template['id_group'],true);
|
||||
|
||||
if (check_acl ($config['id_user'], 0, "AW")) {
|
||||
$data[4] = '<a href="index.php?sec=greporting&sec2=godmode/reporting/graph_template_list&delete_template=1&id='
|
||||
.$template['id_graph_template'].'" onClick="if (!confirm(\''.__('Are you sure?').'\'))
|
||||
return false;">' . html_print_image("images/cross.png", true) . '</a>';
|
||||
}
|
||||
|
||||
array_push ($table->data, $data);
|
||||
}
|
||||
html_print_table ($table);
|
||||
}
|
||||
else {
|
||||
echo "<div class='nf'>".__('There are no defined graph templates')."</div>";
|
||||
}
|
||||
|
||||
echo '<form method="post" action="index.php?sec=greporting&sec2=godmode/reporting/graph_template_editor">';
|
||||
echo '<div class="action-buttons" style="width: 98%;">';
|
||||
html_print_submit_button (__('Create template'), 'create', false, 'class="sub next"');
|
||||
echo "</div>";
|
||||
echo "</form>";
|
||||
|
||||
?>
|
|
@ -27,12 +27,16 @@ if (! check_acl ($config['id_user'], 0, "IW")) {
|
|||
return;
|
||||
}
|
||||
|
||||
$buttons['template'] = '<a href="index.php?sec=greporting&sec2=godmode/reporting/graph_template_list">'
|
||||
. html_print_image ("images/paste_plain.png", true, array ("title" => __('Templates')))
|
||||
. '</a>';
|
||||
|
||||
$delete_graph = (bool) get_parameter ('delete_graph');
|
||||
$view_graph = (bool) get_parameter ('view_graph');
|
||||
$id = (int) get_parameter ('id');
|
||||
|
||||
// Header
|
||||
ui_print_page_header (__('Graphs management'), "", false, "", true);
|
||||
ui_print_page_header (__('Graphs management'), "", false, "", true, $buttons);
|
||||
|
||||
// Delete module SQL code
|
||||
if ($delete_graph) {
|
||||
|
|
|
@ -901,6 +901,7 @@ function get_event_types () {
|
|||
$types['recon_host_detected'] = __('Recon host detected');
|
||||
$types['system'] = __('System');
|
||||
$types['error'] = __('Error');
|
||||
$types['configuration_change'] = __('configuration change ');
|
||||
|
||||
if (isset($config['text_char_long'])) {
|
||||
foreach ($types as $key => $type) {
|
||||
|
|
|
@ -4640,4 +4640,53 @@ function reporting_get_agentmodule_ttr ($id_agent_module, $period, $date = 0) {
|
|||
return $critical_period;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all the template graphs a user can see.
|
||||
*
|
||||
* @param $id_user User id to check.
|
||||
* @param $only_names Wheter to return only graphs names in an associative array
|
||||
* or all the values.
|
||||
* @param $returnAllGroup Wheter to return graphs of group All or not.
|
||||
* @param $privileges Privileges to check in user group
|
||||
*
|
||||
* @return template graphs of a an user. Empty array if none.
|
||||
*/
|
||||
function reporting_template_graphs_get_user ($id_user = 0, $only_names = false, $returnAllGroup = true, $privileges = 'IR') {
|
||||
global $config;
|
||||
|
||||
if (!$id_user) {
|
||||
$id_user = $config['id_user'];
|
||||
}
|
||||
|
||||
$groups = users_get_groups ($id_user, $privileges, $returnAllGroup);
|
||||
|
||||
$all_templates = db_get_all_rows_in_table ('tgraph_template', 'name');
|
||||
if ($all_templates === false)
|
||||
return array ();
|
||||
|
||||
$templates = array ();
|
||||
foreach ($all_templates as $template) {
|
||||
if (!in_array($template['id_group'], array_keys($groups)))
|
||||
continue;
|
||||
|
||||
if ($template["id_user"] != $id_user && $template['private'])
|
||||
continue;
|
||||
|
||||
if ($template["id_group"] > 0)
|
||||
if (!isset($groups[$template["id_group"]])){
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($only_names) {
|
||||
$templates[$template['id_graph_template']] = $template['name'];
|
||||
}
|
||||
else {
|
||||
$templates[$template['id_graph_template']] = $template;
|
||||
$templatesCount = db_get_value_sql("SELECT COUNT(id_gs) FROM tgraph_source WHERE id_graph = " . $template['id_graph_template']);
|
||||
$templates[$template['id_graph_template']]['graphs_template_count'] = $templatesCount;
|
||||
}
|
||||
}
|
||||
|
||||
return $templates;
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -1576,3 +1576,37 @@ CREATE TABLE tevent_filter (
|
|||
tag VARCHAR2(600) default '' NOT NULL,
|
||||
filter_only_alert NUMBER(10, 0) default -1 NOT NULL
|
||||
);
|
||||
|
||||
-- -----------------------------------------------------
|
||||
-- Table `tgraph_template`
|
||||
-- -----------------------------------------------------
|
||||
|
||||
CREATE TABLE tgraph_template (
|
||||
id_graph_template NUMBER(10, 0) NOT NULL PRIMARY KEY,
|
||||
id_user VARCHAR2(255) NOT NULL,
|
||||
name VARCHAR2(255) NOT NULL,
|
||||
description CLOB default '',
|
||||
period NUMBER(11, 0) default 0 NOT NULL,
|
||||
width SMALLINT default 0 NOT NULL,
|
||||
height SMALLINT default 0 NOT NULL,
|
||||
private SMALLINT default 0 NOT NULL,
|
||||
events SMALLINT default 0 NOT NULL,
|
||||
stacked SMALLINT default 0 NOT NULL,
|
||||
id_group NUMBER(8, 0) default 0
|
||||
);
|
||||
|
||||
CREATE SEQUENCE tgraph_template_s INCREMENT BY 1 START WITH 1;
|
||||
|
||||
-- -----------------------------------------------------
|
||||
-- Table `tgraph_source_template`
|
||||
-- -----------------------------------------------------
|
||||
CREATE tgraph_source_template (
|
||||
id_gs_template NUMBER(10, 0) NOT NULL PRIMARY KEY,
|
||||
id_template NUMBER(10, 0) default 0 NOT NULL,
|
||||
agent VARCHAR2(255),
|
||||
module VARCHAR2(255),
|
||||
weight FLOAT(5) DEFAULT 2 NOT NULL;
|
||||
exact_match SMALLINT default 0 NOT NULL
|
||||
);
|
||||
|
||||
CREATE SEQUENCE tgraph_source_template_s INCREMENT BY 1 START WITH 1;
|
||||
|
|
|
@ -1274,3 +1274,36 @@ CREATE TABLE "tevent_filter" (
|
|||
"tag" varchar(600) NOT NULL default '',
|
||||
"filter_only_alert" INTEGER NOT NULL default -1
|
||||
);
|
||||
|
||||
-- -----------------------------------------------------
|
||||
-- Table `tgraph_template`
|
||||
-- -----------------------------------------------------
|
||||
|
||||
CREATE TABLE IF NOT EXISTS "tgraph_template" (
|
||||
"id_graph_template" SERIAL NOT NULL PRIMARY KEY,
|
||||
"id_user" TEXT NOT NULL default '',
|
||||
"name" TEXT NOT NULL default '',
|
||||
"description" TEXT NOT NULL default '',
|
||||
"period" INTEGER NOT NULL default 0,
|
||||
"width" SMALLINT NOT NULL default 0,
|
||||
"height" SMALLINT NOT NULL default 0,
|
||||
"private" SMALLINT NOT NULL default 0,
|
||||
"events" SMALLINT NOT NULL default 0,
|
||||
"stacked" SMALLINT NOT NULL default 0,
|
||||
"id_group" INTEGER NOT NULL default 0
|
||||
);
|
||||
|
||||
-- -----------------------------------------------------
|
||||
-- Table `tgraph_source_template`
|
||||
-- -----------------------------------------------------
|
||||
|
||||
CREATE TABLE IF NOT EXISTS "tgraph_source_template" (
|
||||
"id_gs_template" SERIAL NOT NULL PRIMARY KEY,
|
||||
"id_template" INTEGER NOT NULL default 0,
|
||||
"agent" TEXT NOT NULL default '',
|
||||
"module" TEXT NOT NULL default '',
|
||||
"period" INTEGER NOT NULL default 0,
|
||||
"weight" DOUBLE PRECISION default 2.0,
|
||||
"exact_match" SMALLINT NOT NULL default 0
|
||||
);
|
||||
|
||||
|
|
|
@ -1378,3 +1378,35 @@ CREATE TABLE IF NOT EXISTS `tevent_filter` (
|
|||
`filter_only_alert` int(10) NOT NULL default -1,
|
||||
PRIMARY KEY (`id_filter`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
-- -----------------------------------------------------
|
||||
-- Table `tgraph_template`
|
||||
-- -----------------------------------------------------
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `tgraph_template` (
|
||||
`id_graph_template` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`id_user` TEXT NOT NULL,
|
||||
`name` TEXT NOT NULL,
|
||||
`description` TEXT NOT NULL,
|
||||
`period` int(11) NOT NULL default '0',
|
||||
`width` smallint(5) UNSIGNED NOT NULL DEFAULT 0,
|
||||
`height` smallint(5) UNSIGNED NOT NULL DEFAULT 0,
|
||||
`private` tinyint(1) UNSIGNED NOT NULL default 0,
|
||||
`events` tinyint(1) UNSIGNED NOT NULL default 0,
|
||||
`stacked` tinyint(1) UNSIGNED NOT NULL default 0,
|
||||
`id_group` mediumint(8) unsigned NULL default 0,
|
||||
PRIMARY KEY(`id_graph_template`)
|
||||
) ENGINE = InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
-- -----------------------------------------------------
|
||||
-- Table `tgraph_source_template`
|
||||
-- -----------------------------------------------------
|
||||
CREATE TABLE IF NOT EXISTS `tgraph_source_template` (
|
||||
`id_gs_template` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`id_template` int(11) NOT NULL default 0,
|
||||
`agent` TEXT,
|
||||
`module` TEXT,
|
||||
`weight` FLOAT(5,3) NOT NULL DEFAULT 2,
|
||||
`exact_match` tinyint(1) default 0,
|
||||
PRIMARY KEY(`id_gs_template`)
|
||||
) ENGINE = InnoDB DEFAULT CHARSET=utf8;
|
||||
|
|
Loading…
Reference in New Issue