2011-02-15 Ramon Novoa <rnovoa@artica.es>

* pandoradb_data.sql, include/functions_alerts.php,
	  pandoradb.sql, extras/pandoradb_migrate_v3.2_to_v4.0.sql,
	  godmode/alerts/alert_list.list.php, godmode/alerts/alert_list.php,
	  godmode/alerts/configure_alert_action.php, godmode/alerts/alert_actions.php,
	  godmode/alerts/alert_list.builder.php: Added support for action thresholds.



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@3855 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
ramonn 2011-02-15 16:40:23 +00:00
parent 98398faa0b
commit b0ca20fa89
10 changed files with 57 additions and 16 deletions

View File

@ -1,3 +1,11 @@
2011-02-15 Ramon Novoa <rnovoa@artica.es>
* pandoradb_data.sql, include/functions_alerts.php,
pandoradb.sql, extras/pandoradb_migrate_v3.2_to_v4.0.sql,
godmode/alerts/alert_list.list.php, godmode/alerts/alert_list.php,
godmode/alerts/configure_alert_action.php, godmode/alerts/alert_actions.php,
godmode/alerts/alert_list.builder.php: Added support for action thresholds.
2011-02-15 Miguel de Dios <miguel.dedios@artica.es>
* include/functions_alerts.php, operation/agentes/estado_agente.php: added

View File

@ -39,3 +39,14 @@ ALTER TABLE treport_content ADD only_display_wrong tinyint(1) unsigned DEFAULT 0
ALTER TABLE `tusuario` ADD COLUMN `block_size` int(4) NOT NULL DEFAULT 20;
ALTER TABLE `tusuario` ADD COLUMN `flash_chart` int(4) NOT NULL DEFAULT 1;
-- -----------------------------------------------------
-- Table `talert_actions`
-- -----------------------------------------------------
ALTER TABLE `talert_actions` ADD COLUMN `action_threshold` int(10) NOT NULL DEFAULT '0';
-- -----------------------------------------------------
-- Table `talert_template_module_actions`
-- -----------------------------------------------------
ALTER TABLE `talert_template_module_actions` ADD COLUMN `module_action_threshold` int(10) NOT NULL DEFAULT '0';
ALTER TABLE `talert_template_module_actions` ADD COLUMN `last_execution` bigint(20) NOT NULL DEFAULT '0';

View File

