Killing some unicorns and magic numbers.
This commit is contained in:
parent
2fd82b6ee5
commit
3498e9e1e7
pandora_console
godmode/alerts
include
|
@ -255,9 +255,9 @@ if ($template['time_from'] == $template['time_to']) {
|
|||
}
|
||||
else {
|
||||
$from_array = explode(':', $template['time_from']);
|
||||
$from = $from_array[0] * 3600 + $from_array[1] * 60 + $from_array[2];
|
||||
$from = $from_array[0] * SECONDS_1HOUR + $from_array[1] * SECONDS_1MINUTE + $from_array[2];
|
||||
$to_array = explode(':', $template['time_to']);
|
||||
$to = $to_array[0] * 3600 + $to_array[1] * 60 + $to_array[2];
|
||||
$to = $to_array[0] * SECONDS_1HOUR + $to_array[1] * SECONDS_1MINUTE + $to_array[2];
|
||||
if ($to > $from) {
|
||||
if ($template['time_from'] != '00:00:00') {
|
||||
$table_time->head[0] = '00:00:00<br>-<br>' . $template['time_from'];
|
||||
|
@ -296,7 +296,11 @@ unset($table_time);
|
|||
$table_conditions->data[] = $data;
|
||||
|
||||
$data[0] = __('Use special days list');
|
||||
$data[1] = (isset($alert['special_day']) && $alert['special_day'] == 1) ? __('Yes') : __('No');
|
||||
$data[1] = (isset($alert['special_day']) && $alert['special_day'] == 1)
|
||||
?
|
||||
__('Yes')
|
||||
:
|
||||
__('No');
|
||||
$table_conditions->data[] = $data;
|
||||
|
||||
$data[0] = __('Time threshold');
|
||||
|
@ -372,7 +376,7 @@ else {
|
|||
else {
|
||||
$table->head[$k] = '#' . $k;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$action_threshold = $action['module_action_threshold'] > 0 ? $action['module_action_threshold'] : $action['action_threshold'];
|
||||
|
@ -523,21 +527,21 @@ else {
|
|||
$table->style[3] = 'width: 25%;';
|
||||
$table->style[3] = 'font-weight: bold; width: 25%;';
|
||||
$table->title = __('Recovering fields') . ui_print_help_tip(__('Fields passed to the command executed by this action when the alert is recovered'), true);
|
||||
|
||||
|
||||
$table->head[0] = __('Field') . ui_print_help_tip(__('Fields configured on the command associated to the action'), true);
|
||||
$table->head[1] = __('Firing fields') . ui_print_help_tip(__('Fields used on execution when the alert is fired'), true);
|
||||
$table->head[2] = __('Template recovery fields') . ui_print_help_tip(__('Recovery fields configured in alert template'), true);
|
||||
$table->head[3] = __('Action recovery fields') . ui_print_help_tip(__('Recovery fields configured in alert action'), true);
|
||||
$table->head[4] = __('Executed on recovery') . ui_print_help_tip(__('Fields used on execution when the alert is recovered'), true);
|
||||
$table->style[4] = 'font-weight: bold;';
|
||||
|
||||
|
||||
foreach($firing_fields as $kaction => $firing) {
|
||||
$data = array();
|
||||
$command_preview = $firing_fields[$kaction]['command'];
|
||||
$fieldn = 1;
|
||||
foreach ($firing['description'] as $field => $desc) {
|
||||
$data[0] = $desc;
|
||||
|
||||
|
||||
if (!empty($data[0])) {
|
||||
$data[0] = '<b>' . $data[0] . '</b><br>';
|
||||
}
|
||||
|
@ -609,7 +613,7 @@ $('#firing_action_select').change(function() {
|
|||
$('.action_details').show();
|
||||
}
|
||||
|
||||
|
||||
|
||||
$('.firing_action').hide();
|
||||
if($(this).val() != -1) {
|
||||
$('.firing_action_' + $(this).val()).show();
|
||||
|
|
|
@ -8049,40 +8049,46 @@ function api_get_module_graph($id_module, $thrash2, $other, $thrash4) {
|
|||
if (defined ('METACONSOLE')) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (is_nan($id_module) || $id_module <= 0) {
|
||||
returnError('error_module_graph', __(''));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
$id_exist = (bool) db_get_value ('id_agente_modulo', 'tagente_modulo', 'id_agente_modulo', $id_module);
|
||||
|
||||
|
||||
if (!$id_exist) {
|
||||
// returnError('id_not_found');
|
||||
return;
|
||||
}
|
||||
|
||||
$graph_seconds =(!empty($other) && isset($other['data'])) ? $other['data'] : 3600; // 1 hour by default
|
||||
|
||||
|
||||
$graph_seconds =
|
||||
(!empty($other) && isset($other['data']))
|
||||
?
|
||||
$other['data']
|
||||
:
|
||||
SECONDS_1HOUR; // 1 hour by default
|
||||
|
||||
if (is_nan($graph_seconds) || $graph_seconds <= 0) {
|
||||
// returnError('error_module_graph', __(''));
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the html item
|
||||
$graph_html = grafico_modulo_sparse($id_module, $graph_seconds, false, 600, 300, '',
|
||||
'', false, false, true, time(), '', 0, 0, true, true,
|
||||
ui_get_full_url(false) . '/', 1, false, '', false, true);
|
||||
|
||||
$graph_html = grafico_modulo_sparse(
|
||||
$id_module, $graph_seconds, false, 600, 300, '',
|
||||
'', false, false, true, time(), '', 0, 0, true, true,
|
||||
ui_get_full_url(false) . '/', 1, false, '', false, true);
|
||||
|
||||
$graph_image_file_encoded = false;
|
||||
|
||||
|
||||
// Get the src of the html item
|
||||
if (preg_match("/<img src='(.+)'>/", $graph_html, $matches)) {
|
||||
if (isset($matches) && isset($matches[1])) {
|
||||
$file_url = $matches[1];
|
||||
// Get the file
|
||||
$graph_image_file = file_get_contents($file_url);
|
||||
|
||||
|
||||
if ($graph_image_file !== false) {
|
||||
// Encode the file
|
||||
$graph_image_file_encoded = base64_encode($graph_image_file);
|
||||
|
|
|
@ -6,10 +6,16 @@
|
|||
<h1>Action Threshold</h1>
|
||||
|
||||
<p>
|
||||
An alert action will not be executed more than once every action_threshold seconds, regardless of the number of times the alert is fired.
|
||||
|
||||
For example, if you have configured an action that sends you an email when the alert fires and you don't want to receive more than one email per hour, you can set the action_threshold to 3600.
|
||||
|
||||
Bear in mind that the individual action_threshold of an action overrides the global action_threshold of the alert.
|
||||
|
||||
An alert action will not be executed more than once every
|
||||
action_threshold seconds, regardless of the number of times the alert is
|
||||
fired.
|
||||
</p>
|
||||
<p>
|
||||
For example, if you have configured an action that sends you an email
|
||||
when the alert fires and you don't want to receive more than one email
|
||||
per hour, you can set the action_threshold to 3600.
|
||||
</p>
|
||||
<p>
|
||||
Bear in mind that the individual action_threshold of an action overrides
|
||||
the global action_threshold of the alert.
|
||||
</p>
|
||||
|
|
|
@ -6,10 +6,16 @@
|
|||
<h1>Umbral de acción</h1>
|
||||
|
||||
<p>
|
||||
Una acción de una alerta no se ejecutará más de una vez cada action_threshold segundos, independientemenete del número de veces que se dispare la alerta.
|
||||
|
||||
Por ejemplo, si ha configurado una acción que le envía un email cuando la alerta se dispara y no quiere recibir más de un email por hora, puede configurar un action_threshold de 3600.
|
||||
|
||||
Tenga en cuenta que el action_threshold individual de una acción tiene precedencia sobre el action_threshold global de una alerta.
|
||||
|
||||
Una acción de una alerta no se ejecutará más de una vez cada
|
||||
action_threshold segundos, independientemenete del número de veces que
|
||||
se dispare la alerta.
|
||||
</p>
|
||||
<p>
|
||||
Por ejemplo, si ha configurado una acción que le envía un email cuando
|
||||
la alerta se dispara y no quiere recibir más de un email por hora, puede
|
||||
configurar un action_threshold de 3600.
|
||||
</p>
|
||||
<p>
|
||||
Tenga en cuenta que el action_threshold individual de una acción tiene
|
||||
precedencia sobre el action_threshold global de una alerta.
|
||||
</p>
|
||||
|
|
Loading…
Reference in New Issue