@@ -83,6 +87,7 @@ $common_output[] = '
Device |
Alert |
Severity |
+ ' . $admin_verbose_details . '
@@ -171,12 +176,24 @@ $common_output[] = '
\
$(target).collapse(\'toggle\');
$(this).toggleClass(\'fa-plus fa-minus\');
});
+ grid.find(".command-alert-details").on("click", function(e) {
+ e.preventDefault();
+ var alert_log_id = $(this).data(\'alert_log_id\');
+ $(\'#alert_log_id\').val(alert_log_id);
+ $("#alert_details_modal").modal(\'show\');
+ });
grid.find(".incident").each(function () {
$(this).parent().addClass(\'col-lg-4 col-md-4 col-sm-4 col-xs-4\');
$(this).parent().parent().on("mouseenter", function () {
$(this).find(".incident-toggle").fadeIn(200);
+ if ($(this).find(".alert-status").hasClass(\'label-danger\')){
+ $(this).find(".command-alert-details").fadeIn(200);
+ }
}).on("mouseleave", function () {
$(this).find(".incident-toggle").fadeOut(200);
+ if ($(this).find(".alert-status").hasClass(\'label-danger\')){
+ $(this).find(".command-alert-details").fadeOut(200);
+ }
}).on("click", "td:not(.incident-toggle-td)", function () {
var target = $(this).parent().find(".incident-toggle").data("target");
if ($(this).parent().find(".incident-toggle").hasClass(\'fa-plus\')) {
diff --git a/includes/html/common/alerts.inc.php b/includes/html/common/alerts.inc.php
index bedd6d453e..917b9f4e43 100644
--- a/includes/html/common/alerts.inc.php
+++ b/includes/html/common/alerts.inc.php
@@ -33,6 +33,9 @@ $alert_severities = [
'warning only' => 5,
'critical only' => 6,
];
+if (Auth::user()->hasGlobalAdmin()) {
+ $admin_verbose_details = '
Details | ';
+}
//if( defined('SHOW_SETTINGS') || empty($widget_settings) ) {
if (defined('SHOW_SETTINGS')) {
@@ -232,7 +235,8 @@ if (defined('SHOW_SETTINGS')) {
Hostname |
Location |
ACK |
-
Notes | ';
+
Notes |
+ ' . $admin_verbose_details . '';
if ($proc == '1') {
$common_output[] = '
URL | ';
@@ -315,6 +319,12 @@ var alerts_grid = $("#alerts_' . $unique_id . '").bootgrid({
$(\'#alert_id\').val(alert_id);
$("#alert_notes_modal").modal(\'show\');
});
+ alerts_grid.find(".command-alert-details").on("click", function(e) {
+ e.preventDefault();
+ var alert_log_id = $(this).data(\'alert_log_id\');
+ $(\'#alert_log_id\').val(alert_log_id);
+ $("#alert_details_modal").modal(\'show\');
+ });
});
';
}
diff --git a/includes/html/forms/alert-details.inc.php b/includes/html/forms/alert-details.inc.php
new file mode 100644
index 0000000000..7a3b6f121d
--- /dev/null
+++ b/includes/html/forms/alert-details.inc.php
@@ -0,0 +1,40 @@
+hasGlobalAdmin()) {
+ $message = 'Wrong permissions';
+ $details = 'You need to have admin permissions.';
+ exit(json_encode([
+ 'status' => $status,
+ 'message' => $message,
+ 'details' => $details,
+ ]));
+}
+
+if (is_numeric($alert_log_id)) {
+ foreach (dbFetchRows('SELECT device_id, id, time_logged, details as detail FROM alert_log WHERE state != 2 && state != 0 && id = ?', [$alert_log_id]) as $alertlog) {
+ $details = json_decode(gzuncompress($alertlog['detail']), true)['rule'];
+ if (! empty($details)) {
+ $message = 'Found alert details';
+ $status = 'ok';
+ } else {
+ $details = 'No Details found';
+ }
+ }
+} else {
+ $message = 'Invalid alert id';
+ $details = 'Invalid alert id';
+}
+
+exit(json_encode([
+ 'status' => $status,
+ 'message' => $message,
+ 'details' => $details,
+]));
diff --git a/includes/html/modal/alert_details.php b/includes/html/modal/alert_details.php
new file mode 100644
index 0000000000..c3b144cbda
--- /dev/null
+++ b/includes/html/modal/alert_details.php
@@ -0,0 +1,40 @@
+
+
+
+
+
diff --git a/includes/html/pages/alert-log.inc.php b/includes/html/pages/alert-log.inc.php
index 78c8aa87bf..dac8c2b919 100644
--- a/includes/html/pages/alert-log.inc.php
+++ b/includes/html/pages/alert-log.inc.php
@@ -16,6 +16,7 @@
$no_refresh = true;
$device_id = '';
$vars['fromdevice'] = false;
+require_once 'includes/html/modal/alert_details.php';
require_once 'includes/html/common/alert-log.inc.php';
echo implode('', $common_output);
unset($device_id);
diff --git a/includes/html/pages/alerts.inc.php b/includes/html/pages/alerts.inc.php
index 2559a2fdc2..64d2a18944 100644
--- a/includes/html/pages/alerts.inc.php
+++ b/includes/html/pages/alerts.inc.php
@@ -24,6 +24,7 @@ $page_title = 'Alerts';
';
switch ($vars['section']) {
case 'alerts':
+ include 'includes/html/modal/alert_details.php';
include 'includes/html/modal/alert_notes.inc.php';
include 'includes/html/modal/alert_ack.inc.php';
include 'includes/html/common/alerts.inc.php';
@@ -55,6 +56,7 @@ switch ($vars['section']) {
case 'alert-log':
$vars['fromdevice'] = true;
$device_id = (int) $vars['device'];
+ include 'includes/html/modal/alert_details.php';
include 'includes/html/common/alert-log.inc.php';
echo implode('', $common_output);
break;
diff --git a/includes/html/table/alertlog.inc.php b/includes/html/table/alertlog.inc.php
index 15c973ecff..00c009a5bd 100644
--- a/includes/html/table/alertlog.inc.php
+++ b/includes/html/table/alertlog.inc.php
@@ -84,7 +84,9 @@ foreach (dbFetchRows($sql, $param) as $alertlog) {
$dev = device_by_id_cache($alertlog['device_id']);
logfile($alertlog['rule_id']);
$log = dbFetchCell('SELECT details FROM alert_log WHERE rule_id = ? AND device_id = ? AND `state` = 1 ORDER BY id DESC LIMIT 1', [$alertlog['rule_id'], $alertlog['device_id']]);
+ $alert_log_id = dbFetchCell('SELECT id FROM alert_log WHERE rule_id = ? AND device_id = ? ORDER BY id DESC LIMIT 1', [$alertlog['rule_id'], $alertlog['device_id']]);
$fault_detail = alert_details($log);
+
if (empty($fault_detail)) {
$fault_detail = 'Rule created, no faults found';
}
@@ -105,6 +107,7 @@ foreach (dbFetchRows($sql, $param) as $alertlog) {
'id' => $rulei++,
'time_logged' => $alertlog['humandate'],
'details' => '
',
+ 'verbose_details' => "
",
'hostname' => '
' . generate_device_link($dev, shorthost($dev['hostname'])) . '
' . $fault_detail . '
',
'alert' => htmlspecialchars($alertlog['alert']),
'status' => "
",
diff --git a/includes/html/table/alerts.inc.php b/includes/html/table/alerts.inc.php
index 26e2562858..44b6428858 100644
--- a/includes/html/table/alerts.inc.php
+++ b/includes/html/table/alerts.inc.php
@@ -109,6 +109,7 @@ $rulei = 0;
$format = $vars['format'];
foreach (dbFetchRows($sql, $param) as $alert) {
$log = dbFetchCell('SELECT details FROM alert_log WHERE rule_id = ? AND device_id = ? ORDER BY id DESC LIMIT 1', [$alert['rule_id'], $alert['device_id']]);
+ $alert_log_id = dbFetchCell('SELECT id FROM alert_log WHERE rule_id = ? AND device_id = ? ORDER BY id DESC LIMIT 1', [$alert['rule_id'], $alert['device_id']]);
$fault_detail = alert_details($log);
$info = json_decode($alert['info'], true);
@@ -170,6 +171,7 @@ foreach (dbFetchRows($sql, $param) as $alert) {
'id' => $rulei++,
'rule' => '
' . htmlentities($alert['name']) . '',
'details' => '
',
+ 'verbose_details' => "
",
'hostname' => $hostname,
'location' => generate_link($alert['location'], ['page' => 'devices', 'location' => $alert['location']]),
'timestamp' => ($alert['timestamp'] ? $alert['timestamp'] : 'N/A'),