From 9c8b33b3d9cb99235f6a667dfe76f2ec0e1cd1ad Mon Sep 17 00:00:00 2001 From: slerena Date: Thu, 25 Feb 2010 18:48:36 +0000 Subject: [PATCH] 2010-02-25 Sancho Lerena * include/functions_ui.php: Alert information now show the default actions properly,and the action conditions (max/min). * include/functions_alerts.php: Added support on get_alert_templates_types for new alert type "onchange". * pandoradb.sql, extras/pandoradb_migrate_v3.0_to_v3.1.sql: Added new support for alert type "onchange". * godmode/alerts/alert_list.php: Alert information now shows the default action (if exist) and have a link to edit the template directly from here. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2425 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 15 ++++ .../extras/pandoradb_migrate_v3.0_to_v3.1.sql | 2 + pandora_console/godmode/alerts/alert_list.php | 79 +++++++++++-------- pandora_console/include/functions_alerts.php | 5 +- pandora_console/include/functions_ui.php | 25 +++--- pandora_console/pandoradb.sql | 4 +- 6 files changed, 85 insertions(+), 45 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 9baa55c945..f08fce3adf 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,18 @@ +2010-02-25 Sancho Lerena + + * include/functions_ui.php: Alert information now show the default + actions properly,and the action conditions (max/min). + + * include/functions_alerts.php: Added support on get_alert_templates_types + for new alert type "onchange". + + * pandoradb.sql + * extras/pandoradb_migrate_v3.0_to_v3.1.sql: Added new support for alert + type "onchange". + + * godmode/alerts/alert_list.php: Alert information now shows the default + action (if exist) and have a link to edit the template directly from here. + 2010-02-25 Miguel de Dios * godmode/agentes/agent_manager.php: fix dinamic show icon when change diff --git a/pandora_console/extras/pandoradb_migrate_v3.0_to_v3.1.sql b/pandora_console/extras/pandoradb_migrate_v3.0_to_v3.1.sql index 63a5d24b5e..7550f62532 100644 --- a/pandora_console/extras/pandoradb_migrate_v3.0_to_v3.1.sql +++ b/pandora_console/extras/pandoradb_migrate_v3.0_to_v3.1.sql @@ -256,3 +256,5 @@ CREATE TABLE IF NOT EXISTS `tagente_datos_log4x` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +ALTER TABLE talert_templates MODIFY `type` ENUM ('regex', 'max_min', 'max', 'min', 'equal', 'not_equal', 'warning', 'critical', 'onchange'); diff --git a/pandora_console/godmode/alerts/alert_list.php b/pandora_console/godmode/alerts/alert_list.php index 2bf07f5ae6..3811b4a7d2 100644 --- a/pandora_console/godmode/alerts/alert_list.php +++ b/pandora_console/godmode/alerts/alert_list.php @@ -412,7 +412,10 @@ foreach ($simple_alerts as $alert) { $data[3] = ' '; + + $data[3] .= ""; $data[3] .= get_alert_template_name ($alert['id_alert_template']); + $data[3] .= ""; if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK) { $policyInfo = isAlertInPolicy($alert['id_agent_module'], $alert['id_alert_template'], false); @@ -428,41 +431,53 @@ foreach ($simple_alerts as $alert) { } $actions = get_alert_agent_module_actions ($alert['id']); - $data[5] = '
    '; - foreach ($actions as $action_id => $action) { - $data[5] .= '
  • '; - if ($alert['disabled']) - $data[5] .= ''; - else - $data[5] .= ''; - $data[5] .= $action['name']; - $data[5] .= ' ('; - if ($action['fires_min'] == $action['fires_max']) { - if ($action['fires_min'] == 0) - $data[5] .= __('Always'); - else - $data[5] .= __('On').' '.$action['fires_min']; - } else { - if ($action['fires_min'] == 0) - $data[5] .= __('Until').' '.$action['fires_max']; - else - $data[5] .= __('From').' '.$action['fires_min']. - ' '.__('to').' '.$action['fires_max']; + + + if (empty($actions)){ + // Get and show default actions for this alert + $default_action = get_db_sql ("SELECT id_alert_action FROM talert_templates WHERE id = ".$alert["id_alert_template"]); + if ($default_action != ""){ + $data[5] = __("Default"). " : ".get_db_sql ("SELECT name FROM talert_actions WHERE id = $default_action"); } + + } else { + $data[5] = '
      '; + foreach ($actions as $action_id => $action) { + $data[5] .= '
    • '; + if ($alert['disabled']) + $data[5] .= ''; + else + $data[5] .= ''; + $data[5] .= $action['name']; + $data[5] .= ' ('; + if ($action['fires_min'] == $action['fires_max']) { + if ($action['fires_min'] == 0) + $data[5] .= __('Always'); + else + $data[5] .= __('On').' '.$action['fires_min']; + } else { + if ($action['fires_min'] == 0) + $data[5] .= __('Until').' '.$action['fires_max']; + else + $data[5] .= __('From').' '.$action['fires_min']. + ' '.__('to').' '.$action['fires_max']; + } - $data[5] .= ')'; - $data[5] .= ''; - $data[5] .= ' '; - $data[5] .= ''; - $data[5] .= ''; - $data[5] .= '
    • '; + $data[5] .= ')
      '; + $data[5] .= ''; + $data[5] .= ' '; + $data[5] .= ''; + $data[5] .= ''; + $data[5] .= '
  • '; + } + $data[5] .= '
'; } - $data[5] .= ''; + $data[5] .= ''; $data[5] .= print_image ('images/add.png', true); diff --git a/pandora_console/include/functions_alerts.php b/pandora_console/include/functions_alerts.php index ce89d3994d..cbbf8e9dff 100644 --- a/pandora_console/include/functions_alerts.php +++ b/pandora_console/include/functions_alerts.php @@ -199,7 +199,8 @@ function get_alert_templates_types () { $types['not_equal'] = __('Not equal to'); $types['warning'] = __('Warning status'); $types['critical'] = __('Critical status'); - + $types['onchange'] = __('On Change'); + return $types; } @@ -834,4 +835,6 @@ function get_agents_with_alert_template ($id_alert_template, $id_group, $filter return get_db_all_rows_filter ('tagente, tagente_modulo, talert_template_modules', $filter, $fields); } + + ?> diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index d0cc05467d..c0e0942563 100644 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -375,18 +375,23 @@ function format_alert_row ($alert, $compound = false, $agent = true, $url = '') $data[$index['description']] .= $disabledHtmlStart . mb_substr (safe_input ($description), 0, 35) . $disabledHtmlEnd; $actions = get_alert_agent_module_actions ($alert['id'], false, $compound); - $actionText = '
    '; - foreach ($actions as $action) { - $defaultTagIni = $defaultTagEnd = ''; - if ($action['id'] == $actionDefault) { - $defaultTagIni = ''; - $defaultTagEnd = ' (' . __('default') . ') '; + + if (!empty($actions)){ + $actionText = '
      '; + foreach ($actions as $action) { + $actionText .= '
    • ' . $action['name']; + if ($action["fires_min"] != $action["fires_max"]){ + $actionText .= " (".$action["fires_min"] . " / ". $action["fires_max"] . ")"; + } + $actionText .= '

    • '; } - $actionText .= '
    • ' . $defaultTagIni . $action['name'] . - $defaultTagEnd . '
    • '; + $actionText .= '
    '; } - $actionText .= '
'; - + else { + if ($actionDefault != "") + $actionText = get_db_sql ("SELECT name FROM talert_actions WHERE id = $actionDefault"). " (".__("Default") . ")"; + } + $data[$index['action']] = $actionText; $data[$index['last_fired']] = $disabledHtmlStart . print_timestamp ($alert["last_fired"], true) . $disabledHtmlEnd; diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index 202b0fe8d0..91cac05cfb 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -247,7 +247,7 @@ CREATE TABLE IF NOT EXISTS `talert_templates` ( `field1` varchar(255) default '', `field2` varchar(255) default '', `field3` mediumtext NOT NULL, - `type` ENUM ('regex', 'max_min', 'max', 'min', 'equal', 'not_equal', 'warning', 'critical'), + `type` ENUM ('regex', 'max_min', 'max', 'min', 'equal', 'not_equal', 'warning', 'critical', 'onchange'), `value` varchar(255) default '', `matches_value` tinyint(1) default 0, `max_value` double(18,2) default NULL, @@ -628,7 +628,7 @@ CREATE TABLE IF NOT EXISTS `tserver` ( KEY `name` (`name`), KEY `keepalive` (`keepalive`), KEY `status` (`status`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; +) ENGINE=MyISAM DEFAULT CHARSET=utf8; -- server types: -- 0 data