2009-03-03 Esteban Sanchez <estebans@artica.es>

* general/main_menu.php: Operation and godmode menus files includes
	now the dependant files.

	* godmode/agentes/modificar_agente.php: Removed unnecessary
	require()
	
	* godmode/alerts/alert_list.php: Avoid notice for undefined index when
	calling max(). Added option to delete the template.

	* godmode/alerts/configure_alert_template.php,
	godmode/alerts/alert_templates.php: Fixed field2_recovery and
	field3_recovery updating.

	* operation/menu.php, godmode/menu.php: Require functions_menu.php.

	* include/config_process.php: Updated build version.

	* include/functions.php: Keep time in a static variable on
	get_system_time().

	* include/functions_db.php: Now a custom operation can be passed to
	format_array_to_where_clause_sql() if the field key is numeric.

	* include/functions_reporting.php: Return float value on
	get_agentmodule_sla(). Added required files.

	* include/functions_ui.php: Show template name on format_alert_row().
	Style correction.

	* operation/agentes/export_csv.php: Style correction.
	
	* operation/events/export_csv.php: Use pandora functions to fetch
	results. Fixed auth part. Style correction.

	* operation/reporting/custom_reporting.php: Fixed enterprise include.

	* operation/reporting/reporting_xml.php: Fixed auth part.

	* index.php: process_page_head() may looked for uninitialized
	$config["refr"].

	* include/styles/pandora_width.css: Fixed style for ol.steps



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1500 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
esanchezm 2009-03-03 15:21:13 +00:00
parent 50ac06cce0
commit ff4e9e70ba
20 changed files with 191 additions and 115 deletions

View File

@ -1,3 +1,48 @@
2009-03-03 Esteban Sanchez <estebans@artica.es>
* general/main_menu.php: Operation and godmode menus files includes
now the dependant files.
* godmode/agentes/modificar_agente.php: Removed unnecessary
require()
* godmode/alerts/alert_list.php: Avoid notice for undefined index when
calling max(). Added option to delete the template.
* godmode/alerts/configure_alert_template.php,
godmode/alerts/alert_templates.php: Fixed field2_recovery and
field3_recovery updating.
* operation/menu.php, godmode/menu.php: Require functions_menu.php.
* include/config_process.php: Updated build version.
* include/functions.php: Keep time in a static variable on
get_system_time().
* include/functions_db.php: Now a custom operation can be passed to
format_array_to_where_clause_sql() if the field key is numeric.
* include/functions_reporting.php: Return float value on
get_agentmodule_sla(). Added required files.
* include/functions_ui.php: Show template name on format_alert_row().
Style correction.
* operation/agentes/export_csv.php: Style correction.
* operation/events/export_csv.php: Use pandora functions to fetch
results. Fixed auth part. Style correction.
* operation/reporting/custom_reporting.php: Fixed enterprise include.
* operation/reporting/reporting_xml.php: Fixed auth part.
* index.php: process_page_head() may looked for uninitialized
$config["refr"].
* include/styles/pandora_width.css: Fixed style for ol.steps
2009-03-02 Evi Vanoost <vanooste@rcbi.rochester.edu>
* include/functions_reporting.php: Rewrote get_agentmodule_sla with

View File

@ -21,18 +21,11 @@ if (! isset ($config["id_user"])) {
exit ();
}
require_once ('include/functions_menu.php');
echo '<div class="tit bg">:: '.__('Operation').' ::</div>';
$menu = array ();
require ("operation/menu.php");
print_menu ($menu);
echo '<div class="tit bg3">:: '.__('Administration').' ::</div>';
$menu = array ();
require ("godmode/menu.php");
print_menu ($menu);
unset ($menu);
require ("links_menu.php");

View File

@ -16,11 +16,7 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
// Load global vars
require_once ("include/config.php");
check_login ();
// Take some parameters (GET)

View File

