mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
webui: Allow user to display ok/warning/critical alerts only (#7484)
* Allow user to display ok/warning/critical alerts only * Update alerts.inc.php * Update alerts.inc.php
This commit is contained in:
committed by
Neil Lathwood
parent
2f2234da70
commit
62867a6661
@ -10,14 +10,17 @@ $alert_states = array(
|
||||
'alerted' => 1,
|
||||
'acknowledged' => 2,
|
||||
'worse' => 3,
|
||||
'better' => 4
|
||||
'better' => 4,
|
||||
);
|
||||
|
||||
$alert_severities = array(
|
||||
// alert_rules.status is enum('ok','warning','critical')
|
||||
'ok' => 1,
|
||||
'warning' => 2,
|
||||
'critical' => 3
|
||||
'critical' => 3,
|
||||
'ok only' => 4,
|
||||
'warning only' => 5,
|
||||
'critical only' => 6,
|
||||
);
|
||||
|
||||
//if( defined('SHOW_SETTINGS') || empty($widget_settings) ) {
|
||||
@ -47,14 +50,14 @@ if (defined('SHOW_SETTINGS')) {
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<div class="col-sm-4">
|
||||
<label for="min_severity" class="control-label">Minimum displayed severity:</label>
|
||||
<label for="min_severity" class="control-label">Displayed severity:</label>
|
||||
</div>
|
||||
<div class="col-sm-8">
|
||||
<select class="form-control" name="min_severity">
|
||||
<option value="">any severity</option>';
|
||||
|
||||
foreach ($alert_severities as $name => $val) {
|
||||
$common_output[] = "<option value=\"$val\"".($current_severity == $name || $current_severity == $val ? ' selected' : '').">$name or higher</option>";
|
||||
$common_output[] = "<option value=\"$val\"".($current_severity == $name || $current_severity == $val ? ' selected' : '').">$name".($val > 3 ? "" : " or higher")."</option>";
|
||||
}
|
||||
|
||||
$common_output[] = '
|
||||
@ -154,7 +157,7 @@ if (defined('SHOW_SETTINGS')) {
|
||||
$sev_name = $min_severity;
|
||||
if (is_numeric($min_severity)) {
|
||||
$sev_name = array_search($min_severity, $alert_severities);
|
||||
$title = "$title >=$sev_name";
|
||||
$title = "$title ".($min_severity > 3 ? "" :">")."=$sev_name";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10,14 +10,17 @@ $alert_states = array(
|
||||
'alerted' => 1,
|
||||
'acknowledged' => 2,
|
||||
'worse' => 3,
|
||||
'better' => 4
|
||||
'better' => 4,
|
||||
);
|
||||
|
||||
$alert_severities = array(
|
||||
// alert_rules.status is enum('ok','warning','critical')
|
||||
'ok' => 1,
|
||||
'warning' => 2,
|
||||
'critical' => 3
|
||||
'critical' => 3,
|
||||
'ok only' => 4,
|
||||
'warning only' => 5,
|
||||
'critical only' => 6,
|
||||
);
|
||||
|
||||
$show_recovered = false;
|
||||
@ -45,7 +48,7 @@ if (isset($_POST['min_severity'])) {
|
||||
$min_severity_id = $alert_severities[$_POST['min_severity']];
|
||||
}
|
||||
if (isset($min_severity_id)) {
|
||||
$where .= " AND `alert_rules`.`severity` >= ".$min_severity_id;
|
||||
$where .= " AND `alert_rules`.`severity` ".($min_severity_id > 3 ? "" :">")."= ".($min_severity_id > 3 ? $min_severity_id - 3 : $min_severity_id);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user