mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
* Show verbose alert details in the alert, alert-log webui update file permissions * Make global admin permission required to use alert details ui * StyleCI patch Co-authored-by: root <root@usopsl-libre001.corp.blizzard.net>
41 lines
1.1 KiB
PHP
41 lines
1.1 KiB
PHP
<?php
|
|
|
|
header('Content-type: application/json');
|
|
|
|
$alert_log_id = $vars['alert_log_id'];
|
|
$sub_type = $vars['sub_type'];
|
|
$status = 'error';
|
|
$details = 'No Details found';
|
|
$message = 'No Details found';
|
|
|
|
if (! Auth::user()->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,
|
|
]));
|