@ -122,9 +122,9 @@ if ($create_alert) {
foreach ($actions as $id_action) {
$values = array ();
if (isset ($fires_min[$id_action]))
$values['fires_min'] = max ($fires_min[$id_action], 0);
$values['fires_min'] = @max ($fires_min[$id_action], 0);
if ($fires_max != -1)
$values['fires_max'] = max ($fires_max[$id_action], 0);
$values['fires_max'] = @max ($fires_max[$id_action], 0);
add_alert_agent_module_action ($id, $id_action, $values);
}
}
@ -228,6 +228,7 @@ if (! $id_agente) {
$table->head[2] = __('Module');
$table->head[3] = __('Template');
$table->head[4] = __('Actions');
$table->head[5] = '';
$table->data = array ();
foreach ($simple_alerts as $alert) {
@ -295,6 +296,12 @@ foreach ($simple_alerts as $alert) {
$data[4] .= ' '.__('Add action');
$data[4] .= '</a>';
$data[5] = '<form class="delete_alert_form" method="post" style="display: inline;">';
$data[5] .= print_input_image ('delete', 'images/cross.png', 1, '', true);
$data[5] .= print_input_hidden ('delete_alert', 1, true);
$data[5] .= print_input_hidden ('id_alert', $alert['id'], true);
$data[5] .= '</form>';
array_push ($table->data, $data);
}
@ -442,6 +449,7 @@ $(document).ready (function () {
return true;
});
$("a.add_action").click (function () {
id = this.id.split ("-").pop ();
@ -452,7 +460,7 @@ $(document).ready (function () {
return false;
});
$("form.delete_link").submit (function () {
$("form.delete_link, form.delete_alert_form").submit (function () {
if (! confirm ("<?php echo __('Are you sure?')?>"))
return false;
return true;

View File

@ -110,8 +110,8 @@ if ($update_template) {
$id = (int) get_parameter ('id');
$recovery_notify = (bool) get_parameter ('recovery_notify');
$field2_recovery = (bool) get_parameter ('field2_recovery');
$field3_recovery = (bool) get_parameter ('field3_recovery');
$field2_recovery = (string) get_parameter ('field2_recovery');
$field3_recovery = (string) get_parameter ('field3_recovery');
$result = update_alert_template ($id,
array ('recovery_notify' => $recovery_notify,

View File

@ -89,7 +89,7 @@ function print_alert_template_steps ($step, $id) {
}
echo '</ol>';
echo '<div style="clear: both;"> </div>';
echo '<div style="clear: right"> </div>';
}
function update_template ($step) {
@ -171,9 +171,9 @@ function update_template ($step) {
$result = update_alert_template ($id, $values);
} elseif ($step == 3) {
$recovery_notify = (bool) get_parameter ('recovery_notify');
$field2_recovery = (bool) get_parameter ('field2_recovery');
$field3_recovery = (bool) get_parameter ('field3_recovery');
$field2_recovery = (string) get_parameter ('field2_recovery');
$field3_recovery = (string) get_parameter ('field3_recovery');
print_r ($_POST);
$result = update_alert_template ($id,
array ('recovery_notify' => $recovery_notify,
'field2_recovery' => $field2_recovery,

View File

@ -16,7 +16,7 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
enterprise_include ('godmode/menu.php');
require_once ('include/config.php');
check_login ();
@ -24,6 +24,10 @@ if ((! give_acl ($config['id_user'], 0, "LM")) && (! give_acl ($config['id_user'
return;
}
enterprise_include ('godmode/menu.php');
require_once ('include/functions_menu.php');
$menu = array ();
$menu['class'] = 'godmode';
if (give_acl ($config['id_user'], 0, "AW")) {
@ -197,4 +201,6 @@ if (is_array ($config['extensions'])) {
$menu["gextensions"]["sub"] = $sub;
}
print_menu ($menu);
?>

View File

@ -17,7 +17,7 @@
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//Pandora Version
$build_version = 'PC090217';
$build_version = 'PC090303';
$pandora_version = 'v2.1-dev';
$config['start_time'] = microtime (true);

View File

@ -169,7 +169,7 @@ function popup_help ($help_id, $return = false) {
* (use general/noaccess.php followed by exit instead)
*/
function no_permission () {
require("config.php");
require ("config.php");
echo "<h3 class='error'>".__('You don\'t have access')."</h3>";
echo "<img src='images/noaccess.png' alt='No access' width='120'><br /><br />";
echo "<table width=550>";
@ -352,6 +352,10 @@ function human_time_comparation ($timestamp) {
*/
function get_system_time () {
global $config;
static $time = 0;
if ($time != 0)
return $time;
if ($config["timesource"] = "sql") {
$time = get_db_sql ("SELECT UNIX_TIMESTAMP()");

View File

@ -1984,9 +1984,16 @@ function format_array_to_where_clause_sql ($values, $join = 'AND', $prefix = fal
$i = 1;
$max = count ($values);
foreach ($values as $field => $value) {
if (is_numeric ($field))
/* Avoid numeric field names */
if (is_numeric ($field)) {
/* User provide the exact operation to do */
$query .= $value;
if ($i < $max) {
$query .= ' '.$join.' ';
}
$i++;
continue;
}
if ($field[0] != "`") {
$field = "`".$field."`";

View File

@ -17,6 +17,8 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
require_once ($config["homedir"]."/include/functions.php");
require_once ($config["homedir"]."/include/functions_db.php");
require_once ($config["homedir"]."/include/functions_agents.php");
/**
@ -29,7 +31,7 @@ require_once ($config["homedir"]."/include/functions_agents.php");
* ignore max value
* @param int Beginning date of the report in UNIX time (current date by default).
*
* @return int SLA percentage of the requested module.
* @return float SLA percentage of the requested module.
*/
function get_agentmodule_sla ($id_agentmodule, $period = 0, $min_value = 1, $max_value = false, $date = 0) {
if (empty ($date)) {
@ -40,19 +42,28 @@ function get_agentmodule_sla ($id_agentmodule, $period = 0, $min_value = 1, $max
global $config;
$period = $config["sla_period"];
}
$datelimit = $date - $period; // start date
/* Get the total data entries in the interval */
$sql = sprintf ('SELECT COUNT(*) FROM tagente_datos WHERE id_agente_modulo = %d AND utimestamp > %d AND utimestamp <= %d', $id_agentmodule, $datelimit, $date);
$sql = sprintf ('SELECT COUNT(*)
FROM tagente_datos
WHERE id_agente_modulo = %d
AND utimestamp > %d
AND utimestamp <= %d', $id_agentmodule, $datelimit, $date);
$total = get_db_sql ($sql);
if (empty ($total)) {
//No data to calculate on so we return 100 (fail to good)
return 100;
}
return 100.0;
}
$sql = sprintf ('SELECT COUNT(*) FROM tagente_datos WHERE id_agente_modulo = %d AND utimestamp > %d AND utimestamp <= %d AND datos < %d', $id_agentmodule, $datelimit, $date, $min_value);
$sql = sprintf ('SELECT COUNT(*)
FROM tagente_datos
WHERE id_agente_modulo = %d
AND utimestamp > %d
AND utimestamp <= %d
AND datos < %d', $id_agentmodule, $datelimit, $date, $min_value);
if ($max_value > $min_value) {
$sql .= sprintf (' AND datos > %d', $max_value);
}
@ -64,7 +75,7 @@ function get_agentmodule_sla ($id_agentmodule, $period = 0, $min_value = 1, $max
//Calculate percentage
$result = 100 - ($bad / $total) * 100;
return $result;
return (float) $result;
}
/**

View File

@ -244,7 +244,7 @@ function format_alert_row ($alert, $compound = false, $agent = true, $url = '')
} else {
$id_agent = get_agentmodule_agent ($alert['id_agent_module']);
$template = get_alert_template ($alert['id_alert_template']);
$description = $template['description'];
$description = $template['name'];
}
$data = array ();
@ -640,7 +640,9 @@ function process_page_head ($string, $bitfield) {
}
//Pandora specific jquery should go first
$config['jquery'] = array_merge (array ("jquery" => "include/javascript/jquery.js", "pandora" => "include/javascript/jquery.pandora.js"), $config['jquery']);
$config['jquery'] = array_merge (array ("jquery" => "include/javascript/jquery.js",
"pandora" => "include/javascript/jquery.pandora.js"),
$config['jquery']);
//Then add each script as necessary

View File

@ -51,3 +51,6 @@ div#head {
div#foot {
width: auto;
}
ol.steps {
margin-bottom: 70px;
}

View File

@ -97,18 +97,18 @@ if (!empty ($config["https"]) && empty ($_SERVER['HTTPS'])) {
exit; //Always exit after sending location headers
}
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'."\n";
echo '<html xmlns="http://www.w3.org/1999/xhtml">'."\n";
echo '<head>';
//This starts the page head. In the call back function, things from $page['head'] array will be processed into the head
ob_start ('process_page_head');
// Pure mode (without menu, header and footer).
$config["pure"] = (bool) get_parameter ("pure");
// Auto Refresh page (can now be disabled anywhere in the script)
$config["refr"] = (int) get_parameter ("refr");
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'."\n";
echo '<html xmlns="http://www.w3.org/1999/xhtml">'."\n";
echo '<head>';
//This starts the page head. In the call back function, things from $page['head'] array will be processed into the head
ob_start ('process_page_head');
enterprise_include ('index.php');
//This tag is included in the buffer passed to process_page_head so technically it can be stripped

View File

@ -16,7 +16,7 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
session_start();
session_start ();
require_once ("../../include/config.php");
require_once ("../../include/functions.php");

View File

@ -16,80 +16,85 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
session_start();
include ("../../include/config.php");
include ("../../include/functions.php");
include_once ("../../include/functions_db.php");
require_once ("../../include/config.php");
if (!isset ($config["auth"])) {
require_once ("../../include/auth/mysql.php");
} else {
require_once ("../../include/auth/".$config["auth"]["scheme"].".php");
}
require_once ("../../include/functions.php");
require_once ("../../include/functions_db.php");
require_once ("../../include/functions_events.php");
session_write_close();
session_write_close ();
$config["id_user"] = $_SESSION["id_usuario"];
if ( (give_acl($config["id_user"], 0, "AR")==0) AND (give_acl($config["id_user"], 0, "AW")==0) ){
require ("../../general/noaccess.php");
if (! give_acl ($config["id_user"], 0, "AR") && ! give_acl ($config["id_user"], 0, "AW")) {
exit;
}
$offset = (int) get_parameter ("offset");
$ev_group = (int) get_parameter ("ev_group"); // group
$search = (int) get_parameter ("search"); // free search
$event_type = (string) get_parameter ("event_type", "all"); // 0 all
$severity = (int) get_parameter ("severity", -1); // -1 all
$status = (int) get_parameter ("status", -1); // -1 all, 0 only red, 1 only green
$id_agent = (int) get_parameter ("id_agent", -1);
$offset = get_parameter ( "offset",0);
$ev_group = get_parameter ("ev_group", 0); // group
$search = get_parameter ("search", ""); // free search
$event_type = get_parameter ("event_type", "all"); // 0 all
$severity = get_parameter ("severity", -1); // -1 all
$status = get_parameter ("status", -1); // -1 all, 0 only red, 1 only green
$id_agent = get_parameter ("id_agent", -1);
$sql_post = "";
$filter = array ();
if ($ev_group > 1)
$sql_post .= " AND id_grupo = $ev_group";
$filter['id_grupo'] = $ev_group;
if ($status == 1)
$sql_post .= " AND estado = 1";
$filter['estado'] = 1;
if ($status == 0)
$sql_post .= " AND estado = 0";
$filter['estado'] = 0;
if ($search != "")
$sql_post .= " AND evento LIKE '%$search%'";
$filter[] = 'evento LIKE "%'.$search.'%"';
if (($event_type != "all") AND ($event_type != 0))
$sql_post .= " AND event_type = '$event_type'";
$filter['event_type'] = $event_type;
if ($severity != -1)
$sql_post .= " AND criticity >= $severity";
$filter[] = 'criticity >= '.$severity;
if ($id_agent != -1)
$sql_post .= " AND id_agente = $id_agent";
$filter['id_agente'] = $id_agent;
$sql2 = "SELECT * FROM tevento WHERE 1=1 ";
$sql2 .= $sql_post . " ORDER BY timestamp DESC";
$now = date("Y-m-d");
$filter['order'] = 'timestamp DESC';
$now = date ("Y-m-d");
// Show contentype header
Header("Content-type: text/txt");
header('Content-Disposition: attachment; filename="pandora_export_event'.$now.'.txt"');
Header ("Content-type: text/txt");
header ('Content-Disposition: attachment; filename="pandora_export_event'.$now.'.txt"');
echo "timestamp, agent, group, event, status, user, event_type, severity";
echo chr(13);
echo chr (13);
$result=mysql_query($sql2);
while ($row=mysql_fetch_array($result)){
$id_grupo = $row["id_grupo"];
if (give_acl($config["id_user"], $id_grupo, "AR") == 1){ // Only incident read access to view data !
echo $row["timestamp"];
echo ", ";
echo get_db_sql("SELECT nombre FROM tagente WHERE id_agente = '".$row["id_agente"]."'");
echo ", ";
echo get_db_sql("SELECT nombre FROM tgrupo WHERE id_grupo = '".$row["id_grupo"]."'");
echo ", ";
echo $row["evento"];
echo ", ";
echo $row["estado"];
echo ", ";
echo $row["id_usuario"];
echo ", ";
echo $row["event_type"];
echo ", ";
echo $row["criticity"];
echo chr(13);
}
$fields = array ('id_grupo', 'id_agente', 'evento', 'estado', 'id_usuario',
'event_type', 'criticity', 'timestamp');
$events = get_events ($filter, $fields);
if ($events === false)
$events = array ();
foreach ($events as $event) {
if (! give_acl ($config["id_user"], $event["id_grupo"], "AR"))
continue;
echo $event["timestamp"];
echo ",";
echo get_db_value ('nombre', 'tagente', 'id_agente', $event["id_agente"]);
echo ",";
echo get_db_value ('nombre', 'tgrupo', 'id_grupo', $event["id_grupo"]);
echo ",";
echo $event["evento"];
echo ",";
echo $event["estado"];
echo ",";
echo $event["id_usuario"];
echo ",";
echo $event["event_type"];
echo ",";
echo $event["criticity"];
echo chr (13);
}
?>

View File

@ -20,8 +20,11 @@ if (! isset ($config['id_user'])) {
return;
}
require_once ('include/functions_menu.php');
enterprise_include ('operation/menu.php');
$menu = array ();
$menu['class'] = 'operation';
// Agent read, Server read
@ -197,4 +200,6 @@ if (give_acl ($config['id_user'], 0, "AR")) {
$menu["extensions"]["sub"] = $sub;
}
}
print_menu ($menu);
?>

View File

@ -16,17 +16,11 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
// Login check
require ("include/config.php");
check_login ();
// Load enterprise extensions
if (file_exists( $config["homedir"] . "/enterprise/operation/reporting/custom_reporting.php")) {
include $config["homedir"] . "/enterprise/operation/reporting/custom_reporting.php";
}
enterprise_include ('operation/reporting/custom_reporting.php');
echo "<h2>".__('Reporting')." &gt; ";
echo __('Custom reporting')."</h2>";

View File

@ -512,7 +512,6 @@ foreach ($contents as $content) {
break;
}
print_table ($table);
flush ();
}

View File

@ -17,7 +17,7 @@
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
// Login check
if (isset ($_GET["direct"])) {
if (isset ($_GET["direct"])) {
/*
This is in case somebody wants to access the XML directly without
having the possibility to login and handle sessions
@ -27,10 +27,9 @@ if (isset ($_GET["direct"])) {
Although it's not recommended, you can put your login and password
in a GET request (append &nick=<yourlogin>&password=<password>).
You SHOULD put it in a POST but some programs
might not be able to handle it without extensive re-programming
(M$ ShitPoint). Either way, you should have a read-only user for getting reports
might not be able to handle it without extensive re-programming.
Either way, you should have a read-only user for getting reports
XMLHttpRequest can do it (example):
@ -56,9 +55,9 @@ if (isset ($_GET["direct"])) {
require_once ("../../include/functions_reporting.php");
if (!isset ($config["auth"])) {
require_once ("include/auth/mysql.php");
require_once ("../../include/auth/mysql.php");
} else {
require_once ("include/auth/".$config["auth"]["scheme"].".php");
require_once ("../../include/auth/".$config["auth"]["scheme"].".php");
}
$nick = get_parameter ("nick");
@ -77,12 +76,12 @@ if (isset ($_GET["direct"])) {
} else {
// User not known
$login_failed = true;
require_once ('general/login_page.php');
require_once ($config['homedir'].'/general/login_page.php');
audit_db ($nick, $REMOTE_ADDR, "Logon Failed", "Invalid login: ".$nick);
exit;
}
} else {
require_once ("include/config.php");
@require_once ("include/config.php");
require_once ("include/functions_reporting.php");
if (!isset ($config["auth"])) {
@ -92,7 +91,7 @@ if (isset ($_GET["direct"])) {
}
}
check_login();
check_login ();
$id_report = (int) get_parameter ('id');
@ -100,7 +99,7 @@ if (! $id_report) {
audit_db ($config['id_user'], $REMOTE_ADDR, "HACK Attempt",
"Trying to access graph viewer without valid ID");
require ("general/noaccess.php");
exit;
return;
}
$report = get_db_row ('treport', 'id_report', $id_report);
@ -108,7 +107,7 @@ $report = get_db_row ('treport', 'id_report', $id_report);
if (! give_acl ($config['id_user'], $report['id_group'], "AR")) {
audit_db ($config['id_user'], $REMOTE_ADDR, "ACL Violation","Trying to access graph reader");
include ("general/noaccess.php");
exit;
return;
}
/* Check if the user can see the graph */
@ -161,7 +160,7 @@ foreach ($contents as $content) {
switch ($content["type"]) {
case 1:
case 'simple_graph':
case 'simple_graph':
$data["title"] = __('Simple graph');
$data["objdata"]["img"] = 'reporting/fgraph.php?tipo=sparse&amp;id='.$content['id_agent_module'].'&amp;height=230&amp;width=720&amp;period='.$content['period'].'&amp;date='.$datetime.'&amp;avg_only=1&amp;pure=1';
break;
@ -188,7 +187,7 @@ foreach ($contents as $content) {
case 'SLA':
$data["title"] = __('S.L.A.');
$slas = get_db_all_rows_field_filter ('treport_content_sla_combined','id_report_content', $content['id_rc']);
$slas = get_db_all_rows_field_filter ('treport_content_sla_combined', 'id_report_content', $content['id_rc']);
if ($slas === false) {
$data["objdata"]["error"] = __('There are no SLAs defined');
$slas = array ();
@ -217,7 +216,7 @@ foreach ($contents as $content) {
break;
case 4:
case 'event_report':
case 'event_report':
$data["title"] = __("Event report");
$table_report = event_reporting ($report['id_group'], $content['period'], $datetime, true);
$data["objdata"] = "<![CDATA[";
@ -283,7 +282,6 @@ foreach ($contents as $content) {
array_push ($xml["reports"], $data);
}
function xml_array ($array) {
foreach ($array as $name => $value) {
if (is_int ($name)) {