2009-02-11 Esteban Sanchez <estebans@artica.es>
* general/main_menu.php, include/styles/menu.css: Selected menu style is done with a CSS classs. Slide effect removed. Submenus have now white background. * godmode/agentes/alert_manager.php: Allow creation of alerts without actions which have sense in compound alerts. * include/javascript/jquery.pandora.js: Added showMessage() function. * godmode/agentes/module_manager_editor.php: Use new showMessage() jQuery function. * godmode/alerts/configure_alert_compound.php: Added to repository. New compound alert editor interface. * godmode/alerts/alert_compounds.php: Added to repository. Compound alert list. * godmode/alerts/configure_alert_template.php: Better style for steps of the editor. * godmode/menu.php: Added compound alerts option. Changed default page on Manage alerts. * include/styles/pandora.css: Added style for editor steps. Added new generic classes. * include/functions.php: Added a new line when creating script list. * include/functions_agents.php: Fixed alert tables fields. Renamed get_agent_alerts_compound() and improved the returning value of get_agent_alerts(). * include/functions_alerts.php: Added new functions to manage compound alerts. Avoid SQL errors when using process_sql functions. * include/functions_reporting.php: Temporary disabled compound alert reports. * include/functions_ui.php: Fixed format_alert_row() to fit compound alerts. * operation/agentes/alerts_status.php: Allow compound alert validation. Removed effect of cluetip. * pandoradb.sql, pandoradb_migrate_20_to_21.sql: New compound alert tables (talert_compound, talert_compound_elements and talert_compound_actions). * godmode/alerts/alert_list.php: Added to repository. Shows a list of all the alerts defined. Would be improved in the future to allow sorting and filtering. * index.php, godmode/snmpconsole/snmp_alert.php, include/functions_db.php: Code style correction. * godmode/agentes/configurar_agente.php: Removed old compound alerts code git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1443 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
400b02f09a
commit
f6680b0b98
|
@ -1,3 +1,64 @@
|
|||
2009-02-11 Esteban Sanchez <estebans@artica.es>
|
||||
|
||||
* general/main_menu.php, include/styles/menu.css: Selected menu style
|
||||
is done with a CSS classs. Slide effect removed. Submenus have now
|
||||
white background.
|
||||
|
||||
* godmode/agentes/alert_manager.php: Allow creation of alerts without
|
||||
actions which have sense in compound alerts.
|
||||
|
||||
* include/javascript/jquery.pandora.js: Added showMessage() function.
|
||||
|
||||
* godmode/agentes/module_manager_editor.php: Use new showMessage()
|
||||
jQuery function.
|
||||
|
||||
* godmode/alerts/configure_alert_compound.php: Added to repository.
|
||||
New compound alert editor interface.
|
||||
|
||||
* godmode/alerts/alert_compounds.php: Added to repository. Compound
|
||||
alert list.
|
||||
|
||||
* godmode/alerts/configure_alert_template.php: Better style for steps
|
||||
of the editor.
|
||||
|
||||
* godmode/menu.php: Added compound alerts option. Changed default page
|
||||
on Manage alerts.
|
||||
|
||||
* include/styles/pandora.css: Added style for editor steps. Added new
|
||||
generic classes.
|
||||
|
||||
* include/functions.php: Added a new line when creating script list.
|
||||
|
||||
* include/functions_agents.php: Fixed alert tables fields. Renamed
|
||||
get_agent_alerts_compound() and improved the returning value of
|
||||
get_agent_alerts().
|
||||
|
||||
* include/functions_alerts.php: Added new functions to manage compound
|
||||
alerts. Avoid SQL errors when using process_sql functions.
|
||||
|
||||
* include/functions_reporting.php: Temporary disabled compound alert
|
||||
reports.
|
||||
|
||||
* include/functions_ui.php: Fixed format_alert_row() to fit compound
|
||||
alerts.
|
||||
|
||||
* operation/agentes/alerts_status.php: Allow compound alert
|
||||
validation. Removed effect of cluetip.
|
||||
|
||||
* pandoradb.sql, pandoradb_migrate_20_to_21.sql: New compound alert
|
||||
tables (talert_compound, talert_compound_elements and
|
||||
talert_compound_actions).
|
||||
|
||||
* godmode/alerts/alert_list.php: Added to repository. Shows a list of
|
||||
all the alerts defined. Would be improved in the future to allow
|
||||
sorting and filtering.
|
||||
|
||||
* index.php, godmode/snmpconsole/snmp_alert.php,
|
||||
include/functions_db.php: Code style correction.
|
||||
|
||||
* godmode/agentes/configurar_agente.php: Removed old compound alerts
|
||||
code
|
||||
|
||||
2009-02-11 Sancho Lerena <slerena@artica.es>
|
||||
|
||||
* godmode/reporting/reporting_builder.php: Added 3-month period
|
||||
|
|
|
@ -97,22 +97,22 @@ function temp_print_menu ($menu, $classtype) {
|
|||
$link_add = "";
|
||||
}
|
||||
$submenu_output .= '<li'.($class ? ' class="'.$class.'"' : '').'>';
|
||||
$submenu_output .= '<a href="index.php?sec='.$mainsec.'&sec2='.$subsec2.($main["refr"] ? '&refr='.$main["refr"] : '').$link_add.'"'.($class == 'submenu_selected' ? ' style="font-weight:bold;"' : '').'>'.$sub["text"].'</a>';
|
||||
$submenu_output .= '<a href="index.php?sec='.$mainsec.'&sec2='.$subsec2.($main["refr"] ? '&refr='.$main["refr"] : '').$link_add.'">'.$sub["text"].'</a>';
|
||||
$submenu_output .= '</li>';
|
||||
}
|
||||
}
|
||||
|
||||
//Print out the first level
|
||||
$output .= '<li class="'.implode (" ", $classes).'" id="icon_'.$id.'">';
|
||||
$output .= '<a href="index.php?sec='.$mainsec.'&sec2='.$main["sec2"].($main["refr"] ? '&refr='.$main["refr"] : '').'"'.(($selected || in_array ("selected", $classes)) ? ' style="font-weight:bold;"' : '').'>'.$main["text"].'</a><img class="toggle" src="include/styles/images/toggle.png" alt="toggle" />';
|
||||
$output .= '<a href="index.php?sec='.$mainsec.'&sec2='.$main["sec2"].($main["refr"] ? '&refr='.$main["refr"] : '').'">'.$main["text"].'</a><img class="toggle" src="include/styles/images/toggle.png" alt="toggle" />';
|
||||
if ($submenu_output != '') {
|
||||
//WARNING: IN ORDER TO MODIFY THE VISIBILITY OF MENU'S AND SUBMENU'S (eg. with cookies) YOU HAVE TO ADD TO THIS ELSEIF. DON'T MODIFY THE CSS
|
||||
if ($visible || in_array ("selected", $classes)) {
|
||||
$visible = true;
|
||||
$visible = true;
|
||||
}
|
||||
$output .= '<ul class="submenu'.($visible ? '' : ' invisible').'">';
|
||||
$output .= $submenu_output;
|
||||
$output .= '</ul>';
|
||||
$output .= '</ul>';
|
||||
}
|
||||
$output .= '</li>';
|
||||
echo $output;
|
||||
|
@ -136,13 +136,13 @@ unset ($menu);
|
|||
require ("links_menu.php");
|
||||
|
||||
$config['jquery'][] = 'cookie';
|
||||
print_r ($_COOKIE);
|
||||
?>
|
||||
<script type="text/javascript" language="javascript">
|
||||
$(document).ready( function() {
|
||||
$("img.toggle").click (function() {
|
||||
$(this).siblings("ul").slideToggle ("slow");
|
||||
return false; //In case the A gets activated, we don't want to follow link
|
||||
$("img.toggle").click (function () {
|
||||
$(this).siblings ("ul").toggle ();
|
||||
//In case the links gets activated, we don't want to follow link
|
||||
return false;
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
|
|
@ -323,9 +323,6 @@ $(document).ready (function () {
|
|||
return false;
|
||||
}
|
||||
|
||||
if ($("#action", this).attr ("value") == 0) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
|
|
|
@ -277,38 +277,6 @@ if (isset($_GET["fix_module"])){
|
|||
}
|
||||
}
|
||||
|
||||
// Delete Alert component (from a combined)
|
||||
// ==========================================
|
||||
if (isset($_GET["delete_alert_comp"])) { // if modified some parameter
|
||||
$id_borrar_modulo = get_parameter_get ("delete_alert_comp",0);
|
||||
// get info about agent
|
||||
$sql = sprintf ("DELETE FROM tcompound_alert WHERE id_aam = %d", $id_borrar_modulo);
|
||||
$result = process_sql ($sql);
|
||||
|
||||
if ($result === false) {
|
||||
echo '<h3 class="error">'.__('There was a problem deleting alert').'</h3>';
|
||||
} else {
|
||||
echo '<h3 class="suc">'.__('Alert successfully deleted').'</h3>';
|
||||
}
|
||||
}
|
||||
|
||||
// Combined ALERT - Add component
|
||||
// ================================
|
||||
if (isset($_POST["add_alert_combined"])) { // Update an existing alert
|
||||
$alerta_id_aam = get_parameter ('update_alert', -1);
|
||||
$component_item = get_parameter ('component_item', -1);
|
||||
$component_operation = get_parameter ('component_operation', 'AND');
|
||||
$sql = sprintf ("INSERT INTO tcompound_alert (id, id_aam, operation) VALUES (%d, %d, '%s')",
|
||||
$alerta_id_aam, $component_item, $component_operation);
|
||||
$result = process_sql ($sql);
|
||||
if ($result === false) {
|
||||
echo '<h3 class="error">'.__('There was a problem creating the combined alert').'</h3>';
|
||||
} else {
|
||||
echo '<h3 class="suc">'.__('Combined alert successfully created').'</h3>';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// ================
|
||||
// Update AGENT
|
||||
// ================
|
||||
|
|
|
@ -327,9 +327,7 @@ $(document).ready (function () {
|
|||
$("form#module_form").submit (function () {
|
||||
if ($("#text-name").attr ("value") == "") {
|
||||
$("#text-name").pulsate ().focus ();
|
||||
$("#message").hide ().empty ()
|
||||
.text ("<?php echo __('No module name provided') ?>")
|
||||
.slideDown ();
|
||||
$("#message").showMessage ("<?php echo __('No module name provided') ?>");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -339,9 +337,7 @@ $(document).ready (function () {
|
|||
/* Network module */
|
||||
if ($("#text-ip_target").attr ("value") == "") {
|
||||
$("#text-ip_target").pulsate ().focus ();
|
||||
$("#message").hide ().empty ()
|
||||
.text ("<?php echo __('No target IP provided') ?>")
|
||||
.slideDown ();
|
||||
$("#message").showMessage ("<?php echo __('No target IP provided') ?>");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -349,9 +345,7 @@ $(document).ready (function () {
|
|||
if (snmp.in_array (module)) {
|
||||
if ($("#text-snmp_oid").attr ("value") == "") {
|
||||
if ($("#select_snmp_oid").attr ("value") == "") {
|
||||
$("#message").hide ().empty ()
|
||||
.text ("<?php echo __('No SNMP OID provided') ?>")
|
||||
.slideDown ();
|
||||
$("#message").showMessage ("<?php echo __('No SNMP OID provided') ?>");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,69 @@
|
|||
<?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 General Public License
|
||||
// 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.
|
||||
|
||||
check_login ();
|
||||
|
||||
if (! give_acl ($config['id_user'], 0, "LM")) {
|
||||
audit_db ($config['id_user'], $REMOTE_ADDR, "ACL Violation",
|
||||
"Trying to access Alert Management");
|
||||
require ("general/noaccess.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
require_once ('include/functions_agents.php');
|
||||
|
||||
echo '<h1>'.__('Compound alerts').'</h1>';
|
||||
|
||||
$groups = get_user_groups ();
|
||||
$agents = get_group_agents (array_keys ($groups), false, "none");
|
||||
|
||||
$table->class = 'alert_list';
|
||||
$table->width = '90%';
|
||||
|
||||
foreach ($agents as $agent_id => $agent_name) {
|
||||
$alerts = get_agent_alerts_compound ($agent_id);
|
||||
if (empty ($alerts))
|
||||
continue;
|
||||
|
||||
echo '<h3>'.$agent_name.' - '.__('Compound alerts').'</h3>';
|
||||
|
||||
$table->data = array ();
|
||||
$table->head = array ();
|
||||
$table->style = array ();
|
||||
$table->style[0] = 'font-weight: bold';
|
||||
$table->head[0] = __('Name');
|
||||
|
||||
foreach ($alerts as $alert) {
|
||||
$data = array ();
|
||||
|
||||
$data[0] = '<a href="index.php?sec=galertas&sec2=godmode/alerts/configure_alert_compound&id='.$alert['id'].'">';
|
||||
$data[0] .= $alert['name'];
|
||||
$data[0] .= '</a>';
|
||||
|
||||
array_push ($table->data, $data);
|
||||
}
|
||||
|
||||
print_table ($table);
|
||||
}
|
||||
|
||||
echo '<div class="action-buttons" style="width: '.$table->width.'">';
|
||||
echo '<form method="post" action="index.php?sec=galertas&sec2=godmode/alerts/configure_alert_compound">';
|
||||
print_submit_button (__('Create'), 'crtbtn', false, 'class="sub next"');
|
||||
print_input_hidden ('new_compound', 1);
|
||||
echo '</form>';
|
||||
echo '</div>';
|
||||
?>
|
|
@ -0,0 +1,167 @@
|
|||
<?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 General Public License
|
||||
// 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.
|
||||
|
||||
check_login ();
|
||||
|
||||
if (! give_acl ($config['id_user'], 0, "LM")) {
|
||||
audit_db ($config['id_user'], $REMOTE_ADDR, "ACL Violation",
|
||||
"Trying to access Alert Management");
|
||||
require ("general/noaccess.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
require_once ('include/functions_agents.php');
|
||||
require_once ('include/functions_alerts.php');
|
||||
|
||||
|
||||
$disable_alert = (bool) get_parameter ('disable_alert');
|
||||
$enable_alert = (bool) get_parameter ('enable_alert');
|
||||
|
||||
if ($enable_alert) {
|
||||
$id_alert = (int) get_parameter ('id_alert');
|
||||
|
||||
$result = set_alerts_agent_module_disable ($id_alert, false);
|
||||
print_error_message ($id, __('Successfully enabled'),
|
||||
__('Could not be enabled'));
|
||||
if (defined ('AJAX'))
|
||||
return;
|
||||
}
|
||||
|
||||
if ($disable_alert) {
|
||||
$id_alert = (int) get_parameter ('id_alert');
|
||||
|
||||
$result = set_alerts_agent_module_disable ($id_alert, true);
|
||||
print_error_message ($id, __('Successfully disabled'),
|
||||
__('Could not be disabled'));
|
||||
if (defined ('AJAX'))
|
||||
return;
|
||||
}
|
||||
|
||||
echo '<h1>'.__('Alerts').'</h1>';
|
||||
|
||||
$groups = get_user_groups ();
|
||||
$agents = get_group_agents (array_keys ($groups), false, "none");
|
||||
|
||||
$simple_alerts = array ();
|
||||
$compound_alerts = array ();
|
||||
foreach ($agents as $agent_id => $agent_name) {
|
||||
$agent_alerts = get_agent_alerts_simple ($agent_id);
|
||||
if (! empty ($agent_alerts))
|
||||
$simple_alerts[$agent_id] = $agent_alerts;
|
||||
|
||||
$compound_alerts = get_agent_alerts_compound ($agent_id);
|
||||
if (! empty ($agent_alerts))
|
||||
$compound_alerts[$agent_id] = $compound_alerts;
|
||||
}
|
||||
|
||||
foreach ($simple_alerts as $agent_id => $alerts) {
|
||||
if (empty ($alerts))
|
||||
continue;
|
||||
|
||||
echo '<h3>'.get_agent_name ($agent_id).' - '.__('Alerts defined').'</h3>';
|
||||
|
||||
$table->class = 'alert_list';
|
||||
$table->width = '90%';
|
||||
$table->data = array ();
|
||||
$table->head = array ();
|
||||
$table->head[0] = '';
|
||||
$table->head[1] = __('Module');
|
||||
$table->head[2] = __('Template');
|
||||
$table->head[3] = __('Actions');
|
||||
$table->size = array ();
|
||||
$table->size[0] = '20px';
|
||||
|
||||
foreach ($alerts as $alert) {
|
||||
$data = array ();
|
||||
|
||||
$data[0] = '<form class="disable_alert_form" method="post" style="display: inline;">';
|
||||
if ($alert['disabled']) {
|
||||
$data[0] .= print_input_image ('enable', 'images/lightbulb_off.png', 1, '', true);
|
||||
$data[0] .= print_input_hidden ('enable_alert', 1, true);
|
||||
} else {
|
||||
$data[0] .= print_input_image ('disable', 'images/lightbulb.png', 1, '', true);
|
||||
$data[0] .= print_input_hidden ('disable_alert', 1, true);
|
||||
}
|
||||
$data[0] .= print_input_hidden ('id_alert', $alert['id'], true);
|
||||
$data[0] .= '</form>';
|
||||
$data[1] = get_agentmodule_name ($alert['id_agent_module']);
|
||||
$data[2] = get_alert_template_name ($alert['id_alert_template']);
|
||||
$data[2] .= ' <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>';
|
||||
|
||||
$actions = get_alert_actions ($alert['id']);
|
||||
$data[3] = '<ul class="action_list">';
|
||||
foreach ($actions as $action) {
|
||||
$data[3] .= '<li>'.$action.'</li>';
|
||||
}
|
||||
$data[3] .= '</ul>';
|
||||
|
||||
array_push ($table->data, $data);
|
||||
}
|
||||
|
||||
print_table ($table);
|
||||
}
|
||||
?>
|
||||
|
||||
<link rel="stylesheet" href="include/styles/cluetip.css" type="text/css" />
|
||||
<script type="text/javascript" src="include/javascript/jquery.cluetip.js"></script>
|
||||
<script type="text/javascript" src="include/javascript/jquery.form.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
/* <![CDATA[ */
|
||||
$(document).ready (function () {
|
||||
$("a.template_details").cluetip ({
|
||||
arrows: true,
|
||||
attribute: 'href',
|
||||
cluetipClass: 'default'
|
||||
}).click (function () {
|
||||
return false;
|
||||
});;
|
||||
$("input[name=disable]").attr ("title", "<?php echo __('Disable')?>")
|
||||
.hover (function () {
|
||||
$(this).attr ("src", "images/lightbulb_off.png");
|
||||
},
|
||||
function () {
|
||||
$(this).attr ("src", "images/lightbulb.png");
|
||||
}
|
||||
);
|
||||
$("input[name=enable]").attr ("title", "<?php echo __('Enable')?>")
|
||||
.hover (function () {
|
||||
$(this).attr ("src", "images/lightbulb.png");
|
||||
},
|
||||
function () {
|
||||
$(this).attr ("src", "images/lightbulb_off.png");
|
||||
}
|
||||
);
|
||||
$("form.disable_alert_form").submit (function () {
|
||||
jQuery.post ("ajax.php",
|
||||
{"page" : "godmode/alerts/alert_list",
|
||||
"enable-alert" : $("#hidden-enable_alert", this).attr ("value"),
|
||||
"disable-alert" : $("#hidden-disable_alert", this).attr ("value"),
|
||||
"id-alert" : $("#hidden-id_alert", this).attr ("value")},
|
||||
function (data, status) {
|
||||
$("#hidden-enable_alert", this).attr ("value", 0);
|
||||
$("#hidden-disable_alert", this).attr ("value", 1);
|
||||
},
|
||||
"html"
|
||||
);
|
||||
return false;
|
||||
});
|
||||
});
|
||||
/* ]]> */
|
||||
</script>
|
|
@ -0,0 +1,834 @@
|
|||
<?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 General Public License
|
||||
// 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.
|
||||
|
||||
check_login ();
|
||||
|
||||
if (! give_acl ($config['id_user'], 0, "AW")) {
|
||||
audit_db ($config['id_user'], $REMOTE_ADDR, "ACL Violation",
|
||||
"Trying to access Alert Management");
|
||||
require ("general/noaccess.php");
|
||||
return;
|
||||
}
|
||||
|
||||
if (defined ('AJAX')) {
|
||||
$get_group_agents = (bool) get_parameter ('get_group_agents');
|
||||
$get_agent_alerts = (bool) get_parameter ('get_agent_alerts');
|
||||
|
||||
if ($get_group_agents) {
|
||||
$id_group = (int) get_parameter ('id_group');
|
||||
echo json_encode (get_group_agents ($id_group));
|
||||
return;
|
||||
}
|
||||
|
||||
if ($get_agent_alerts) {
|
||||
$id_agent = (int) get_parameter ('id_agent');
|
||||
if ($id_agent <= 0) {
|
||||
echo json_encode (false);
|
||||
return;
|
||||
}
|
||||
$id_group = get_agent_group ($id_agent);
|
||||
|
||||
if (! give_acl ($config['id_user'], $id_group, "AR")) {
|
||||
audit_db ($config['id_user'], $REMOTE_ADDR, "ACL Violation",
|
||||
"Trying to access Alert Management");
|
||||
echo json_encode (false);
|
||||
return;
|
||||
}
|
||||
|
||||
require_once ('include/functions_agents.php');
|
||||
require_once ('include/functions_alerts.php');
|
||||
|
||||
$alerts = get_agent_alerts_simple ($id_agent);
|
||||
if (empty ($alerts)) {
|
||||
echo json_encode (false);
|
||||
return;
|
||||
}
|
||||
|
||||
$retval = array ();
|
||||
foreach ($alerts as $alert) {
|
||||
$alert['template'] = get_alert_template ($alert['id_alert_template']);
|
||||
$alert['module_name'] = get_agentmodule_name ($alert['id_agent_module']);
|
||||
$alert['agent_name'] = get_agentmodule_agent_name ($alert['id_agent_module']);
|
||||
$retval[$alert['id']] = $alert;
|
||||
}
|
||||
|
||||
echo json_encode ($retval);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
$id = (int) get_parameter ('id');
|
||||
$id_agent = (int) get_parameter ('id_agent');
|
||||
|
||||
require_once ('include/functions_agents.php');
|
||||
require_once ('include/functions_alerts.php');
|
||||
|
||||
function print_alert_compound_steps ($step, $id) {
|
||||
echo '<ol class="steps">';
|
||||
|
||||
/* Step 1 */
|
||||
if ($step == 1)
|
||||
echo '<li class="first current">';
|
||||
elseif ($step > 1)
|
||||
echo '<li class="first visited">';
|
||||
else
|
||||
echo '<li class="first">';
|
||||
|
||||
if ($id) {
|
||||
echo '<a href="index.php?sec=galertas&sec2=godmode/alerts/configure_alert_compound&id='.$id.'">';
|
||||
echo __('Step').' 1 » ';
|
||||
echo '<span>'.__('Conditions').'</span>';
|
||||
echo '</a>';
|
||||
} else {
|
||||
echo __('Step').' 1 » ';
|
||||
echo '<span>'.__('Conditions').'</span>';
|
||||
}
|
||||
echo '</li>';
|
||||
|
||||
/* Step 2 */
|
||||
if ($step == 2)
|
||||
echo '<li class="current">';
|
||||
elseif ($step > 2)
|
||||
echo '<li class="visited">';
|
||||
else
|
||||
echo '<li>';
|
||||
|
||||
if ($id) {
|
||||
echo '<a href="index.php?sec=galertas&sec2=godmode/alerts/configure_alert_compound&id='.$id.'&step=2">';
|
||||
echo __('Step').' 2 » ';
|
||||
echo '<span>'.__('Firing').'</span>';
|
||||
echo '</a>';
|
||||
} else {
|
||||
echo __('Step').' 2 » ';
|
||||
echo '<span>'.__('Firing').'</span>';
|
||||
}
|
||||
|
||||
/* Step 3 */
|
||||
if ($step == 3)
|
||||
echo '<li class="last current">';
|
||||
elseif ($step > 3)
|
||||
echo '<li class="last visited">';
|
||||
else
|
||||
echo '<li class="last">';
|
||||
|
||||
if ($id) {
|
||||
echo '<a href="index.php?sec=galertas&sec2=godmode/alerts/configure_alert_compound&id='.$id.'&step=3">';
|
||||
echo __('Step').' 3 » ';
|
||||
echo '<span>'.__('Recovery').'</span>';
|
||||
echo '</a>';
|
||||
} else {
|
||||
echo __('Step').' 3 » ';
|
||||
echo '<span>'.__('Recovery').'</span>';
|
||||
}
|
||||
|
||||
echo '</ol>';
|
||||
echo '<div style="clear: both;"> </div>';
|
||||
}
|
||||
|
||||
function update_compound ($step) {
|
||||
$id = (int) get_parameter ('id');
|
||||
|
||||
if (empty ($id))
|
||||
return false;
|
||||
|
||||
if ($step == 1) {
|
||||
$id_agent = (int) get_parameter ('id_agent');
|
||||
$name = (string) get_parameter ('name');
|
||||
$description = (string) get_parameter ('description');
|
||||
|
||||
$result = update_alert_compound ($id,
|
||||
array ('name' => $name,
|
||||
'description' => $description,
|
||||
'id_agent' => $id_agent));
|
||||
} elseif ($step == 2) {
|
||||
$monday = (bool) get_parameter ('monday');
|
||||
$tuesday = (bool) get_parameter ('tuesday');
|
||||
$wednesday = (bool) get_parameter ('wednesday');
|
||||
$thursday = (bool) get_parameter ('thursday');
|
||||
$friday = (bool) get_parameter ('friday');
|
||||
$saturday = (bool) get_parameter ('saturday');
|
||||
$sunday = (bool) get_parameter ('sunday');
|
||||
$time_from = (string) get_parameter ('time_from');
|
||||
$time_from = date ("H:s:00", strtotime ($time_from));
|
||||
$time_to = (string) get_parameter ('time_to');
|
||||
$time_to = date ("H:s:00", strtotime ($time_to));
|
||||
$threshold = (int) get_parameter ('threshold');
|
||||
$max_alerts = (int) get_parameter ('max_alerts');
|
||||
$min_alerts = (int) get_parameter ('min_alerts');
|
||||
if ($threshold == -1)
|
||||
$threshold = (int) get_parameter ('other_threshold');
|
||||
|
||||
$values = array ('monday' => $monday,
|
||||
'tuesday' => $tuesday,
|
||||
'wednesday' => $wednesday,
|
||||
'thursday' => $thursday,
|
||||
'friday' => $friday,
|
||||
'saturday' => $saturday,
|
||||
'sunday' => $sunday,
|
||||
'time_from' => $time_from,
|
||||
'time_to' => $time_to,
|
||||
'time_threshold' => $threshold,
|
||||
'max_alerts' => $max_alerts,
|
||||
'min_alerts' => $min_alerts
|
||||
);
|
||||
|
||||
$result = update_alert_compound ($id, $values);
|
||||
|
||||
/* Update actions */
|
||||
$actions = (array) get_parameter ('actions');
|
||||
foreach ($actions as $id_action) {
|
||||
/* TODO: fires_min and fires_max missing */
|
||||
add_alert_compound_action ($id, (int) $id_action);
|
||||
}
|
||||
} elseif ($step == 3) {
|
||||
$recovery_notify = (bool) get_parameter ('recovery_notify');
|
||||
$field2_recovery = (bool) get_parameter ('field2_recovery');
|
||||
$field3_recovery = (bool) get_parameter ('field3_recovery');
|
||||
|
||||
$result = update_alert_compound ($id,
|
||||
array ('recovery_notify' => $recovery_notify,
|
||||
'field2_recovery' => $field2_recovery,
|
||||
'field3_recovery' => $field3_recovery));
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/* We set here the number of steps */
|
||||
define ('LAST_STEP', 3);
|
||||
|
||||
$step = (int) get_parameter ('step', 1);
|
||||
|
||||
$create_compound = (bool) get_parameter ('create_compound');
|
||||
$update_compound = (bool) get_parameter ('update_compound');
|
||||
|
||||
$name = '';
|
||||
$description = '';
|
||||
$time_from = '12:00';
|
||||
$time_to = '12:00';
|
||||
$monday = true;
|
||||
$tuesday = true;
|
||||
$wednesday = true;
|
||||
$thursday = true;
|
||||
$friday = true;
|
||||
$saturday = true;
|
||||
$sunday = true;
|
||||
$default_action = 0;
|
||||
$field1 = '';
|
||||
$field2 = '';
|
||||
$field3 = '';
|
||||
$min_alerts = 0;
|
||||
$max_alerts = 1;
|
||||
$threshold = 300;
|
||||
$recovery_notify = false;
|
||||
$field2_recovery = '';
|
||||
$field3_recovery = '';
|
||||
|
||||
if ($id && ! $create_compound) {
|
||||
$compound = get_alert_compound ($id);
|
||||
$name = $compound['name'];
|
||||
$description = $compound['description'];
|
||||
$time_from = $compound['time_from'];
|
||||
$time_to = $compound['time_to'];
|
||||
$monday = (bool) $compound['monday'];
|
||||
$tuesday = (bool) $compound['tuesday'];
|
||||
$wednesday = (bool) $compound['wednesday'];
|
||||
$thursday = (bool) $compound['thursday'];
|
||||
$friday = (bool) $compound['friday'];
|
||||
$saturday = (bool) $compound['saturday'];
|
||||
$sunday = (bool) $compound['sunday'];
|
||||
$max_alerts = $compound['max_alerts'];
|
||||
$min_alerts = $compound['min_alerts'];
|
||||
$threshold = $compound['time_threshold'];
|
||||
$recovery_notify = $compound['recovery_notify'];
|
||||
$field2_recovery = $compound['field2_recovery'];
|
||||
$field3_recovery = $compound['field3_recovery'];
|
||||
$id_agent = $compound['id_agent'];
|
||||
$id_group = get_agent_group ($id_agent);
|
||||
if (! give_acl ($config['id_user'], $id_group, "AW")) {
|
||||
audit_db ($config['id_user'], $REMOTE_ADDR, "ACL Violation",
|
||||
"Trying to access Alert Management");
|
||||
require ("general/noaccess.php");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if ($create_compound) {
|
||||
$name = (string) get_parameter ('name');
|
||||
$description = (string) get_parameter ('description');
|
||||
|
||||
$result = create_alert_compound ($name, $id_agent,
|
||||
array ('description' => $description));
|
||||
|
||||
print_error_message ($result, __('Successfully created'),
|
||||
__('Could not be created'));
|
||||
/* Go to previous step in case of error */
|
||||
if ($result === false)
|
||||
$step = $step - 1;
|
||||
else {
|
||||
$id = $result;
|
||||
$alerts = (array) get_parameter ('conditions');
|
||||
$operations = (array) get_parameter ('operations');
|
||||
|
||||
foreach ($alerts as $id_alert) {
|
||||
add_alert_compound_element ($id, (int) $id_alert, $operations[$id_alert]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($update_compound) {
|
||||
$result = update_compound ($step - 1);
|
||||
|
||||
print_error_message ($result, __('Successfully updated'),
|
||||
__('Could not be updated'));
|
||||
/* Go to previous step in case of error */
|
||||
if ($result === false) {
|
||||
$step = $step - 1;
|
||||
}
|
||||
}
|
||||
|
||||
echo '<h1>'.__('Configure compound alert').'</h1>';
|
||||
|
||||
print_alert_compound_steps ($step, $id);
|
||||
|
||||
$table->id = 'compound';
|
||||
$table->width = '90%';
|
||||
$table->style = array ();
|
||||
$table->style[0] = 'font-weight: bold; vertical-align: top';
|
||||
$table->style[2] = 'font-weight: bold';
|
||||
$table->size = array ();
|
||||
$table->size[0] = '20%';
|
||||
$table->size[2] = '20%';
|
||||
if ($step == 2) {
|
||||
/* Firing conditions and events */
|
||||
$threshold_values = get_alert_compound_threshold_values ();
|
||||
if (in_array ($threshold, array_keys ($threshold_values))) {
|
||||
$table->style['other_label'] = 'display:none; font-weight: bold';
|
||||
$table->style['other_input'] = 'display:none';
|
||||
$threshold_selected = $threshold;
|
||||
} else {
|
||||
$table->style['other_label'] = 'font-weight: bold';
|
||||
$threshold_selected = -1;
|
||||
}
|
||||
|
||||
if ($default_action == 0) {
|
||||
$table->rowstyle = array ();
|
||||
$table->rowstyle['field1'] = 'display: none';
|
||||
$table->rowstyle['field2'] = 'display: none';
|
||||
$table->rowstyle['field3'] = 'display: none';
|
||||
$table->rowstyle['preview'] = 'display: none';
|
||||
}
|
||||
$table->colspan = array ();
|
||||
$table->colspan[0][1] = 3;
|
||||
$table->colspan[4][1] = 3;
|
||||
$table->colspan['actions'][1] = 3;
|
||||
$table->colspan['field1'][1] = 3;
|
||||
$table->colspan['field2'][1] = 3;
|
||||
$table->colspan['field3'][1] = 3;
|
||||
$table->colspan['preview'][1] = 3;
|
||||
|
||||
$table->data[0][0] = __('Days of week');
|
||||
$table->data[0][1] = __('Mon');
|
||||
$table->data[0][1] .= print_checkbox ('monday', 1, $monday, true);
|
||||
$table->data[0][1] .= __('Tue');
|
||||
$table->data[0][1] .= print_checkbox ('tuesday', 1, $tuesday, true);
|
||||
$table->data[0][1] .= __('Wed');
|
||||
$table->data[0][1] .= print_checkbox ('wednesday', 1, $wednesday, true);
|
||||
$table->data[0][1] .= __('Thu');
|
||||
$table->data[0][1] .= print_checkbox ('thursday', 1, $thursday, true);
|
||||
$table->data[0][1] .= __('Fri');
|
||||
$table->data[0][1] .= print_checkbox ('friday', 1, $friday, true);
|
||||
$table->data[0][1] .= __('Sat');
|
||||
$table->data[0][1] .= print_checkbox ('saturday', 1, $saturday, true);
|
||||
$table->data[0][1] .= __('Sun');
|
||||
$table->data[0][1] .= print_checkbox ('sunday', 1, $sunday, true);
|
||||
|
||||
$table->data[1][0] = __('Time from');
|
||||
$table->data[1][1] = print_input_text ('time_from', $time_from, '', 7, 7,
|
||||
true);
|
||||
$table->data[1][2] = __('Time to');
|
||||
$table->data[1][3] = print_input_text ('time_to', $time_to, '', 7, 7,
|
||||
true);
|
||||
|
||||
$table->data['threshold'][0] = __('Time threshold');
|
||||
$table->data['threshold'][1] = print_select ($threshold_values,
|
||||
'threshold', $threshold_selected, '', '', '', true, false, false);
|
||||
$table->data['threshold']['other_label'] = __('Other value');
|
||||
$table->data['threshold']['other_input'] = print_input_text ('other_threshold',
|
||||
$threshold, '', 5, 7, true);
|
||||
$table->data['threshold']['other_input'] .= ' '.__('seconds');
|
||||
|
||||
$table->data[3][0] = __('Min. number of alerts');
|
||||
$table->data[3][1] = print_input_text ('min_alerts', $min_alerts, '',
|
||||
5, 7, true);
|
||||
$table->data[3][2] = __('Max. number of alerts');
|
||||
$table->data[3][3] = print_input_text ('max_alerts', $max_alerts, '',
|
||||
5, 7, true);
|
||||
|
||||
$table->data[4][0] = __('Actions');
|
||||
$table->data[4][1] = print_select_from_sql ('SELECT id, name FROM talert_actions ORDER BY name',
|
||||
'action', '', '', __('Select'), 0, true, false, false).' ';
|
||||
$table->data[4][1] .= print_button (__('Add'), 'add_action', false, '',
|
||||
'class="sub next"', true);
|
||||
$table->data[4][1] .= '<br />';
|
||||
$table->data[4][1] .= '<span><a href="#" class="show_advanced_actions">'.__('Advanced options').' » </a></span>';
|
||||
$table->data[4][1] .= '<span class="advanced_actions invisible">';
|
||||
$table->data[4][1] .= __('From').' ';
|
||||
$table->data[4][1] .= print_input_text ('fires_min', 0, '', 4, 10, true);
|
||||
$table->data[4][1] .= ' '.__('to').' ';
|
||||
$table->data[4][1] .= print_input_text ('fires_max', 0, '', 4, 10, true);
|
||||
$table->data[4][1] .= ' '.__('matches of the alert');
|
||||
$table->data[4][1] .= pandora_help("alert-matches", true);
|
||||
$table->data[4][1] .= '</span>';
|
||||
|
||||
$table->data['actions'][0] = __('Assigned actions');
|
||||
$table->data['actions'][1] = '<ul id="alert_actions">';
|
||||
if ($id) {
|
||||
$actions = get_alert_compound_actions ($id);
|
||||
if (empty ($actions))
|
||||
$table->rowstyle['actions'] = 'display: none';
|
||||
foreach ($actions as $action) {
|
||||
$table->data['actions'][1] .= '<li>';
|
||||
$table->data['actions'][1] .= $action['name'];
|
||||
$table->data['actions'][1] .= ' <em>(';
|
||||
if ($action['fires_min'] == $action['fires_max']) {
|
||||
if ($action['fires_min'] == 0)
|
||||
$table->data['actions'][1] .= __('Always');
|
||||
else
|
||||
$table->data['actions'][1] .= __('On').' '.$action['fires_min'];
|
||||
} else {
|
||||
if ($action['fires_min'] == 0)
|
||||
$table->data['actions'][1] .= __('Until').' '.$action['fires_max'];
|
||||
else
|
||||
$table->data['actions'][1] .= __('From').' '.$action['fires_min'].
|
||||
' '.__('to').' '.$action['fires_max'];
|
||||
}
|
||||
$table->data['actions'][1] .= ')</em></li>';
|
||||
}
|
||||
}
|
||||
$table->data['actions'][1] .= '</ul>';
|
||||
|
||||
} else if ($step == 3) {
|
||||
/* Alert recover */
|
||||
if (! $recovery_notify) {
|
||||
$table->rowstyle = array ();
|
||||
$table->rowstyle['field2'] = 'display:none;';
|
||||
$table->rowstyle['field3'] = 'display:none';
|
||||
}
|
||||
$table->data[0][0] = __('Alert recovery');
|
||||
$values = array (false => __('Disabled'), true => __('Enabled'));
|
||||
$table->data[0][1] = print_select ($values,
|
||||
'recovery_notify', $recovery_notify, '', '', '', true, false,
|
||||
false);
|
||||
|
||||
$table->data['field2'][0] = __('Field 2');
|
||||
$table->data['field2'][1] = print_input_text ('field2_recovery',
|
||||
$field2_recovery, '', 35, 255, true);
|
||||
|
||||
$table->data['field3'][0] = __('Field 3');
|
||||
$table->data['field3'][1] = print_textarea ('field3_recovery', 30, 30,
|
||||
$field3_recovery, '', true);
|
||||
} else {
|
||||
/* Step 1 by default */
|
||||
$table->size = array ();
|
||||
$table->size[0] = '20%';
|
||||
$table->data = array ();
|
||||
$table->rowstyle = array ();
|
||||
$table->rowstyle['value'] = 'display: none';
|
||||
$table->rowstyle['max'] = 'display: none';
|
||||
$table->rowstyle['min'] = 'display: none';
|
||||
$table->rowstyle['conditions'] = 'display: none';
|
||||
|
||||
$show_matches = false;
|
||||
if ($id) {
|
||||
$table->rowstyle['conditions'] = '';
|
||||
}
|
||||
|
||||
$table->data[0][0] = __('Name');
|
||||
$table->data[0][1] = print_input_text ('name', $name, '', 35, 255, true);
|
||||
|
||||
$table->data[1][0] = __('Assigned to');
|
||||
$groups = get_user_groups ();
|
||||
$table->data[1][1] = print_select (get_group_agents (),
|
||||
'id_agent', $id_agent, '', __('Select'), 0, true);
|
||||
$table->data[2][0] = __('Description');
|
||||
$table->data[2][1] = print_textarea ('description', 30, 30,
|
||||
$description, '', true);
|
||||
|
||||
$table->data[3][0] = __('Condition');
|
||||
$table->data[3][0] .= '<a name="condition" />';
|
||||
$table->colspan[3][0] = 2;
|
||||
|
||||
$table_alerts->id = 'conditions_list';
|
||||
$table_alerts->width = '100%';
|
||||
$table_alerts->data = array ();
|
||||
$table_alerts->head = array ();
|
||||
$table_alerts->head[0] = '';
|
||||
$table_alerts->head[1] = __('Module');
|
||||
$table_alerts->head[2] = __('Alert');
|
||||
$table_alerts->head[3] = __('Operator');
|
||||
$table_alerts->size = array ();
|
||||
$table_alerts->size[0] = '20px';
|
||||
$table_alerts->size[1] = '45%';
|
||||
$table_alerts->size[2] = '45%';
|
||||
$table_alerts->size[3] = '10%';
|
||||
|
||||
if ($id) {
|
||||
$conditions = get_alert_compound_elements ($id);
|
||||
if ($conditions === false)
|
||||
$conditions = array ();
|
||||
foreach ($conditions as $condition) {
|
||||
$data = array ();
|
||||
|
||||
$alert = get_alert_agent_module ($condition['id_alert_template_module']);
|
||||
$data[0] = '<a href="#" class="remove_alert" id="alert-'.$alert['id'].'" />';
|
||||
$data[0] .= '<img src="images/delete.png" />';
|
||||
$data[0] .= '</a>';
|
||||
$data[1] = get_alert_template_name ($alert['id_alert_template']);
|
||||
$data[2] = get_agentmodule_name ($alert['id_agent_module']);
|
||||
$data[3] = print_select (get_alert_compound_operations (),
|
||||
'operations['.$id.']', $condition['operation'], '', '', '', true);
|
||||
$data[3] .= print_input_hidden ("conditions[]", $alert['id']);
|
||||
|
||||
array_push ($table_alerts->data, $data);
|
||||
}
|
||||
}
|
||||
|
||||
$table->data['conditions'][1] = print_table ($table_alerts, true);
|
||||
$table->colspan['conditions'][1] = 2;
|
||||
}
|
||||
|
||||
/* If it's the last step it will redirect to compound lists */
|
||||
if ($step >= LAST_STEP) {
|
||||
echo '<form method="post" id="alert_form" action="index.php?sec=galertas&sec2=godmode/alerts/alert_compounds">';
|
||||
} else {
|
||||
echo '<form method="post" id="alert_form">';
|
||||
}
|
||||
print_table ($table);
|
||||
|
||||
echo '<div id="message" class="invisible error"> </div>';
|
||||
echo '<div class="action-buttons" style="width: '.$table->width.'">';
|
||||
if ($id) {
|
||||
print_input_hidden ('id', $id);
|
||||
print_input_hidden ('update_compound', 1);
|
||||
} else {
|
||||
print_input_hidden ('create_compound', 1);
|
||||
}
|
||||
|
||||
if ($step >= LAST_STEP) {
|
||||
print_submit_button (__('Finish'), 'finish', false, 'class="sub upd"');
|
||||
} else {
|
||||
print_input_hidden ('step', $step + 1);
|
||||
print_submit_button (__('Next'), 'next', false, 'class="sub next"');
|
||||
}
|
||||
echo '</div>';
|
||||
echo '</form>';
|
||||
|
||||
/* Show alert search when we're on the first step */
|
||||
if ($step == 1) {
|
||||
echo '<h2>'.__('Add condition').'</h2>';
|
||||
|
||||
$id_group = (int) get_parameter ('id_group');
|
||||
|
||||
$table->id = 'alert_search';
|
||||
$table->data = array ();
|
||||
$table->head = array ();
|
||||
$table->size = array ();
|
||||
$table->size[0] = '10%';
|
||||
$table->size[1] = '40%';
|
||||
$table->size[2] = '10%';
|
||||
$table->size[3] = '40%';
|
||||
|
||||
$table->data[0][0] = __('Group');
|
||||
$table->data[0][1] = print_select ($groups, 'search_id_group', $id_group,
|
||||
false, '', '', true);
|
||||
$table->data[0][2] = __('Agent');
|
||||
$table->data[0][3] = print_select (get_group_agents ($id_group, false, "none"),
|
||||
'search_id_agent', $id_agent, false, __('Select'), 0, true);
|
||||
$table->data[0][3] .= '<span id="agent_loading" class="invisible">';
|
||||
$table->data[0][3] .= '<img src="images/spinner.gif" />';
|
||||
$table->data[0][3] .= '</span>';
|
||||
|
||||
print_table ($table);
|
||||
echo '<div id="alerts_loading" class="loading invisible">';
|
||||
echo '<img src="images/spinner.gif" />';
|
||||
echo __('Loading').'…';
|
||||
echo '</div>';
|
||||
|
||||
/* Rest of fields are reused */
|
||||
$table_alerts->id = 'alert_list';
|
||||
$table_alerts->width = '80%';
|
||||
$table_alerts->data = array ();
|
||||
unset ($table_alerts->head[3]);
|
||||
|
||||
if (! $id_agent) {
|
||||
$table_alerts->class = 'invisible';
|
||||
} else {
|
||||
$alerts = get_agent_alerts_simple ($id_agent);
|
||||
|
||||
foreach ($alerts as $alert) {
|
||||
$data = array ();
|
||||
|
||||
$data[0] = '<a href="#" class="add_alert" id="add-'.$alert['id'].'" />';
|
||||
$data[0] .= '<img src="images/add.png" />';
|
||||
$data[0] .= '</a>';
|
||||
$data[1] = get_agentmodule_name ($alert['id_agent_module']);
|
||||
$data[2] = get_alert_template_name ($alert['id_alert_template']);
|
||||
|
||||
array_push ($table_alerts->data, $data);
|
||||
}
|
||||
}
|
||||
|
||||
print_table ($table_alerts);
|
||||
|
||||
/* Pager for alert list using Javascript */
|
||||
echo '<div id="alerts_pager" class="'.($id_agent ? '' : 'invisible ').'pager">';
|
||||
echo '<form>';
|
||||
echo '<img src="images/control_start_blue.png" class="first" />';
|
||||
echo '<img src="images/control_rewind_blue.png" class="prev" />';
|
||||
echo '<input type="text" class="pagedisplay" />';
|
||||
echo '<img src="images/control_fastforward_blue.png" class="next" />';
|
||||
echo '<img src="images/control_end_blue.png" class="last" />';
|
||||
echo '<select class="pagesize invisible">';
|
||||
echo '<option selected="selected" value="'.$config['block_size'].'">'.$config['block_size'].'</option>';
|
||||
echo '</select>';
|
||||
echo '</form>';
|
||||
echo '</div>';
|
||||
|
||||
echo '<div class="invisible">';
|
||||
print_select (get_alert_compound_operations (), 'operations');
|
||||
echo '</div>';
|
||||
}
|
||||
?>
|
||||
|
||||
<script type="text/javascript" src="include/javascript/jquery.form.js"></script>
|
||||
<script type="text/javascript" src="include/javascript/jquery.tablesorter.js"></script>
|
||||
<script type="text/javascript" src="include/javascript/jquery.tablesorter.pager.js"></script>
|
||||
<script type="text/javascript" src="include/javascript/pandora_alerts.js"></script>
|
||||
<link rel="stylesheet" href="include/styles/timeentry.css" type="text/css" media="screen">
|
||||
<script src="include/javascript/jquery.ui.core.js"></script>
|
||||
<script src="include/javascript/jquery.timeentry.js"></script>
|
||||
<script src="include/languages/time_<?php echo $config['language']; ?>.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
var block_size = <?php echo $config['block_size']; ?>;
|
||||
var alerts;
|
||||
var compound_alerts;
|
||||
<?php if ($id_agent && isset ($alerts) && $alerts) : ?>
|
||||
alerts = Array ();
|
||||
<?php foreach ($alerts as $alert) : ?>
|
||||
alerts[<?php echo $alert['id'] ?>] = eval ("("+'<?php echo json_encode ($alert); ?>'+")");
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
|
||||
function remove_alert () {
|
||||
$(this).parents ("tr:first").remove ();
|
||||
len = $("#conditions_list tbody tr").length;
|
||||
if (len == 1) {
|
||||
$("select option[value=NOR]", tr).select (1);
|
||||
} else if (len == 0) {
|
||||
$("#conditions_list").hide ();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function add_alert () {
|
||||
id = this.id.split ("-").pop ();
|
||||
alert = alerts[id];
|
||||
if (alert == null)
|
||||
return;
|
||||
input = $("<input type=\"hidden\"></input>")
|
||||
.attr ("name", "conditions[]")
|
||||
.attr ("value", id);
|
||||
td = $("<td></td>")
|
||||
.append (input)
|
||||
.append ($("select#operations:last").clone ()
|
||||
.show ()
|
||||
.attr ("name", "operations["+id+"]")
|
||||
);
|
||||
tr = $(this).parents ("tr")
|
||||
.clone ()
|
||||
.append (td);
|
||||
$("img", tr).attr ("src", "images/delete.png");
|
||||
$("a", tr).attr("id", "remove-"+id)
|
||||
.click (remove_alert);
|
||||
|
||||
/* Select NOR operation if there's only one alert */
|
||||
if ($("#conditions_list tbody tr").length == 0)
|
||||
$("select option[value=NOR]", tr).select (1);
|
||||
|
||||
$("#conditions_list tbody").append (tr);
|
||||
$("#conditions_list").show ();
|
||||
$("#compound-conditions").show ();
|
||||
return false;
|
||||
}
|
||||
|
||||
$(document).ready (function () {
|
||||
<?php if ($step == 1): ?>
|
||||
$("a.add_alert").click (add_alert);
|
||||
$("a.remove_alert").click (remove_alert);
|
||||
|
||||
$("#alert_list").tablesorter ();
|
||||
<?php if ($id_agent && isset ($alerts) && $alerts) : ?>
|
||||
$("#alert_list").tablesorterPager ({
|
||||
container: $("#alerts_pager"),
|
||||
size: block_size
|
||||
});
|
||||
<?php endif; ?>
|
||||
$("#search_id_group").change (function () {
|
||||
$("#agent_loading").show ();
|
||||
var select = $("#search_id_agent").disable ();
|
||||
/* Remove all but "Select" */
|
||||
$("option[value!=0]", select).remove ();
|
||||
jQuery.post ("ajax.php",
|
||||
{"page" : "godmode/alerts/configure_alert_compound",
|
||||
"get_group_agents" : 1,
|
||||
"id_group" : this.value
|
||||
},
|
||||
function (data, status) {
|
||||
jQuery.each (data, function (id, value) {
|
||||
$(select).append ($("<option></option>").attr ("value", id).html (value));
|
||||
});
|
||||
$("#agent_loading").hide ();
|
||||
$("#search_id_agent").enable ();
|
||||
},
|
||||
"json"
|
||||
);
|
||||
});
|
||||
|
||||
$("#search_id_agent").change (function () {
|
||||
$("#alerts_pager").hide ();
|
||||
$("#alert_list").hide ();
|
||||
if (this.value == 0) {
|
||||
$("#alert_list tr:gt(0)").remove ();
|
||||
return;
|
||||
}
|
||||
|
||||
$("#alerts_loading").show ();
|
||||
$("#alert_list tbody").empty ();
|
||||
jQuery.post ("ajax.php",
|
||||
{"page" : "godmode/alerts/configure_alert_compound",
|
||||
"get_agent_alerts" : 1,
|
||||
"id_agent" : this.value
|
||||
},
|
||||
function (data, status) {
|
||||
if (! data) {
|
||||
$("#alerts_loading").hide ();
|
||||
tr = $('<tr></tr>').append ($('<td></td>')
|
||||
.append ("<?php echo __('No alerts found') ?>")
|
||||
.attr ("colspan", 3));
|
||||
$("#alert_list").append (tr)
|
||||
.trigger ("update")
|
||||
.show ();
|
||||
|
||||
return;
|
||||
}
|
||||
alerts = Array ();
|
||||
jQuery.each (data, function () {
|
||||
tr = $('<tr></tr>');
|
||||
img = $("<img></img>").attr ("src", "images/add.png")
|
||||
.addClass ("clickable");
|
||||
a = $("<a></a>").append (img)
|
||||
.attr ("id", "add-"+this["id"])
|
||||
.attr ("href", "#condition")
|
||||
.click (add_alert);
|
||||
td = $('<td></td>').append (a)
|
||||
.attr ("width", "20px");
|
||||
tr.append (td);
|
||||
td = $('<td></td>').append (this["module_name"])
|
||||
.attr ("width", "50%");
|
||||
tr.append (td);
|
||||
td = $('<td></td>').append (this["template"]["name"])
|
||||
.attr ("width", "50%");
|
||||
tr.append (td);
|
||||
$("#alert_list").append (tr);
|
||||
alerts[this["id"]] = this;
|
||||
});
|
||||
$("#alert_list").trigger ("update").tablesorterPager ({
|
||||
container: $("#alerts_pager"),
|
||||
size: block_size
|
||||
}).show ();
|
||||
$("#alerts_pager").show ();
|
||||
$("#alerts_loading").hide ();
|
||||
},
|
||||
"json"
|
||||
);
|
||||
});
|
||||
$("#alert_form").submit (function () {
|
||||
values = $(this).formToArray ();
|
||||
if ($("#text-name").attr ("value") == '') {
|
||||
$("#message").showMessage ("<?php echo __('No name was given') ?>");
|
||||
return false;
|
||||
}
|
||||
if ($("#id_agent").attr ("value") == 0) {
|
||||
$("#message").showMessage ("<?php echo __('No agent was given') ?>");
|
||||
return false;
|
||||
}
|
||||
if ($("input[name^=conditions]").length == 0) {
|
||||
$("#message").showMessage ("<?php echo __('No conditions were given') ?>");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
<?php elseif ($step == 2): ?>
|
||||
$("#text-time_from, #text-time_to").timeEntry ({
|
||||
spinnerImage: 'images/time-entry.png',
|
||||
spinnerSize: [20, 20, 0]
|
||||
}
|
||||
);
|
||||
|
||||
$("#threshold").change (function () {
|
||||
if (this.value == -1) {
|
||||
$("#text-other_threshold").attr ("value", "");
|
||||
$("#compound-threshold-other_label").show ();
|
||||
$("#compound-threshold-other_input").show ();
|
||||
} else {
|
||||
$("#compound-threshold-other_label").hide ();
|
||||
$("#compound-threshold-other_input").hide ();
|
||||
}
|
||||
});
|
||||
$("a.show_advanced_actions").click (function () {
|
||||
$("#text-fires_min").attr ("value", 0);
|
||||
$("#text-fires_max").attr ("value", 0);
|
||||
$(this).parents ("td").children ("span.advanced_actions").show ();
|
||||
$(this).remove ();
|
||||
return false;
|
||||
});
|
||||
$("#button-add_action").click (function () {
|
||||
value = $("#action option[selected]").html ();
|
||||
id = $("#action").fieldValue ();
|
||||
input = input = $("<input type=\"hidden\"></input>")
|
||||
.attr ("name", "actions[]")
|
||||
.attr ("value", id);
|
||||
li = $("<li></li>").append (value).append (input);
|
||||
$("ul#alert_actions").append (li);
|
||||
$("#compound-actions").show ();
|
||||
});
|
||||
<?php elseif ($step == 3): ?>
|
||||
$("#recovery_notify").change (function () {
|
||||
if (this.value == 1) {
|
||||
$("#compound-field2, #compound-field3").show ();
|
||||
} else {
|
||||
$("#compound-field2, #compound-field3").hide ();
|
||||
}
|
||||
});
|
||||
<?php endif; ?>
|
||||
});
|
||||
</script>
|
|
@ -30,52 +30,66 @@ if (! give_acl ($config['id_user'], 0, "LM")) {
|
|||
}
|
||||
|
||||
function print_alert_template_steps ($step, $id) {
|
||||
echo '<div style="margin-bottom: 15px">';
|
||||
echo '<ol class="steps">';
|
||||
|
||||
/* Step 1 */
|
||||
if ($step == 1)
|
||||
echo '<strong>';
|
||||
echo '<li class="first current">';
|
||||
elseif ($step > 1)
|
||||
echo '<li class="visited">';
|
||||
else
|
||||
echo '<li class="first">';
|
||||
|
||||
if ($id) {
|
||||
echo '<a href="index.php?sec=galertas&sec2=godmode/alerts/configure_alert_template&id='.$id.'">';
|
||||
echo __('Step').' 1 : '.__('Conditions');
|
||||
echo __('Step').' 1 » ';
|
||||
echo '<span>'.__('Conditions').'</span>';
|
||||
echo '</a>';
|
||||
} else {
|
||||
echo __('Step').' 1 : '.__('Conditions');
|
||||
echo __('Step').' 1 » ';
|
||||
echo '<span>'.__('Conditions').'</span>';
|
||||
}
|
||||
if ($step == 1)
|
||||
echo '</strong>';
|
||||
echo '</li>';
|
||||
|
||||
/* Step 2 */
|
||||
echo ' » ';
|
||||
|
||||
if ($step == 2)
|
||||
echo '<strong>';
|
||||
echo '<li class="current">';
|
||||
elseif ($step > 2)
|
||||
echo '<li class="visited">';
|
||||
else
|
||||
echo '<li>';
|
||||
|
||||
if ($id) {
|
||||
echo '<a href="index.php?sec=galertas&sec2=godmode/alerts/configure_alert_template&id='.$id.'&step=2">';
|
||||
echo __('Step').' 2 : '.__('Firing');
|
||||
echo __('Step').' 2 » ';
|
||||
echo '<span>'.__('Firing').'</span>';
|
||||
echo '</a>';
|
||||
} else {
|
||||
echo __('Step').' 2 : '.__('Firing');
|
||||
echo __('Step').' 2 » ';
|
||||
echo '<span>'.__('Firing').'</span>';
|
||||
}
|
||||
if ($step == 2)
|
||||
echo '</strong>';
|
||||
echo '</li>';
|
||||
|
||||
/* Step 3 */
|
||||
echo ' » ';
|
||||
|
||||
if ($step == 3)
|
||||
echo '<strong>';
|
||||
echo '<li class="last current">';
|
||||
elseif ($step > 3)
|
||||
echo '<li class="last visited">';
|
||||
else
|
||||
echo '<li class="last">';
|
||||
|
||||
if ($id) {
|
||||
echo '<a href="index.php?sec=galertas&sec2=godmode/alerts/configure_alert_template&id='.$id.'&step=3">';
|
||||
echo __('Step').' 3 : '.__('Recovery');
|
||||
echo __('Step').' 3 » ';
|
||||
echo '<span>'.__('Recovery').'</span>';
|
||||
echo '</a>';
|
||||
} else {
|
||||
echo __('Step').' 3 : '.__('Recovery');
|
||||
echo __('Step').' 3 » ';
|
||||
echo '<span>'.__('Recovery').'</span>';
|
||||
}
|
||||
if ($step == 3)
|
||||
echo '</strong>';
|
||||
|
||||
echo '</div>';
|
||||
echo '</ol>';
|
||||
echo '<div style="clear: both;"> </div>';
|
||||
}
|
||||
|
||||
function update_template ($step) {
|
||||
|
@ -85,7 +99,6 @@ function update_template ($step) {
|
|||
return false;
|
||||
|
||||
if ($step == 1) {
|
||||
$type = (string) get_parameter ('type');
|
||||
$name = (string) get_parameter ('name');
|
||||
$description = (string) get_parameter ('description');
|
||||
$type = (string) get_parameter ('type');
|
||||
|
@ -95,7 +108,8 @@ function update_template ($step) {
|
|||
$matches = (bool) get_parameter ('matches_value');
|
||||
|
||||
$result = update_alert_template ($id,
|
||||
array ('type' => $type,
|
||||
array ('name' => $name,
|
||||
'type' => $type,
|
||||
'description' => $description,
|
||||
'value' => $value,
|
||||
'max_value' => $max,
|
||||
|
@ -550,13 +564,8 @@ function render_example () {
|
|||
}
|
||||
|
||||
$(document).ready (function () {
|
||||
<?php if ($step == 1): ?>
|
||||
render_example ();
|
||||
$("#text-time_from, #text-time_to").timeEntry ({
|
||||
spinnerImage: 'images/time-entry.png',
|
||||
spinnerSize: [20, 20, 0]
|
||||
}
|
||||
);
|
||||
|
||||
$("input#text-value").keyup (render_example);
|
||||
$("input#text-max").keyup (render_example);
|
||||
$("input#text-min").keyup (render_example);
|
||||
|
@ -641,6 +650,13 @@ $(document).ready (function () {
|
|||
});
|
||||
|
||||
$("#text-value").keyup (check_regex);
|
||||
<?php elseif ($step == 2): ?>
|
||||
$("#text-time_from, #text-time_to").timeEntry ({
|
||||
spinnerImage: 'images/time-entry.png',
|
||||
spinnerSize: [20, 20, 0]
|
||||
}
|
||||
);
|
||||
|
||||
$("#threshold").change (function () {
|
||||
if (this.value == -1) {
|
||||
$("#text-other_threshold").attr ("value", "");
|
||||
|
@ -652,14 +668,6 @@ $(document).ready (function () {
|
|||
}
|
||||
});
|
||||
|
||||
$("#recovery_notify").change (function () {
|
||||
if (this.value == 1) {
|
||||
$("#template-field2, #template-field3").show ();
|
||||
} else {
|
||||
$("#template-field2, #template-field3").hide ();
|
||||
}
|
||||
});
|
||||
|
||||
$("#default_action").change (function () {
|
||||
if (this.value != 0) {
|
||||
values = Array ();
|
||||
|
@ -691,5 +699,14 @@ $(document).ready (function () {
|
|||
$("#text-field1").keyup (render_command_preview);
|
||||
$("#text-field2").keyup (render_command_preview);
|
||||
$("#text-field3").keyup (render_command_preview);
|
||||
<?php elseif ($step == 3): ?>
|
||||
$("#recovery_notify").change (function () {
|
||||
if (this.value == 1) {
|
||||
$("#template-field2, #template-field3").show ();
|
||||
} else {
|
||||
$("#template-field2, #template-field3").hide ();
|
||||
}
|
||||
});
|
||||
<?php endif; ?>
|
||||
})
|
||||
</script>
|
||||
|
|
|
@ -61,7 +61,7 @@ if (give_acl ($config['id_user'], 0, "PM")) {
|
|||
|
||||
if (give_acl ($config['id_user'], 0, "LM")) {
|
||||
$menu["galertas"]["text"] = __('Manage alerts');
|
||||
$menu["galertas"]["sec2"] = "godmode/alerts/alert_templates";
|
||||
$menu["galertas"]["sec2"] = "godmode/alerts/alert_list";
|
||||
$menu["galertas"]["id"] = "god-alerts";
|
||||
|
||||
$sub = array ();
|
||||
|
@ -71,6 +71,8 @@ if (give_acl ($config['id_user'], 0, "LM")) {
|
|||
|
||||
$sub["godmode/alerts/alert_commands"]["text"] = __('Commands');
|
||||
|
||||
$sub["godmode/alerts/alert_compounds"]["text"] = __('Compounds');
|
||||
|
||||
$menu["galertas"]["sub"] = $sub;
|
||||
}
|
||||
|
||||
|
|
|
@ -392,10 +392,8 @@ $(document).ready (function () {
|
|||
$('#alert_trigger').change (function () {
|
||||
trigger_changed (this.value)
|
||||
});
|
||||
<?php
|
||||
if ($id_as) {
|
||||
echo 'trigger_changed ('.$alert_trigger.');';
|
||||
}
|
||||
?>
|
||||
<?php if (isset ($id_as) && $id_as) : ?>
|
||||
trigger_changed ("<?php echo $alert_trigger ?>");
|
||||
<?php endif; ?>
|
||||
});
|
||||
</script>
|
||||
|
|
|
@ -1077,7 +1077,7 @@ function process_page_head ($string, $bitfield) {
|
|||
continue;
|
||||
}
|
||||
array_push ($loaded, $style);
|
||||
$output .= '<link rel="stylesheet" href="include/styles/'.$style.'.css" type="text/css" />';
|
||||
$output .= '<link rel="stylesheet" href="include/styles/'.$style.'.css" type="text/css" />'."\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1089,7 +1089,7 @@ function process_page_head ($string, $bitfield) {
|
|||
continue;
|
||||
}
|
||||
array_push ($loaded, $javascript);
|
||||
$output .= '<script type="text/javascript" src="include/javascript/'.$javascript.'.js"></script>';
|
||||
$output .= '<script type="text/javascript" src="include/javascript/'.$javascript.'.js"></script>'."\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -30,13 +30,13 @@
|
|||
function get_agent_alerts_simple ($id_agent, $filter = false) {
|
||||
switch ($filter) {
|
||||
case "notfired":
|
||||
$filter = ' AND times_fired = 0 AND disable = 0';
|
||||
$filter = ' AND times_fired = 0 AND disabled = 0';
|
||||
break;
|
||||
case "fired":
|
||||
$filter = ' AND times_fired > 0 AND disable = 0';
|
||||
$filter = ' AND times_fired > 0 AND disabled = 0';
|
||||
break;
|
||||
case "disabled":
|
||||
$filter = ' AND disable = 1';
|
||||
$filter = ' AND disabled = 1';
|
||||
break;
|
||||
default:
|
||||
$filter = '';
|
||||
|
@ -65,30 +65,25 @@ function get_agent_alerts_simple ($id_agent, $filter = false) {
|
|||
*
|
||||
* @return array An array with all combined alerts defined for an agent.
|
||||
*/
|
||||
function get_agent_alerts_combined ($id_agent, $filter = false) {
|
||||
/* TODO: Combined alerts */
|
||||
return array ();
|
||||
function get_agent_alerts_compound ($id_agent, $filter = false) {
|
||||
switch ($filter) {
|
||||
case "notfired":
|
||||
$filter = ' AND times_fired = 0 AND disable = 0';
|
||||
break;
|
||||
case "fired":
|
||||
$filter = ' AND times_fired > 0 AND disable = 0';
|
||||
break;
|
||||
case "disabled":
|
||||
$filter = ' AND disable = 1';
|
||||
break;
|
||||
default:
|
||||
$filter = '';
|
||||
case "notfired":
|
||||
$filter = ' AND times_fired = 0 AND disabled = 0';
|
||||
break;
|
||||
case "fired":
|
||||
$filter = ' AND times_fired > 0 AND disabled = 0';
|
||||
break;
|
||||
case "disabled":
|
||||
$filter = ' AND disabled = 1';
|
||||
break;
|
||||
default:
|
||||
$filter = '';
|
||||
}
|
||||
|
||||
$id_modules = array_keys (get_agent_modules ($id_agent));
|
||||
if (empty ($id_modules))
|
||||
return array ();
|
||||
$sql = sprintf ("SELECT * FROM talert_compound
|
||||
WHERE id_agent = %d%s",
|
||||
$id_agent, $filter);
|
||||
|
||||
$sql = sprintf ("SELECT * FROM talert_template_modules
|
||||
WHERE id_agent_module IN (%s)%s",
|
||||
implode (',', $id_modules), $filter);
|
||||
$alerts = get_db_all_rows_sql ($sql);
|
||||
|
||||
if ($alerts === false)
|
||||
|
@ -105,9 +100,9 @@ function get_agent_alerts_combined ($id_agent, $filter = false) {
|
|||
*/
|
||||
function get_agent_alerts ($id_agent, $filter = false) {
|
||||
$simple_alerts = get_agent_alerts_simple ($id_agent, $filter);
|
||||
$combined_alerts = get_agent_alerts_combined ($id_agent, $filter);
|
||||
$combined_alerts = get_agent_alerts_compound ($id_agent, $filter);
|
||||
|
||||
return array_merge ($simple_alerts, $combined_alerts);
|
||||
return array ('simple' => $simple_alerts, 'compounds' => $combined_alerts);
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
@ -44,7 +44,7 @@ function create_alert_command ($name, $command, $values = false) {
|
|||
$sql = sprintf ('INSERT talert_commands (name, command, description)
|
||||
VALUES ("%s", "%s", "%s")',
|
||||
$name, $command, $values['description']);
|
||||
return process_sql ($sql, 'insert_id');
|
||||
return @process_sql ($sql, 'insert_id');
|
||||
}
|
||||
|
||||
function update_alert_command ($id_alert_command, $name, $command, $description = '', $values = false) {
|
||||
|
@ -61,7 +61,7 @@ function update_alert_command ($id_alert_command, $name, $command, $description
|
|||
$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;
|
||||
return @process_sql ($sql) !== false;
|
||||
}
|
||||
|
||||
function delete_alert_command ($id_alert_command) {
|
||||
|
@ -150,7 +150,7 @@ function create_alert_action ($name, $id_alert_command, $values = false) {
|
|||
$name, $id_alert_command, $values['field1'], $values['field2'],
|
||||
$values['field3']);
|
||||
|
||||
return process_sql ($sql, 'insert_id');
|
||||
return @process_sql ($sql, 'insert_id');
|
||||
}
|
||||
|
||||
function update_alert_action ($id_alert_action, $id_alert_command, $name, $values = false) {
|
||||
|
@ -171,7 +171,7 @@ function update_alert_action ($id_alert_action, $id_alert_command, $name, $value
|
|||
$name, $id_alert_command, $values['field1'], $values['field2'],
|
||||
$values['field3'], $id_alert_action);
|
||||
|
||||
return process_sql ($sql) !== false;
|
||||
return @process_sql ($sql) !== false;
|
||||
}
|
||||
|
||||
function delete_alert_action ($id_alert_action) {
|
||||
|
@ -375,7 +375,7 @@ function create_alert_template ($name, $type, $values = false) {
|
|||
$values['time_threshold'], $values['max_alerts'],
|
||||
$values['min_alerts'], $values['matches_value']);
|
||||
|
||||
return process_sql ($sql, 'insert_id');
|
||||
return @process_sql ($sql, 'insert_id');
|
||||
}
|
||||
|
||||
function update_alert_template ($id_alert_template, $values = false) {
|
||||
|
@ -390,7 +390,7 @@ function update_alert_template ($id_alert_template, $values = false) {
|
|||
WHERE id = %d',
|
||||
format_array_to_update_sql ($values), $id_alert_template);
|
||||
|
||||
return process_sql ($sql) !== false;
|
||||
return @process_sql ($sql) !== false;
|
||||
}
|
||||
|
||||
function delete_alert_template ($id_alert_template) {
|
||||
|
@ -571,7 +571,7 @@ function create_alert_agent_module ($id_agent_module, $id_alert_template, $value
|
|||
$values['times_fired'], $values['disabled'], $values['priority'],
|
||||
$values['force_execution']);
|
||||
|
||||
return process_sql ($sql, 'insert_id');
|
||||
return @process_sql ($sql, 'insert_id');
|
||||
}
|
||||
|
||||
function update_alert_agent_module ($id_alert_agent_module, $values = false) {
|
||||
|
@ -587,7 +587,7 @@ function update_alert_agent_module ($id_alert_agent_module, $values = false) {
|
|||
WHERE id = %d',
|
||||
format_array_to_update_sql ($values), $id_alert_agent_module);
|
||||
|
||||
return process_sql ($sql) !== false;
|
||||
return @process_sql ($sql) !== false;
|
||||
}
|
||||
|
||||
function delete_alert_agent_module ($id_alert_agent_module) {
|
||||
|
@ -598,7 +598,7 @@ function delete_alert_agent_module ($id_alert_agent_module) {
|
|||
WHERE id = %d',
|
||||
$id_alert_agent_module);
|
||||
|
||||
return process_sql ($sql) !== false;
|
||||
return @process_sql ($sql) !== false;
|
||||
}
|
||||
|
||||
function get_alert_agent_module ($id_alert_agent_module) {
|
||||
|
@ -636,7 +636,7 @@ function set_alerts_agent_module_force_execution ($id_alert_agent_module) {
|
|||
WHERE id = %d',
|
||||
$id_alert_agent_module);
|
||||
|
||||
return process_sql ($sql) !== false;
|
||||
return @process_sql ($sql) !== false;
|
||||
}
|
||||
|
||||
function set_alerts_agent_module_disable ($id_alert_agent_module, $disabled) {
|
||||
|
@ -646,7 +646,7 @@ function set_alerts_agent_module_disable ($id_alert_agent_module, $disabled) {
|
|||
WHERE id = %d',
|
||||
$disabled ? 1 : 0, $id_alert_agent_module);
|
||||
|
||||
return process_sql ($sql) !== false;
|
||||
return @process_sql ($sql) !== false;
|
||||
}
|
||||
|
||||
function get_alerts_agent_module_last_fired ($id_alert_agent_module) {
|
||||
|
@ -679,7 +679,7 @@ function add_alert_agent_module_action ($id_alert_agent_module, $id_alert_action
|
|||
VALUES (%d, %d, %d, %d)',
|
||||
$id_alert_agent_module, $id_alert_action, $fires_min, $fires_max);
|
||||
|
||||
return process_sql ($sql) !== false;
|
||||
return @process_sql ($sql) !== false;
|
||||
}
|
||||
|
||||
function delete_alert_agent_module_action ($id_alert_agent_module, $id_alert_action) {
|
||||
|
@ -693,7 +693,7 @@ function delete_alert_agent_module_action ($id_alert_agent_module, $id_alert_act
|
|||
AND id_alert_action = %d',
|
||||
$id_alert_agent_module, $id_alert_action);
|
||||
|
||||
return process_sql ($sql) !== false;
|
||||
return @process_sql ($sql) !== false;
|
||||
}
|
||||
|
||||
function get_alert_agent_module_actions ($id_alert_agent_module) {
|
||||
|
@ -740,16 +740,8 @@ function validate_alert_agent_module ($id_alert_agent_module) {
|
|||
|
||||
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);
|
||||
}
|
||||
$agent_id = get_agentmodule_agent ($alert["id_agent_module"]);
|
||||
$group_id = get_agentmodule_group ($agent_id);
|
||||
|
||||
if (! give_acl ($config['id_user'], $group_id, "AW")) {
|
||||
continue;
|
||||
|
@ -771,4 +763,253 @@ function validate_alert_agent_module ($id_alert_agent_module) {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Compound alerts */
|
||||
|
||||
function get_alert_compound_threshold_values () {
|
||||
/* At this moment we don't need different threshold values */
|
||||
return get_alert_template_threshold_values ();
|
||||
}
|
||||
|
||||
function get_alert_compound_operations () {
|
||||
$operations = array ();
|
||||
|
||||
$operations['OR'] = 'OR';
|
||||
$operations['AND'] = 'AND';
|
||||
$operations['NOR'] = 'NOR';
|
||||
$operations['NAND'] = 'NAND';
|
||||
$operations['NXOR'] = 'NXOR';
|
||||
|
||||
return $operations;
|
||||
}
|
||||
|
||||
function clean_alert_compound_values ($values, $set_empty = true) {
|
||||
$retvalues = array ();
|
||||
|
||||
if ($set_empty) {
|
||||
$retvalues['description'] = '';
|
||||
$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'] = '';
|
||||
}
|
||||
|
||||
if (empty ($values))
|
||||
return $retvalues;
|
||||
|
||||
if (isset ($values['name']))
|
||||
$retvalues['name'] = (string) $values['name'];
|
||||
if (isset ($values['description']))
|
||||
$retvalues['description'] = (string) $values['description'];
|
||||
if (isset ($values['id_agent']))
|
||||
$retvalues['id_agent'] = (int) $values['id_agent'];
|
||||
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;
|
||||
}
|
||||
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_compound ($name, $id_agent, $values = false) {
|
||||
if (empty ($name))
|
||||
return false;
|
||||
|
||||
$values = clean_alert_compound_values ($values);
|
||||
$values['name'] = $name;
|
||||
$values['id_agent'] = $id_agent;
|
||||
|
||||
return @process_sql_insert ('talert_compound', $values);
|
||||
}
|
||||
|
||||
function update_alert_compound ($id_alert_compound, $values = false) {
|
||||
if (empty ($id_alert_compound))
|
||||
return false;
|
||||
$values = clean_alert_compound_values ($values, false);
|
||||
|
||||
return @process_sql_update ('talert_compound', $values,
|
||||
array ('id' => $id_alert_compound)) !== false;
|
||||
}
|
||||
|
||||
function add_alert_compound_element ($id_alert_compound, $id_alert_template_module, $operation) {
|
||||
if (empty ($id_alert_compound))
|
||||
return false;
|
||||
if (empty ($id_alert_template_module))
|
||||
return false;
|
||||
if (empty ($operation))
|
||||
return false;
|
||||
|
||||
$values = array ();
|
||||
$values['id_alert_compound'] = $id_alert_compound;
|
||||
$values['id_alert_template_module'] = $id_alert_template_module;
|
||||
$values['operation'] = $operation;
|
||||
|
||||
return @process_sql_insert ('talert_compound_elements', $values);
|
||||
}
|
||||
|
||||
function get_alert_compound ($id_alert_compound) {
|
||||
return get_db_row ('talert_compound', 'id', $id_alert_compound);
|
||||
}
|
||||
|
||||
function get_alert_compound_actions ($id_alert_compound) {
|
||||
if (empty ($id_alert_compound))
|
||||
return false;
|
||||
|
||||
$sql = sprintf ('SELECT id_alert_action id, fires_min, fires_max
|
||||
FROM talert_compound_actions
|
||||
WHERE id_alert_compound = %d',
|
||||
$id_alert_compound);
|
||||
$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;
|
||||
}
|
||||
|
||||
function get_alert_compound_name ($id_alert_compound) {
|
||||
return (string) get_db_value ('name', 'talert_compund', 'id', $id_alert_compound);
|
||||
}
|
||||
|
||||
function get_alert_compound_elements ($id_alert_compound) {
|
||||
return get_db_all_rows_field_filter ('talert_compound_elements',
|
||||
'id_alert_compound', $id_alert_compound);
|
||||
}
|
||||
|
||||
function add_alert_compound_action ($id_alert_compound, $id_alert_action, $options = false) {
|
||||
if (empty ($id_alert_compound))
|
||||
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_compound_actions
|
||||
VALUES (%d, %d, %d, %d)',
|
||||
$id_alert_compound, $id_alert_action, $fires_min, $fires_max);
|
||||
|
||||
return @process_sql ($sql) !== false;
|
||||
}
|
||||
|
||||
function set_alerts_compound_disable ($id_alert_compound, $disabled) {
|
||||
$id_alert_agent_module = safe_int ($id_alert_compound, 0);
|
||||
$sql = sprintf ('UPDATE talert_compound
|
||||
SET disabled = %d
|
||||
WHERE id = %d',
|
||||
$disabled ? 1 : 0, $id_alert_compound);
|
||||
|
||||
return @process_sql ($sql) !== false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates a compound alert id or an array of alert id's
|
||||
*
|
||||
* @param mixed Array of compound alert ids or single id
|
||||
*
|
||||
* @return bool True if it was successful, false otherwise.
|
||||
*/
|
||||
function validate_alert_compound ($id_alert_compound) {
|
||||
global $config;
|
||||
require_once ("include/functions_events.php");
|
||||
|
||||
$alerts = safe_int ($id_alert_compound, 1);
|
||||
|
||||
if (empty ($alerts)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$alerts = (array) $alerts;
|
||||
|
||||
foreach ($alerts as $id) {
|
||||
$alert = get_alert_compound ($id);
|
||||
|
||||
$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_compound',
|
||||
array ('times_fired' => 0,
|
||||
'internal_counter' => 0),
|
||||
array ('id' => $id));
|
||||
|
||||
if ($result > 0) {
|
||||
create_event ("Manual validation of compound alert for ".
|
||||
$alert["name"],
|
||||
$group_id, $agent_id, 1, $config["id_user"],
|
||||
"alert_manual_validation", 1, $alert["id"],
|
||||
$id);
|
||||
} elseif ($result === false) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -352,9 +352,8 @@ $modules = get_agent_modules ($id_agent, '*', 'disabled = 0 AND history_data = 0
|
|||
function get_agent_modules ($id_agent, $details = false, $filter = false) {
|
||||
$id_agent = safe_int ($id_agent, 1);
|
||||
|
||||
if (empty ($id_agent)) {
|
||||
$where = '';
|
||||
} else {
|
||||
$where = '';
|
||||
if (! empty ($id_agent)) {
|
||||
$where = sprintf (' WHERE id_agente IN (%s)', implode (",", (array) $id_agent));
|
||||
}
|
||||
|
||||
|
|
|
@ -538,7 +538,8 @@ function get_agent_alerts_reporting_table ($id_agent, $period = 0, $date = 0) {
|
|||
$table->head[5] = __('Times Fired');
|
||||
|
||||
$alerts = get_agent_alerts ($id_agent);
|
||||
foreach ($alerts as $alert) {
|
||||
/* FIXME: Add compound alerts to the report. Some extra code is needed here */
|
||||
foreach ($alerts['simple'] as $alert) {
|
||||
$fires = get_alert_fires_in_period ($alert['id'], $period, $date);
|
||||
if (! $fires) {
|
||||
continue;
|
||||
|
|
|
@ -231,21 +231,26 @@ function print_agent_name ($id_agent, $return = false, $cutoff = 0) {
|
|||
*
|
||||
* @return array A formatted array with proper html for use in $table->data (6 columns)
|
||||
*/
|
||||
function format_alert_row ($alert, $combined = false, $agent = true, $url = '') {
|
||||
function format_alert_row ($alert, $compound = false, $agent = true, $url = '') {
|
||||
require_once ("include/functions_alerts.php");
|
||||
|
||||
if (empty ($alert))
|
||||
return array ("", "", "", "", "", "", "");
|
||||
|
||||
// Get agent id
|
||||
$id_agente = get_agentmodule_agent ($alert["id_agent_module"]);
|
||||
$template = get_alert_template ($alert['id_alert_template']);
|
||||
|
||||
if ($compound) {
|
||||
$id_agent = $alert['id_agent'];
|
||||
$description = $alert['description'];
|
||||
} else {
|
||||
$id_agent = get_agentmodule_agent ($alert['id_agent_module']);
|
||||
$template = get_alert_template ($alert['id_alert_template']);
|
||||
$description = $template['description'];
|
||||
}
|
||||
$data = array ();
|
||||
|
||||
// Force alert execution
|
||||
$data[0] = '';
|
||||
if (! $combined) {
|
||||
if (! $compound) {
|
||||
if ($alert["force_execution"] == 0) {
|
||||
$data[0] = '<a href="'.$url.'&id_alert='.$alert["id"].'&force_execution=1&refr=60"><img src="images/target.png" ></a>';
|
||||
} else {
|
||||
|
@ -253,8 +258,8 @@ function format_alert_row ($alert, $combined = false, $agent = true, $url = '')
|
|||
}
|
||||
}
|
||||
|
||||
if ($combined == 1) {
|
||||
$data[1] = print_agent_name ($id_agente, true, 20);
|
||||
if ($compound) {
|
||||
$data[1] = print_agent_name ($id_agent, true, 20);
|
||||
} elseif ($agent == 0) {
|
||||
$data[1] = mb_substr (get_agentmodule_name ($alert["id_agent_module"]), 0, 20);
|
||||
} else {
|
||||
|
@ -262,17 +267,20 @@ function format_alert_row ($alert, $combined = false, $agent = true, $url = '')
|
|||
}
|
||||
|
||||
$data[2] = '<span class="left">';
|
||||
$data[2] .= mb_substr (safe_input ($template["description"]), 0, 35);
|
||||
$data[2] .= '</span> <span class="right">';
|
||||
$data[2] .= '<a class="template_details" href="ajax.php?page=godmode/alerts/alert_templates&get_template_tooltip=1&id_template='.$template['id'].'">';
|
||||
$data[2] .= '<img src="images/zoom.png" />';
|
||||
$data[2] .= '</a></span>';
|
||||
$data[2] .= mb_substr (safe_input ($description), 0, 35);
|
||||
$data[2] .= '</span>';
|
||||
if (! $compound) {
|
||||
$data[2] .= ' <span class="right">';
|
||||
$data[2] .= '<a class="template_details" href="ajax.php?page=godmode/alerts/alert_templates&get_template_tooltip=1&id_template='.$template['id'].'">';
|
||||
$data[2] .= '<img src="images/zoom.png" />';
|
||||
$data[2] .= '</a></span>';
|
||||
}
|
||||
|
||||
$data[3] = print_timestamp ($alert["last_fired"], true);
|
||||
|
||||
$options = array ();
|
||||
$options["height"] = 9;
|
||||
$options["width"] = 20;
|
||||
$options["height"] = 18;
|
||||
$options["width"] = 40;
|
||||
|
||||
if ($alert["times_fired"] > 0) {
|
||||
$options["src"] = "images/pixel_red.png";
|
||||
|
@ -287,7 +295,11 @@ function format_alert_row ($alert, $combined = false, $agent = true, $url = '')
|
|||
|
||||
$data[4] = print_image ($options["src"], true, $options);
|
||||
|
||||
$data[5] = print_checkbox ("validate[]", $alert["id"], false, true);
|
||||
if ($compound) {
|
||||
$data[5] = print_checkbox ("validate_compound[]", $alert["id"], false, true);
|
||||
} else {
|
||||
$data[5] = print_checkbox ("validate[]", $alert["id"], false, true);
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
|
|
@ -28,5 +28,10 @@ $(document).ready (function () {
|
|||
});
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
$.fn.showMessage = function (msg) {
|
||||
return $(this).hide ().empty ()
|
||||
.text (msg)
|
||||
.slideDown ();
|
||||
};
|
||||
});
|
||||
|
|
|
@ -36,7 +36,9 @@
|
|||
border-bottom: 1px solid #d4d4d4;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.menu li.selected {
|
||||
background-color: #D3F389 !important;
|
||||
}
|
||||
.menu li a {
|
||||
background-color: inherit;
|
||||
color: #000000;
|
||||
|
@ -57,11 +59,11 @@
|
|||
width:155px;
|
||||
}
|
||||
.submenu li a {
|
||||
background-color: #E9F3D2;
|
||||
background-color: #fff;
|
||||
margin-left: 0px;
|
||||
padding-left: 29px;
|
||||
display:block;
|
||||
border-width: 1px 0 0 1px;
|
||||
border-width: 1px 1px 0 1px;
|
||||
border-style: solid;
|
||||
border-color: #dadbdc;
|
||||
}
|
||||
|
@ -69,18 +71,23 @@
|
|||
visibility: hidden;
|
||||
float:right;
|
||||
margin: -20px 2px 0 0; /* Positions it back where it should be */
|
||||
border-left: 1px;
|
||||
}
|
||||
.menu li.has_submenu.selected > img.toggle, .menu li:hover.has_submenu > img.toggle {
|
||||
.menu li.has_submenu.selected > img.toggle,
|
||||
.menu li:hover.has_submenu > img.toggle {
|
||||
visibility: visible;
|
||||
z-index: 1; /* Positions it on top of the rest */
|
||||
}
|
||||
|
||||
.menu li.submenu_selected a {
|
||||
font-weight: bold;
|
||||
}
|
||||
.menu li.links {
|
||||
background: #E9F3D2 url(../../images/link.png) no-repeat 4px 8px;
|
||||
border-width: 1px 0 0 1px;
|
||||
border-style: solid;
|
||||
border-color: #dadbdc;
|
||||
}
|
||||
|
||||
/* Icons specified here */
|
||||
#icon_oper-agents {
|
||||
background: #E9F3D2 url(../../images/bricks.png) no-repeat 4px 4px;
|
||||
|
@ -148,4 +155,4 @@
|
|||
}
|
||||
#icon_oper-inventory {
|
||||
background: #E9F3D2 url(../../images/page_white_text.png) no-repeat 4px 4px;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -719,19 +719,6 @@ a.big_data {
|
|||
border-bottom: 1px solid #CCCCCC;
|
||||
border-top: 1px solid #CCCCCC;
|
||||
}
|
||||
.left {
|
||||
float: left;
|
||||
text-align: left;
|
||||
}
|
||||
.right {
|
||||
float: right;
|
||||
text-align: right;
|
||||
}
|
||||
.top {
|
||||
vertical-align: top;
|
||||
margin-top: 0;
|
||||
padding-top: 0;
|
||||
}
|
||||
ul {
|
||||
list-style-type: none;
|
||||
padding-left: 0;
|
||||
|
@ -755,7 +742,9 @@ select#template, select#action {
|
|||
input[type=image] {
|
||||
border:0px;
|
||||
}
|
||||
table#simple select#id_module_type {
|
||||
table#simple select#id_module_type,
|
||||
table#alert_search select#id_agent,
|
||||
table#alert_search select#id_group {
|
||||
width: 200px;
|
||||
}
|
||||
table#simple select#select_snmp_oid,
|
||||
|
@ -770,6 +759,100 @@ table#simple select#prediction_module {
|
|||
.clickable {
|
||||
cursor: pointer;
|
||||
}
|
||||
table#agent_list tr {
|
||||
table#agent_list tr, table.alert_list tr {
|
||||
vertical-align: top;
|
||||
}
|
||||
ul.actions_list {
|
||||
list-style-image: url(../../images/arrow.png);
|
||||
list-style-position: inside;
|
||||
margin-top: 0;
|
||||
}
|
||||
div.loading {
|
||||
background-color: #FFF1A8;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
padding: 5px;
|
||||
text-align: center;
|
||||
font-style: italic;
|
||||
width: 95%;
|
||||
}
|
||||
div.loading img {
|
||||
float: right;
|
||||
}
|
||||
/* Tablesorter jQuery pager */
|
||||
div.pager {
|
||||
margin-left: 10px;
|
||||
margin-top: 5px;
|
||||
}
|
||||
div.pager img{
|
||||
position: relative;
|
||||
top: 4px;
|
||||
padding-left: 5px;
|
||||
}
|
||||
div.pager input {
|
||||
padding-left: 5px;
|
||||
}
|
||||
.pagedisplay {
|
||||
border: 0;
|
||||
width: 35px;
|
||||
}
|
||||
/* Steps style */
|
||||
ol.steps {
|
||||
margin-bottom: 15px;
|
||||
padding: 0;
|
||||
list-style-type: none;
|
||||
list-style-position: outline;
|
||||
}
|
||||
ol.steps li {
|
||||
float: left;
|
||||
background-color: #efefef;
|
||||
padding: 5px;
|
||||
margin-left: 5px;
|
||||
width: 150px;
|
||||
}
|
||||
ol.steps li a {
|
||||
color: #000;
|
||||
}
|
||||
ol.steps li.visited a {
|
||||
color: #999;
|
||||
}
|
||||
ol.steps li span {
|
||||
font-weight: normal;
|
||||
display: block;
|
||||
}
|
||||
ol.steps li span {
|
||||
color: #777;
|
||||
}
|
||||
ol.steps li.visited span {
|
||||
color: #999;
|
||||
}
|
||||
ol.steps li.current {
|
||||
border-left: 5px solid #778866;
|
||||
margin-left: 0;
|
||||
font-weight: bold;
|
||||
background-color: #E9F3D2;
|
||||
}
|
||||
ol.steps li.visited {
|
||||
color: #999 !important;
|
||||
}
|
||||
|
||||
/* Common useful styles */
|
||||
.left { clear: left; }
|
||||
.right { clear: right; }
|
||||
.clear { clear:both; }
|
||||
.top {
|
||||
vertical-align: top;
|
||||
margin-top: 0;
|
||||
padding-top: 0;
|
||||
}
|
||||
img.left {
|
||||
margin-right:1em;
|
||||
margin-bottom:1.8em;
|
||||
}
|
||||
img.right {
|
||||
margin-left:1em;
|
||||
margin-bottom:1.8em;
|
||||
}
|
||||
.text-right {
|
||||
text-align:right;
|
||||
}
|
||||
|
|
|
@ -53,13 +53,13 @@ if ($develop_bypass != 1) {
|
|||
}
|
||||
}
|
||||
|
||||
if ((! file_exists("include/config.php")) || (! is_readable("include/config.php"))) {
|
||||
if ((! file_exists ("include/config.php")) || (! is_readable ("include/config.php"))) {
|
||||
include ("general/error_noconfig.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
// Real start
|
||||
session_start();
|
||||
session_start ();
|
||||
require_once ("include/config.php");
|
||||
require_once ("include/functions.php");
|
||||
require_once ("include/functions_db.php");
|
||||
|
@ -99,17 +99,19 @@ if (!empty ($config["https"]) && empty ($_SERVER['HTTPS'])) {
|
|||
|
||||
|
||||
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head>';
|
||||
ob_start ('process_page_head'); //This starts the page head. In the call back function, things from $page['head'] array will be processed into the head
|
||||
//This starts the page head. In the call back function, things from $page['head'] array will be processed into the head
|
||||
ob_start ('process_page_head');
|
||||
// Pure mode (without menu, header and footer).
|
||||
$config["pure"] = (bool) get_parameter ("pure", 0);
|
||||
$config["pure"] = (bool) get_parameter ("pure");
|
||||
|
||||
// Auto Refresh page (can now be disabled anywhere in the script)
|
||||
$config["refr"] = (int) get_parameter ("refr", 0);
|
||||
$config["refr"] = (int) get_parameter ("refr");
|
||||
|
||||
enterprise_include ('index.php');
|
||||
enterprise_hook ('load_html_header');
|
||||
|
||||
echo '</head>'; //This tag is included in the buffer passed to process_page_head so technically it can be stripped
|
||||
//This tag is included in the buffer passed to process_page_head so technically it can be stripped
|
||||
echo '</head>';
|
||||
|
||||
ob_start ('process_page_body');
|
||||
|
||||
|
@ -137,10 +139,9 @@ if (! isset ($_SESSION['id_usuario']) && isset ($_GET["loginhash"])) {
|
|||
audit_db ("system", $REMOTE_ADDR, "Logon Failed (loginhash", "");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
// Login process
|
||||
elseif (! isset ($_SESSION['id_usuario']) && isset ($_GET["login"])) {
|
||||
} elseif (! isset ($_SESSION['id_usuario']) && isset ($_GET["login"])) {
|
||||
// Login process
|
||||
|
||||
$config["auth_error"] = ""; //Set this to the error message from the authorization mechanism
|
||||
$nick = get_parameter_post ("nick"); //This is the variable with the login
|
||||
$pass = get_parameter_post ("pass"); //This is the variable with the password
|
||||
|
@ -187,7 +188,7 @@ if (isset ($_GET["bye"])) {
|
|||
|
||||
// http://es2.php.net/manual/en/ref.session.php#64525
|
||||
// Session locking concurrency speedup!
|
||||
session_write_close();
|
||||
session_write_close ();
|
||||
|
||||
// Header
|
||||
if ($config["pure"] == 0) {
|
||||
|
@ -219,7 +220,7 @@ if ($page != "") {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
echo '<br><b class="error">'.__('Sorry! I can\'t find the page!').'</b>';
|
||||
echo '<br /><strong class="error">'.__('Sorry! I can\'t find the page!').'</strong>';
|
||||
}
|
||||
} else {
|
||||
if (enterprise_hook ('load_logon_ok') === ENTERPRISE_NOT_HOOK) {
|
||||
|
@ -241,6 +242,6 @@ if ($config["pure"] == 0) {
|
|||
echo '</div>';
|
||||
}
|
||||
echo '</div>'; //container div
|
||||
while (@ob_end_flush());
|
||||
while (@ob_end_flush ());
|
||||
echo '</html>';
|
||||
?>
|
||||
?>
|
||||
|
|
|
@ -54,13 +54,13 @@ if (isset ($_GET["id_agente"])) {
|
|||
}
|
||||
|
||||
$alerts_simple = get_agent_alerts_simple ($id_agent, $filter);
|
||||
$alerts_combined = get_agent_alerts_combined ($id_agent, $filter);
|
||||
$alerts_combined = get_agent_alerts_compound ($id_agent, $filter);
|
||||
$print_agent = false;
|
||||
} else {
|
||||
if (give_acl ($config["id_user"], $id_group, "AR") == 0) {
|
||||
if (! give_acl ($config["id_user"], $id_group, "AR")) {
|
||||
audit_db ($config["id_user"], $config["remote_addr"], "ACL Violation","Trying to access alert view");
|
||||
require ("general/noaccess.php");
|
||||
exit;
|
||||
return;
|
||||
}
|
||||
|
||||
$alerts_simple = array ();
|
||||
|
@ -70,7 +70,7 @@ if (isset ($_GET["id_agente"])) {
|
|||
|
||||
foreach ($agents as $id_agent) {
|
||||
$simple = get_agent_alerts_simple ($id_agent, $filter);
|
||||
$combined = get_agent_alerts_combined ($id_agent, $filter);
|
||||
$combined = get_agent_alerts_compound ($id_agent, $filter);
|
||||
|
||||
$alerts_simple = array_merge ($alerts_simple, $simple);
|
||||
$alerts_combined = array_merge ($alerts_combined, $combined);
|
||||
|
@ -88,9 +88,13 @@ echo "<h2>".__('Pandora Agents')." > ".__('Alerts').'</h2>';
|
|||
|
||||
if (get_parameter ('alert_validate')) {
|
||||
$ids = (array) get_parameter_post ("validate", array ());
|
||||
if (! empty ($ids)) {
|
||||
$compound_ids = (array) get_parameter_post ("validate_compound", array ());
|
||||
|
||||
if (! empty ($ids) || ! empty ($compound_ids)) {
|
||||
require_once ("include/functions_alerts.php");
|
||||
$result = validate_alert_agent_module ($ids);
|
||||
$result1 = validate_alert_agent_module ($ids);
|
||||
$result2 = validate_alert_compound ($compound_ids);
|
||||
$result == $result1 || $result2;
|
||||
|
||||
print_error_message ($result, __('Alert(s) validated'),
|
||||
__('Error processing alert(s)'));
|
||||
|
@ -159,7 +163,7 @@ foreach ($alerts_simple as $alert) {
|
|||
continue;
|
||||
}
|
||||
$printed++;
|
||||
array_push ($table->data, format_alert_row ($alert, 0, $print_agent, $url));
|
||||
array_push ($table->data, format_alert_row ($alert, false, $print_agent, $url));
|
||||
}
|
||||
|
||||
if (!empty ($table->data)) {
|
||||
|
@ -169,8 +173,9 @@ if (!empty ($table->data)) {
|
|||
echo '<div class="nf">'.__('No simple alerts found').'</div>';
|
||||
}
|
||||
|
||||
$table->title = __('Combined alerts');
|
||||
$table->title = __('Compound alerts');
|
||||
$table->head[1] = __('Agent');
|
||||
$table->head[2] = __('Name');
|
||||
$table->data = array ();
|
||||
|
||||
$combined_total = 0;
|
||||
|
@ -181,7 +186,7 @@ foreach ($alerts_combined as $alert) {
|
|||
continue;
|
||||
}
|
||||
$combined_printed++;
|
||||
array_push ($table->data, format_alert_row ($alert, 1, $print_agent));
|
||||
array_push ($table->data, format_alert_row ($alert, true, $print_agent));
|
||||
}
|
||||
|
||||
if (!empty ($table->data)) {
|
||||
|
@ -205,8 +210,7 @@ $(document).ready (function () {
|
|||
$("a.template_details").cluetip ({
|
||||
arrows: true,
|
||||
attribute: 'href',
|
||||
cluetipClass: 'default',
|
||||
fx: { open: 'fadeIn', openSpeed: 'slow' },
|
||||
cluetipClass: 'default'
|
||||
}).click (function () {
|
||||
return false;
|
||||
});
|
||||
|
|
|
@ -284,11 +284,58 @@ CREATE TABLE IF NOT EXISTS `talert_template_module_actions` (
|
|||
ON DELETE RESTRICT ON UPDATE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `tcompound_alert` (
|
||||
CREATE TABLE IF NOT EXISTS `talert_compound` (
|
||||
`id` int(10) unsigned NOT NULL auto_increment,
|
||||
`id_aam` int(10) unsigned NOT NULL default '0',
|
||||
`name` varchar(255) default '',
|
||||
`description` mediumtext,
|
||||
`id_agent` int(10) unsigned NOT 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',
|
||||
`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,
|
||||
`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',
|
||||
PRIMARY KEY (`id`),
|
||||
FOREIGN KEY (`id_agent`) REFERENCES tagente(`id_agente`)
|
||||
ON DELETE CASCADE ON UPDATE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `talert_compound_elements` (
|
||||
`id_alert_compound` int(10) unsigned NOT NULL,
|
||||
`id_alert_template_module` int(10) unsigned NOT NULL,
|
||||
`operation` enum('NOP', 'AND','OR','XOR','NAND','NOR','NXOR'),
|
||||
PRIMARY KEY (`id`, `id_aam`)
|
||||
`order` tinyint(2) unsigned default 0,
|
||||
UNIQUE (`id_alert_compound`, `id_alert_template_module`, `operation`),
|
||||
FOREIGN KEY (`id_alert_compound`) REFERENCES talert_compound(`id`)
|
||||
ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
FOREIGN KEY (`id_alert_template_module`) REFERENCES talert_template_modules(`id`)
|
||||
ON DELETE CASCADE ON UPDATE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `talert_compound_actions` (
|
||||
`id_alert_compound` int(10) unsigned NOT NULL,
|
||||
`id_alert_action` int(10) unsigned NOT NULL,
|
||||
`fires_min` int(3) unsigned default 0,
|
||||
`fires_max` int(3) unsigned default 0,
|
||||
FOREIGN KEY (`id_alert_compound`) REFERENCES talert_compound(`id`)
|
||||
ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
FOREIGN KEY (`id_alert_action`) REFERENCES talert_actions(`id`)
|
||||
ON DELETE CASCADE ON UPDATE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
-- Priority : 0 - Maintance (grey)
|
||||
|
|
|
@ -181,3 +181,58 @@ ALTER TABLE `tusuario` ADD `middlename` VARCHAR( 255 ) NOT NULL AFTER `lastna
|
|||
ALTER TABLE `tusuario` CHANGE `direccion` `email` VARCHAR( 100 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL;
|
||||
ALTER TABLE `tusuario` CHANGE `telefono` `phone` VARCHAR( 100 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL;
|
||||
ALTER TABLE `tusuario` CHANGE `nivel` `is_admin` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '0';
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `talert_compound` (
|
||||
`id` int(10) unsigned NOT NULL auto_increment,
|
||||
`name` varchar(255) default '',
|
||||
`description` mediumtext,
|
||||
`id_agent` int(10) unsigned NOT 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',
|
||||
`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,
|
||||
`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',
|
||||
PRIMARY KEY (`id`),
|
||||
FOREIGN KEY (`id_agent`) REFERENCES tagente(`id_agente`)
|
||||
ON DELETE CASCADE ON UPDATE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `talert_compound_elements` (
|
||||
`id_alert_compound` int(10) unsigned NOT NULL,
|
||||
`id_alert_template_module` int(10) unsigned NOT NULL,:w
|
||||
`operation` enum('NOP', 'AND','OR','XOR','NAND','NOR','NXOR'),
|
||||
`order` tinyint(2) unsigned default 0,
|
||||
UNIQUE (`id_alert_compound`, `id_alert_template_module`, `operation`),
|
||||
FOREIGN KEY (`id_alert_compound`) REFERENCES talert_compound(`id`)
|
||||
ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
FOREIGN KEY (`id_alert_template_module`) REFERENCES talert_template_modules(`id`)
|
||||
ON DELETE CASCADE ON UPDATE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `talert_compound_actions` (
|
||||
`id_alert_compound` int(10) unsigned NOT NULL,
|
||||
`id_alert_action` int(10) unsigned NOT NULL,
|
||||
`fires_min` int(3) unsigned default 0,
|
||||
`fires_max` int(3) unsigned default 0,
|
||||
FOREIGN KEY (`id_alert_compound`) REFERENCES talert_compound(`id`)
|
||||
ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
FOREIGN KEY (`id_alert_action`) REFERENCES talert_actions(`id`)
|
||||
ON DELETE CASCADE ON UPDATE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
|
Loading…
Reference in New Issue