2009-03-24 Esteban Sanchez <estebans@artica.es>
* godmode/alerts/configure_alert_compound.php: Fixed clean up div for variable width styles. Min and max fire values commented because it's not implemented yet. * include/config_process.php: Keep database connection resource in config. * include/functions.php: Use mysql_real_escape_string(), replacing deprecated function. * include/functions_alerts.php: Updated to use process_sql_* functions. Many fixes done such as updating a template name or escaping the value when duplicating a template. * include/functions_ui.php: Fixed an error on refresh header when using other web servers like Cherokee. * operation/agentes/estado_agente.php: Style corrections. * reporting/fgraph.php: Fixed a typo on grafico_db_agentes_paquetes(). * pandora_db.sql, extras/pandoradb_migrate_v2.x_to_v3.0.sql: Added foreign key on treport_content and id field on talert_compound_actions. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1555 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
4445032be1
commit
8bd22e5ca8
|
@ -1,3 +1,30 @@
|
|||
2009-03-24 Esteban Sanchez <estebans@artica.es>
|
||||
|
||||
* godmode/alerts/configure_alert_compound.php: Fixed clean up div for
|
||||
variable width styles. Min and max fire values commented because it's
|
||||
not implemented yet.
|
||||
|
||||
* include/config_process.php: Keep database connection resource in
|
||||
config.
|
||||
|
||||
* include/functions.php: Use mysql_real_escape_string(), replacing
|
||||
deprecated function.
|
||||
|
||||
* include/functions_alerts.php: Updated to use process_sql_*
|
||||
functions. Many fixes done such as updating a template name or
|
||||
escaping the value when duplicating a template.
|
||||
|
||||
* include/functions_ui.php: Fixed an error on refresh header when
|
||||
using other web servers like Cherokee.
|
||||
|
||||
* operation/agentes/estado_agente.php: Style corrections.
|
||||
|
||||
* reporting/fgraph.php: Fixed a typo on grafico_db_agentes_paquetes().
|
||||
|
||||
* pandoradb.sql, extras/pandoradb_migrate_v2.x_to_v3.0.sql: Added
|
||||
foreign key on treport_content and id field on
|
||||
talert_compound_actions.
|
||||
|
||||
2009-03-24 Sancho Lerena <slerena@gmail.com>
|
||||
|
||||
* module_manager_editor.php,
|
||||
|
|
|
@ -33,6 +33,9 @@ ALTER TABLE `tagente_modulo` DROP INDEX `tam_plugin`;
|
|||
ALTER TABLE `tagente_modulo` DROP PRIMARY KEY , ADD PRIMARY KEY
|
||||
( `id_agente_modulo` );
|
||||
|
||||
ALTER TABLE `treport_content` ADD FOREIGN KEY (`id_report`) REFERENCES treport(`id_report`)
|
||||
ON UPDATE CASCADE ON DELETE CASCADE;
|
||||
|
||||
ALTER TABLE `tagent_access` DROP `timestamp`;
|
||||
|
||||
ALTER TABLE `tlayout_data` ADD `id_agent` int(10) unsigned NOT NULL default 0;
|
||||
|
@ -241,10 +244,12 @@ CREATE TABLE IF NOT EXISTS `talert_compound_elements` (
|
|||
DROP TABLE IF EXISTS talert_compound_actions;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `talert_compound_actions` (
|
||||
`id` int(10) unsigned NOT NULL auto_increment,
|
||||
`id_alert_compound` int(10) unsigned NOT NULL,
|
||||
`id_alert_action` int(10) unsigned NOT NULL,
|
||||
`fires_min` int(3) unsigned default 0,
|
||||
`fires_max` int(3) unsigned default 0,
|
||||
PRIMARY KEY (`id`),
|
||||
FOREIGN KEY (`id_alert_compound`) REFERENCES talert_compound(`id`)
|
||||
ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
FOREIGN KEY (`id_alert_action`) REFERENCES talert_actions(`id`)
|
||||
|
|
|
@ -89,7 +89,7 @@ function print_alert_compound_steps ($step, $id) {
|
|||
}
|
||||
|
||||
echo '</ol>';
|
||||
echo '<div style="clear: both;"> </div>';
|
||||
echo '<div class="steps_clean"> </div>';
|
||||
}
|
||||
|
||||
function update_compound ($step) {
|
||||
|
@ -155,6 +155,7 @@ function update_compound ($step) {
|
|||
|
||||
/* Update actions */
|
||||
$actions = (array) get_parameter ('actions');
|
||||
|
||||
foreach ($actions as $id_action) {
|
||||
/* TODO: fires_min and fires_max missing */
|
||||
add_alert_compound_action ($id, (int) $id_action);
|
||||
|
@ -352,7 +353,8 @@ if ($step == 2) {
|
|||
$table->data[4][1] .= print_button (__('Add'), 'add_action', false, '',
|
||||
'class="sub next"', true);
|
||||
$table->data[4][1] .= '<br />';
|
||||
$table->data[4][1] .= '<span><a href="#" class="show_advanced_actions">'.__('Advanced options').' » </a></span>';
|
||||
/* TODO: Finish fires_max and fires_min support */
|
||||
/* $table->data[4][1] .= '<span><a href="" class="show_advanced_actions">'.__('Advanced options').' » </a></span>';
|
||||
$table->data[4][1] .= '<span class="advanced_actions invisible">';
|
||||
$table->data[4][1] .= __('From').' ';
|
||||
$table->data[4][1] .= print_input_text ('fires_min', 0, '', 4, 10, true);
|
||||
|
@ -361,7 +363,7 @@ if ($step == 2) {
|
|||
$table->data[4][1] .= ' '.__('matches of the alert');
|
||||
$table->data[4][1] .= pandora_help("alert-matches", true);
|
||||
$table->data[4][1] .= '</span>';
|
||||
|
||||
*/
|
||||
$table->data['actions'][0] = __('Assigned actions');
|
||||
$table->data['actions'][1] = '<ul id="alert_actions">';
|
||||
if ($id) {
|
||||
|
|
|
@ -34,9 +34,9 @@ $config['fontpath'] = $config['homedir'].'/reporting/FreeSans.ttf';
|
|||
// Style (pandora by default)
|
||||
$config['style'] = 'pandora';
|
||||
|
||||
// Read remaining config tokens from DB
|
||||
if (! mysql_connect ($config["dbhost"], $config["dbuser"], $config["dbpass"])) {
|
||||
//Non-persistent connection. If you want persistent conn change it to mysql_pconnect()
|
||||
//Non-persistent connection. If you want persistent conn change it to mysql_pconnect()
|
||||
$config['dbconnection'] = mysql_connect ($config["dbhost"], $config["dbuser"], $config["dbpass"]);
|
||||
if (! $config['dbconnection']) {
|
||||
exit ('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Pandora FMS Error</title>
|
||||
<link rel="stylesheet" href="./include/styles/pandora.css" type="text/css">
|
||||
|
|
|
@ -946,7 +946,9 @@ function unsafe_string ($string) {
|
|||
function safe_sql_string ($string) {
|
||||
if (get_magic_quotes_gpc () == 0)
|
||||
return $string;
|
||||
return mysql_escape_string ($string);
|
||||
global $config;
|
||||
|
||||
return mysql_real_escape_string ($string, $config['dbconnection']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -289,6 +289,8 @@ function clean_alert_template_values ($values, $set_empty = true) {
|
|||
if (empty ($values))
|
||||
return $retvalues;
|
||||
|
||||
if (isset ($values['name']))
|
||||
$retvalues['name'] = (string) $values['name'];
|
||||
if (isset ($values['type']))
|
||||
$retvalues['type'] = (string) $values['type'];
|
||||
if (isset ($values['description']))
|
||||
|
@ -359,23 +361,14 @@ function create_alert_template ($name, $type, $values = false) {
|
|||
return false;
|
||||
|
||||
$values = clean_alert_template_values ($values);
|
||||
$values['name'] = $name;
|
||||
$values['type'] = $type;
|
||||
|
||||
switch ($type) {
|
||||
/* TODO: Check values based on type, return false if failure */
|
||||
}
|
||||
|
||||
$sql = sprintf ('INSERT talert_templates (name, type, description,
|
||||
field1, field2, field3, value, max_value, min_value,
|
||||
time_threshold, max_alerts, min_alerts, matches_value)
|
||||
VALUES ("%s", "%s", "%s", "%s", "%s", "%s", "%s", %.2f,
|
||||
%.2f, %d, %d, %d, %d)',
|
||||
$name, $type, $values['description'], $values['field1'],
|
||||
$values['field2'], $values['field3'], $values['value'],
|
||||
$values['max_value'], $values['min_value'],
|
||||
$values['time_threshold'], $values['max_alerts'],
|
||||
$values['min_alerts'], $values['matches_value']);
|
||||
|
||||
return @process_sql ($sql, 'insert_id');
|
||||
return @process_sql_insert ('talert_templates', $values);
|
||||
}
|
||||
|
||||
function update_alert_template ($id_alert_template, $values = false) {
|
||||
|
@ -385,12 +378,9 @@ function update_alert_template ($id_alert_template, $values = false) {
|
|||
|
||||
$values = clean_alert_template_values ($values, false);
|
||||
|
||||
$sql = sprintf ('UPDATE talert_templates
|
||||
SET %s
|
||||
WHERE id = %d',
|
||||
format_array_to_update_sql ($values), $id_alert_template);
|
||||
|
||||
return @process_sql ($sql) !== false;
|
||||
return (@process_sql_update ('talert_templates',
|
||||
$values,
|
||||
array ('id' => $id_alert_template))) !== false;
|
||||
}
|
||||
|
||||
function delete_alert_template ($id_alert_template) {
|
||||
|
@ -398,9 +388,7 @@ function delete_alert_template ($id_alert_template) {
|
|||
if (empty ($id_alert_template))
|
||||
return false;
|
||||
|
||||
$sql = sprintf ('DELETE FROM talert_templates WHERE id = %d',
|
||||
$id_alert_template);
|
||||
return @process_sql ($sql);
|
||||
return @process_sql_delete ('talert_templates', array ('id' => $id_alert_template));
|
||||
}
|
||||
|
||||
function get_alert_templates ($only_names = true) {
|
||||
|
@ -537,6 +525,7 @@ function duplicate_alert_template ($id_alert_template) {
|
|||
unset ($template['name']);
|
||||
unset ($template['id']);
|
||||
unset ($template['type']);
|
||||
$template['value'] = safe_sql_string ($template['value']);
|
||||
|
||||
return create_alert_template ($name, $type, $template);
|
||||
}
|
||||
|
@ -579,17 +568,11 @@ function create_alert_agent_module ($id_agent_module, $id_alert_template, $value
|
|||
return false;
|
||||
|
||||
$values = clean_alert_agent_module_values ($values);
|
||||
|
||||
$sql = sprintf ('INSERT talert_template_modules (id_agent_module,
|
||||
id_alert_template, internal_counter, last_fired, times_fired,
|
||||
disabled, priority, force_execution)
|
||||
VALUES (%d, %d, %d, %d, %d, %d, %d, %d)',
|
||||
$id_agent_module, $id_alert_template,
|
||||
$values['internal_counter'], $values['last_fired'],
|
||||
$values['times_fired'], $values['disabled'], $values['priority'],
|
||||
$values['force_execution']);
|
||||
|
||||
return @process_sql ($sql, 'insert_id');
|
||||
$values['id_agent_module'] = $id_agent_module;
|
||||
$values['id_alert_template'] = $id_alert_template;
|
||||
return @process_sql_insert ('talert_template_modules',
|
||||
$values,
|
||||
array ('id' => $id_alert_template));
|
||||
}
|
||||
|
||||
function update_alert_agent_module ($id_alert_agent_module, $values = false) {
|
||||
|
@ -600,23 +583,17 @@ function update_alert_agent_module ($id_alert_agent_module, $values = false) {
|
|||
if ($empty ($values))
|
||||
return true;
|
||||
|
||||
$sql = sprintf ('UPDATE talert_template_modules
|
||||
SET %s
|
||||
WHERE id = %d',
|
||||
format_array_to_update_sql ($values), $id_alert_agent_module);
|
||||
|
||||
return @process_sql ($sql) !== false;
|
||||
return (@process_sql_update ('talert_template_modules',
|
||||
$values,
|
||||
array ('id' => $id_alert_template))) !== false;
|
||||
}
|
||||
|
||||
function delete_alert_agent_module ($id_alert_agent_module) {
|
||||
if (empty ($id_alert_agent_module))
|
||||
return false;
|
||||
|
||||
$sql = sprintf ('DELETE FROM talert_template_modules
|
||||
WHERE id = %d',
|
||||
$id_alert_agent_module);
|
||||
|
||||
return @process_sql ($sql) !== false;
|
||||
return (@process_sql_delete ('talert_template_modules',
|
||||
array ('id' => $id_alert_agent_module))) !== false;
|
||||
}
|
||||
|
||||
function get_alert_agent_module ($id_alert_agent_module) {
|
||||
|
@ -627,22 +604,17 @@ function get_alert_agent_module ($id_alert_agent_module) {
|
|||
return get_db_row ('talert_template_modules', 'id', $id_alert_agent_module);
|
||||
}
|
||||
|
||||
function get_alerts_agent_module ($id_agent_module, $disabled = false, $filter = false) {
|
||||
function get_alerts_agent_module ($id_agent_module, $disabled = false, $filter = false, $fields = false) {
|
||||
$id_alert_agent_module = safe_int ($id_agent_module, 0);
|
||||
|
||||
$where = '';
|
||||
if (! is_array ($filter))
|
||||
$filter = array ();
|
||||
if (! $disabled)
|
||||
$where .= ' AND disabled = 0 ';
|
||||
$filter['disabled'] = 0;
|
||||
$filter['id_agent_module'] = $id_agent_module;
|
||||
|
||||
if ($filter) {
|
||||
$where .= format_array_to_where_clause_sql ($filter, 'AND', ' AND ');
|
||||
}
|
||||
|
||||
$sql = sprintf ('SELECT * FROM talert_template_modules
|
||||
WHERE id_agent_module = %d %s',
|
||||
$id_agent_module, $where);
|
||||
|
||||
return get_db_all_rows_sql ($sql);
|
||||
return get_db_all_rows_filter ('talert_template_modules',
|
||||
$filter, $fields);
|
||||
}
|
||||
|
||||
function get_alert_agent_module_disabled ($id_alert_agent_module) {
|
||||
|
@ -653,22 +625,16 @@ function get_alert_agent_module_disabled ($id_alert_agent_module) {
|
|||
|
||||
function set_alerts_agent_module_force_execution ($id_alert_agent_module) {
|
||||
$id_alert_agent_module = safe_int ($id_alert_agent_module, 0);
|
||||
$sql = sprintf ('UPDATE talert_template_modules
|
||||
SET force_execution = 1
|
||||
WHERE id = %d',
|
||||
$id_alert_agent_module);
|
||||
|
||||
return @process_sql ($sql) !== false;
|
||||
return (@process_sql_update ('talert_template_modules',
|
||||
array ('force_execution' => 1),
|
||||
array ('id' => $id_alert_agent_module))) !== false;
|
||||
}
|
||||
|
||||
function set_alerts_agent_module_disable ($id_alert_agent_module, $disabled) {
|
||||
$id_alert_agent_module = safe_int ($id_alert_agent_module, 0);
|
||||
$sql = sprintf ('UPDATE talert_template_modules
|
||||
SET disabled = %d
|
||||
WHERE id = %d',
|
||||
$disabled ? 1 : 0, $id_alert_agent_module);
|
||||
|
||||
return @process_sql ($sql) !== false;
|
||||
return (@process_sql_update ('talert_template_modules',
|
||||
array ('disabled' => (bool) $disabled),
|
||||
array ('id' => $id_alert_agent_module))) !== false;
|
||||
}
|
||||
|
||||
function get_alerts_agent_module_last_fired ($id_alert_agent_module) {
|
||||
|
@ -677,14 +643,17 @@ function get_alerts_agent_module_last_fired ($id_alert_agent_module) {
|
|||
$id_alert_agent_module);
|
||||
}
|
||||
|
||||
function add_alert_agent_module_action ($id_alert_agent_module, $id_alert_action, $options = false) {
|
||||
if (empty ($id_alert_agent_module))
|
||||
function add_alert_agent_module_action ($id_alert_template_module, $id_alert_action, $options = false) {
|
||||
if (empty ($id_alert_template_module))
|
||||
return false;
|
||||
if (empty ($id_alert_action))
|
||||
return false;
|
||||
|
||||
$fires_max = 0;
|
||||
$fires_min = 0;
|
||||
$values = array ();
|
||||
$values['id_alert_template_module'] = $id_alert_template_module;
|
||||
$values['id_alert_action'] = $id_alert_action;
|
||||
$values['fires_max'] = 0;
|
||||
$values['fires_min'] = 0;
|
||||
if ($options) {
|
||||
$max = 0;
|
||||
$min = 0;
|
||||
|
@ -693,40 +662,32 @@ function add_alert_agent_module_action ($id_alert_agent_module, $id_alert_action
|
|||
if (isset ($options['fires_min']))
|
||||
$min = (int) $options['fires_min'];
|
||||
|
||||
$fires_max = max ($max, $min);
|
||||
$fires_min = min ($max, $min);
|
||||
$values['fires_max'] = max ($max, $min);
|
||||
$values['fires_min'] = min ($max, $min);
|
||||
}
|
||||
|
||||
$sql = sprintf ('INSERT INTO talert_template_module_actions
|
||||
(id_alert_template_module, id_alert_action, fires_min, fires_max)
|
||||
VALUES (%d, %d, %d, %d)',
|
||||
$id_alert_agent_module, $id_alert_action, $fires_min, $fires_max);
|
||||
|
||||
return process_sql ($sql, 'insert_id');
|
||||
return (@process_sql_insert ('talert_template_module_actions', $values)) !== false;
|
||||
}
|
||||
|
||||
function delete_alert_agent_module_action ($id_alert_agent_module_action) {
|
||||
if (empty ($id_alert_agent_module_action))
|
||||
return false;
|
||||
|
||||
$sql = sprintf ('DELETE FROM talert_template_module_actions
|
||||
WHERE id = %d',
|
||||
$id_alert_agent_module_action);
|
||||
|
||||
return process_sql ($sql) !== false;
|
||||
return (@process_sql_delete ('talert_template_module_actions',
|
||||
array ('id' => $id_alert_agent_module_action))) !== false;
|
||||
}
|
||||
|
||||
function get_alert_agent_module_actions ($id_alert_agent_module) {
|
||||
function get_alert_agent_module_actions ($id_alert_agent_module, $fields = false) {
|
||||
if (empty ($id_alert_agent_module))
|
||||
return false;
|
||||
|
||||
$sql = sprintf ('SELECT id, id_alert_action, fires_min, fires_max
|
||||
FROM talert_template_module_actions
|
||||
WHERE id_alert_template_module = %d',
|
||||
$id_alert_agent_module);
|
||||
$actions = get_db_all_rows_sql ($sql);
|
||||
$actions = get_db_all_rows_filter ('talert_template_module_actions',
|
||||
array ('id_alert_template_module' => $id_alert_agent_module),
|
||||
$fields);
|
||||
if ($actions === false)
|
||||
return array ();
|
||||
if ($fields !== false)
|
||||
return $actions;
|
||||
|
||||
$retval = array ();
|
||||
foreach ($actions as $element) {
|
||||
|
@ -936,24 +897,26 @@ function create_alert_compound ($name, $id_agent, $values = false) {
|
|||
}
|
||||
|
||||
function update_alert_compound ($id_alert_compound, $values = false) {
|
||||
$id_alert_compound = safe_int ($id_alert_compound);
|
||||
if (empty ($id_alert_compound))
|
||||
return false;
|
||||
$values = clean_alert_compound_values ($values, false);
|
||||
|
||||
return @process_sql_update ('talert_compound', $values,
|
||||
array ('id' => $id_alert_compound)) !== false;
|
||||
return (@process_sql_update ('talert_compound', $values,
|
||||
array ('id' => $id_alert_compound))) !== false;
|
||||
}
|
||||
|
||||
function delete_alert_compound_elements ($id_alert_compound) {
|
||||
$id_alert_compound = safe_int ($id_alert_compound);
|
||||
if (empty ($id_alert_compound))
|
||||
return false;
|
||||
|
||||
$sql = sprintf ('DELETE FROM talert_compound_elements
|
||||
WHERE id_alert_compound = %d', $id_alert_compound);
|
||||
return @process_sql ($sql);
|
||||
return (@process_sql_delete ('talert_compound_elements',
|
||||
array ('id_alert_compound' => $id_alert_compound))) !== false;
|
||||
}
|
||||
|
||||
function add_alert_compound_element ($id_alert_compound, $id_alert_template_module, $operation) {
|
||||
$id_alert_compound = safe_int ($id_alert_compound);
|
||||
if (empty ($id_alert_compound))
|
||||
return false;
|
||||
if (empty ($id_alert_template_module))
|
||||
|
@ -973,31 +936,32 @@ function get_alert_compound ($id_alert_compound) {
|
|||
return get_db_row ('talert_compound', 'id', $id_alert_compound);
|
||||
}
|
||||
|
||||
function get_alert_compound_actions ($id_alert_compound) {
|
||||
function get_alert_compound_actions ($id_alert_compound, $fields = false) {
|
||||
$id_alert_compound = safe_int ($id_alert_compound);
|
||||
if (empty ($id_alert_compound))
|
||||
return false;
|
||||
|
||||
$sql = sprintf ('SELECT id_alert_action id, fires_min, fires_max
|
||||
FROM talert_compound_actions
|
||||
WHERE id_alert_compound = %d',
|
||||
$id_alert_compound);
|
||||
$actions = get_db_all_rows_sql ($sql);
|
||||
$actions = get_db_all_rows_filter ('talert_compound_actions',
|
||||
array ('id_alert_compound' => $id_alert_compound),
|
||||
$fields);
|
||||
if ($actions === false)
|
||||
return array ();
|
||||
if ($fields !== false)
|
||||
return $actions;
|
||||
|
||||
$retval = array ();
|
||||
foreach ($actions as $element) {
|
||||
$action = get_alert_action ($element['id']);
|
||||
$action = get_alert_action ($element['id_alert_action']);
|
||||
$action['fires_min'] = $element['fires_min'];
|
||||
$action['fires_max'] = $element['fires_max'];
|
||||
array_push ($retval, $action);
|
||||
$retval[$element['id']] = $action;
|
||||
}
|
||||
|
||||
return $retval;
|
||||
}
|
||||
|
||||
function get_alert_compound_name ($id_alert_compound) {
|
||||
return (string) get_db_value ('name', 'talert_compund', 'id', $id_alert_compound);
|
||||
return (string) get_db_value ('name', 'talert_compound', 'id', $id_alert_compound);
|
||||
}
|
||||
|
||||
function get_alert_compound_elements ($id_alert_compound) {
|
||||
|
@ -1011,8 +975,11 @@ function add_alert_compound_action ($id_alert_compound, $id_alert_action, $optio
|
|||
if (empty ($id_alert_action))
|
||||
return false;
|
||||
|
||||
$fires_max = 0;
|
||||
$fires_min = 0;
|
||||
$values = array ();
|
||||
$values['id_alert_compound'] = $id_alert_compound;
|
||||
$values['id_alert_action'] = $id_alert_action;
|
||||
$values['fires_max'] = 0;
|
||||
$values['fires_min'] = 0;
|
||||
if ($options) {
|
||||
$max = 0;
|
||||
$min = 0;
|
||||
|
@ -1021,25 +988,18 @@ function add_alert_compound_action ($id_alert_compound, $id_alert_action, $optio
|
|||
if (isset ($options['fires_min']))
|
||||
$min = (int) $options['fires_min'];
|
||||
|
||||
$fires_max = max ($max, $min);
|
||||
$fires_min = min ($max, $min);
|
||||
$values['fires_max'] = max ($max, $min);
|
||||
$values['fires_min'] = min ($max, $min);
|
||||
}
|
||||
|
||||
$sql = sprintf ('INSERT INTO talert_compound_actions
|
||||
VALUES (%d, %d, %d, %d)',
|
||||
$id_alert_compound, $id_alert_action, $fires_min, $fires_max);
|
||||
|
||||
return @process_sql ($sql) !== false;
|
||||
return (@process_sql_insert ('talert_compound_actions', $values)) !== false;
|
||||
}
|
||||
|
||||
function set_alerts_compound_disable ($id_alert_compound, $disabled) {
|
||||
$id_alert_agent_module = safe_int ($id_alert_compound, 0);
|
||||
$sql = sprintf ('UPDATE talert_compound
|
||||
SET disabled = %d
|
||||
WHERE id = %d',
|
||||
$disabled ? 1 : 0, $id_alert_compound);
|
||||
|
||||
return @process_sql ($sql) !== false;
|
||||
return (@process_sql_update ('talert_compound',
|
||||
array ('disabled' => (bool) $disabled),
|
||||
array ('id' => $id_alert_compound))) !== false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1092,9 +1052,7 @@ function delete_alert_compound ($id_alert_compound) {
|
|||
$id_alert_compound = safe_int ($id_alert_compound, 1);
|
||||
if (empty ($id_alert_compound))
|
||||
return false;
|
||||
|
||||
$sql = sprintf ('DELETE FROM talert_compound WHERE id = %d',
|
||||
$id_alert_compound);
|
||||
return @process_sql ($sql);
|
||||
return (@process_sql_delete ('talert_compound',
|
||||
array ('id' => $id_alert_compound))) !== false;
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -537,9 +537,20 @@ function process_page_head ($string, $bitfield) {
|
|||
|
||||
if ($config["refr"] > 0) {
|
||||
// Agent selection filters and refresh
|
||||
$query = 'http' . (isset ($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == TRUE ? 's': '') . '://' . $_SERVER['SERVER_NAME'];
|
||||
if ($_SERVER['SERVER_PORT'] != 80 && (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == TRUE && $_SERVER['SERVER_PORT'] != 443)) {
|
||||
$query .= ":" . $_SERVER['SERVER_PORT'];
|
||||
$protocol = 'http';
|
||||
$ssl = false;
|
||||
if ($config['https']) {
|
||||
/* Check with "on" because some web servers like Cherokee always
|
||||
set this value even if SSL is not enabled */
|
||||
if (isset ($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] == true || $_SERVER['HTTPS'] == 'on')) {
|
||||
$protocol = 'https';
|
||||
$ssl = true;
|
||||
}
|
||||
}
|
||||
|
||||
$query = $protocol.'://' . $_SERVER['SERVER_NAME'];
|
||||
if ($_SERVER['SERVER_PORT'] != 80 && ($ssl && $_SERVER['SERVER_PORT'] != 443)) {
|
||||
$query .= ":".$_SERVER['SERVER_PORT'];
|
||||
}
|
||||
$query .= $_SERVER['SCRIPT_NAME'];
|
||||
|
||||
|
|
|
@ -101,9 +101,9 @@ if ($search != ""){
|
|||
// Show only selected groups
|
||||
if ($ag_group > 1){
|
||||
$sql="SELECT * FROM tagente WHERE id_grupo=$ag_group
|
||||
AND disabled = 0 $search_sql ORDER BY nombre LIMIT $offset, ".$config["block_size"];
|
||||
AND disabled = 0 $search_sql ORDER BY nombre LIMIT $offset, ".$config["block_size"];
|
||||
$sql2="SELECT COUNT(id_agente) FROM tagente WHERE id_grupo=$ag_group
|
||||
AND disabled = 0 $search_sql ORDER BY nombre";
|
||||
AND disabled = 0 $search_sql ORDER BY nombre";
|
||||
// Not selected any specific group
|
||||
} else {
|
||||
// Is admin user ??
|
||||
|
@ -118,31 +118,31 @@ if ($ag_group > 1){
|
|||
|
||||
if ($all_group > 0) {
|
||||
$sql = sprintf ("SELECT * FROM tagente
|
||||
WHERE disabled = 0 %s
|
||||
ORDER BY nombre, id_grupo LIMIT %d,%d",
|
||||
$search_sql, $offset,
|
||||
$config["block_size"]);
|
||||
WHERE disabled = 0 %s
|
||||
ORDER BY nombre, id_grupo LIMIT %d,%d",
|
||||
$search_sql, $offset,
|
||||
$config["block_size"]);
|
||||
$sql2 = sprintf ("SELECT COUNT(id_agente)
|
||||
FROM tagente WHERE disabled = 0 %s
|
||||
ORDER BY nombre, id_grupo",
|
||||
$search_sql);
|
||||
FROM tagente WHERE disabled = 0 %s
|
||||
ORDER BY nombre, id_grupo",
|
||||
$search_sql);
|
||||
} else {
|
||||
$sql = sprintf ("SELECT * FROM tagente
|
||||
WHERE disabled = 0 %s
|
||||
AND id_grupo IN (SELECT id_grupo
|
||||
FROM tusuario_perfil
|
||||
WHERE id_usuario='%s')
|
||||
ORDER BY nombre, id_grupo LIMIT %d,%d",
|
||||
$search_sql, $config['id_user'], $offset,
|
||||
$config["block_size"]);
|
||||
WHERE disabled = 0 %s
|
||||
AND id_grupo IN (SELECT id_grupo
|
||||
FROM tusuario_perfil
|
||||
WHERE id_usuario='%s')
|
||||
ORDER BY nombre, id_grupo LIMIT %d,%d",
|
||||
$search_sql, $config['id_user'], $offset,
|
||||
$config["block_size"]);
|
||||
$sql2 = sprintf ("SELECT COUNT(id_agente)
|
||||
FROM tagente
|
||||
WHERE disabled = 0 %s
|
||||
AND id_grupo IN (SELECT id_grupo
|
||||
FROM tusuario_perfil
|
||||
WHERE id_usuario='%s')
|
||||
ORDER BY nombre, id_grupo",
|
||||
$search_sql, $config['id_user']);
|
||||
FROM tagente
|
||||
WHERE disabled = 0 %s
|
||||
AND id_grupo IN (SELECT id_grupo
|
||||
FROM tusuario_perfil
|
||||
WHERE id_usuario='%s')
|
||||
ORDER BY nombre, id_grupo",
|
||||
$search_sql, $config['id_user']);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -174,21 +174,22 @@ if ($agents !== false) {
|
|||
$color = 1;
|
||||
foreach ($agents as $agent) {
|
||||
$intervalo = $agent["intervalo"]; // Interval in seconds
|
||||
$id_agente = $agent['id_agente'];
|
||||
$id_agente = $agent['id_agente'];
|
||||
$nombre_agente = substr (strtoupper ($agent["nombre"]), 0, 18);
|
||||
$direccion_agente = $agent["direccion"];
|
||||
$id_grupo = $agent["id_grupo"];
|
||||
$id_os = $agent["id_os"];
|
||||
$ultimo_contacto = $agent["ultimo_contacto"];
|
||||
$biginterval = $intervalo;
|
||||
$pertenece = 0;
|
||||
foreach ($groups as $migrupo) { //Verifiy if the group this agent begins is one of the user groups
|
||||
$belongs = false;
|
||||
//Verifiy if the group this agent begins is one of the user groups
|
||||
foreach ($groups as $migrupo) {
|
||||
if ($migrupo || $id_grupo == $migrupo) {
|
||||
$pertenece = 1;
|
||||
$belongs = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (! $pertenece == 1)
|
||||
if (! $belongs)
|
||||
continue;
|
||||
|
||||
// Obtenemos la lista de todos los modulos de cada agente
|
||||
|
@ -231,7 +232,7 @@ if ($agents !== false) {
|
|||
$async = 1;
|
||||
}
|
||||
// Defines if Agent is down (interval x 2 > time last contact
|
||||
if (($seconds >= ($intervalo_comp * 2)) AND ($module_type < 21)) { // If (intervalx2) secs. ago we don't get anything, show alert
|
||||
if (($seconds >= ($intervalo_comp * 2)) && ($module_type < 21)) { // If (intervalx2) secs. ago we don't get anything, show alert
|
||||
$agent_down = 1;
|
||||
if ($async == 0)
|
||||
$monitor_down++;
|
||||
|
@ -302,7 +303,7 @@ if ($agents !== false) {
|
|||
if ($numero_modulos > 0){
|
||||
if ($agent_down > 0) {
|
||||
echo '<img src="images/pixel_fucsia.png" width="40" height="18" title="'.__('Agent down').'" />';
|
||||
} elseif ($monitor_critical > 0){
|
||||
} elseif ($monitor_critical > 0) {
|
||||
echo '<img src="images/pixel_red.png" width="40" height="18" title="'.__('At least one module in CRITICAL status').'" />';
|
||||
} elseif ($monitor_warning > 0) {
|
||||
echo '<img src="images/pixel_yellow.png" width="40" height="18" title="'.__('At least one module in WARNING status').'" />';
|
||||
|
@ -310,7 +311,7 @@ if ($agents !== false) {
|
|||
echo '<img src="images/pixel_green.png" width="40" height="18" title="'.__('All Monitors OK').'" />';
|
||||
}
|
||||
} else {
|
||||
echo '<img src="images/pixel_blue.png" width="40" height="18" title="'.__('Agent without data').'" />';
|
||||
echo '<img src="images/pixel_blue.png" width="40" height="18" title="'.__('Agent without data').'" />';
|
||||
}
|
||||
|
||||
// checks if an alert was fired recently
|
||||
|
|
|
@ -330,10 +330,12 @@ CREATE TABLE IF NOT EXISTS `talert_compound_elements` (
|
|||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `talert_compound_actions` (
|
||||
`id` int(10) unsigned NOT NULL auto_increment,
|
||||
`id_alert_compound` int(10) unsigned NOT NULL,
|
||||
`id_alert_action` int(10) unsigned NOT NULL,
|
||||
`fires_min` int(3) unsigned default 0,
|
||||
`fires_max` int(3) unsigned default 0,
|
||||
PRIMARY KEY (`id`),
|
||||
FOREIGN KEY (`id_alert_compound`) REFERENCES talert_compound(`id`)
|
||||
ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
FOREIGN KEY (`id_alert_action`) REFERENCES talert_actions(`id`)
|
||||
|
@ -705,7 +707,9 @@ 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,
|
||||
PRIMARY KEY(`id_rc`)
|
||||
PRIMARY KEY(`id_rc`),
|
||||
FOREIGN KEY (`id_report`) REFERENCES treport(`id_report`)
|
||||
ON UPDATE CASCADE ON DELETE CASCADE
|
||||
) ENGINE = InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `treport_content_sla_combined` (
|
||||
|
|
|
@ -817,7 +817,7 @@ function grafico_db_agentes_paquetes ($width = 380, $height = 300) {
|
|||
$count = get_agent_modules_data_count (array_keys ($agents));
|
||||
unset ($count["total"]);
|
||||
arsort ($count, SORT_NUMERIC);
|
||||
$count = array_slice ($count, 10, 10, true);
|
||||
$count = array_slice ($count, 0, 10, true);
|
||||
|
||||
foreach ($count as $agent_id => $value) {
|
||||
$data[$agents[$agent_id]] = $value;
|
||||
|
|
Loading…
Reference in New Issue