pandorafms/pandora_console/include/functions_alerts.php

775 lines
23 KiB
PHP
Raw Normal View History

2009-01-12 Esteban Sanchez <estebans@artica.es> * godmode/agentes/alert_manager.php: Complete rewritten of the alert system when assigned alerts to an agent. * pandoradb.sql: New tables for alert system. These are: talert_commands, talert_actions, talert_templates, talert_template_modules, talert_template_module_actions. No migration tool is available yet. * godmode/alerts/configure_alert_template.php, godmode/alerts/configure_alert_action.php, godmode/alerts/alert_templates.php, godmode/alerts/configure_alert_command.php, godmode/alerts/alert_actions.php: Added to repository. Administration interface to new alert system. * godmode/alerts/modify_alert.php: Deleted from repository. * godmode/setup/setup.php: Added an example of the date format. Main table has now percentage width. * godmode/menu.php, operation/menu.php: Added new alert options. Removed refr value when it's not neccesary. * include/styles/pandora.css: Added width to textarea elements. Style correction and cleanup. Tables doesn't have a odd-even pattern, but the hovered row now changes its colour. New styles for alert pages. * include/functions_custom_graphs.php: Added to repository. custom graphs functions moved here. * include/functions_incidents.php, include/functions_events.php: Moved to LGPL. Style comment corrections. * include/functions_html.php: Documentation style correction. Added print_input_file() and print_label(). * include/functions_ui.php: Doc style correction. * operation/reporting/graph_viewer.php: Include new function file with custom graphs. Use generic functions. * index.php: Unset pass from POST and REQUEST arrays. * include/functions_db.php: Some documentation updated to new format. Added format_array_to_update_sql() to generate SQL sentences for updates. Style correction. * godmode/agentes/configurar_agente.php: Variables renamed to have a meaning. * extensions/update_manager/main.php: Mark an string translatable. * extensions/update_manager/lib/libupdate_manager_client.php, godmode/alerts/configure_alert.php, include/functions.php, godmode/agentes/module_manager.php, operation/agentes/networkmap.php, operation/reporting/reporting_viewer.php, godmode/agentes/manage_config.php: Style correction. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1331 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-01-12 15:31:01 +01:00
<?php
// Pandora FMS - the Flexible Monitoring System
// ============================================
// Copyright (c) 2008 Artica Soluciones Tecnologicas, http://www.artica.es
// Please see http://pandora.sourceforge.net 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 (LGPL)
// 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.
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
function clean_alert_command_values ($values, $set_empty = true) {
$retvalues = array ();
if ($set_empty) {
$retvalues['description'] = '';
}
if (empty ($values))
return $retvalues;
if (isset ($values['description']))
$retvalues['description'] = (string) $values['description'];
return $retvalues;
}
function create_alert_command ($name, $command, $values = false) {
if (empty ($name))
return false;
if (empty ($command))
return false;
$values = clean_alert_command_values ($values);
$sql = sprintf ('INSERT talert_commands (name, command, description)
VALUES ("%s", "%s", "%s")',
$name, $command, $values['description']);
return process_sql ($sql, 'insert_id');
}
function update_alert_command ($id_alert_command, $name, $command, $description = '', $values = false) {
2009-01-12 Esteban Sanchez <estebans@artica.es> * godmode/agentes/alert_manager.php: Complete rewritten of the alert system when assigned alerts to an agent. * pandoradb.sql: New tables for alert system. These are: talert_commands, talert_actions, talert_templates, talert_template_modules, talert_template_module_actions. No migration tool is available yet. * godmode/alerts/configure_alert_template.php, godmode/alerts/configure_alert_action.php, godmode/alerts/alert_templates.php, godmode/alerts/configure_alert_command.php, godmode/alerts/alert_actions.php: Added to repository. Administration interface to new alert system. * godmode/alerts/modify_alert.php: Deleted from repository. * godmode/setup/setup.php: Added an example of the date format. Main table has now percentage width. * godmode/menu.php, operation/menu.php: Added new alert options. Removed refr value when it's not neccesary. * include/styles/pandora.css: Added width to textarea elements. Style correction and cleanup. Tables doesn't have a odd-even pattern, but the hovered row now changes its colour. New styles for alert pages. * include/functions_custom_graphs.php: Added to repository. custom graphs functions moved here. * include/functions_incidents.php, include/functions_events.php: Moved to LGPL. Style comment corrections. * include/functions_html.php: Documentation style correction. Added print_input_file() and print_label(). * include/functions_ui.php: Doc style correction. * operation/reporting/graph_viewer.php: Include new function file with custom graphs. Use generic functions. * index.php: Unset pass from POST and REQUEST arrays. * include/functions_db.php: Some documentation updated to new format. Added format_array_to_update_sql() to generate SQL sentences for updates. Style correction. * godmode/agentes/configurar_agente.php: Variables renamed to have a meaning. * extensions/update_manager/main.php: Mark an string translatable. * extensions/update_manager/lib/libupdate_manager_client.php, godmode/alerts/configure_alert.php, include/functions.php, godmode/agentes/module_manager.php, operation/agentes/networkmap.php, operation/reporting/reporting_viewer.php, godmode/agentes/manage_config.php: Style correction. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1331 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-01-12 15:31:01 +01:00
$id_alert_command = safe_int ($id_alert_command, 1);
if (empty ($id_alert_command))
return false;
if (empty ($name))
return false;
if (empty ($command))
return false;
$values = clean_alert_command_values ($values);
$sql = sprintf ('UPDATE talert_commands SET name = "%s", command = "%s",
description = "%s" WHERE id = %d',
$name, $command, $values['description'], $id_alert_command);
return process_sql ($sql) !== false;
}
function delete_alert_command ($id_alert_command) {
$id_alert_command = safe_int ($id_alert_command, 1);
if (empty ($id_alert_command))
return false;
$sql = sprintf ('DELETE FROM talert_commands WHERE id = %d',
$id_alert_command);
return @process_sql ($sql);
2009-01-12 Esteban Sanchez <estebans@artica.es> * godmode/agentes/alert_manager.php: Complete rewritten of the alert system when assigned alerts to an agent. * pandoradb.sql: New tables for alert system. These are: talert_commands, talert_actions, talert_templates, talert_template_modules, talert_template_module_actions. No migration tool is available yet. * godmode/alerts/configure_alert_template.php, godmode/alerts/configure_alert_action.php, godmode/alerts/alert_templates.php, godmode/alerts/configure_alert_command.php, godmode/alerts/alert_actions.php: Added to repository. Administration interface to new alert system. * godmode/alerts/modify_alert.php: Deleted from repository. * godmode/setup/setup.php: Added an example of the date format. Main table has now percentage width. * godmode/menu.php, operation/menu.php: Added new alert options. Removed refr value when it's not neccesary. * include/styles/pandora.css: Added width to textarea elements. Style correction and cleanup. Tables doesn't have a odd-even pattern, but the hovered row now changes its colour. New styles for alert pages. * include/functions_custom_graphs.php: Added to repository. custom graphs functions moved here. * include/functions_incidents.php, include/functions_events.php: Moved to LGPL. Style comment corrections. * include/functions_html.php: Documentation style correction. Added print_input_file() and print_label(). * include/functions_ui.php: Doc style correction. * operation/reporting/graph_viewer.php: Include new function file with custom graphs. Use generic functions. * index.php: Unset pass from POST and REQUEST arrays. * include/functions_db.php: Some documentation updated to new format. Added format_array_to_update_sql() to generate SQL sentences for updates. Style correction. * godmode/agentes/configurar_agente.php: Variables renamed to have a meaning. * extensions/update_manager/main.php: Mark an string translatable. * extensions/update_manager/lib/libupdate_manager_client.php, godmode/alerts/configure_alert.php, include/functions.php, godmode/agentes/module_manager.php, operation/agentes/networkmap.php, operation/reporting/reporting_viewer.php, godmode/agentes/manage_config.php: Style correction. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1331 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-01-12 15:31:01 +01:00
}
function get_alert_command ($id_alert_command) {
$id_alert_command = safe_int ($id_alert_command, 1);
if (empty ($id_alert_command))
return false;
return get_db_row ('talert_commands', 'id', $id_alert_command);
}
function get_alert_command_name ($id_alert_command) {
$id_alert_command = safe_int ($id_alert_command, 1);
if (empty ($id_alert_command))
return false;
return get_db_value ('name', 'talert_commands', 'id', $id_alert_command);
}
function get_alert_command_command ($id_alert_command) {
$id_alert_command = safe_int ($id_alert_command, 1);
if (empty ($id_alert_command))
return false;
return get_db_value ('command', 'talert_commands', 'id', $id_alert_command);
}
function get_alert_command_internal ($id_alert_command) {
$id_alert_command = safe_int ($id_alert_command, 1);
if (empty ($id_alert_command))
return false;
return (bool) get_db_value ('internal', 'talert_commands', 'id', $id_alert_command);
}
2009-01-12 Esteban Sanchez <estebans@artica.es> * godmode/agentes/alert_manager.php: Complete rewritten of the alert system when assigned alerts to an agent. * pandoradb.sql: New tables for alert system. These are: talert_commands, talert_actions, talert_templates, talert_template_modules, talert_template_module_actions. No migration tool is available yet. * godmode/alerts/configure_alert_template.php, godmode/alerts/configure_alert_action.php, godmode/alerts/alert_templates.php, godmode/alerts/configure_alert_command.php, godmode/alerts/alert_actions.php: Added to repository. Administration interface to new alert system. * godmode/alerts/modify_alert.php: Deleted from repository. * godmode/setup/setup.php: Added an example of the date format. Main table has now percentage width. * godmode/menu.php, operation/menu.php: Added new alert options. Removed refr value when it's not neccesary. * include/styles/pandora.css: Added width to textarea elements. Style correction and cleanup. Tables doesn't have a odd-even pattern, but the hovered row now changes its colour. New styles for alert pages. * include/functions_custom_graphs.php: Added to repository. custom graphs functions moved here. * include/functions_incidents.php, include/functions_events.php: Moved to LGPL. Style comment corrections. * include/functions_html.php: Documentation style correction. Added print_input_file() and print_label(). * include/functions_ui.php: Doc style correction. * operation/reporting/graph_viewer.php: Include new function file with custom graphs. Use generic functions. * index.php: Unset pass from POST and REQUEST arrays. * include/functions_db.php: Some documentation updated to new format. Added format_array_to_update_sql() to generate SQL sentences for updates. Style correction. * godmode/agentes/configurar_agente.php: Variables renamed to have a meaning. * extensions/update_manager/main.php: Mark an string translatable. * extensions/update_manager/lib/libupdate_manager_client.php, godmode/alerts/configure_alert.php, include/functions.php, godmode/agentes/module_manager.php, operation/agentes/networkmap.php, operation/reporting/reporting_viewer.php, godmode/agentes/manage_config.php: Style correction. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1331 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-01-12 15:31:01 +01:00
function get_alert_command_description ($id_alert_command) {
$id_alert_command = safe_int ($id_alert_command, 1);
if (empty ($id_alert_command))
return false;
return get_db_value ('description', 'talert_commands', 'id', $id_alert_command);
}
function clean_alert_action_values ($values, $set_empty = true) {
$retvalues = array ();
if ($set_empty) {
$retvalues['field1'] = '';
$retvalues['field2'] = '';
$retvalues['field3'] = '';
}
if (empty ($values))
return $retvalues;
if (isset ($values['field1']))
$retvalues['field1'] = (string) $values['field1'];
if (isset ($values['field2']))
$retvalues['field2'] = (string) $values['field2'];
if (isset ($values['field3']))
$retvalues['field3'] = (string) $values['field3'];
return $retvalues;
}
function create_alert_action ($name, $id_alert_command, $values = false) {
$id_alert_command = safe_int ($id_alert_command, 1);
if (empty ($id_alert_command))
return false;
if (empty ($name))
return false;
$values = clean_alert_action_values ($values);
$sql = sprintf ('INSERT talert_actions (name, id_alert_command, field1, field2, field3)
VALUES ("%s", %d, "%s", "%s", "%s")',
$name, $id_alert_command, $values['field1'], $values['field2'],
$values['field3']);
return process_sql ($sql, 'insert_id');
}
function update_alert_action ($id_alert_action, $id_alert_command, $name, $values = false) {
$id_alert_action = safe_int ($id_alert_action, 1);
if (empty ($id_alert_action))
return false;
$id_alert_command = safe_int ($id_alert_command, 1);
if (empty ($id_alert_command))
return false;
if (empty ($name))
return false;
$values = clean_alert_action_values ($values);
$sql = sprintf ('UPDATE talert_actions SET name = "%s",
id_alert_command = %d, field1 = "%s",
field2 = "%s", field3 = "%s" WHERE id = %d',
$name, $id_alert_command, $values['field1'], $values['field2'],
$values['field3'], $id_alert_action);
return process_sql ($sql) !== false;
}
function delete_alert_action ($id_alert_action) {
$id_alert_action = safe_int ($id_alert_action, 1);
if (empty ($id_alert_action))
return false;
$sql = sprintf ('DELETE FROM talert_actions WHERE id = %d',
$id_alert_action);
return @process_sql ($sql);
2009-01-12 Esteban Sanchez <estebans@artica.es> * godmode/agentes/alert_manager.php: Complete rewritten of the alert system when assigned alerts to an agent. * pandoradb.sql: New tables for alert system. These are: talert_commands, talert_actions, talert_templates, talert_template_modules, talert_template_module_actions. No migration tool is available yet. * godmode/alerts/configure_alert_template.php, godmode/alerts/configure_alert_action.php, godmode/alerts/alert_templates.php, godmode/alerts/configure_alert_command.php, godmode/alerts/alert_actions.php: Added to repository. Administration interface to new alert system. * godmode/alerts/modify_alert.php: Deleted from repository. * godmode/setup/setup.php: Added an example of the date format. Main table has now percentage width. * godmode/menu.php, operation/menu.php: Added new alert options. Removed refr value when it's not neccesary. * include/styles/pandora.css: Added width to textarea elements. Style correction and cleanup. Tables doesn't have a odd-even pattern, but the hovered row now changes its colour. New styles for alert pages. * include/functions_custom_graphs.php: Added to repository. custom graphs functions moved here. * include/functions_incidents.php, include/functions_events.php: Moved to LGPL. Style comment corrections. * include/functions_html.php: Documentation style correction. Added print_input_file() and print_label(). * include/functions_ui.php: Doc style correction. * operation/reporting/graph_viewer.php: Include new function file with custom graphs. Use generic functions. * index.php: Unset pass from POST and REQUEST arrays. * include/functions_db.php: Some documentation updated to new format. Added format_array_to_update_sql() to generate SQL sentences for updates. Style correction. * godmode/agentes/configurar_agente.php: Variables renamed to have a meaning. * extensions/update_manager/main.php: Mark an string translatable. * extensions/update_manager/lib/libupdate_manager_client.php, godmode/alerts/configure_alert.php, include/functions.php, godmode/agentes/module_manager.php, operation/agentes/networkmap.php, operation/reporting/reporting_viewer.php, godmode/agentes/manage_config.php: Style correction. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1331 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-01-12 15:31:01 +01:00
}
function get_alert_actions ($only_names = true) {
$all_actions = get_db_all_rows_in_table ('talert_actions');
if ($all_actions === false)
return array ();
if (! $only_names)
return $all_actions;
$actions = array ();
foreach ($all_actions as $action) {
$actions[$action['id']] = $action['name'];
}
return $actions;
}
function get_alert_action ($id_alert_action) {
$id_alert_action = safe_int ($id_alert_action, 1);
if (empty ($id_alert_action))
return false;
return get_db_row ('talert_actions', 'id', $id_alert_action);
}
function get_alert_action_alert_command_id ($id_alert_action) {
return get_db_value ('id_alert_command', 'talert_actions', 'id', $id_alert_action);
}
function get_alert_action_alert_command ($id_alert_action) {
$id_command = get_alert_action_alert_command_id ($id_alert_action);
return get_alert_command ($id_command);
}
function get_alert_action_field1 ($id_alert_action) {
return get_db_value ('field1', 'talert_actions', 'id', $id_alert_action);
}
function get_alert_action_field2 ($id_alert_action) {
return get_db_value ('field2', 'talert_actions', 'id', $id_alert_action);
}
function get_alert_action_field3 ($id_alert_action) {
return get_db_value ('field3', 'talert_actions', 'id', $id_alert_action);
}
function get_alert_action_name ($id_alert_action) {
return get_db_value ('name', 'talert_actions', 'id', $id_alert_action);
}
function get_alert_templates_types () {
$types = array ();
$types['regex'] = __('Regular expression');
$types['max_min'] = __('Max and min');
$types['max'] = __('Max.');
$types['min'] = __('Min.');
2009-01-12 Esteban Sanchez <estebans@artica.es> * godmode/agentes/alert_manager.php: Complete rewritten of the alert system when assigned alerts to an agent. * pandoradb.sql: New tables for alert system. These are: talert_commands, talert_actions, talert_templates, talert_template_modules, talert_template_module_actions. No migration tool is available yet. * godmode/alerts/configure_alert_template.php, godmode/alerts/configure_alert_action.php, godmode/alerts/alert_templates.php, godmode/alerts/configure_alert_command.php, godmode/alerts/alert_actions.php: Added to repository. Administration interface to new alert system. * godmode/alerts/modify_alert.php: Deleted from repository. * godmode/setup/setup.php: Added an example of the date format. Main table has now percentage width. * godmode/menu.php, operation/menu.php: Added new alert options. Removed refr value when it's not neccesary. * include/styles/pandora.css: Added width to textarea elements. Style correction and cleanup. Tables doesn't have a odd-even pattern, but the hovered row now changes its colour. New styles for alert pages. * include/functions_custom_graphs.php: Added to repository. custom graphs functions moved here. * include/functions_incidents.php, include/functions_events.php: Moved to LGPL. Style comment corrections. * include/functions_html.php: Documentation style correction. Added print_input_file() and print_label(). * include/functions_ui.php: Doc style correction. * operation/reporting/graph_viewer.php: Include new function file with custom graphs. Use generic functions. * index.php: Unset pass from POST and REQUEST arrays. * include/functions_db.php: Some documentation updated to new format. Added format_array_to_update_sql() to generate SQL sentences for updates. Style correction. * godmode/agentes/configurar_agente.php: Variables renamed to have a meaning. * extensions/update_manager/main.php: Mark an string translatable. * extensions/update_manager/lib/libupdate_manager_client.php, godmode/alerts/configure_alert.php, include/functions.php, godmode/agentes/module_manager.php, operation/agentes/networkmap.php, operation/reporting/reporting_viewer.php, godmode/agentes/manage_config.php: Style correction. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1331 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-01-12 15:31:01 +01:00
$types['equal'] = __('Equal to');
$types['not_equal'] = __('Not equal to');
return $types;
}
function get_alert_templates_type_name ($type) {
$types = get_alert_templates_types ();
if (! isset ($type[$type]))
return __('Unknown');
return $types[$type];
}
function clean_alert_template_values ($values, $set_empty = true) {
$retvalues = array ();
if ($set_empty) {
$retvalues['type'] = 'equal';
$retvalues['description'] = '';
$retvalues['id_alert_action'] = NULL;
$retvalues['field1'] = '';
$retvalues['field2'] = '';
$retvalues['field3'] = '';
$retvalues['value'] = '';
$retvalues['max_value'] = 0;
$retvalues['min_value'] = 0;
$retvalues['time_threshold'] = 0;
$retvalues['max_alerts'] = 0;
$retvalues['min_alerts'] = 0;
$retvalues['monday'] = 0;
$retvalues['tuesday'] = 0;
$retvalues['wednesday'] = 0;
$retvalues['thursday'] = 0;
$retvalues['friday'] = 0;
$retvalues['saturday'] = 0;
$retvalues['sunday'] = 0;
$retvalues['time_from'] = '00:00';
$retvalues['time_to'] = '00:00';
$retvalues['time_threshold'] = '300';
$retvalues['recovery_notify'] = '';
$retvalues['field2_recovery'] = '';
$retvalues['field2_recovery'] = '';
$retvalues['matches_value'] = true;
2009-01-12 Esteban Sanchez <estebans@artica.es> * godmode/agentes/alert_manager.php: Complete rewritten of the alert system when assigned alerts to an agent. * pandoradb.sql: New tables for alert system. These are: talert_commands, talert_actions, talert_templates, talert_template_modules, talert_template_module_actions. No migration tool is available yet. * godmode/alerts/configure_alert_template.php, godmode/alerts/configure_alert_action.php, godmode/alerts/alert_templates.php, godmode/alerts/configure_alert_command.php, godmode/alerts/alert_actions.php: Added to repository. Administration interface to new alert system. * godmode/alerts/modify_alert.php: Deleted from repository. * godmode/setup/setup.php: Added an example of the date format. Main table has now percentage width. * godmode/menu.php, operation/menu.php: Added new alert options. Removed refr value when it's not neccesary. * include/styles/pandora.css: Added width to textarea elements. Style correction and cleanup. Tables doesn't have a odd-even pattern, but the hovered row now changes its colour. New styles for alert pages. * include/functions_custom_graphs.php: Added to repository. custom graphs functions moved here. * include/functions_incidents.php, include/functions_events.php: Moved to LGPL. Style comment corrections. * include/functions_html.php: Documentation style correction. Added print_input_file() and print_label(). * include/functions_ui.php: Doc style correction. * operation/reporting/graph_viewer.php: Include new function file with custom graphs. Use generic functions. * index.php: Unset pass from POST and REQUEST arrays. * include/functions_db.php: Some documentation updated to new format. Added format_array_to_update_sql() to generate SQL sentences for updates. Style correction. * godmode/agentes/configurar_agente.php: Variables renamed to have a meaning. * extensions/update_manager/main.php: Mark an string translatable. * extensions/update_manager/lib/libupdate_manager_client.php, godmode/alerts/configure_alert.php, include/functions.php, godmode/agentes/module_manager.php, operation/agentes/networkmap.php, operation/reporting/reporting_viewer.php, godmode/agentes/manage_config.php: Style correction. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1331 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-01-12 15:31:01 +01:00
}
if (empty ($values))
return $retvalues;
if (isset ($values['type']))
$retvalues['type'] = (string) $values['type'];
if (isset ($values['description']))
$retvalues['description'] = (string) $values['description'];
if (isset ($values['id_alert_action']))
$retvalues['id_alert_action'] = (int) $values['id_alert_action'];
if (isset ($values['field1']))
$retvalues['field1'] = (string) $values['field1'];
if (isset ($values['field2']))
$retvalues['field2'] = (string) $values['field2'];
if (isset ($values['field3']))
$retvalues['field3'] = (string) $values['field3'];
if (isset ($values['value']))
$retvalues['value'] = (string) $values['value'];
if (isset ($values['matches_value']))
$retvalues['matches_value'] = (bool) $values['matches_value'];
2009-01-12 Esteban Sanchez <estebans@artica.es> * godmode/agentes/alert_manager.php: Complete rewritten of the alert system when assigned alerts to an agent. * pandoradb.sql: New tables for alert system. These are: talert_commands, talert_actions, talert_templates, talert_template_modules, talert_template_module_actions. No migration tool is available yet. * godmode/alerts/configure_alert_template.php, godmode/alerts/configure_alert_action.php, godmode/alerts/alert_templates.php, godmode/alerts/configure_alert_command.php, godmode/alerts/alert_actions.php: Added to repository. Administration interface to new alert system. * godmode/alerts/modify_alert.php: Deleted from repository. * godmode/setup/setup.php: Added an example of the date format. Main table has now percentage width. * godmode/menu.php, operation/menu.php: Added new alert options. Removed refr value when it's not neccesary. * include/styles/pandora.css: Added width to textarea elements. Style correction and cleanup. Tables doesn't have a odd-even pattern, but the hovered row now changes its colour. New styles for alert pages. * include/functions_custom_graphs.php: Added to repository. custom graphs functions moved here. * include/functions_incidents.php, include/functions_events.php: Moved to LGPL. Style comment corrections. * include/functions_html.php: Documentation style correction. Added print_input_file() and print_label(). * include/functions_ui.php: Doc style correction. * operation/reporting/graph_viewer.php: Include new function file with custom graphs. Use generic functions. * index.php: Unset pass from POST and REQUEST arrays. * include/functions_db.php: Some documentation updated to new format. Added format_array_to_update_sql() to generate SQL sentences for updates. Style correction. * godmode/agentes/configurar_agente.php: Variables renamed to have a meaning. * extensions/update_manager/main.php: Mark an string translatable. * extensions/update_manager/lib/libupdate_manager_client.php, godmode/alerts/configure_alert.php, include/functions.php, godmode/agentes/module_manager.php, operation/agentes/networkmap.php, operation/reporting/reporting_viewer.php, godmode/agentes/manage_config.php: Style correction. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1331 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-01-12 15:31:01 +01:00
if (isset ($values['max_value']))
$retvalues['max_value'] = (float) $values['max_value'];
if (isset ($values['min_value']))
$retvalues['min_value'] = (float) $values['min_value'];
if (isset ($values['time_threshold']))
$retvalues['time_threshold'] = (int) $values['time_threshold'];
if (isset ($values['max_alerts']))
$retvalues['max_alerts'] = (int) $values['max_alerts'];
if (isset ($values['min_alerts']))
$retvalues['min_alerts'] = (int) $values['min_alerts'];
/* Ensure max an min orders */
if (isset ($values['min_alerts']) && isset ($values['max_alerts'])) {
$max = max ($retvalues['max_alerts'], $retvalues['min_alerts']);
$min = min ($retvalues['max_alerts'], $retvalues['min_alerts']);
$retvalues['max_alerts'] = $max;
$retvalues['min_alerts'] = $min;
}
2009-01-12 Esteban Sanchez <estebans@artica.es> * godmode/agentes/alert_manager.php: Complete rewritten of the alert system when assigned alerts to an agent. * pandoradb.sql: New tables for alert system. These are: talert_commands, talert_actions, talert_templates, talert_template_modules, talert_template_module_actions. No migration tool is available yet. * godmode/alerts/configure_alert_template.php, godmode/alerts/configure_alert_action.php, godmode/alerts/alert_templates.php, godmode/alerts/configure_alert_command.php, godmode/alerts/alert_actions.php: Added to repository. Administration interface to new alert system. * godmode/alerts/modify_alert.php: Deleted from repository. * godmode/setup/setup.php: Added an example of the date format. Main table has now percentage width. * godmode/menu.php, operation/menu.php: Added new alert options. Removed refr value when it's not neccesary. * include/styles/pandora.css: Added width to textarea elements. Style correction and cleanup. Tables doesn't have a odd-even pattern, but the hovered row now changes its colour. New styles for alert pages. * include/functions_custom_graphs.php: Added to repository. custom graphs functions moved here. * include/functions_incidents.php, include/functions_events.php: Moved to LGPL. Style comment corrections. * include/functions_html.php: Documentation style correction. Added print_input_file() and print_label(). * include/functions_ui.php: Doc style correction. * operation/reporting/graph_viewer.php: Include new function file with custom graphs. Use generic functions. * index.php: Unset pass from POST and REQUEST arrays. * include/functions_db.php: Some documentation updated to new format. Added format_array_to_update_sql() to generate SQL sentences for updates. Style correction. * godmode/agentes/configurar_agente.php: Variables renamed to have a meaning. * extensions/update_manager/main.php: Mark an string translatable. * extensions/update_manager/lib/libupdate_manager_client.php, godmode/alerts/configure_alert.php, include/functions.php, godmode/agentes/module_manager.php, operation/agentes/networkmap.php, operation/reporting/reporting_viewer.php, godmode/agentes/manage_config.php: Style correction. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1331 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-01-12 15:31:01 +01:00
if (isset ($values['monday']))
$retvalues['monday'] = (bool) $values['monday'];
if (isset ($values['tuesday']))
$retvalues['tuesday'] = (bool) $values['tuesday'];
if (isset ($values['wednesday']))
$retvalues['wednesday'] = (bool) $values['wednesday'];
if (isset ($values['thursday']))
$retvalues['thursday'] = (bool) $values['thursday'];
if (isset ($values['friday']))
$retvalues['friday'] = (bool) $values['friday'];
if (isset ($values['saturday']))
$retvalues['saturday'] = (bool) $values['saturday'];
if (isset ($values['sunday']))
$retvalues['sunday'] = (bool) $values['sunday'];
if (isset ($values['time_from']))
$retvalues['time_from'] = (string) $values['time_from'];
if (isset ($values['time_to']))
$retvalues['time_to'] = (string) $values['time_to'];
if (isset ($values['time_threshold']))
$retvalues['time_threshold'] = (int) $values['time_threshold'];
if (isset ($values['recovery_notify']))
$retvalues['recovery_notify'] = (bool) $values['recovery_notify'];
if (isset ($values['field2_recovery']))
$retvalues['field2_recovery'] = (string) $values['field2_recovery'];
if (isset ($values['field3_recovery']))
$retvalues['field3_recovery'] = (string) $values['field3_recovery'];
return $retvalues;
}
function create_alert_template ($name, $type, $values = false) {
if (empty ($name))
return false;
if (empty ($type))
return false;
$values = clean_alert_template_values ($values);
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)
2009-01-12 Esteban Sanchez <estebans@artica.es> * godmode/agentes/alert_manager.php: Complete rewritten of the alert system when assigned alerts to an agent. * pandoradb.sql: New tables for alert system. These are: talert_commands, talert_actions, talert_templates, talert_template_modules, talert_template_module_actions. No migration tool is available yet. * godmode/alerts/configure_alert_template.php, godmode/alerts/configure_alert_action.php, godmode/alerts/alert_templates.php, godmode/alerts/configure_alert_command.php, godmode/alerts/alert_actions.php: Added to repository. Administration interface to new alert system. * godmode/alerts/modify_alert.php: Deleted from repository. * godmode/setup/setup.php: Added an example of the date format. Main table has now percentage width. * godmode/menu.php, operation/menu.php: Added new alert options. Removed refr value when it's not neccesary. * include/styles/pandora.css: Added width to textarea elements. Style correction and cleanup. Tables doesn't have a odd-even pattern, but the hovered row now changes its colour. New styles for alert pages. * include/functions_custom_graphs.php: Added to repository. custom graphs functions moved here. * include/functions_incidents.php, include/functions_events.php: Moved to LGPL. Style comment corrections. * include/functions_html.php: Documentation style correction. Added print_input_file() and print_label(). * include/functions_ui.php: Doc style correction. * operation/reporting/graph_viewer.php: Include new function file with custom graphs. Use generic functions. * index.php: Unset pass from POST and REQUEST arrays. * include/functions_db.php: Some documentation updated to new format. Added format_array_to_update_sql() to generate SQL sentences for updates. Style correction. * godmode/agentes/configurar_agente.php: Variables renamed to have a meaning. * extensions/update_manager/main.php: Mark an string translatable. * extensions/update_manager/lib/libupdate_manager_client.php, godmode/alerts/configure_alert.php, include/functions.php, godmode/agentes/module_manager.php, operation/agentes/networkmap.php, operation/reporting/reporting_viewer.php, godmode/agentes/manage_config.php: Style correction. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1331 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-01-12 15:31:01 +01:00
VALUES ("%s", "%s", "%s", "%s", "%s", "%s", "%s", %.2f,
%.2f, %d, %d, %d, %d)',
2009-01-12 Esteban Sanchez <estebans@artica.es> * godmode/agentes/alert_manager.php: Complete rewritten of the alert system when assigned alerts to an agent. * pandoradb.sql: New tables for alert system. These are: talert_commands, talert_actions, talert_templates, talert_template_modules, talert_template_module_actions. No migration tool is available yet. * godmode/alerts/configure_alert_template.php, godmode/alerts/configure_alert_action.php, godmode/alerts/alert_templates.php, godmode/alerts/configure_alert_command.php, godmode/alerts/alert_actions.php: Added to repository. Administration interface to new alert system. * godmode/alerts/modify_alert.php: Deleted from repository. * godmode/setup/setup.php: Added an example of the date format. Main table has now percentage width. * godmode/menu.php, operation/menu.php: Added new alert options. Removed refr value when it's not neccesary. * include/styles/pandora.css: Added width to textarea elements. Style correction and cleanup. Tables doesn't have a odd-even pattern, but the hovered row now changes its colour. New styles for alert pages. * include/functions_custom_graphs.php: Added to repository. custom graphs functions moved here. * include/functions_incidents.php, include/functions_events.php: Moved to LGPL. Style comment corrections. * include/functions_html.php: Documentation style correction. Added print_input_file() and print_label(). * include/functions_ui.php: Doc style correction. * operation/reporting/graph_viewer.php: Include new function file with custom graphs. Use generic functions. * index.php: Unset pass from POST and REQUEST arrays. * include/functions_db.php: Some documentation updated to new format. Added format_array_to_update_sql() to generate SQL sentences for updates. Style correction. * godmode/agentes/configurar_agente.php: Variables renamed to have a meaning. * extensions/update_manager/main.php: Mark an string translatable. * extensions/update_manager/lib/libupdate_manager_client.php, godmode/alerts/configure_alert.php, include/functions.php, godmode/agentes/module_manager.php, operation/agentes/networkmap.php, operation/reporting/reporting_viewer.php, godmode/agentes/manage_config.php: Style correction. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1331 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-01-12 15:31:01 +01:00
$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']);
2009-01-12 Esteban Sanchez <estebans@artica.es> * godmode/agentes/alert_manager.php: Complete rewritten of the alert system when assigned alerts to an agent. * pandoradb.sql: New tables for alert system. These are: talert_commands, talert_actions, talert_templates, talert_template_modules, talert_template_module_actions. No migration tool is available yet. * godmode/alerts/configure_alert_template.php, godmode/alerts/configure_alert_action.php, godmode/alerts/alert_templates.php, godmode/alerts/configure_alert_command.php, godmode/alerts/alert_actions.php: Added to repository. Administration interface to new alert system. * godmode/alerts/modify_alert.php: Deleted from repository. * godmode/setup/setup.php: Added an example of the date format. Main table has now percentage width. * godmode/menu.php, operation/menu.php: Added new alert options. Removed refr value when it's not neccesary. * include/styles/pandora.css: Added width to textarea elements. Style correction and cleanup. Tables doesn't have a odd-even pattern, but the hovered row now changes its colour. New styles for alert pages. * include/functions_custom_graphs.php: Added to repository. custom graphs functions moved here. * include/functions_incidents.php, include/functions_events.php: Moved to LGPL. Style comment corrections. * include/functions_html.php: Documentation style correction. Added print_input_file() and print_label(). * include/functions_ui.php: Doc style correction. * operation/reporting/graph_viewer.php: Include new function file with custom graphs. Use generic functions. * index.php: Unset pass from POST and REQUEST arrays. * include/functions_db.php: Some documentation updated to new format. Added format_array_to_update_sql() to generate SQL sentences for updates. Style correction. * godmode/agentes/configurar_agente.php: Variables renamed to have a meaning. * extensions/update_manager/main.php: Mark an string translatable. * extensions/update_manager/lib/libupdate_manager_client.php, godmode/alerts/configure_alert.php, include/functions.php, godmode/agentes/module_manager.php, operation/agentes/networkmap.php, operation/reporting/reporting_viewer.php, godmode/agentes/manage_config.php: Style correction. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1331 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-01-12 15:31:01 +01:00
return process_sql ($sql, 'insert_id');
}
function update_alert_template ($id_alert_template, $values = false) {
$id_alert_template = safe_int ($id_alert_template, 1);
if (empty ($id_alert_template))
return 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);
2009-01-12 Esteban Sanchez <estebans@artica.es> * godmode/agentes/alert_manager.php: Complete rewritten of the alert system when assigned alerts to an agent. * pandoradb.sql: New tables for alert system. These are: talert_commands, talert_actions, talert_templates, talert_template_modules, talert_template_module_actions. No migration tool is available yet. * godmode/alerts/configure_alert_template.php, godmode/alerts/configure_alert_action.php, godmode/alerts/alert_templates.php, godmode/alerts/configure_alert_command.php, godmode/alerts/alert_actions.php: Added to repository. Administration interface to new alert system. * godmode/alerts/modify_alert.php: Deleted from repository. * godmode/setup/setup.php: Added an example of the date format. Main table has now percentage width. * godmode/menu.php, operation/menu.php: Added new alert options. Removed refr value when it's not neccesary. * include/styles/pandora.css: Added width to textarea elements. Style correction and cleanup. Tables doesn't have a odd-even pattern, but the hovered row now changes its colour. New styles for alert pages. * include/functions_custom_graphs.php: Added to repository. custom graphs functions moved here. * include/functions_incidents.php, include/functions_events.php: Moved to LGPL. Style comment corrections. * include/functions_html.php: Documentation style correction. Added print_input_file() and print_label(). * include/functions_ui.php: Doc style correction. * operation/reporting/graph_viewer.php: Include new function file with custom graphs. Use generic functions. * index.php: Unset pass from POST and REQUEST arrays. * include/functions_db.php: Some documentation updated to new format. Added format_array_to_update_sql() to generate SQL sentences for updates. Style correction. * godmode/agentes/configurar_agente.php: Variables renamed to have a meaning. * extensions/update_manager/main.php: Mark an string translatable. * extensions/update_manager/lib/libupdate_manager_client.php, godmode/alerts/configure_alert.php, include/functions.php, godmode/agentes/module_manager.php, operation/agentes/networkmap.php, operation/reporting/reporting_viewer.php, godmode/agentes/manage_config.php: Style correction. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1331 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-01-12 15:31:01 +01:00
return process_sql ($sql) !== false;
}
function delete_alert_template ($id_alert_template) {
$id_alert_template = safe_int ($id_alert_template, 1);
if (empty ($id_alert_template))
return false;
$sql = sprintf ('DELETE FROM talert_templates WHERE id = %d',
$id_alert_template);
return @process_sql ($sql);
2009-01-12 Esteban Sanchez <estebans@artica.es> * godmode/agentes/alert_manager.php: Complete rewritten of the alert system when assigned alerts to an agent. * pandoradb.sql: New tables for alert system. These are: talert_commands, talert_actions, talert_templates, talert_template_modules, talert_template_module_actions. No migration tool is available yet. * godmode/alerts/configure_alert_template.php, godmode/alerts/configure_alert_action.php, godmode/alerts/alert_templates.php, godmode/alerts/configure_alert_command.php, godmode/alerts/alert_actions.php: Added to repository. Administration interface to new alert system. * godmode/alerts/modify_alert.php: Deleted from repository. * godmode/setup/setup.php: Added an example of the date format. Main table has now percentage width. * godmode/menu.php, operation/menu.php: Added new alert options. Removed refr value when it's not neccesary. * include/styles/pandora.css: Added width to textarea elements. Style correction and cleanup. Tables doesn't have a odd-even pattern, but the hovered row now changes its colour. New styles for alert pages. * include/functions_custom_graphs.php: Added to repository. custom graphs functions moved here. * include/functions_incidents.php, include/functions_events.php: Moved to LGPL. Style comment corrections. * include/functions_html.php: Documentation style correction. Added print_input_file() and print_label(). * include/functions_ui.php: Doc style correction. * operation/reporting/graph_viewer.php: Include new function file with custom graphs. Use generic functions. * index.php: Unset pass from POST and REQUEST arrays. * include/functions_db.php: Some documentation updated to new format. Added format_array_to_update_sql() to generate SQL sentences for updates. Style correction. * godmode/agentes/configurar_agente.php: Variables renamed to have a meaning. * extensions/update_manager/main.php: Mark an string translatable. * extensions/update_manager/lib/libupdate_manager_client.php, godmode/alerts/configure_alert.php, include/functions.php, godmode/agentes/module_manager.php, operation/agentes/networkmap.php, operation/reporting/reporting_viewer.php, godmode/agentes/manage_config.php: Style correction. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1331 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-01-12 15:31:01 +01:00
}
function get_alert_templates ($only_names = true) {
$all_templates = get_db_all_rows_in_table ('talert_templates');
if ($all_templates === false)
return array ();
if (! $only_names)
return $all_templates;
$templates = array ();
foreach ($all_templates as $template) {
$templates[$template['id']] = $template['name'];
}
return $templates;
}
function get_alert_template ($id_alert_template) {
$id_alert_template = safe_int ($id_alert_template, 1);
if (empty ($id_alert_template))
return false;
return get_db_row ('talert_templates', 'id', $id_alert_template);
}
function get_alert_template_field1 ($id_alert_template) {
return get_db_value ('field1', 'talert_templates', 'id', $id_alert_template);
}
function get_alert_template_field2 ($id_alert_template) {
return get_db_value ('field2', 'talert_templates', 'id', $id_alert_template);
}
function get_alert_template_field3 ($id_alert_template) {
return get_db_value ('field3', 'talert_templates', 'id', $id_alert_template);
}
function get_alert_template_name ($id_alert_template) {
return get_db_value ('name', 'talert_templates', 'id', $id_alert_template);
}
function get_alert_template_description ($id_alert_template) {
return get_db_value ('description', 'talert_templates', 'id', $id_alert_template);
}
function get_alert_template_type ($id_alert_template) {
return get_db_value ('type', 'talert_templates', 'id', $id_alert_template);
}
function get_alert_template_type_name ($id_alert_template) {
$type = get_alert_template_type ($id_alert_template);
return get_alert_templates_type_name ($type);
}
function get_alert_template_value ($id_alert_template) {
return get_db_value ('value', 'talert_templates', 'id', $id_alert_template);
}
function get_alert_template_max_value ($id_alert_template) {
return get_db_value ('max_value', 'talert_templates', 'id', $id_alert_template);
}
function get_alert_template_min_value ($id_alert_template) {
return get_db_value ('min_value', 'talert_templates', 'id', $id_alert_template);
}
function get_alert_template_alert_text ($id_alert_template) {
return get_db_value ('alert_text', 'talert_templates', 'id', $id_alert_template);
}
function get_alert_template_time_from ($id_alert_template) {
return get_db_value ('time_from', 'talert_templates', 'id', $id_alert_template);
}
function get_alert_template_time_to ($id_alert_template) {
return get_db_value ('time_from', 'talert_templates', 'id', $id_alert_template);
}
function get_alert_template_weekdays ($id_alert_template) {
$alert = get_alert_template ($id_alert_template);
if ($alert === false)
return false;
$retval = array ();
$days = array ('monday', 'tuesday', 'wednesday', 'thursday', 'friday',
'saturday', 'sunday');
foreach ($days as $day)
$retval[$day] = (bool) $alert[$day];
return $retval;
}
function get_alert_template_recovery_notify ($id_alert_template) {
return get_db_value ('recovery_notify', 'talert_templates', 'id', $id_alert_template);
}
function get_alert_template_field2_recovery ($id_alert_template) {
return get_db_value ('field2_recovery', 'talert_templates', 'id', $id_alert_template);
}
function get_alert_template_field3_recovery ($id_alert_template) {
return get_db_value ('field3_recovery', 'talert_templates', 'id', $id_alert_template);
}
function get_alert_template_threshold_values () {
$times = array ();
$times['300'] = '5 '.__('minutes');
$times['600'] = '10 '.__('minutes');
$times['900'] = '15 '.__('minutes');
$times['1800'] = '30 '.__('minutes');
$times['3600'] = '1 '.__('hour');
$times['7200'] = '2 '.__('hours');
$times['18000'] = '5 '.__('hours');
$times['43200'] = '12 '.__('hours');
$times['86400'] = '1 '.__('day');
$times['604800'] = '1 '.__('week');
$times['-1'] = __('Other value');
return $times;
}
function clean_alert_agent_module_values ($values, $set_empty = true) {
$retvalues = array ();
if ($set_empty) {
$retvalues['internal_counter'] = 0;
$retvalues['last_fired'] = 0;
$retvalues['times_fired'] = 0;
$retvalues['disabled'] = 0;
$retvalues['priority'] = 0;
$retvalues['force_execution'] = 0;
}
if (empty ($values))
return $retvalues;
if (isset ($values['internal_counter']))
$retvalues['internal_counter'] = (int) $values['internal_counter'];
if (isset ($values['last_fired']))
$retvalues['last_fired'] = (int) $values['last_fired'];
if (isset ($values['times_fired']))
$retvalues['times_fired'] = (int) $values['times_fired'];
if (isset ($values['disabled']))
$retvalues['disabled'] = (int) $values['disabled'];
if (isset ($values['priority']))
$retvalues['priority'] = (int) $values['priority'];
if (isset ($values['force_execution']))
$retvalues['force_execution'] = (int) $values['force_execution'];
return $retvalues;
}
function create_alert_agent_module ($id_agent_module, $id_alert_template, $values = false) {
if (empty ($id_agent_module))
return false;
if (empty ($id_alert_template))
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');
}
function update_alert_agent_module ($id_alert_agent_module, $values = false) {
if (empty ($id_agent_module))
return false;
$values = clean_alert_agent_module_values ($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;
}
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;
}
2009-01-12 Esteban Sanchez <estebans@artica.es> * godmode/agentes/alert_manager.php: Complete rewritten of the alert system when assigned alerts to an agent. * pandoradb.sql: New tables for alert system. These are: talert_commands, talert_actions, talert_templates, talert_template_modules, talert_template_module_actions. No migration tool is available yet. * godmode/alerts/configure_alert_template.php, godmode/alerts/configure_alert_action.php, godmode/alerts/alert_templates.php, godmode/alerts/configure_alert_command.php, godmode/alerts/alert_actions.php: Added to repository. Administration interface to new alert system. * godmode/alerts/modify_alert.php: Deleted from repository. * godmode/setup/setup.php: Added an example of the date format. Main table has now percentage width. * godmode/menu.php, operation/menu.php: Added new alert options. Removed refr value when it's not neccesary. * include/styles/pandora.css: Added width to textarea elements. Style correction and cleanup. Tables doesn't have a odd-even pattern, but the hovered row now changes its colour. New styles for alert pages. * include/functions_custom_graphs.php: Added to repository. custom graphs functions moved here. * include/functions_incidents.php, include/functions_events.php: Moved to LGPL. Style comment corrections. * include/functions_html.php: Documentation style correction. Added print_input_file() and print_label(). * include/functions_ui.php: Doc style correction. * operation/reporting/graph_viewer.php: Include new function file with custom graphs. Use generic functions. * index.php: Unset pass from POST and REQUEST arrays. * include/functions_db.php: Some documentation updated to new format. Added format_array_to_update_sql() to generate SQL sentences for updates. Style correction. * godmode/agentes/configurar_agente.php: Variables renamed to have a meaning. * extensions/update_manager/main.php: Mark an string translatable. * extensions/update_manager/lib/libupdate_manager_client.php, godmode/alerts/configure_alert.php, include/functions.php, godmode/agentes/module_manager.php, operation/agentes/networkmap.php, operation/reporting/reporting_viewer.php, godmode/agentes/manage_config.php: Style correction. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1331 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-01-12 15:31:01 +01:00
function get_alert_agent_module ($id_alert_agent_module) {
$id_alert_agent_module = safe_int ($id_alert_agent_module, 0);
2009-01-12 Esteban Sanchez <estebans@artica.es> * godmode/agentes/alert_manager.php: Complete rewritten of the alert system when assigned alerts to an agent. * pandoradb.sql: New tables for alert system. These are: talert_commands, talert_actions, talert_templates, talert_template_modules, talert_template_module_actions. No migration tool is available yet. * godmode/alerts/configure_alert_template.php, godmode/alerts/configure_alert_action.php, godmode/alerts/alert_templates.php, godmode/alerts/configure_alert_command.php, godmode/alerts/alert_actions.php: Added to repository. Administration interface to new alert system. * godmode/alerts/modify_alert.php: Deleted from repository. * godmode/setup/setup.php: Added an example of the date format. Main table has now percentage width. * godmode/menu.php, operation/menu.php: Added new alert options. Removed refr value when it's not neccesary. * include/styles/pandora.css: Added width to textarea elements. Style correction and cleanup. Tables doesn't have a odd-even pattern, but the hovered row now changes its colour. New styles for alert pages. * include/functions_custom_graphs.php: Added to repository. custom graphs functions moved here. * include/functions_incidents.php, include/functions_events.php: Moved to LGPL. Style comment corrections. * include/functions_html.php: Documentation style correction. Added print_input_file() and print_label(). * include/functions_ui.php: Doc style correction. * operation/reporting/graph_viewer.php: Include new function file with custom graphs. Use generic functions. * index.php: Unset pass from POST and REQUEST arrays. * include/functions_db.php: Some documentation updated to new format. Added format_array_to_update_sql() to generate SQL sentences for updates. Style correction. * godmode/agentes/configurar_agente.php: Variables renamed to have a meaning. * extensions/update_manager/main.php: Mark an string translatable. * extensions/update_manager/lib/libupdate_manager_client.php, godmode/alerts/configure_alert.php, include/functions.php, godmode/agentes/module_manager.php, operation/agentes/networkmap.php, operation/reporting/reporting_viewer.php, godmode/agentes/manage_config.php: Style correction. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1331 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-01-12 15:31:01 +01:00
if (empty ($id_alert_agent_module))
return false;
return get_db_row ('talert_template_modules', 'id', $id_alert_agent_module);
}
function get_alerts_agent_module ($id_agent_module, $disabled = false) {
$id_alert_agent_module = safe_int ($id_agent_module, 0);
$filter = '';
if (! $disabled)
$filter .= 'AND disabled = 0';
2009-01-12 Esteban Sanchez <estebans@artica.es> * godmode/agentes/alert_manager.php: Complete rewritten of the alert system when assigned alerts to an agent. * pandoradb.sql: New tables for alert system. These are: talert_commands, talert_actions, talert_templates, talert_template_modules, talert_template_module_actions. No migration tool is available yet. * godmode/alerts/configure_alert_template.php, godmode/alerts/configure_alert_action.php, godmode/alerts/alert_templates.php, godmode/alerts/configure_alert_command.php, godmode/alerts/alert_actions.php: Added to repository. Administration interface to new alert system. * godmode/alerts/modify_alert.php: Deleted from repository. * godmode/setup/setup.php: Added an example of the date format. Main table has now percentage width. * godmode/menu.php, operation/menu.php: Added new alert options. Removed refr value when it's not neccesary. * include/styles/pandora.css: Added width to textarea elements. Style correction and cleanup. Tables doesn't have a odd-even pattern, but the hovered row now changes its colour. New styles for alert pages. * include/functions_custom_graphs.php: Added to repository. custom graphs functions moved here. * include/functions_incidents.php, include/functions_events.php: Moved to LGPL. Style comment corrections. * include/functions_html.php: Documentation style correction. Added print_input_file() and print_label(). * include/functions_ui.php: Doc style correction. * operation/reporting/graph_viewer.php: Include new function file with custom graphs. Use generic functions. * index.php: Unset pass from POST and REQUEST arrays. * include/functions_db.php: Some documentation updated to new format. Added format_array_to_update_sql() to generate SQL sentences for updates. Style correction. * godmode/agentes/configurar_agente.php: Variables renamed to have a meaning. * extensions/update_manager/main.php: Mark an string translatable. * extensions/update_manager/lib/libupdate_manager_client.php, godmode/alerts/configure_alert.php, include/functions.php, godmode/agentes/module_manager.php, operation/agentes/networkmap.php, operation/reporting/reporting_viewer.php, godmode/agentes/manage_config.php: Style correction. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1331 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-01-12 15:31:01 +01:00
$sql = sprintf ('SELECT * FROM talert_template_modules
WHERE id_agent_module = %d %s',
$id_agent_module, $filter);
2009-01-12 Esteban Sanchez <estebans@artica.es> * godmode/agentes/alert_manager.php: Complete rewritten of the alert system when assigned alerts to an agent. * pandoradb.sql: New tables for alert system. These are: talert_commands, talert_actions, talert_templates, talert_template_modules, talert_template_module_actions. No migration tool is available yet. * godmode/alerts/configure_alert_template.php, godmode/alerts/configure_alert_action.php, godmode/alerts/alert_templates.php, godmode/alerts/configure_alert_command.php, godmode/alerts/alert_actions.php: Added to repository. Administration interface to new alert system. * godmode/alerts/modify_alert.php: Deleted from repository. * godmode/setup/setup.php: Added an example of the date format. Main table has now percentage width. * godmode/menu.php, operation/menu.php: Added new alert options. Removed refr value when it's not neccesary. * include/styles/pandora.css: Added width to textarea elements. Style correction and cleanup. Tables doesn't have a odd-even pattern, but the hovered row now changes its colour. New styles for alert pages. * include/functions_custom_graphs.php: Added to repository. custom graphs functions moved here. * include/functions_incidents.php, include/functions_events.php: Moved to LGPL. Style comment corrections. * include/functions_html.php: Documentation style correction. Added print_input_file() and print_label(). * include/functions_ui.php: Doc style correction. * operation/reporting/graph_viewer.php: Include new function file with custom graphs. Use generic functions. * index.php: Unset pass from POST and REQUEST arrays. * include/functions_db.php: Some documentation updated to new format. Added format_array_to_update_sql() to generate SQL sentences for updates. Style correction. * godmode/agentes/configurar_agente.php: Variables renamed to have a meaning. * extensions/update_manager/main.php: Mark an string translatable. * extensions/update_manager/lib/libupdate_manager_client.php, godmode/alerts/configure_alert.php, include/functions.php, godmode/agentes/module_manager.php, operation/agentes/networkmap.php, operation/reporting/reporting_viewer.php, godmode/agentes/manage_config.php: Style correction. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1331 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-01-12 15:31:01 +01:00
return get_db_all_rows_sql ($sql);
}
function get_alert_agent_module_disabled ($id_alert_agent_module) {
$id_alert_agent_module = safe_int ($id_alert_agent_module, 0);
2009-01-15 Esteban Sanchez <estebans@artica.es> * include/styles/menu.css: Changed the z-index property of the menu which was overlapped in some cases. * include/functions.php: format_alert_row() moved to functions_ui.php * include/functions_ui.php: Added format_alert_row() from function.php * include/functions_agents.php: Added to repository. * include/functions_alerts.php: Added new functions get_alerts_agent_module_disabled(), set_alerts_agent_module_force_execution(), get_alerts_agent_module_last_fired(). * include/functions_db.php, operation/agentes/estado_agente.php, operation/agentes/networkmap.php: Style correction. * include/functions_reporting.php: Use new functions_agent.php. Added a bit of documentation and style correction. * godmode/alerts/alert_templates.php: Improved a bit the template tooltip. * operation/agentes/alerts_status.php: Added to repository. New interface to list agent alerts. * operation/agentes/estado_alertas.php: Removed from repository. Replaced by alert_status.php. * operation/agentes/ver_agente.php: Removed flag_alert code snippet. Use new files added. Style correction. * operation/menu.php: Old files references replaced by new ones. * index.php: Removed build and pandora version references. * pandoradb.sql: Removed useless module_type field in talert_templates. * pandoradb_migrate_20_to_21.sql: Removed duplicate fields addition. Fixed some warnings. Added custom_id field to tagente. Style correction. * include/config_process.php: Updated build version. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1344 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-01-15 11:21:38 +01:00
return get_db_value ('disabled', 'talert_template_modules', 'id',
$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);
2009-01-15 Esteban Sanchez <estebans@artica.es> * include/styles/menu.css: Changed the z-index property of the menu which was overlapped in some cases. * include/functions.php: format_alert_row() moved to functions_ui.php * include/functions_ui.php: Added format_alert_row() from function.php * include/functions_agents.php: Added to repository. * include/functions_alerts.php: Added new functions get_alerts_agent_module_disabled(), set_alerts_agent_module_force_execution(), get_alerts_agent_module_last_fired(). * include/functions_db.php, operation/agentes/estado_agente.php, operation/agentes/networkmap.php: Style correction. * include/functions_reporting.php: Use new functions_agent.php. Added a bit of documentation and style correction. * godmode/alerts/alert_templates.php: Improved a bit the template tooltip. * operation/agentes/alerts_status.php: Added to repository. New interface to list agent alerts. * operation/agentes/estado_alertas.php: Removed from repository. Replaced by alert_status.php. * operation/agentes/ver_agente.php: Removed flag_alert code snippet. Use new files added. Style correction. * operation/menu.php: Old files references replaced by new ones. * index.php: Removed build and pandora version references. * pandoradb.sql: Removed useless module_type field in talert_templates. * pandoradb_migrate_20_to_21.sql: Removed duplicate fields addition. Fixed some warnings. Added custom_id field to tagente. Style correction. * include/config_process.php: Updated build version. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1344 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-01-15 11:21:38 +01:00
$sql = sprintf ('UPDATE talert_template_modules
SET force_execution = 1
WHERE id = %d',
$id_alert_agent_module);
return process_sql ($sql) !== 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;
}
2009-01-15 Esteban Sanchez <estebans@artica.es> * include/styles/menu.css: Changed the z-index property of the menu which was overlapped in some cases. * include/functions.php: format_alert_row() moved to functions_ui.php * include/functions_ui.php: Added format_alert_row() from function.php * include/functions_agents.php: Added to repository. * include/functions_alerts.php: Added new functions get_alerts_agent_module_disabled(), set_alerts_agent_module_force_execution(), get_alerts_agent_module_last_fired(). * include/functions_db.php, operation/agentes/estado_agente.php, operation/agentes/networkmap.php: Style correction. * include/functions_reporting.php: Use new functions_agent.php. Added a bit of documentation and style correction. * godmode/alerts/alert_templates.php: Improved a bit the template tooltip. * operation/agentes/alerts_status.php: Added to repository. New interface to list agent alerts. * operation/agentes/estado_alertas.php: Removed from repository. Replaced by alert_status.php. * operation/agentes/ver_agente.php: Removed flag_alert code snippet. Use new files added. Style correction. * operation/menu.php: Old files references replaced by new ones. * index.php: Removed build and pandora version references. * pandoradb.sql: Removed useless module_type field in talert_templates. * pandoradb_migrate_20_to_21.sql: Removed duplicate fields addition. Fixed some warnings. Added custom_id field to tagente. Style correction. * include/config_process.php: Updated build version. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1344 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-01-15 11:21:38 +01:00
function get_alerts_agent_module_last_fired ($id_alert_agent_module) {
$id_alert_agent_module = safe_int ($id_alert_agent_module, 1);
return get_db_value ('last_fired', 'talert_template_modules', 'id',
$id_alert_agent_module);
}
2009-01-12 Esteban Sanchez <estebans@artica.es> * godmode/agentes/alert_manager.php: Complete rewritten of the alert system when assigned alerts to an agent. * pandoradb.sql: New tables for alert system. These are: talert_commands, talert_actions, talert_templates, talert_template_modules, talert_template_module_actions. No migration tool is available yet. * godmode/alerts/configure_alert_template.php, godmode/alerts/configure_alert_action.php, godmode/alerts/alert_templates.php, godmode/alerts/configure_alert_command.php, godmode/alerts/alert_actions.php: Added to repository. Administration interface to new alert system. * godmode/alerts/modify_alert.php: Deleted from repository. * godmode/setup/setup.php: Added an example of the date format. Main table has now percentage width. * godmode/menu.php, operation/menu.php: Added new alert options. Removed refr value when it's not neccesary. * include/styles/pandora.css: Added width to textarea elements. Style correction and cleanup. Tables doesn't have a odd-even pattern, but the hovered row now changes its colour. New styles for alert pages. * include/functions_custom_graphs.php: Added to repository. custom graphs functions moved here. * include/functions_incidents.php, include/functions_events.php: Moved to LGPL. Style comment corrections. * include/functions_html.php: Documentation style correction. Added print_input_file() and print_label(). * include/functions_ui.php: Doc style correction. * operation/reporting/graph_viewer.php: Include new function file with custom graphs. Use generic functions. * index.php: Unset pass from POST and REQUEST arrays. * include/functions_db.php: Some documentation updated to new format. Added format_array_to_update_sql() to generate SQL sentences for updates. Style correction. * godmode/agentes/configurar_agente.php: Variables renamed to have a meaning. * extensions/update_manager/main.php: Mark an string translatable. * extensions/update_manager/lib/libupdate_manager_client.php, godmode/alerts/configure_alert.php, include/functions.php, godmode/agentes/module_manager.php, operation/agentes/networkmap.php, operation/reporting/reporting_viewer.php, godmode/agentes/manage_config.php: Style correction. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1331 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-01-12 15:31:01 +01:00
function add_alert_agent_module_action ($id_alert_agent_module, $id_alert_action, $options = false) {
if (empty ($id_alert_agent_module))
return false;
if (empty ($id_alert_action))
return false;
$fires_max = 0;
$fires_min = 0;
if ($options) {
$max = 0;
$min = 0;
if (isset ($options['fires_max']))
$max = (int) $options['fires_max'];
if (isset ($options['fires_min']))
$min = (int) $options['fires_min'];
$fires_max = max ($max, $min);
$fires_min = min ($max, $min);
}
$sql = sprintf ('INSERT INTO talert_template_module_actions
VALUES (%d, %d, %d, %d)',
$id_alert_agent_module, $id_alert_action, $fires_min, $fires_max);
return process_sql ($sql) !== false;
}
function delete_alert_agent_module_action ($id_alert_agent_module, $id_alert_action) {
if (empty ($id_alert_agent_module))
return false;
if (empty ($id_alert_action))
return false;
$sql = sprintf ('DELETE FROM talert_template_module_actions
WHERE id_alert_template_module = %d
AND id_alert_action = %d',
$id_alert_agent_module, $id_alert_action);
return process_sql ($sql) !== false;
}
2009-01-12 Esteban Sanchez <estebans@artica.es> * godmode/agentes/alert_manager.php: Complete rewritten of the alert system when assigned alerts to an agent. * pandoradb.sql: New tables for alert system. These are: talert_commands, talert_actions, talert_templates, talert_template_modules, talert_template_module_actions. No migration tool is available yet. * godmode/alerts/configure_alert_template.php, godmode/alerts/configure_alert_action.php, godmode/alerts/alert_templates.php, godmode/alerts/configure_alert_command.php, godmode/alerts/alert_actions.php: Added to repository. Administration interface to new alert system. * godmode/alerts/modify_alert.php: Deleted from repository. * godmode/setup/setup.php: Added an example of the date format. Main table has now percentage width. * godmode/menu.php, operation/menu.php: Added new alert options. Removed refr value when it's not neccesary. * include/styles/pandora.css: Added width to textarea elements. Style correction and cleanup. Tables doesn't have a odd-even pattern, but the hovered row now changes its colour. New styles for alert pages. * include/functions_custom_graphs.php: Added to repository. custom graphs functions moved here. * include/functions_incidents.php, include/functions_events.php: Moved to LGPL. Style comment corrections. * include/functions_html.php: Documentation style correction. Added print_input_file() and print_label(). * include/functions_ui.php: Doc style correction. * operation/reporting/graph_viewer.php: Include new function file with custom graphs. Use generic functions. * index.php: Unset pass from POST and REQUEST arrays. * include/functions_db.php: Some documentation updated to new format. Added format_array_to_update_sql() to generate SQL sentences for updates. Style correction. * godmode/agentes/configurar_agente.php: Variables renamed to have a meaning. * extensions/update_manager/main.php: Mark an string translatable. * extensions/update_manager/lib/libupdate_manager_client.php, godmode/alerts/configure_alert.php, include/functions.php, godmode/agentes/module_manager.php, operation/agentes/networkmap.php, operation/reporting/reporting_viewer.php, godmode/agentes/manage_config.php: Style correction. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1331 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-01-12 15:31:01 +01:00
function get_alert_agent_module_actions ($id_alert_agent_module) {
if (empty ($id_alert_agent_module))
return false;
$sql = sprintf ('SELECT id_alert_action id, 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);
if ($actions === false)
return array ();
$retval = array ();
foreach ($actions as $element) {
$action = get_alert_action ($element['id']);
$action['fires_min'] = $element['fires_min'];
$action['fires_max'] = $element['fires_max'];
array_push ($retval, $action);
}
return $retval;
}
/**
* Validates an alert id or an array of alert id's
*
* @param mixed Array of alerts ids or single id
*
* @return bool True if it was successful, false otherwise.
*/
function validate_alert_agent_module ($id_alert_agent_module) {
global $config;
require_once ("include/functions_events.php");
$alerts = safe_int ($id_alert_agent_module, 1);
if (empty ($alerts)) {
return false;
}
$alerts = (array) $alerts;
foreach ($alerts as $id) {
$alert = get_alert_agent_module ($id);
if (! empty ($alert["id_agent_module"])) {
//Simple alert
$agent_id = get_agentmodule_agent ($alert["id_agent_module"]);
$group_id = get_agentmodule_group ($agent_id);
} else {
//Combined alert
$agent_id = $alert["id_agent"];
$group_id = get_agent_group ($agent_id);
}
if (! give_acl ($config['id_user'], $group_id, "AW")) {
continue;
}
$result = process_sql_update ('talert_template_modules',
array ('times_fired' => 0,
'internal_counter' => 0),
array ('id' => $id));
if ($result > 0) {
create_event ("Manual validation of alert for ".
get_alert_template_description ($alert["id_alert_template"]),
$group_id, $agent_id, 1, $config["id_user"],
"alert_manual_validation", 1, $alert["id_agent_module"],
$id);
} elseif ($result === false) {
return false;
}
}
return true;
}
2009-01-12 Esteban Sanchez <estebans@artica.es> * godmode/agentes/alert_manager.php: Complete rewritten of the alert system when assigned alerts to an agent. * pandoradb.sql: New tables for alert system. These are: talert_commands, talert_actions, talert_templates, talert_template_modules, talert_template_module_actions. No migration tool is available yet. * godmode/alerts/configure_alert_template.php, godmode/alerts/configure_alert_action.php, godmode/alerts/alert_templates.php, godmode/alerts/configure_alert_command.php, godmode/alerts/alert_actions.php: Added to repository. Administration interface to new alert system. * godmode/alerts/modify_alert.php: Deleted from repository. * godmode/setup/setup.php: Added an example of the date format. Main table has now percentage width. * godmode/menu.php, operation/menu.php: Added new alert options. Removed refr value when it's not neccesary. * include/styles/pandora.css: Added width to textarea elements. Style correction and cleanup. Tables doesn't have a odd-even pattern, but the hovered row now changes its colour. New styles for alert pages. * include/functions_custom_graphs.php: Added to repository. custom graphs functions moved here. * include/functions_incidents.php, include/functions_events.php: Moved to LGPL. Style comment corrections. * include/functions_html.php: Documentation style correction. Added print_input_file() and print_label(). * include/functions_ui.php: Doc style correction. * operation/reporting/graph_viewer.php: Include new function file with custom graphs. Use generic functions. * index.php: Unset pass from POST and REQUEST arrays. * include/functions_db.php: Some documentation updated to new format. Added format_array_to_update_sql() to generate SQL sentences for updates. Style correction. * godmode/agentes/configurar_agente.php: Variables renamed to have a meaning. * extensions/update_manager/main.php: Mark an string translatable. * extensions/update_manager/lib/libupdate_manager_client.php, godmode/alerts/configure_alert.php, include/functions.php, godmode/agentes/module_manager.php, operation/agentes/networkmap.php, operation/reporting/reporting_viewer.php, godmode/agentes/manage_config.php: Style correction. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1331 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-01-12 15:31:01 +01:00
?>