@ -92,15 +92,18 @@ if ($create_action) {
$field2 = (string) get_parameter ('field2');
$field3 = (string) get_parameter ('field3');
$group = (string) get_parameter ('group');
$action_threshold = (int) get_parameter ('action_threshold');
$result = create_alert_action ($name, $id_alert_command,
array ('field1' => $field1,
'field2' => $field2,
'field3' => $field3,
'id_group' => $group));
'id_group' => $group,
'action_threshold' => $action_threshold));
$info = 'Name: ' . $name . ' ID alert Command: ' . $id_alert_command .
' Field1: ' . $field1 . ' Field2: ' . $field2 . ' Field3: ' . $field3 . ' Group: ' . $group;
' Field1: ' . $field1 . ' Field2: ' . $field2 . ' Field3: ' . $field3 . ' Group: ' . $group .
' Action threshold: ' . $action_threshold;
if ($result) {
pandora_audit("Command management", "Create alert action " . $result, false, false, $info);
@ -141,6 +144,7 @@ if ($update_action) {
$field2 = (string) get_parameter ('field2');
$field3 = (string) get_parameter ('field3');
$group = get_parameter ('group');
$action_threshold = (int) get_parameter ('action_threshold');
$values = array ();
$values['name'] = $name;
@ -149,11 +153,13 @@ if ($update_action) {
$values['field2'] = $field2;
$values['field3'] = $field3;
$values['id_group'] = $group;
$values['action_threshold'] = $action_threshold;
$result = update_alert_action ($id, $values);
$info = 'Name: ' . $name . ' ID alert Command: ' . $id_alert_command .
' Field1: ' . $field1 . ' Field2: ' . $field2 . ' Field3: ' . $field3 . ' Group: ' . $group;
' Field1: ' . $field1 . ' Field2: ' . $field2 . ' Field3: ' . $field3 . ' Group: ' . $group .
' Action threshold: ' . $action_threshold;
if ($result) {
pandora_audit("Command management", "Update alert action " . $id, false, false, json_encode($values));

View File

@ -32,8 +32,8 @@ $table->head = array ();
$table->data = array ();
$table->size = array ();
$table->size = array ();
$table->size[0] = '10%';
$table->size[1] = '90%';
$table->size[0] = '20%';
$table->size[1] = '80%';
$table->style[0] = 'font-weight: bold; vertical-align: top;';
$table->align[0] = 'left';
$table->align[1] = 'left';
@ -96,6 +96,8 @@ $table->data[2][1] .= print_image ('images/add.png', true);
$table->data[2][1] .= '<a href="index.php?sec=galertas&sec2=godmode/alerts/configure_alert_action">';
$table->data[2][1] .= __('Create Action');
$table->data[2][1] .= '</a>';
$table->data[3][0] = __('Threshold');
$table->data[3][1] = print_input_text ('module_action_threshold', '', '', 4, 10, true) . print_help_icon ('action_threshold', true);
echo '<form class="add_alert_form" method="post">';

View File

@ -489,6 +489,8 @@ foreach ($simple_alerts as $alert) {
$data[6] .= ' '.__('to').' ';
$data[6] .= print_input_text ('fires_max', -1, '', 4, 10, true);
$data[6] .= print_help_icon ("alert-matches", true);
$data[6] .= '<br />' . __('Threshold');
$data[6] .= print_input_text ('module_action_threshold', '', '', 4, 10, true) . print_help_icon ('action_threshold', true);
$data[6] .= '</span>';
$data[6] .= '<div class="right">';
$data[6] .= print_submit_button (__('Add'), 'add_action', false, 'class="sub next"', true);

View File

@ -97,6 +97,7 @@ if ($create_alert) {
$values = array();
$values['fires_min'] = get_parameter ('fires_min');
$values['fires_max'] = get_parameter ('fires_max');
$values['module_action_threshold'] = (int) get_parameter ('module_action_threshold');
add_alert_agent_module_action ($id, $action_select, $values);
}
@ -138,6 +139,7 @@ if ($add_action) {
$values['fires_min'] = $fires_min;
if ($fires_max != -1)
$values['fires_max'] = $fires_max;
$values['module_action_threshold'] = (int) get_parameter ('module_action_threshold');
$result = add_alert_agent_module_action ($id_alert_module, $id_action, $values);

View File

@ -55,6 +55,7 @@ $field1 = '';
$field2 = '';
$field3 = '';
$group = 0; //All group is 0
$action_threshold = 0; //All group is 0
if ($id) {
$action = get_alert_action ($id);
@ -64,6 +65,7 @@ if ($id) {
$field2 = $action['field2'];
$field3 = $action['field3'];
$group = $action ['id_group'];
$action_threshold = $action ['action_threshold'];
}
$table->width = '90%';
@ -88,18 +90,20 @@ $table->data[2][1] .= print_image ('images/add.png', true);
$table->data[2][1] .= '<a href="index.php?sec=galertas&sec2=godmode/alerts/configure_alert_command">';
$table->data[2][1] .= __('Create Command');
$table->data[2][1] .= '</a>';
$table->data[3][0] = __('Threshold');
$table->data[3][1] = print_input_text ('action_threshold', $action_threshold, '', 5, 7, true);
$table->data[3][1] .= ' '.__('seconds') . print_help_icon ('action_threshold', true);
$table->data[4][0] = __('Field 1');
$table->data[4][1] = print_input_text ('field1', $field1, '', 35, 255, true) . print_help_icon ('alert_macros', true);
$table->data[3][0] = __('Field 1');
$table->data[3][1] = print_input_text ('field1', $field1, '', 35, 255, true) . print_help_icon ('alert_macros', true);
$table->data[5][0] = __('Field 2');
$table->data[5][1] = print_input_text ('field2', $field2, '', 80, 255, true);
$table->data[4][0] = __('Field 2');
$table->data[4][1] = print_input_text ('field2', $field2, '', 80, 255, true);
$table->data[6][0] = __('Field 3');
$table->data[6][1] = print_textarea ('field3', 10, 30, $field3, '', true);
$table->data[5][0] = __('Field 3');
$table->data[5][1] = print_textarea ('field3', 10, 30, $field3, '', true);
$table->data[6][0] = __('Command preview');
$table->data[6][1] = print_textarea ('command_preview', 10, 30, '', 'disabled="disabled"', true);
$table->data[7][0] = __('Command preview');
$table->data[7][1] = print_textarea ('command_preview', 10, 30, '', 'disabled="disabled"', true);
echo '<form method="post" action="index.php?sec=galertas&sec2=godmode/alerts/alert_actions">';
print_table ($table);

View File

@ -573,6 +573,7 @@ function add_alert_agent_module_action ($id_alert_template_module, $id_alert_act
$values['id_alert_action'] = (int) $id_alert_action;
$values['fires_max'] = 0;
$values['fires_min'] = 0;
$values['module_action_threshold'] = 0;
if ($options) {
$max = 0;
$min = 0;
@ -580,6 +581,8 @@ function add_alert_agent_module_action ($id_alert_template_module, $id_alert_act
$max = (int) $options['fires_max'];
if (isset ($options['fires_min']))
$min = (int) $options['fires_min'];
if (isset ($options['module_action_threshold']))
$values['module_action_threshold'] = (int) $options['module_action_threshold'];
$values['fires_max'] = max ($max, $min);
$values['fires_min'] = min ($max, $min);

View File

@ -237,6 +237,7 @@ CREATE TABLE IF NOT EXISTS `talert_actions` (
`field2` text default '',
`field3` text default '',
`id_group` mediumint(8) unsigned NULL default 0,
`action_threshold` int(10) NOT NULL default '0',
PRIMARY KEY (`id`),
FOREIGN KEY (`id_alert_command`) REFERENCES talert_commands(`id`)
ON DELETE CASCADE ON UPDATE CASCADE
@ -306,6 +307,8 @@ CREATE TABLE IF NOT EXISTS `talert_template_module_actions` (
`id_alert_action` int(10) unsigned NOT NULL,
`fires_min` int(3) unsigned default 0,
`fires_max` int(3) unsigned default 0,
`module_action_threshold` int(10) NOT NULL default '0',
`last_execution` bigint(20) NOT NULL default '0',
PRIMARY KEY (`id`),
FOREIGN KEY (`id_alert_template_module`) REFERENCES talert_template_modules(`id`)
ON DELETE CASCADE ON UPDATE CASCADE,

View File

@ -392,9 +392,9 @@ INSERT INTO `tgis_map_layer` VALUES (1,'Group All',1,0,1,0);
INSERT INTO `talert_commands` VALUES (10,'Remote&#x20;agent&#x20;control','/usr/share/pandora_server/udp_client.pl _address_ 41122 &quot;_field1_&quot;','This command is used to send commands to the Pandora FMS agents with the UDP server enabled. The UDP server is used to order agents (Windows and UNIX) to &quot;refresh&quot; the agent execution: that means, to force the agent to execute and send data to s',0);
INSERT INTO `talert_actions` VALUES (1,'Mail&#x20;to&#x20;XXX',1,'yourmail@domain.es','[PANDORA] Alert from agent _agent_ on module _module_','',0);
INSERT INTO `talert_actions` VALUES (1,'Mail&#x20;to&#x20;XXX',1,'yourmail@domain.es','[PANDORA] Alert from agent _agent_ on module _module_','',0,0);
INSERT INTO `talert_actions` VALUES (2,'Restart&#x20;agent',10,'REFRESH AGENT','','',0);
INSERT INTO `talert_actions` VALUES (2,'Restart&#x20;agent',10,'REFRESH AGENT','','',0,0);
INSERT INTO `talert_templates` VALUES (1,'Critical&#x20;condition','This is a generic alert template to fire on condition CRITICAL',1,'','','Hello, this is an automated email coming from Pandora FMS\r\n\r\nThis alert has been fired because a CRITICAL condition in one of your monitored items:\r\n\r\nAgent : _agent_\r\nModule: _module_\r\nModule description: _moduledescription_\r\nTimestamp _timestamp_\r\nCurrent value: _data_\r\n\r\nThanks for your time.\r\n\r\nBest regards\r\nPandora FMS\r\n','critical','',1,0.00,0.00,86400,1,0,'12:00:00','12:00:00',1,1,1,1,1,1,1,1,'[PANDORA] Alert RECOVERED for CRITICAL status on _agent_ / _module_','Hello, this is an automated email coming from Pandora FMS\r\n\r\nThis alert has been RECOVERED from a CRITICAL condition in one of your monitored items:\r\n\r\nAgent : _agent_\r\nModule: _module_\r\nModule description: _moduledescription_\r\nTimestamp _timestamp_\r\nCurrent value: _data_\r\n\r\nThanks for your time.\r\n\r\nBest regards\r\nPandora FMS\r\n',4,0);