diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 0d20bc565b..94d4d324a3 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,38 @@ +2009-01-16 Esteban Sanchez + + * pandoradb.sql: Added new field to talert_templates to specify if the + alert should fire when on match or mismatch of the values. + + * general/header.php: Fixed the columns width. Added a control when + the autorefresh is clicked so the user can select the refresh time. A + countdown is also shown when the page is set to refresh. + + * godmode/alerts/configure_alert_template.php: Control the new flag on + templates. Added an explanation to explain when the alert is going to + fire. + + * include/javascript/jquery.js: Updated to v1.3. It promise to be + quicker in a lot of situations. + + * include/javascript/jquery.countdown.js: Updated to latest version. + + * include/styles/pandora.css: Fixed duplicated input.ok. Style + correction. Added invisible class and a style for alert templates + page. + + * include/functions_alerts.php: Fixed a notice error on + clean_alert_template_values(). + + * operation/visual_console/render_view.php: Removed jquery inclusion + because it's already done in the index page. + + * general/main_menu.php: Do not add refr if it's zero. + + * index.php: Avoid the recursive addition of 1=1 when autorefresh is + set. + + * pandoradb_migrate_20_to_21.sql: Added new fields on the tables. + 2009-01-16 Ramon Novoa * pandoradb.sql: Updated alert schema to work with the new alert diff --git a/pandora_console/general/header.php b/pandora_console/general/header.php index e4af273559..19be37ad5b 100644 --- a/pandora_console/general/header.php +++ b/pandora_console/general/header.php @@ -33,14 +33,14 @@ echo 'logo '; // First column (identifier) -echo ' '.''.__('You are').' ['.$_SESSION["id_usuario"].']'; +echo ' '.''.__('You are').' ['.$_SESSION["id_usuario"].']'; //First column, second row (logout button) echo '

'; echo ' '. __('Logout').''; // Second column (link to main page) -echo ''; +echo ''; echo ' '.__('General information').''; //Second column, second row (System up/down) @@ -65,11 +65,27 @@ echo ""; // Third column // Autorefresh -echo ""; -if (get_parameter ("refr") != 0) { - echo ' '. __('Autorefresh').''; +echo ''; +$refr = (int) get_parameter ("refr"); +if ($refr) { + echo ' '. __('Autorefresh'); + echo ' ('.date ("i:s", $refr).')'; + echo ''; } else { - echo ' '.__('Autorefresh').''; + echo ' '.__('Autorefresh').''; + $values = array ('5' => '5 '.__('seconds'), + '10' => '10 '.__('seconds'), + '15' => '15 '.__('seconds'), + '30' => '30 '.__('seconds'), + '60' => '1 '.__('minute'), + '120' => '2 '.__('minutes'), + '300' => '5 '.__('minutes'), + '900' => '15 '.__('minutes'), + '1800' => '30 '.__('minutes'), + '3600' => '1 '.__('hour')); + echo ''; } //Events @@ -77,5 +93,35 @@ echo '

