mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Updated alerts interface to support inverted rules, worse/better alerts
This commit is contained in:
@@ -23,6 +23,7 @@ $alert_id = $_POST['alert_id'];
|
|||||||
$count = mres($_POST['count']);
|
$count = mres($_POST['count']);
|
||||||
$delay = mres($_POST['delay']);
|
$delay = mres($_POST['delay']);
|
||||||
$mute = mres($_POST['mute']);
|
$mute = mres($_POST['mute']);
|
||||||
|
$invert = mres($_POST['invert']);
|
||||||
$name = mres($_POST['name']);
|
$name = mres($_POST['name']);
|
||||||
|
|
||||||
if(empty($rule)) {
|
if(empty($rule)) {
|
||||||
@@ -38,7 +39,12 @@ if(empty($rule)) {
|
|||||||
} else {
|
} else {
|
||||||
$mute = false;
|
$mute = false;
|
||||||
}
|
}
|
||||||
$extra = array('mute'=>$mute,'count'=>$count,'delay'=>$delay_sec);
|
if($invert == 'on') {
|
||||||
|
$invert = true;
|
||||||
|
} else {
|
||||||
|
$invert = false;
|
||||||
|
}
|
||||||
|
$extra = array('mute'=>$mute,'count'=>$count,'delay'=>$delay_sec,'invert'=>$invert);
|
||||||
$extra_json = json_encode($extra);
|
$extra_json = json_encode($extra);
|
||||||
if(is_numeric($alert_id) && $alert_id > 0) {
|
if(is_numeric($alert_id) && $alert_id > 0) {
|
||||||
if(dbUpdate(array('rule' => $rule,'severity'=>mres($_POST['severity']),'extra'=>$extra_json,'name'=>$name), 'alert_rules', 'id=?',array($alert_id)) >= 0) {
|
if(dbUpdate(array('rule' => $rule,'severity'=>mres($_POST['severity']),'extra'=>$extra_json,'name'=>$name), 'alert_rules', 'id=?',array($alert_id)) >= 0) {
|
||||||
|
@@ -99,6 +99,10 @@ if(is_admin() === false) {
|
|||||||
<div class='col-sm-2'>
|
<div class='col-sm-2'>
|
||||||
<input type="checkbox" name="mute" id="mute">
|
<input type="checkbox" name="mute" id="mute">
|
||||||
</div>
|
</div>
|
||||||
|
<label for='invert' class='col-sm-3 control-label'>Invert match: </label>
|
||||||
|
<div class='col-sm-2'>
|
||||||
|
<input type='checkbox' name='invert' id='invert'>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class='form-group'>
|
<div class='form-group'>
|
||||||
<label for='name' class='col-sm-3 control-label'>Rule name: </label>
|
<label for='name' class='col-sm-3 control-label'>Rule name: </label>
|
||||||
@@ -120,6 +124,7 @@ if(is_admin() === false) {
|
|||||||
<script>
|
<script>
|
||||||
|
|
||||||
$("[name='mute']").bootstrapSwitch('offColor','danger');
|
$("[name='mute']").bootstrapSwitch('offColor','danger');
|
||||||
|
$("[name='invert']").bootstrapSwitch('offColor','danger');
|
||||||
|
|
||||||
$('#create-alert').on('hide.bs.modal', function (event) {
|
$('#create-alert').on('hide.bs.modal', function (event) {
|
||||||
$('#response').data('tagmanager').empty();
|
$('#response').data('tagmanager').empty();
|
||||||
@@ -161,6 +166,7 @@ $('#create-alert').on('show.bs.modal', function (event) {
|
|||||||
}
|
}
|
||||||
$('#delay').val(delay);
|
$('#delay').val(delay);
|
||||||
$("[name='mute']").bootstrapSwitch('state',extra['mute']);
|
$("[name='mute']").bootstrapSwitch('state',extra['mute']);
|
||||||
|
$("[name='invert']").bootstrapSwitch('state',extra['invert']);
|
||||||
$('#name').val(output['name']);
|
$('#name').val(output['name']);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@@ -116,7 +116,11 @@ foreach( dbFetchRows($full_query, $param) as $rule ) {
|
|||||||
echo "<tr class='".$extra."' id='row_".$rule['id']."'>";
|
echo "<tr class='".$extra."' id='row_".$rule['id']."'>";
|
||||||
echo "<td><i>#".((int) $rulei++)."</i></td>";
|
echo "<td><i>#".((int) $rulei++)."</i></td>";
|
||||||
echo "<td>".$rule['name']."</td>";
|
echo "<td>".$rule['name']."</td>";
|
||||||
echo "<td><i>".htmlentities($rule['rule'])."</i></td>";
|
echo "<td>";
|
||||||
|
if($rule_extra['invert'] === true) {
|
||||||
|
echo "<strong><em>Inverted</em></strong> ";
|
||||||
|
}
|
||||||
|
echo "<i>".htmlentities($rule['rule'])."</i></td>";
|
||||||
echo "<td>".$rule['severity']."</td>";
|
echo "<td>".$rule['severity']."</td>";
|
||||||
echo "<td><span id='alert-rule-".$rule['id']."' class='glyphicon glyphicon-".$ico." glyphicon-large text-".$col."'></span> ";
|
echo "<td><span id='alert-rule-".$rule['id']."' class='glyphicon glyphicon-".$ico." glyphicon-large text-".$col."'></span> ";
|
||||||
if($rule_extra['mute'] === true) {
|
if($rule_extra['mute'] === true) {
|
||||||
|
@@ -51,7 +51,7 @@ if(isset($device['device_id']) && $device['device_id'] > 0) {
|
|||||||
$sql = 'AND `alerts`.`device_id`=?';
|
$sql = 'AND `alerts`.`device_id`=?';
|
||||||
$param = array($device['device_id']);
|
$param = array($device['device_id']);
|
||||||
}
|
}
|
||||||
$query = " FROM `alerts` LEFT JOIN `devices` ON `alerts`.`device_id`=`devices`.`device_id` RIGHT JOIN alert_rules ON alerts.rule_id=alert_rules.id WHERE `state` IN (1,2) $sql ORDER BY `alerts`.`timestamp` DESC";
|
$query = " FROM `alerts` LEFT JOIN `devices` ON `alerts`.`device_id`=`devices`.`device_id` RIGHT JOIN alert_rules ON alerts.rule_id=alert_rules.id WHERE `state` IN (1,2,3,4) $sql ORDER BY `alerts`.`timestamp` DESC";
|
||||||
$count_query = $count_query . $query;
|
$count_query = $count_query . $query;
|
||||||
$count = dbFetchCell($count_query,$param);
|
$count = dbFetchCell($count_query,$param);
|
||||||
if(!isset($_POST['page_number']) && $_POST['page_number'] < 1) {
|
if(!isset($_POST['page_number']) && $_POST['page_number'] < 1) {
|
||||||
@@ -88,12 +88,18 @@ foreach( dbFetchRows($full_query, $param) as $alert ) {
|
|||||||
echo "<td><i>".htmlentities($rule['rule'])."</i></td>";
|
echo "<td><i>".htmlentities($rule['rule'])."</i></td>";
|
||||||
echo "<td>".$alert['hostname']."</td>";
|
echo "<td>".$alert['hostname']."</td>";
|
||||||
echo "<td>".($alert['timestamp'] ? $alert['timestamp'] : "N/A")."</td>";
|
echo "<td>".($alert['timestamp'] ? $alert['timestamp'] : "N/A")."</td>";
|
||||||
echo "<td>".$rule['severity']."</td>";
|
echo "<td>".$rule['severity'];
|
||||||
|
if($alert['state'] == 3) {
|
||||||
|
echo " <strong>+</strong>";
|
||||||
|
} elseif($alert['state'] == 4) {
|
||||||
|
echo " <strong>-</strong>";
|
||||||
|
}
|
||||||
|
echo "</td>";
|
||||||
echo "<td>";
|
echo "<td>";
|
||||||
if ($_SESSION['userlevel'] == '10') {
|
if ($_SESSION['userlevel'] == '10') {
|
||||||
$ack_ico = 'volume-up';
|
$ack_ico = 'volume-up';
|
||||||
$ack_col = 'success';
|
$ack_col = 'success';
|
||||||
if($alert['state'] == 2) {
|
if(in_array($alert['state'],array(2,3,4))) {
|
||||||
$ack_ico = 'volume-off';
|
$ack_ico = 'volume-off';
|
||||||
$ack_col = 'danger';
|
$ack_col = 'danger';
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user