2010-02-25 Sancho Lerena <slerena@artica.es>

* 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
This commit is contained in:
slerena 2010-02-25 18:48:36 +00:00
parent 56d11dd57c
commit 70b343f9c3
6 changed files with 85 additions and 45 deletions

View File

@ -1,3 +1,18 @@
2010-02-25 Sancho Lerena <slerena@artica.es>
* 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 <miguel.dedios@artica.es>
* godmode/agentes/agent_manager.php: fix dinamic show icon when change

View File

@ -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');

View File

@ -412,7 +412,10 @@ foreach ($simple_alerts as $alert) {
$data[3] = ' <a class="template_details"
href="ajax.php?page=godmode/alerts/alert_templates&get_template_tooltip=1&id_template='.$alert['id_alert_template'].'">
<img id="template-details-'.$alert['id_alert_template'].'" class="img_help" src="images/zoom.png"/></a> ';
$data[3] .= "<a href='index.php?sec=galertas&sec2=godmode/alerts/configure_alert_template&id=".$alert['id_alert_template']."'>";
$data[3] .= get_alert_template_name ($alert['id_alert_template']);
$data[3] .= "</a>";
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] = '<ul class="action_list">';
foreach ($actions as $action_id => $action) {
$data[5] .= '<li><div>';
if ($alert['disabled'])
$data[5] .= '<span class="action_name" style="font-style: italic; color: #aaaaaa;">';
else
$data[5] .= '<span class="action_name">';
$data[5] .= $action['name'];
$data[5] .= ' <em>(';
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] = '<ul class="action_list">';
foreach ($actions as $action_id => $action) {
$data[5] .= '<li><div>';
if ($alert['disabled'])
$data[5] .= '<span class="action_name" style="font-style: italic; color: #aaaaaa;">';
else
$data[5] .= '<span class="action_name">';
$data[5] .= $action['name'];
$data[5] .= ' <em>(';
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] .= ')</em>';
$data[5] .= '</span>';
$data[5] .= ' <span class="delete" style="clear:right">';
$data[5] .= '<form method="post" class="delete_link">';
$data[5] .= print_input_image ('delete', 'images/cross.png', 1, '', true);
$data[5] .= print_input_hidden ('delete_action', 1, true);
$data[5] .= print_input_hidden ('id_alert', $alert['id'], true);
$data[5] .= print_input_hidden ('id_action', $action_id, true);
$data[5] .= '</form>';
$data[5] .= '</span>';
$data[5] .= '</div></li>';
$data[5] .= ')</em>';
$data[5] .= '</span>';
$data[5] .= ' <span class="delete" style="clear:right">';
$data[5] .= '<form method="post" class="delete_link">';
$data[5] .= print_input_image ('delete', 'images/cross.png', 1, '', true);
$data[5] .= print_input_hidden ('delete_action', 1, true);
$data[5] .= print_input_hidden ('id_alert', $alert['id'], true);
$data[5] .= print_input_hidden ('id_action', $action_id, true);
$data[5] .= '</form>';
$data[5] .= '</span>';
$data[5] .= '</div></li>';
}
$data[5] .= '</ul>';
}
$data[5] .= '</ul>';
$data[5] .= '<a class="add_action" id="add-action-'.$alert['id'].'" href="#">';
$data[5] .= print_image ('images/add.png', true);

View File

@ -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);
}
?>

View File

@ -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 = '<ul>';
foreach ($actions as $action) {
$defaultTagIni = $defaultTagEnd = '';
if ($action['id'] == $actionDefault) {
$defaultTagIni = '<i>';
$defaultTagEnd = ' (' . __('default') . ') </i>';
if (!empty($actions)){
$actionText = '<ul class="action_list">';
foreach ($actions as $action) {
$actionText .= '<li><div><span class="action_name">' . $action['name'];
if ($action["fires_min"] != $action["fires_max"]){
$actionText .= " (".$action["fires_min"] . " / ". $action["fires_max"] . ")";
}
$actionText .= '</li></span><br></div>';
}
$actionText .= '<li>' . $defaultTagIni . $action['name'] .
$defaultTagEnd . '</li>';
$actionText .= '</div></ul>';
}
$actionText .= '</ul>';
else {
if ($actionDefault != "")
$actionText = get_db_sql ("SELECT name FROM talert_actions WHERE id = $actionDefault"). " <i>(".__("Default") . ")</i>";
}
$data[$index['action']] = $actionText;
$data[$index['last_fired']] = $disabledHtmlStart . print_timestamp ($alert["last_fired"], true) . $disabledHtmlEnd;

View File

@ -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