'; echo ' '.__('Events').''; // Styled text -echo '
Pandora FMS
'; +echo '
Pandora FMS
'; ?> + + + diff --git a/pandora_console/general/main_menu.php b/pandora_console/general/main_menu.php index 37ed478ecf..c2f3add257 100644 --- a/pandora_console/general/main_menu.php +++ b/pandora_console/general/main_menu.php @@ -50,7 +50,7 @@ function temp_print_menu ($menu, $type) { //Print out the first level echo ''; echo ''; foreach ($main["sub"] as $subsec2 => $sub) { @@ -85,7 +85,7 @@ function temp_print_menu ($menu, $type) { $link_add = ""; } echo ''; - echo ''.$sub["text"].''; + echo ''.$sub["text"].''; echo ''; } } diff --git a/pandora_console/godmode/alerts/configure_alert_template.php b/pandora_console/godmode/alerts/configure_alert_template.php index 068e74fb06..302a2d7a6a 100644 --- a/pandora_console/godmode/alerts/configure_alert_template.php +++ b/pandora_console/godmode/alerts/configure_alert_template.php @@ -78,6 +78,71 @@ function print_alert_template_steps ($step, $id) { echo ''; } +function print_alert_template_example ($id, $return = false) { + $output = ''; + + $is = false; + $is_not = false; + $matches = false; + $matches_not = false; + $between = false; + $between_not = false; + $under = false; + $over = false; + $max = false; + $min = false; + $value = false; + + $output .= ' '; + $output .= ''; + + if ($id) { + $template = get_alert_template ($id); + + switch ($template['type']) { + case 'not_equal': + /* Do not translate the HTML attributes */ + $output .= __('The alert would fire when the value is '); + break; + case 'equal': + /* Do not translate the HTML attributes */ + $output .= __('The alert would fire when the value is not '); + break; + case 'regex': + if ($template['matches_value']) + /* Do not translate the HTML attributes */ + $output .= __('The alert would fire when the value matches '); + else + /* Do not translate the HTML attributes */ + $output .= __('The alert would fire when the value doesn\'t match '); + $value = $template['value']; + break; + case 'max_min': + if ($template['matches_value']) + /* Do not translate the HTML attributes */ + $output .= __('The alert would fire when the value is between and '); + else + /* Do not translate the HTML attributes */ + $output .= __('The alert would fire when the value is not between and '); + break; + case 'max': + /* Do not translate the HTML attributes */ + $output .= __('The alert would fire when the value is over '); + + break; + case 'min': + /* Do not translate the HTML attributes */ + $output .= __('The alert would fire when the value is under '); + break; + } + } + + $output .= ''; + if ($return) + return $output; + echo $output; +} + function update_template ($step) { $id = (int) get_parameter ('id'); @@ -92,13 +157,15 @@ function update_template ($step) { $value = (string) get_parameter ('value'); $max = (float) get_parameter ('max'); $min = (float) get_parameter ('min'); + $matches = (bool) get_parameter ('matches_value'); $result = update_alert_template ($id, array ('type' => $type, 'description' => $description, 'value' => $value, 'max_value' => $max, - 'min_value' => $min)); + 'min_value' => $min, + 'matches_value' => $matches)); } elseif ($step == 2) { $monday = (bool) get_parameter ('monday'); $tuesday = (bool) get_parameter ('tuesday'); @@ -247,6 +314,7 @@ if ($id && ! $create_template) { $value = $template['value']; $max = $template['max_value']; $min = $template['min_value']; + $matches = $template['matches_value']; $time_from = $template['time_from']; $time_to = $template['time_to']; $monday = (bool) $template['monday']; @@ -392,15 +460,18 @@ if ($step == 2) { $table->rowstyle['value'] = 'display: none'; $table->rowstyle['max'] = 'display: none'; $table->rowstyle['min'] = 'display: none'; + $table->rowstyle['example'] = 'display: none'; + $show_matches = false; if ($id) { + $table->rowstyle['example'] = ''; switch ($type) { - case "equal": - case "not_equal": case "regex": + $show_matches = true; $table->rowstyle['value'] = ''; break; case "max_min": + $show_matches = true; case "max": $table->rowstyle['max'] = ''; if ($type == 'max') @@ -421,6 +492,11 @@ if ($step == 2) { $table->data[2][0] = __('Condition type'); $table->data[2][1] = print_select (get_alert_templates_types (), 'type', $type, '', __('Select'), 0, true, false, false); + $table->data[2][1] .= ''; + $table->data[2][1] .= print_checkbox ('matches_value', 1, $matches, true); + $table->data[2][1] .= print_label (__('Trigger when matches the value'), + 'checkbox-matches_value', true); + $table->data[2][1] .= ''; $table->data['value'][0] = __('Value'); $table->data['value'][1] = print_input_text ('value', $value, '', @@ -441,6 +517,9 @@ if ($step == 2) { $table->data['min'][0] = __('Min.'); $table->data['min'][1] = print_input_text ('min', $min, '', 5, 255, true); + + $table->data['example'][1] = print_alert_template_example ($id, true); + $table->colspan['example'][1] = 2; } /* If it's the last step it will redirect to template lists */ @@ -476,6 +555,16 @@ echo ''; diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index aa0f153415..e64f435a96 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -231,6 +231,7 @@ CREATE TABLE IF NOT EXISTS `talert_templates` ( `field3` mediumtext NOT NULL, `type` ENUM ('regex', 'max_min', 'max', 'min', 'equal', 'not_equal'), `value` varchar(255) default '', + `matches_value` tinyint(1) default 0, `max_value` double(18,2) default NULL, `min_value` double(18,2) default NULL, `time_threshold` int(10) NOT NULL default '0', @@ -239,13 +240,13 @@ CREATE TABLE IF NOT EXISTS `talert_templates` ( `alert_text` varchar(255) default '', `time_from` time default '00:00:00', `time_to` time default '00:00:00', - `monday` tinyint(1) default '1', - `tuesday` tinyint(1) default '1', - `wednesday` tinyint(1) default '1', - `thursday` tinyint(1) default '1', - `friday` tinyint(1) default '1', - `saturday` tinyint(1) default '1', - `sunday` tinyint(1) default '1', + `monday` tinyint(1) default 1, + `tuesday` tinyint(1) default 1, + `wednesday` tinyint(1) default 1, + `thursday` tinyint(1) default 1, + `friday` tinyint(1) default 1, + `saturday` tinyint(1) default 1, + `sunday` tinyint(1) default 1, `recovery_notify` tinyint(1) default '0', `field2_recovery` varchar(255) NOT NULL default '', `field3_recovery` mediumtext NOT NULL, diff --git a/pandora_console/pandoradb_migrate_20_to_21.sql b/pandora_console/pandoradb_migrate_20_to_21.sql index 48264ac44c..45239eb3ac 100644 --- a/pandora_console/pandoradb_migrate_20_to_21.sql +++ b/pandora_console/pandoradb_migrate_20_to_21.sql @@ -50,55 +50,56 @@ CREATE TABLE IF NOT EXISTS `talert_actions` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8; CREATE TABLE IF NOT EXISTS `talert_templates` ( - `id` int(10) unsigned NOT NULL auto_increment, - `name` varchar(255) default '', - `description` mediumtext, - `id_alert_action` int(10) unsigned NULL, - `field1` varchar(255) default '', - `field2` varchar(255) default '', - `field3` mediumtext NOT NULL, - `type` ENUM ('regex', 'max_min', 'max', 'min', 'equal', 'not_equal'), - `value` varchar(255) default '', - `max_value` double(18,2) default NULL, - `min_value` double(18,2) default NULL, - `time_threshold` int(10) NOT NULL default '0', - `max_alerts` int(4) unsigned NOT NULL default '1', - `module_type` int(10) unsigned NOT NULL default '0', - `min_alerts` int(4) unsigned NOT NULL default '0', - `alert_text` varchar(255) default '', - `time_from` time default '00:00:00', - `time_to` time default '00:00:00', - `monday` tinyint(1) default '1', - `tuesday` tinyint(1) default '1', - `wednesday` tinyint(1) default '1', - `thursday` tinyint(1) default '1', - `friday` tinyint(1) default '1', - `saturday` tinyint(1) default '1', - `sunday` tinyint(1) default '1', - `recovery_notify` tinyint(1) default '0', - `field2_recovery` varchar(255) NOT NULL default '', - `field3_recovery` mediumtext NOT NULL, - PRIMARY KEY (`id`), - FOREIGN KEY (`id_alert_action`) REFERENCES talert_actions(`id`) - ON DELETE RESTRICT ON UPDATE CASCADE + `id` int(10) unsigned NOT NULL auto_increment, + `name` varchar(255) default '', + `description` mediumtext default '', + `id_alert_action` int(10) unsigned NULL, + `field1` varchar(255) default '', + `field2` varchar(255) default '', + `field3` mediumtext NOT NULL, + `type` ENUM ('regex', 'max_min', 'max', 'min', 'equal', 'not_equal'), + `value` varchar(255) default '', + `matches_value` tinyint(1) default 0, + `max_value` double(18,2) default NULL, + `min_value` double(18,2) default NULL, + `time_threshold` int(10) NOT NULL default '0', + `max_alerts` int(4) unsigned NOT NULL default '1', + `min_alerts` int(4) unsigned NOT NULL default '0', + `alert_text` varchar(255) default '', + `time_from` time default '00:00:00', + `time_to` time default '00:00:00', + `monday` tinyint(1) default 1, + `tuesday` tinyint(1) default 1, + `wednesday` tinyint(1) default 1, + `thursday` tinyint(1) default 1, + `friday` tinyint(1) default 1, + `saturday` tinyint(1) default 1, + `sunday` tinyint(1) default 1, + `recovery_notify` tinyint(1) default '0', + `field2_recovery` varchar(255) NOT NULL default '', + `field3_recovery` mediumtext NOT NULL, + PRIMARY KEY (`id`), + FOREIGN KEY (`id_alert_action`) REFERENCES talert_actions(`id`) + ON DELETE RESTRICT ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8; CREATE TABLE IF NOT EXISTS `talert_template_modules` ( - `id` int(10) unsigned NOT NULL auto_increment, - `id_agent_module` int(10) unsigned NOT NULL, - `id_alert_template` int(10) unsigned NOT NULL, - `internal_counter` int(4) default '0', - `last_fired` bigint(20) NOT NULL default '0', - `times_fired` int(3) NOT NULL default '0', - `disabled` tinyint(1) default '0', - `priority` tinyint(4) default '0', - `force_execution` tinyint(1) default '0', - PRIMARY KEY (`id`), - FOREIGN KEY (`id_agent_module`) REFERENCES tagente_modulo(`id_agente_modulo`) - ON DELETE CASCADE ON UPDATE CASCADE, - FOREIGN KEY (`id_alert_template`) REFERENCES talert_templates(`id`) - ON DELETE RESTRICT ON UPDATE CASCADE, - UNIQUE (`id_agent_module`, `id_alert_template`) + `id` int(10) unsigned NOT NULL auto_increment, + `id_agent_module` int(10) unsigned NOT NULL, + `id_alert_template` int(10) unsigned NOT NULL, + `internal_counter` int(4) default '0', + `last_fired` bigint(20) NOT NULL default '0', + `last_reference` bigint(20) NOT NULL default '0', + `times_fired` int(3) NOT NULL default '0', + `disabled` tinyint(1) default '0', + `priority` tinyint(4) default '0', + `force_execution` tinyint(1) default '0', + PRIMARY KEY (`id`), + FOREIGN KEY (`id_agent_module`) REFERENCES tagente_modulo(`id_agente_modulo`) + ON DELETE CASCADE ON UPDATE CASCADE, + FOREIGN KEY (`id_alert_template`) REFERENCES talert_templates(`id`) + ON DELETE RESTRICT ON UPDATE CASCADE, + UNIQUE (`id_agent_module`, `id_alert_template`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; CREATE TABLE IF NOT EXISTS `talert_template_module_actions` (