From 42b65c0fda0351b9be09af9ffa788372416b4bd8 Mon Sep 17 00:00:00 2001 From: Wheel Date: Tue, 9 Dec 2025 14:00:03 +0100 Subject: [PATCH 01/30] Fix filter fields device event and syslog tabs --- .../views/device/tabs/logs/eventlog.blade.php | 34 +++++--- .../views/device/tabs/logs/syslog.blade.php | 80 +++++++++++++------ 2 files changed, 76 insertions(+), 38 deletions(-) diff --git a/resources/views/device/tabs/logs/eventlog.blade.php b/resources/views/device/tabs/logs/eventlog.blade.php index 58af21f68410..162bc1991e2c 100644 --- a/resources/views/device/tabs/logs/eventlog.blade.php +++ b/resources/views/device/tabs/logs/eventlog.blade.php @@ -18,10 +18,7 @@ - - @if(! $filter_device) - - @endif + @endsection @@ -65,14 +62,27 @@ '' ); - init_select2("select#device", "device", {limit: 100}, "{{ $device->device_id }}"); - init_select2("#eventtype", "eventlog", function(params) { - return { - field: "type", - device: $('#device').val(), - term: params.term, - page: params.page || 1 + $('#eventtype').select2({ + theme: 'bootstrap', + dropdownAutoWidth: true, + width: 'auto', + allowClear: true, + placeholder: 'All Types', + ajax: { + url: '{{ route('ajax.select.eventlog') }}', + delay: 200, + data: function (params) { + return { + field: 'type', + device: $('#device').val(), + term: params.term, + page: params.page || 1 + }; + } } - }, @json($eventtype)); + }); + @if(!empty($eventtype)) + $('#eventtype').val({!! json_encode($eventtype) !!}).trigger('change'); + @endif @endsection diff --git a/resources/views/device/tabs/logs/syslog.blade.php b/resources/views/device/tabs/logs/syslog.blade.php index 4d7726c5f57d..bf3a18f731d4 100644 --- a/resources/views/device/tabs/logs/syslog.blade.php +++ b/resources/views/device/tabs/logs/syslog.blade.php @@ -20,10 +20,7 @@ - - @if(! $filter_device) - - @endif + @endsection @@ -61,18 +58,22 @@ '' + '  
' + '' + '
' + '  
' + '' + '
' + '  
' + @@ -131,22 +132,49 @@ $("#dtpickerto").data("DateTimePicker").maxDate('{{ $now }}'); } - init_select2("select#device", "device", {limit: 100}, "{{ $device->device_id }}"); - init_select2("#program", "syslog", function(params) { - return { - field: "program", - device: $('#device').val(), - term: params.term, - page: params.page || 1 + $('#program').select2({ + theme: 'bootstrap', + dropdownAutoWidth: true, + width: 'auto', + allowClear: true, + placeholder: 'All Programs', + ajax: { + url: '{{ route('ajax.select.syslog') }}', + delay: 200, + data: function (params) { + return { + field: 'program', + device: $('#device').val(), + term: params.term, + page: params.page || 1 + }; + } } - }, @json($program)); - init_select2("#priority", "syslog", function(params) { - return { - field: "priority", - device: $('#device').val(), - term: params.term, - page: params.page || 1 + }); + @if(!empty($program)) + $('#program').val({!! json_encode($program) !!}).trigger('change'); + @endif + $('#priority').select2({ + theme: 'bootstrap', + dropdownAutoWidth: true, + width: 'auto', + allowClear: true, + placeholder: 'All Priorities', + ajax: { + url: '{{ route('ajax.select.syslog') }}', + delay: 200, + data: function (params) { + return { + field: 'priority', + device: $('#device').val(), + term: params.term, + page: params.page || 1 + }; + } } - }, @json($priority)); + }); + @if(!empty($priority)) + $('#priority').val({!! json_encode($priority) !!}).trigger('change'); + @endif @endsection From 15c13e9fa9b7077c485aa011030a81447e3a995c Mon Sep 17 00:00:00 2001 From: Wheel Date: Wed, 10 Dec 2025 12:27:13 +0100 Subject: [PATCH 02/30] Revisit the issue with keep init_select2() approach --- .../views/device/tabs/logs/eventlog.blade.php | 58 +++------ .../views/device/tabs/logs/syslog.blade.php | 123 ++++++------------ 2 files changed, 55 insertions(+), 126 deletions(-) diff --git a/resources/views/device/tabs/logs/eventlog.blade.php b/resources/views/device/tabs/logs/eventlog.blade.php index 162bc1991e2c..97bbdf092dc9 100644 --- a/resources/views/device/tabs/logs/eventlog.blade.php +++ b/resources/views/device/tabs/logs/eventlog.blade.php @@ -39,50 +39,26 @@ $('.actionBar').append( '
' + - '
' + - - @if($filter_device) + '' + '
' + - '' + - '' + - '
    ' + - @endif - - '
' + - '' + - '
  ' + - '' + - '
' + + '' + + '' + + '
' + + '  ' + + '' + + '' + '
' ); - $('#eventtype').select2({ - theme: 'bootstrap', - dropdownAutoWidth: true, - width: 'auto', - allowClear: true, - placeholder: 'All Types', - ajax: { - url: '{{ route('ajax.select.eventlog') }}', - delay: 200, - data: function (params) { - return { - field: 'type', - device: $('#device').val(), - term: params.term, - page: params.page || 1 - }; - } + init_select2("#eventtype", "eventlog", function(params) { + return { + field: "type", + device: $('#device').val(), + term: params.term, + page: params.page || 1 } - }); - @if(!empty($eventtype)) - $('#eventtype').val({!! json_encode($eventtype) !!}).trigger('change'); - @endif + }, @json($eventtype ? ['id' => $eventtype, 'text' => $eventtype] : null),'All types'); -@endsection +@endsection \ No newline at end of file diff --git a/resources/views/device/tabs/logs/syslog.blade.php b/resources/views/device/tabs/logs/syslog.blade.php index bf3a18f731d4..723cd2ecd560 100644 --- a/resources/views/device/tabs/logs/syslog.blade.php +++ b/resources/views/device/tabs/logs/syslog.blade.php @@ -45,48 +45,29 @@ $('.actionBar').append( '
' + - '
' + - '
' + - @if($filter_device) - '' + - @endif - '
' + - '  
' + - '' + - '
' + - '  
' + - '' + - '
' + - '  
' + - '' + - '
' + - '
' + - '  ' + - '
' + - '  ' + - '
' + - '
' + - '' + - '' + + '
' + + '
' + + '' + + '
' + + '  ' + + '
' + + '' + + '
' + + '  ' + + '
' + + '' + + '
' + + '  ' + + '
' + + '' + + '
' + + '  ' + + '' + + '
' + '' ); @@ -132,49 +113,21 @@ $("#dtpickerto").data("DateTimePicker").maxDate('{{ $now }}'); } - $('#program').select2({ - theme: 'bootstrap', - dropdownAutoWidth: true, - width: 'auto', - allowClear: true, - placeholder: 'All Programs', - ajax: { - url: '{{ route('ajax.select.syslog') }}', - delay: 200, - data: function (params) { - return { - field: 'program', - device: $('#device').val(), - term: params.term, - page: params.page || 1 - }; - } + init_select2("#program", "syslog", function(params) { + return { + field: "program", + device: $('#device').val(), + term: params.term, + page: params.page || 1 } - }); - @if(!empty($program)) - $('#program').val({!! json_encode($program) !!}).trigger('change'); - @endif - $('#priority').select2({ - theme: 'bootstrap', - dropdownAutoWidth: true, - width: 'auto', - allowClear: true, - placeholder: 'All Priorities', - ajax: { - url: '{{ route('ajax.select.syslog') }}', - delay: 200, - data: function (params) { - return { - field: 'priority', - device: $('#device').val(), - term: params.term, - page: params.page || 1 - }; - } + }, @json($program ? ['id' => $program, 'text' => $program] : null),'All Programs'); + init_select2("#priority", "syslog", function(params) { + return { + field: "priority", + device: $('#device').val(), + term: params.term, + page: params.page || 1 } - }); - @if(!empty($priority)) - $('#priority').val({!! json_encode($priority) !!}).trigger('change'); - @endif + }, @json($priority ? ['id' => $priority, 'text' => $priority] : null),'All Priorities'); -@endsection +@endsection \ No newline at end of file From 53594cdf816c6dfad9d60fb8ec09ed2779b62f75 Mon Sep 17 00:00:00 2001 From: Wheel Date: Wed, 10 Dec 2025 23:05:26 +0100 Subject: [PATCH 03/30] Match with the code from #18631 --- resources/views/device/tabs/logs/eventlog.blade.php | 2 +- resources/views/device/tabs/logs/graylog.blade.php | 4 ++-- resources/views/device/tabs/logs/syslog.blade.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/resources/views/device/tabs/logs/eventlog.blade.php b/resources/views/device/tabs/logs/eventlog.blade.php index 97bbdf092dc9..678b11711f74 100644 --- a/resources/views/device/tabs/logs/eventlog.blade.php +++ b/resources/views/device/tabs/logs/eventlog.blade.php @@ -59,6 +59,6 @@ term: params.term, page: params.page || 1 } - }, @json($eventtype ? ['id' => $eventtype, 'text' => $eventtype] : null),'All types'); + }, @json($eventtype),'All types'); @endsection \ No newline at end of file diff --git a/resources/views/device/tabs/logs/graylog.blade.php b/resources/views/device/tabs/logs/graylog.blade.php index fbd7a5ba51f6..94aac28acb3e 100644 --- a/resources/views/device/tabs/logs/graylog.blade.php +++ b/resources/views/device/tabs/logs/graylog.blade.php @@ -110,7 +110,7 @@ url: "{{ route('table.graylog', ) }}", }); - init_select2("#stream", "graylog-streams", {}, @json($stream)); - init_select2("select#device", "device", {limit: 100}, "{{ $device->device_id }}"); + init_select2("#stream", "graylog-streams", {}, @json($stream), 'All Streams'); + init_select2("select#device", "device", {limit: 100}, "{{ $device->device_id }}", 'All Devices'); @endsection diff --git a/resources/views/device/tabs/logs/syslog.blade.php b/resources/views/device/tabs/logs/syslog.blade.php index 723cd2ecd560..d7fea8e9ace2 100644 --- a/resources/views/device/tabs/logs/syslog.blade.php +++ b/resources/views/device/tabs/logs/syslog.blade.php @@ -120,7 +120,7 @@ term: params.term, page: params.page || 1 } - }, @json($program ? ['id' => $program, 'text' => $program] : null),'All Programs'); + }, @json($program),'All Programs'); init_select2("#priority", "syslog", function(params) { return { field: "priority", @@ -128,6 +128,6 @@ term: params.term, page: params.page || 1 } - }, @json($priority ? ['id' => $priority, 'text' => $priority] : null),'All Priorities'); + }, @json($priority),'All Priorities'); @endsection \ No newline at end of file From 38348f53707621502cdb01da3f520a2302bdd44b Mon Sep 17 00:00:00 2001 From: Wheel Date: Thu, 11 Dec 2025 00:24:09 +0100 Subject: [PATCH 04/30] Consistency across all device logs blades --- .../views/device/tabs/logs/eventlog.blade.php | 5 +- .../views/device/tabs/logs/graylog.blade.php | 152 ++++++++---------- .../views/device/tabs/logs/syslog.blade.php | 7 +- 3 files changed, 72 insertions(+), 92 deletions(-) diff --git a/resources/views/device/tabs/logs/eventlog.blade.php b/resources/views/device/tabs/logs/eventlog.blade.php index 678b11711f74..4e9217c6a24f 100644 --- a/resources/views/device/tabs/logs/eventlog.blade.php +++ b/resources/views/device/tabs/logs/eventlog.blade.php @@ -18,7 +18,6 @@ - @endsection @@ -41,9 +40,7 @@ '
' + '
' + '
' + - '' + '' + '
' + '  ' + @@ -55,7 +52,7 @@ init_select2("#eventtype", "eventlog", function(params) { return { field: "type", - device: $('#device').val(), + device: {{ $device->device_id }}, term: params.term, page: params.page || 1 } diff --git a/resources/views/device/tabs/logs/graylog.blade.php b/resources/views/device/tabs/logs/graylog.blade.php index 94aac28acb3e..469742db2d14 100644 --- a/resources/views/device/tabs/logs/graylog.blade.php +++ b/resources/views/device/tabs/logs/graylog.blade.php @@ -20,97 +20,83 @@
- - @if(! $filter_device) - - @endif @endsection @section('scripts') - + field: "stream", + device: {{ $device->device_id }}, + term: params.term, + page: params.page || 1 + } + }, @json($stream),'All Messages'); + @endsection diff --git a/resources/views/device/tabs/logs/syslog.blade.php b/resources/views/device/tabs/logs/syslog.blade.php index d7fea8e9ace2..efb5976e119a 100644 --- a/resources/views/device/tabs/logs/syslog.blade.php +++ b/resources/views/device/tabs/logs/syslog.blade.php @@ -20,7 +20,6 @@ - @endsection @@ -48,13 +47,11 @@ '' + '
' + '' + '
' + '  ' + '
' + '' + '
' + '  ' + @@ -116,7 +113,7 @@ init_select2("#program", "syslog", function(params) { return { field: "program", - device: $('#device').val(), + device: {{ $device->device_id }}, term: params.term, page: params.page || 1 } @@ -124,7 +121,7 @@ init_select2("#priority", "syslog", function(params) { return { field: "priority", - device: $('#device').val(), + device: {{ $device->device_id }}, term: params.term, page: params.page || 1 } From f194dd583d0e792dfca19605424b5eece75ffcf8 Mon Sep 17 00:00:00 2001 From: Wheel Date: Thu, 11 Dec 2025 00:52:29 +0100 Subject: [PATCH 05/30] More room for meaningfull message without device column on device specific page --- bootstrap/cache/.gitignore | 0 logs/.gitignore | 0 resources/views/device/tabs/logs/eventlog.blade.php | 1 - resources/views/device/tabs/logs/syslog.blade.php | 1 - rrd/.gitignore | 0 storage/app/.gitignore | 0 storage/app/private/.gitignore | 0 storage/app/public/.gitignore | 0 storage/debugbar/.gitignore | 0 storage/framework/cache/.gitignore | 0 storage/framework/cache/data/.gitignore | 0 storage/framework/sessions/.gitignore | 0 storage/framework/testing/.gitignore | 0 storage/framework/views/.gitignore | 0 storage/logs/.gitignore | 0 15 files changed, 2 deletions(-) mode change 100644 => 100755 bootstrap/cache/.gitignore mode change 100644 => 100755 logs/.gitignore mode change 100644 => 100755 rrd/.gitignore mode change 100644 => 100755 storage/app/.gitignore mode change 100644 => 100755 storage/app/private/.gitignore mode change 100644 => 100755 storage/app/public/.gitignore mode change 100644 => 100755 storage/debugbar/.gitignore mode change 100644 => 100755 storage/framework/cache/.gitignore mode change 100644 => 100755 storage/framework/cache/data/.gitignore mode change 100644 => 100755 storage/framework/sessions/.gitignore mode change 100644 => 100755 storage/framework/testing/.gitignore mode change 100644 => 100755 storage/framework/views/.gitignore mode change 100644 => 100755 storage/logs/.gitignore diff --git a/bootstrap/cache/.gitignore b/bootstrap/cache/.gitignore old mode 100644 new mode 100755 diff --git a/logs/.gitignore b/logs/.gitignore old mode 100644 new mode 100755 diff --git a/resources/views/device/tabs/logs/eventlog.blade.php b/resources/views/device/tabs/logs/eventlog.blade.php index 4e9217c6a24f..85e98a6f151d 100644 --- a/resources/views/device/tabs/logs/eventlog.blade.php +++ b/resources/views/device/tabs/logs/eventlog.blade.php @@ -11,7 +11,6 @@ Timestamp Type - Hostname Message User diff --git a/resources/views/device/tabs/logs/syslog.blade.php b/resources/views/device/tabs/logs/syslog.blade.php index efb5976e119a..1552e250fada 100644 --- a/resources/views/device/tabs/logs/syslog.blade.php +++ b/resources/views/device/tabs/logs/syslog.blade.php @@ -12,7 +12,6 @@ Timestamp Level - Hostname Program Message Priority diff --git a/rrd/.gitignore b/rrd/.gitignore old mode 100644 new mode 100755 diff --git a/storage/app/.gitignore b/storage/app/.gitignore old mode 100644 new mode 100755 diff --git a/storage/app/private/.gitignore b/storage/app/private/.gitignore old mode 100644 new mode 100755 diff --git a/storage/app/public/.gitignore b/storage/app/public/.gitignore old mode 100644 new mode 100755 diff --git a/storage/debugbar/.gitignore b/storage/debugbar/.gitignore old mode 100644 new mode 100755 diff --git a/storage/framework/cache/.gitignore b/storage/framework/cache/.gitignore old mode 100644 new mode 100755 diff --git a/storage/framework/cache/data/.gitignore b/storage/framework/cache/data/.gitignore old mode 100644 new mode 100755 diff --git a/storage/framework/sessions/.gitignore b/storage/framework/sessions/.gitignore old mode 100644 new mode 100755 diff --git a/storage/framework/testing/.gitignore b/storage/framework/testing/.gitignore old mode 100644 new mode 100755 diff --git a/storage/framework/views/.gitignore b/storage/framework/views/.gitignore old mode 100644 new mode 100755 diff --git a/storage/logs/.gitignore b/storage/logs/.gitignore old mode 100644 new mode 100755 From 7bdbd6681ea0d3af074f5c57736b1a8b0934d209 Mon Sep 17 00:00:00 2001 From: Wheel Date: Thu, 11 Dec 2025 00:57:36 +0100 Subject: [PATCH 06/30] Unintentional --- rrd/.gitignore | 0 storage/app/.gitignore | 0 storage/app/private/.gitignore | 0 storage/app/public/.gitignore | 0 storage/debugbar/.gitignore | 0 storage/framework/cache/.gitignore | 0 storage/framework/cache/data/.gitignore | 0 storage/framework/sessions/.gitignore | 0 storage/framework/testing/.gitignore | 0 storage/framework/views/.gitignore | 0 storage/logs/.gitignore | 0 11 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 rrd/.gitignore mode change 100755 => 100644 storage/app/.gitignore mode change 100755 => 100644 storage/app/private/.gitignore mode change 100755 => 100644 storage/app/public/.gitignore mode change 100755 => 100644 storage/debugbar/.gitignore mode change 100755 => 100644 storage/framework/cache/.gitignore mode change 100755 => 100644 storage/framework/cache/data/.gitignore mode change 100755 => 100644 storage/framework/sessions/.gitignore mode change 100755 => 100644 storage/framework/testing/.gitignore mode change 100755 => 100644 storage/framework/views/.gitignore mode change 100755 => 100644 storage/logs/.gitignore diff --git a/rrd/.gitignore b/rrd/.gitignore old mode 100755 new mode 100644 diff --git a/storage/app/.gitignore b/storage/app/.gitignore old mode 100755 new mode 100644 diff --git a/storage/app/private/.gitignore b/storage/app/private/.gitignore old mode 100755 new mode 100644 diff --git a/storage/app/public/.gitignore b/storage/app/public/.gitignore old mode 100755 new mode 100644 diff --git a/storage/debugbar/.gitignore b/storage/debugbar/.gitignore old mode 100755 new mode 100644 diff --git a/storage/framework/cache/.gitignore b/storage/framework/cache/.gitignore old mode 100755 new mode 100644 diff --git a/storage/framework/cache/data/.gitignore b/storage/framework/cache/data/.gitignore old mode 100755 new mode 100644 diff --git a/storage/framework/sessions/.gitignore b/storage/framework/sessions/.gitignore old mode 100755 new mode 100644 diff --git a/storage/framework/testing/.gitignore b/storage/framework/testing/.gitignore old mode 100755 new mode 100644 diff --git a/storage/framework/views/.gitignore b/storage/framework/views/.gitignore old mode 100755 new mode 100644 diff --git a/storage/logs/.gitignore b/storage/logs/.gitignore old mode 100755 new mode 100644 From 8dfd6cc7e1dfeb58459320c197f536b333e86251 Mon Sep 17 00:00:00 2001 From: Wheel Date: Thu, 11 Dec 2025 00:58:38 +0100 Subject: [PATCH 07/30] Unintentional --- bootstrap/cache/.gitignore | 0 logs/.gitignore | 0 2 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 bootstrap/cache/.gitignore mode change 100755 => 100644 logs/.gitignore diff --git a/bootstrap/cache/.gitignore b/bootstrap/cache/.gitignore old mode 100755 new mode 100644 diff --git a/logs/.gitignore b/logs/.gitignore old mode 100755 new mode 100644 From 6877ebe887883d94332d384b689b7eef8565683f Mon Sep 17 00:00:00 2001 From: Wheel Date: Thu, 11 Dec 2025 01:00:50 +0100 Subject: [PATCH 08/30] makes no sense hear --- resources/views/device/tabs/logs/graylog.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/device/tabs/logs/graylog.blade.php b/resources/views/device/tabs/logs/graylog.blade.php index 469742db2d14..7b52a67a27bb 100644 --- a/resources/views/device/tabs/logs/graylog.blade.php +++ b/resources/views/device/tabs/logs/graylog.blade.php @@ -28,7 +28,7 @@ -'; diff --git a/includes/html/common/graylog.inc.php b/includes/html/common/graylog.inc.php index 611daa1f9ba3..9a72c5681a22 100644 --- a/includes/html/common/graylog.inc.php +++ b/includes/html/common/graylog.inc.php @@ -50,7 +50,7 @@ '; $tmp_output .= '"
"+ '; - if ($vars['device'] && $device = Device::find($vars['device'])) { + if (! empty($vars['device']) && $device = Device::find($vars['device'])) { $tmp_output .= '"" +'; $filter_device = $device->device_id; } @@ -109,7 +109,7 @@ ""+ ""+ " 
"+ - " "+ + " "+ ""+ "

"; @@ -123,7 +123,7 @@ }, '; -if (! isset($no_form) && $no_form !== true) { +if (empty($no_form)) { $tmp_output .= ' templates: { header: searchbar diff --git a/includes/html/common/syslog.inc.php b/includes/html/common/syslog.inc.php index c8e21f9d5150..10a25b897272 100644 --- a/includes/html/common/syslog.inc.php +++ b/includes/html/common/syslog.inc.php @@ -21,8 +21,8 @@ Timestamp - Level Hostname + Level Program Message Priority diff --git a/includes/html/pages/eventlog.inc.php b/includes/html/pages/eventlog.inc.php deleted file mode 100644 index 3797d9453a15..000000000000 --- a/includes/html/pages/eventlog.inc.php +++ /dev/null @@ -1,111 +0,0 @@ - - -
-
- Eventlog -
- - -
- - diff --git a/includes/html/table/eventlog.inc.php b/includes/html/table/eventlog.inc.php deleted file mode 100644 index fc9a5bfed19a..000000000000 --- a/includes/html/table/eventlog.inc.php +++ /dev/null @@ -1,105 +0,0 @@ -hasGlobalRead()) { - $sql = " FROM `eventlog` AS E LEFT JOIN `devices` AS `D` ON `E`.`device_id`=`D`.`device_id` WHERE $where"; -} else { - $sql = " FROM `eventlog` AS E, devices_perms AS P WHERE $where AND E.device_id = P.device_id AND P.user_id = ?"; - $param[] = Auth::id(); -} - -if (isset($searchPhrase) && ! empty($searchPhrase)) { - $sql .= ' AND (`D`.`hostname` LIKE ? OR `D`.`sysName` LIKE ? OR `E`.`datetime` LIKE ? OR `E`.`message` LIKE ? OR `E`.`type` LIKE ? OR `E`.`username` LIKE ?)'; - $param[] = "%$searchPhrase%"; - $param[] = "%$searchPhrase%"; - $param[] = "%$searchPhrase%"; - $param[] = "%$searchPhrase%"; - $param[] = "%$searchPhrase%"; - $param[] = "%$searchPhrase%"; -} - -$count_sql = "SELECT COUNT(event_id) $sql"; -$total = dbFetchCell($count_sql, $param); -if (empty($total)) { - $total = 0; -} - -if (! isset($sort) || empty($sort)) { - $sort = 'datetime DESC'; -} - -$sql .= " ORDER BY $sort"; - -if (isset($current)) { - $limit_low = (($current * $rowCount) - $rowCount); - $limit_high = $rowCount; -} - -if ($rowCount != -1) { - $sql .= " LIMIT $limit_low,$limit_high"; -} - -$sql = "SELECT `E`.*,DATE_FORMAT(datetime, '" . \App\Facades\LibrenmsConfig::get('dateformat.mysql.compact') . "') as humandate,severity $sql"; - -foreach (dbFetchRows($sql, $param) as $eventlog) { - $dev = device_by_id_cache($eventlog['device_id']); - if ($eventlog['type'] == 'interface') { - $this_if = cleanPort(get_port_by_id($eventlog['reference'])); - $type = '' . generate_port_link($this_if, Rewrite::shortenIfName(strtolower((string) $this_if['label']))) . ''; - } else { - $type = $eventlog['type']; - } - $severity_colour = $eventlog['severity']; - - if ($eventlog['username'] == '') { - $eventlog['username'] = 'System'; - } - - $response[] = [ - 'datetime' => "" . $eventlog['humandate'], - 'hostname' => generate_device_link($dev, shorthost($dev['hostname'])), - 'type' => $type, - 'message' => htmlspecialchars((string) $eventlog['message']), - 'username' => $eventlog['username'], - ]; -} - -$output = [ - 'current' => $current, - 'rowCount' => $rowCount, - 'rows' => $response, - 'total' => $total, -]; -echo json_encode($output, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); diff --git a/resources/views/device/tabs/logs/eventlog.blade.php b/resources/views/device/tabs/logs/eventlog.blade.php index 85e98a6f151d..22d86e485479 100644 --- a/resources/views/device/tabs/logs/eventlog.blade.php +++ b/resources/views/device/tabs/logs/eventlog.blade.php @@ -6,13 +6,15 @@
- +
- - - - + + + + +
TimestampTypeMessageUser@lang('Timestamp')@lang('Type')@lang('Message')@lang('User')
@@ -21,40 +23,121 @@ @endsection -@section('scripts') +@push('scripts') -@endsection \ No newline at end of file +@endpush + +@push('styles') + +@endpush \ No newline at end of file diff --git a/resources/views/device/tabs/logs/syslog.blade.php b/resources/views/device/tabs/logs/syslog.blade.php index 1552e250fada..b835bcac3219 100644 --- a/resources/views/device/tabs/logs/syslog.blade.php +++ b/resources/views/device/tabs/logs/syslog.blade.php @@ -55,6 +55,8 @@ '
' + '  ' + '
' + + '' + + '  ' + '' + '
' + '  ' + diff --git a/resources/views/eventlog.blade.php b/resources/views/eventlog.blade.php new file mode 100644 index 000000000000..b6bcb64abb49 --- /dev/null +++ b/resources/views/eventlog.blade.php @@ -0,0 +1,152 @@ +@extends('layouts.librenmsv1') + +@section('title', __('Eventlog')) + +@section('content') +
+ + +

@lang('Eventlog')

+
+
+ + + + + + + + + + + +
@lang('Timestamp')@lang('Device')@lang('Type')@lang('Message')@lang('User')
+
+
+
+@endsection + +@push('scripts') + +@endpush + +@push('styles') + +@endpush \ No newline at end of file diff --git a/resources/views/layouts/menu.blade.php b/resources/views/layouts/menu.blade.php index 71c32d319d4f..eb8edbd541f4 100644 --- a/resources/views/layouts/menu.blade.php +++ b/resources/views/layouts/menu.blade.php @@ -82,7 +82,7 @@ class="tw:md:hidden tw:2xl:inline-block">{{ __('Overview') }} -
  • {{ __('Eventlog') }}
  • @config('enable_syslog')
  • name('alert.ack'); Route::resource('device-groups', DeviceGroupController::class); + Route::any('eventlog', App\Http\Controllers\EventlogController::class)->name('eventlog'); Route::any('inventory', App\Http\Controllers\InventoryController::class)->name('inventory'); Route::get('inventory/purge', [App\Http\Controllers\InventoryController::class, 'purge'])->name('inventory.purge'); Route::get('outages', [OutagesController::class, 'index'])->name('outages'); From 7fd69710a4e2b1683822b02661311ebe070d7790 Mon Sep 17 00:00:00 2001 From: Wheel Date: Fri, 12 Dec 2025 14:28:13 +0100 Subject: [PATCH 10/30] Syslog pages --- .../Device/Tabs/SyslogController.php | 32 ++- app/Http/Controllers/SyslogController.php | 65 ++++++ .../Controllers/Table/SyslogController.php | 9 +- includes/html/common/syslog.inc.php | 52 ----- includes/html/pages/syslog.inc.php | 196 ---------------- .../views/device/tabs/logs/eventlog.blade.php | 3 + .../views/device/tabs/logs/syslog.blade.php | 221 ++++++++++-------- resources/views/eventlog.blade.php | 3 + resources/views/layouts/menu.blade.php | 2 +- resources/views/syslog.blade.php | 162 +++++++++++++ routes/web.php | 1 + 11 files changed, 390 insertions(+), 356 deletions(-) create mode 100644 app/Http/Controllers/SyslogController.php delete mode 100644 includes/html/common/syslog.inc.php delete mode 100644 includes/html/pages/syslog.inc.php create mode 100644 resources/views/syslog.blade.php diff --git a/app/Http/Controllers/Device/Tabs/SyslogController.php b/app/Http/Controllers/Device/Tabs/SyslogController.php index fa2751f42e4f..998a87a8189d 100644 --- a/app/Http/Controllers/Device/Tabs/SyslogController.php +++ b/app/Http/Controllers/Device/Tabs/SyslogController.php @@ -40,19 +40,41 @@ public function __invoke(Device $device, Request $request): View $request->validate([ 'program' => 'nullable|string', 'priority' => 'nullable|string', + 'device' => 'nullable|int', 'from' => 'nullable|string', 'to' => 'nullable|string', + 'level' => 'nullable|string', ]); + $syslog_program_filter = [ + 'field' => 'program', + 'device' => $device->device_id, + ]; + $syslog_priority_filter = [ + 'field' => 'priority', + 'device' => $device->device_id, + ]; + + $format = LibrenmsConfig::get('dateformat.byminute', 'Y-m-d H:i'); + $now = Carbon::now(); + $defaultFrom = (clone $now)->subDays(7); + $fromInput = $request->input('from'); + $toInput = $request->input('to'); + + if (empty($fromInput) && empty($toInput)) { + $fromInput = $defaultFrom->format($format); + $toInput = $now->format($format); + } return view('device.tabs.logs.syslog', [ 'device' => $device, - 'filter_device' => false, - 'now' => Carbon::now()->format(LibrenmsConfig::get('dateformat.byminute', 'Y-m-d H:i')), - 'default_date' => Carbon::now()->subDay()->format(LibrenmsConfig::get('dateformat.byminute', 'Y-m-d H:i')), + 'now' => $now->format($format), + 'default_date' => $defaultFrom->format($format), 'program' => $request->input('program', ''), 'priority' => $request->input('priority', ''), - 'from' => $request->input('from', ''), - 'to' => $request->input('to', ''), + 'from' => $fromInput, + 'to' => $toInput, + 'syslog_program_filter' => $syslog_program_filter, + 'syslog_priority_filter' => $syslog_priority_filter, ]); } } diff --git a/app/Http/Controllers/SyslogController.php b/app/Http/Controllers/SyslogController.php new file mode 100644 index 000000000000..cfbdacbda702 --- /dev/null +++ b/app/Http/Controllers/SyslogController.php @@ -0,0 +1,65 @@ +validate([ + 'program' => 'nullable|string', + 'priority' => 'nullable|string', + 'device' => 'nullable|int', + 'from' => 'nullable|string', + 'to' => 'nullable|string', + 'level' => 'nullable|string', + ]); + + $device = \App\Models\Device::hasAccess($request->user()) + ->select(['device_id', 'hostname', 'ip', 'sysName', 'display']) + ->firstWhere('device_id', $request->input('device')); + + $syslog_program_filter = ['field' => 'program']; + $syslog_priority_filter = ['field' => 'priority']; + $device_selected = ''; + if ($device) { + $device_selected = ['id' => $device->device_id, 'text' => $device->displayName()]; + $syslog_program_filter['device'] = $device->device_id; + $syslog_priority_filter['device'] = $device->device_id; + } + + $format = LibrenmsConfig::get('dateformat.byminute', 'Y-m-d H:i'); + $now = Carbon::now(); + $defaultFrom = (clone $now)->subDays(1); + $fromInput = $request->input('from'); + $toInput = $request->input('to'); + + if (empty($fromInput) && empty($toInput)) { + $fromInput = $defaultFrom->format($format); + $toInput = $now->format($format); + } + + return view('syslog', [ + 'device' => $device_selected, + 'filter' => [ + 'device' => $device, + 'filter_device' => false, + 'now' => $now->format($format), + 'default_date' => $defaultFrom->format($format), + 'program' => $request->input('program', ''), + 'priority' => $request->input('priority', ''), + 'from' => $fromInput, + 'to' => $toInput, + ], + 'syslog_program_filter' => $syslog_program_filter, + 'syslog_priority_filter' => $syslog_priority_filter, + ]); + } +} \ No newline at end of file diff --git a/app/Http/Controllers/Table/SyslogController.php b/app/Http/Controllers/Table/SyslogController.php index a1134a0bbf40..f82e13c5ba49 100644 --- a/app/Http/Controllers/Table/SyslogController.php +++ b/app/Http/Controllers/Table/SyslogController.php @@ -26,7 +26,9 @@ namespace App\Http\Controllers\Table; +use App\Facades\LibrenmsConfig; use App\Models\Syslog; +use Carbon\Carbon; use Illuminate\Support\Facades\Blade; use LibreNMS\Enum\SyslogSeverity; @@ -36,7 +38,6 @@ public function rules() { return [ 'device' => 'nullable|int', - 'device_group' => 'nullable|int', 'program' => 'nullable|string', 'priority' => 'nullable|string', 'to' => 'nullable|date', @@ -47,7 +48,7 @@ public function rules() public function searchFields($request) { - return ['msg']; + return ['program', 'msg']; } public function filterFields($request) @@ -100,7 +101,9 @@ public function formatItem($syslog) { return [ 'label' => $this->setLabel($syslog), - 'timestamp' => $syslog->timestamp, + 'timestamp' => (new Carbon($syslog->timestamp)) + ->setTimezone(session('preferences.timezone')) + ->format(LibrenmsConfig::get('dateformat.compact')), 'level' => htmlentities((string) $syslog->level), 'device_id' => Blade::render('', ['device' => $syslog->device]), 'program' => htmlentities((string) $syslog->program), diff --git a/includes/html/common/syslog.inc.php b/includes/html/common/syslog.inc.php deleted file mode 100644 index 10a25b897272..000000000000 --- a/includes/html/common/syslog.inc.php +++ /dev/null @@ -1,52 +0,0 @@ - - - - - - - - - - - - - -
    TimestampHostnameLevelProgramMessagePriority
    - - -'; diff --git a/includes/html/pages/syslog.inc.php b/includes/html/pages/syslog.inc.php deleted file mode 100644 index ca7ef5c4f143..000000000000 --- a/includes/html/pages/syslog.inc.php +++ /dev/null @@ -1,196 +0,0 @@ -hasGlobalAdmin()) { - \App\Models\Syslog::truncate(); - print_message('syslog truncated'); -} - -$pagetitle[] = 'Syslog'; -?> -
    -
    - Syslog -
    - - -
    - - diff --git a/resources/views/device/tabs/logs/eventlog.blade.php b/resources/views/device/tabs/logs/eventlog.blade.php index 22d86e485479..bde44c8cfc11 100644 --- a/resources/views/device/tabs/logs/eventlog.blade.php +++ b/resources/views/device/tabs/logs/eventlog.blade.php @@ -102,6 +102,9 @@ $("#eventlog_clear").on("click", function () { $("#eventtype").val(null).trigger("change"); + $("#eventlog").find(".search-field").val(""); + eventlog_grid.bootgrid("search", ""); + const fromPicker = $("#dtpickerfrom").data("DateTimePicker"); const toPicker = $("#dtpickerto").data("DateTimePicker"); diff --git a/resources/views/device/tabs/logs/syslog.blade.php b/resources/views/device/tabs/logs/syslog.blade.php index b835bcac3219..770cc725f0f2 100644 --- a/resources/views/device/tabs/logs/syslog.blade.php +++ b/resources/views/device/tabs/logs/syslog.blade.php @@ -6,15 +6,16 @@
    - +
    - - - - - - + + + + + +
    TimestampLevelProgramMessagePriority@lang('Timestamp')@lang('Level')@lang('Program')@lang('Message')@lang('Priority')
    @@ -23,71 +24,49 @@ @endsection -@section('scripts') +@push('scripts') +@endpush + +@push('styles') + +@endpush \ No newline at end of file diff --git a/resources/views/eventlog.blade.php b/resources/views/eventlog.blade.php index b6bcb64abb49..6bcd82eb9013 100644 --- a/resources/views/eventlog.blade.php +++ b/resources/views/eventlog.blade.php @@ -111,6 +111,9 @@ $("#device").val(null).trigger("change"); $("#eventtype").val(null).trigger("change"); + $("#eventlog").find(".search-field").val(""); + eventlog_grid.bootgrid("search", ""); + const fromPicker = $("#dtpickerfrom").data("DateTimePicker"); const toPicker = $("#dtpickerto").data("DateTimePicker"); diff --git a/resources/views/layouts/menu.blade.php b/resources/views/layouts/menu.blade.php index eb8edbd541f4..7f95b9dcce08 100644 --- a/resources/views/layouts/menu.blade.php +++ b/resources/views/layouts/menu.blade.php @@ -85,7 +85,7 @@ class="tw:md:hidden tw:2xl:inline-block">{{ __('Overview') }}
  • {{ __('Eventlog') }}
  • @config('enable_syslog') -
  • {{ __('syslog.title') }}
  • @endconfig @config('graylog.server') diff --git a/resources/views/syslog.blade.php b/resources/views/syslog.blade.php new file mode 100644 index 000000000000..b21f82e7a2a3 --- /dev/null +++ b/resources/views/syslog.blade.php @@ -0,0 +1,162 @@ +@extends('layouts.librenmsv1') + +@section('title', __('Syslog')) + +@section('content') +
    + + +

    @lang('Syslog')

    +
    +
    + + + + + + + + + + + + +
    TimestampLevel@lang('Device')ProgramMessagePriority
    +
    +
    +
    +@endsection + +@push('scripts') + +@endpush +@push('styles') + +@endpush \ No newline at end of file diff --git a/routes/web.php b/routes/web.php index 28c5cd4dcb82..7c414a691582 100644 --- a/routes/web.php +++ b/routes/web.php @@ -84,6 +84,7 @@ Route::post('alert/{alert}/ack', [AlertController::class, 'ack'])->name('alert.ack'); Route::resource('device-groups', DeviceGroupController::class); Route::any('eventlog', App\Http\Controllers\EventlogController::class)->name('eventlog'); + Route::any('syslog', App\Http\Controllers\SyslogController::class)->name('syslog'); Route::any('inventory', App\Http\Controllers\InventoryController::class)->name('inventory'); Route::get('inventory/purge', [App\Http\Controllers\InventoryController::class, 'purge'])->name('inventory.purge'); Route::get('outages', [OutagesController::class, 'index'])->name('outages'); From d386854391755cfbd905ce1fa584f12888afa05c Mon Sep 17 00:00:00 2001 From: Wheel Date: Tue, 9 Dec 2025 14:00:03 +0100 Subject: [PATCH 11/30] Fix filter fields device event and syslog tabs --- .../views/device/tabs/logs/eventlog.blade.php | 29 ++++++++++++------- .../views/device/tabs/logs/syslog.blade.php | 23 ++++++++------- 2 files changed, 30 insertions(+), 22 deletions(-) diff --git a/resources/views/device/tabs/logs/eventlog.blade.php b/resources/views/device/tabs/logs/eventlog.blade.php index 7583e21c4e99..16bed6f04a89 100644 --- a/resources/views/device/tabs/logs/eventlog.blade.php +++ b/resources/views/device/tabs/logs/eventlog.blade.php @@ -18,10 +18,7 @@ - - @if(! $filter_device) - - @endif +
    @endsection @@ -65,13 +62,23 @@ '' ); - init_select2("select#device", "device", {limit: 100}, "{{ $device->device_id }}"); - init_select2("#eventtype", "eventlog", function(params) { - return { - field: "type", - device: $('#device').val(), - term: params.term, - page: params.page || 1 + $('#eventtype').select2({ + theme: 'bootstrap', + dropdownAutoWidth: true, + width: 'auto', + allowClear: true, + placeholder: 'All Types', + ajax: { + url: '{{ route('ajax.select.eventlog') }}', + delay: 200, + data: function (params) { + return { + field: 'type', + device: $('#device').val(), + term: params.term, + page: params.page || 1 + }; + } } }, @json($eventtype), 'All Types'); diff --git a/resources/views/device/tabs/logs/syslog.blade.php b/resources/views/device/tabs/logs/syslog.blade.php index 1f49a1194df2..af1c5e3793ff 100644 --- a/resources/views/device/tabs/logs/syslog.blade.php +++ b/resources/views/device/tabs/logs/syslog.blade.php @@ -20,10 +20,7 @@ - - @if(! $filter_device) - - @endif + @endsection @@ -61,18 +58,22 @@ '' + '  
    ' + '' + '
    ' + '  
    ' + '' + '
    ' + '  
    ' + From 0223a56a2ba19fff79e78a6fce8f770b5ce753f5 Mon Sep 17 00:00:00 2001 From: Wheel Date: Wed, 10 Dec 2025 12:27:13 +0100 Subject: [PATCH 12/30] Revisit the issue with keep init_select2() approach --- .../views/device/tabs/logs/eventlog.blade.php | 57 +++++--------- .../views/device/tabs/logs/syslog.blade.php | 78 +++++++++---------- 2 files changed, 55 insertions(+), 80 deletions(-) diff --git a/resources/views/device/tabs/logs/eventlog.blade.php b/resources/views/device/tabs/logs/eventlog.blade.php index 16bed6f04a89..28196691d0f9 100644 --- a/resources/views/device/tabs/logs/eventlog.blade.php +++ b/resources/views/device/tabs/logs/eventlog.blade.php @@ -39,47 +39,30 @@ $('.actionBar').append( '
    ' + - '
    ' + - - @if($filter_device) + '' + '
    ' + - '' + - '' + - '
        ' + - @endif - - '
    ' + - '' + - '
      ' + - '' + - '
    ' + + '' + + '' + + '
    ' + + '  ' + + '' + + '' + '
    ' ); - $('#eventtype').select2({ - theme: 'bootstrap', - dropdownAutoWidth: true, - width: 'auto', - allowClear: true, - placeholder: 'All Types', - ajax: { - url: '{{ route('ajax.select.eventlog') }}', - delay: 200, - data: function (params) { - return { - field: 'type', - device: $('#device').val(), - term: params.term, - page: params.page || 1 - }; - } + init_select2("#eventtype", "eventlog", function(params) { + return { + field: "type", + device: $('#device').val(), + term: params.term, + page: params.page || 1 } +<<<<<<< HEAD }, @json($eventtype), 'All Types'); +======= + }, @json($eventtype ? ['id' => $eventtype, 'text' => $eventtype] : null),'All types'); +>>>>>>> 15c13e9fa (Revisit the issue with keep init_select2() approach) -@endsection +@endsection \ No newline at end of file diff --git a/resources/views/device/tabs/logs/syslog.blade.php b/resources/views/device/tabs/logs/syslog.blade.php index af1c5e3793ff..8019eddc16f5 100644 --- a/resources/views/device/tabs/logs/syslog.blade.php +++ b/resources/views/device/tabs/logs/syslog.blade.php @@ -45,48 +45,29 @@ $('.actionBar').append( '
    ' + - '
    ' + - '
    ' + - @if($filter_device) - '' + - @endif - '
    ' + - '  
    ' + - '' + - '
    ' + - '  
    ' + - '' + - '
    ' + - '  
    ' + - '' + - '
    ' + - '
    ' + - '  ' + - '
    ' + - '  ' + - '
    ' + - '
    ' + - '' + - '' + + '
    ' + + '
    ' + + '' + + '
    ' + + '  ' + + '
    ' + + '' + + '
    ' + + '  ' + + '
    ' + + '' + + '
    ' + + '  ' + + '
    ' + + '' + + '
    ' + + '  ' + + '' + + '
    ' + '' ); @@ -132,7 +113,10 @@ $("#dtpickerto").data("DateTimePicker").maxDate('{{ $now }}'); } +<<<<<<< HEAD init_select2("select#device", "device", {limit: 100}, "{{ $device->device_id }}", 'All Devices'); +======= +>>>>>>> 15c13e9fa (Revisit the issue with keep init_select2() approach) init_select2("#program", "syslog", function(params) { return { field: "program", @@ -140,7 +124,11 @@ term: params.term, page: params.page || 1 } +<<<<<<< HEAD }, @json($program), 'All Programs'); +======= + }, @json($program ? ['id' => $program, 'text' => $program] : null),'All Programs'); +>>>>>>> 15c13e9fa (Revisit the issue with keep init_select2() approach) init_select2("#priority", "syslog", function(params) { return { field: "priority", @@ -148,6 +136,10 @@ term: params.term, page: params.page || 1 } +<<<<<<< HEAD }, @json($priority), 'All Priorities'); +======= + }, @json($priority ? ['id' => $priority, 'text' => $priority] : null),'All Priorities'); +>>>>>>> 15c13e9fa (Revisit the issue with keep init_select2() approach) -@endsection +@endsection \ No newline at end of file From 41fa73071010aac7cf80ae8b944e57b43531aacc Mon Sep 17 00:00:00 2001 From: Wheel Date: Wed, 10 Dec 2025 23:05:26 +0100 Subject: [PATCH 13/30] Match with the code from #18631 --- resources/views/device/tabs/logs/eventlog.blade.php | 4 ---- resources/views/device/tabs/logs/syslog.blade.php | 12 ------------ 2 files changed, 16 deletions(-) diff --git a/resources/views/device/tabs/logs/eventlog.blade.php b/resources/views/device/tabs/logs/eventlog.blade.php index 28196691d0f9..5ad1cf5fcdf0 100644 --- a/resources/views/device/tabs/logs/eventlog.blade.php +++ b/resources/views/device/tabs/logs/eventlog.blade.php @@ -59,10 +59,6 @@ term: params.term, page: params.page || 1 } -<<<<<<< HEAD }, @json($eventtype), 'All Types'); -======= - }, @json($eventtype ? ['id' => $eventtype, 'text' => $eventtype] : null),'All types'); ->>>>>>> 15c13e9fa (Revisit the issue with keep init_select2() approach) @endsection \ No newline at end of file diff --git a/resources/views/device/tabs/logs/syslog.blade.php b/resources/views/device/tabs/logs/syslog.blade.php index 8019eddc16f5..c26743bc3359 100644 --- a/resources/views/device/tabs/logs/syslog.blade.php +++ b/resources/views/device/tabs/logs/syslog.blade.php @@ -113,10 +113,6 @@ $("#dtpickerto").data("DateTimePicker").maxDate('{{ $now }}'); } -<<<<<<< HEAD - init_select2("select#device", "device", {limit: 100}, "{{ $device->device_id }}", 'All Devices'); -======= ->>>>>>> 15c13e9fa (Revisit the issue with keep init_select2() approach) init_select2("#program", "syslog", function(params) { return { field: "program", @@ -124,11 +120,7 @@ term: params.term, page: params.page || 1 } -<<<<<<< HEAD }, @json($program), 'All Programs'); -======= - }, @json($program ? ['id' => $program, 'text' => $program] : null),'All Programs'); ->>>>>>> 15c13e9fa (Revisit the issue with keep init_select2() approach) init_select2("#priority", "syslog", function(params) { return { field: "priority", @@ -136,10 +128,6 @@ term: params.term, page: params.page || 1 } -<<<<<<< HEAD }, @json($priority), 'All Priorities'); -======= - }, @json($priority ? ['id' => $priority, 'text' => $priority] : null),'All Priorities'); ->>>>>>> 15c13e9fa (Revisit the issue with keep init_select2() approach) @endsection \ No newline at end of file From dcef14ae133cbc3f256ec2c35b327f9b9261a658 Mon Sep 17 00:00:00 2001 From: Wheel Date: Thu, 11 Dec 2025 00:24:09 +0100 Subject: [PATCH 14/30] Consistency across all device logs blades --- .../views/device/tabs/logs/eventlog.blade.php | 5 +- .../views/device/tabs/logs/graylog.blade.php | 152 ++++++++---------- .../views/device/tabs/logs/syslog.blade.php | 7 +- 3 files changed, 72 insertions(+), 92 deletions(-) diff --git a/resources/views/device/tabs/logs/eventlog.blade.php b/resources/views/device/tabs/logs/eventlog.blade.php index 5ad1cf5fcdf0..113eba9d52a5 100644 --- a/resources/views/device/tabs/logs/eventlog.blade.php +++ b/resources/views/device/tabs/logs/eventlog.blade.php @@ -18,7 +18,6 @@ - @endsection @@ -41,9 +40,7 @@ '
    ' + '
    ' + '
    ' + - '' + '' + '
    ' + '  ' + @@ -55,7 +52,7 @@ init_select2("#eventtype", "eventlog", function(params) { return { field: "type", - device: $('#device').val(), + device: {{ $device->device_id }}, term: params.term, page: params.page || 1 } diff --git a/resources/views/device/tabs/logs/graylog.blade.php b/resources/views/device/tabs/logs/graylog.blade.php index 94aac28acb3e..469742db2d14 100644 --- a/resources/views/device/tabs/logs/graylog.blade.php +++ b/resources/views/device/tabs/logs/graylog.blade.php @@ -20,97 +20,83 @@
    - - @if(! $filter_device) - - @endif @endsection @section('scripts') - + field: "stream", + device: {{ $device->device_id }}, + term: params.term, + page: params.page || 1 + } + }, @json($stream),'All Messages'); + @endsection diff --git a/resources/views/device/tabs/logs/syslog.blade.php b/resources/views/device/tabs/logs/syslog.blade.php index c26743bc3359..c1e570ec8593 100644 --- a/resources/views/device/tabs/logs/syslog.blade.php +++ b/resources/views/device/tabs/logs/syslog.blade.php @@ -20,7 +20,6 @@ - @endsection @@ -48,13 +47,11 @@ '' + '
    ' + '' + '
    ' + '  ' + '
    ' + '' + '
    ' + '  ' + @@ -116,7 +113,7 @@ init_select2("#program", "syslog", function(params) { return { field: "program", - device: $('#device').val(), + device: {{ $device->device_id }}, term: params.term, page: params.page || 1 } @@ -124,7 +121,7 @@ init_select2("#priority", "syslog", function(params) { return { field: "priority", - device: $('#device').val(), + device: {{ $device->device_id }}, term: params.term, page: params.page || 1 } From 103bd179d0282ae3c540d484496d143a827970fa Mon Sep 17 00:00:00 2001 From: Wheel Date: Thu, 11 Dec 2025 00:52:29 +0100 Subject: [PATCH 15/30] More room for meaningfull message without device column on device specific page --- bootstrap/cache/.gitignore | 0 logs/.gitignore | 0 resources/views/device/tabs/logs/eventlog.blade.php | 1 - resources/views/device/tabs/logs/syslog.blade.php | 1 - rrd/.gitignore | 0 storage/app/.gitignore | 0 storage/app/private/.gitignore | 0 storage/app/public/.gitignore | 0 storage/debugbar/.gitignore | 0 storage/framework/cache/.gitignore | 0 storage/framework/cache/data/.gitignore | 0 storage/framework/sessions/.gitignore | 0 storage/framework/testing/.gitignore | 0 storage/framework/views/.gitignore | 0 storage/logs/.gitignore | 0 15 files changed, 2 deletions(-) mode change 100644 => 100755 bootstrap/cache/.gitignore mode change 100644 => 100755 logs/.gitignore mode change 100644 => 100755 rrd/.gitignore mode change 100644 => 100755 storage/app/.gitignore mode change 100644 => 100755 storage/app/private/.gitignore mode change 100644 => 100755 storage/app/public/.gitignore mode change 100644 => 100755 storage/debugbar/.gitignore mode change 100644 => 100755 storage/framework/cache/.gitignore mode change 100644 => 100755 storage/framework/cache/data/.gitignore mode change 100644 => 100755 storage/framework/sessions/.gitignore mode change 100644 => 100755 storage/framework/testing/.gitignore mode change 100644 => 100755 storage/framework/views/.gitignore mode change 100644 => 100755 storage/logs/.gitignore diff --git a/bootstrap/cache/.gitignore b/bootstrap/cache/.gitignore old mode 100644 new mode 100755 diff --git a/logs/.gitignore b/logs/.gitignore old mode 100644 new mode 100755 diff --git a/resources/views/device/tabs/logs/eventlog.blade.php b/resources/views/device/tabs/logs/eventlog.blade.php index 113eba9d52a5..0bb4f46dd2f7 100644 --- a/resources/views/device/tabs/logs/eventlog.blade.php +++ b/resources/views/device/tabs/logs/eventlog.blade.php @@ -11,7 +11,6 @@ Timestamp Type - Hostname Message User diff --git a/resources/views/device/tabs/logs/syslog.blade.php b/resources/views/device/tabs/logs/syslog.blade.php index c1e570ec8593..13166ce66a8d 100644 --- a/resources/views/device/tabs/logs/syslog.blade.php +++ b/resources/views/device/tabs/logs/syslog.blade.php @@ -12,7 +12,6 @@ Timestamp Level - Hostname Program Message Priority diff --git a/rrd/.gitignore b/rrd/.gitignore old mode 100644 new mode 100755 diff --git a/storage/app/.gitignore b/storage/app/.gitignore old mode 100644 new mode 100755 diff --git a/storage/app/private/.gitignore b/storage/app/private/.gitignore old mode 100644 new mode 100755 diff --git a/storage/app/public/.gitignore b/storage/app/public/.gitignore old mode 100644 new mode 100755 diff --git a/storage/debugbar/.gitignore b/storage/debugbar/.gitignore old mode 100644 new mode 100755 diff --git a/storage/framework/cache/.gitignore b/storage/framework/cache/.gitignore old mode 100644 new mode 100755 diff --git a/storage/framework/cache/data/.gitignore b/storage/framework/cache/data/.gitignore old mode 100644 new mode 100755 diff --git a/storage/framework/sessions/.gitignore b/storage/framework/sessions/.gitignore old mode 100644 new mode 100755 diff --git a/storage/framework/testing/.gitignore b/storage/framework/testing/.gitignore old mode 100644 new mode 100755 diff --git a/storage/framework/views/.gitignore b/storage/framework/views/.gitignore old mode 100644 new mode 100755 diff --git a/storage/logs/.gitignore b/storage/logs/.gitignore old mode 100644 new mode 100755 From a5b3bbc3723c2bc32965e681b597127581b7765b Mon Sep 17 00:00:00 2001 From: Wheel Date: Thu, 11 Dec 2025 00:57:36 +0100 Subject: [PATCH 16/30] Unintentional --- rrd/.gitignore | 0 storage/app/.gitignore | 0 storage/app/private/.gitignore | 0 storage/app/public/.gitignore | 0 storage/debugbar/.gitignore | 0 storage/framework/cache/.gitignore | 0 storage/framework/cache/data/.gitignore | 0 storage/framework/sessions/.gitignore | 0 storage/framework/testing/.gitignore | 0 storage/framework/views/.gitignore | 0 storage/logs/.gitignore | 0 11 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 rrd/.gitignore mode change 100755 => 100644 storage/app/.gitignore mode change 100755 => 100644 storage/app/private/.gitignore mode change 100755 => 100644 storage/app/public/.gitignore mode change 100755 => 100644 storage/debugbar/.gitignore mode change 100755 => 100644 storage/framework/cache/.gitignore mode change 100755 => 100644 storage/framework/cache/data/.gitignore mode change 100755 => 100644 storage/framework/sessions/.gitignore mode change 100755 => 100644 storage/framework/testing/.gitignore mode change 100755 => 100644 storage/framework/views/.gitignore mode change 100755 => 100644 storage/logs/.gitignore diff --git a/rrd/.gitignore b/rrd/.gitignore old mode 100755 new mode 100644 diff --git a/storage/app/.gitignore b/storage/app/.gitignore old mode 100755 new mode 100644 diff --git a/storage/app/private/.gitignore b/storage/app/private/.gitignore old mode 100755 new mode 100644 diff --git a/storage/app/public/.gitignore b/storage/app/public/.gitignore old mode 100755 new mode 100644 diff --git a/storage/debugbar/.gitignore b/storage/debugbar/.gitignore old mode 100755 new mode 100644 diff --git a/storage/framework/cache/.gitignore b/storage/framework/cache/.gitignore old mode 100755 new mode 100644 diff --git a/storage/framework/cache/data/.gitignore b/storage/framework/cache/data/.gitignore old mode 100755 new mode 100644 diff --git a/storage/framework/sessions/.gitignore b/storage/framework/sessions/.gitignore old mode 100755 new mode 100644 diff --git a/storage/framework/testing/.gitignore b/storage/framework/testing/.gitignore old mode 100755 new mode 100644 diff --git a/storage/framework/views/.gitignore b/storage/framework/views/.gitignore old mode 100755 new mode 100644 diff --git a/storage/logs/.gitignore b/storage/logs/.gitignore old mode 100755 new mode 100644 From f171b41e27e548c8f8df2b042dc642cf3e2e0570 Mon Sep 17 00:00:00 2001 From: Wheel Date: Thu, 11 Dec 2025 00:58:38 +0100 Subject: [PATCH 17/30] Unintentional --- bootstrap/cache/.gitignore | 0 logs/.gitignore | 0 2 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 bootstrap/cache/.gitignore mode change 100755 => 100644 logs/.gitignore diff --git a/bootstrap/cache/.gitignore b/bootstrap/cache/.gitignore old mode 100755 new mode 100644 diff --git a/logs/.gitignore b/logs/.gitignore old mode 100755 new mode 100644 From 67543c5f67f9b34ffb5f9c24d53d570622fc1659 Mon Sep 17 00:00:00 2001 From: Wheel Date: Thu, 11 Dec 2025 01:00:50 +0100 Subject: [PATCH 18/30] makes no sense hear --- resources/views/device/tabs/logs/graylog.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/device/tabs/logs/graylog.blade.php b/resources/views/device/tabs/logs/graylog.blade.php index 469742db2d14..7b52a67a27bb 100644 --- a/resources/views/device/tabs/logs/graylog.blade.php +++ b/resources/views/device/tabs/logs/graylog.blade.php @@ -28,7 +28,7 @@ -'; diff --git a/includes/html/common/graylog.inc.php b/includes/html/common/graylog.inc.php index 611daa1f9ba3..9a72c5681a22 100644 --- a/includes/html/common/graylog.inc.php +++ b/includes/html/common/graylog.inc.php @@ -50,7 +50,7 @@ '; $tmp_output .= '"
    "+ '; - if ($vars['device'] && $device = Device::find($vars['device'])) { + if (! empty($vars['device']) && $device = Device::find($vars['device'])) { $tmp_output .= '"" +'; $filter_device = $device->device_id; } @@ -109,7 +109,7 @@ ""+ ""+ " 
    "+ - " "+ + " "+ ""+ "

    "; @@ -123,7 +123,7 @@ }, '; -if (! isset($no_form) && $no_form !== true) { +if (empty($no_form)) { $tmp_output .= ' templates: { header: searchbar diff --git a/includes/html/common/syslog.inc.php b/includes/html/common/syslog.inc.php index c8e21f9d5150..10a25b897272 100644 --- a/includes/html/common/syslog.inc.php +++ b/includes/html/common/syslog.inc.php @@ -21,8 +21,8 @@ Timestamp - Level Hostname + Level Program Message Priority diff --git a/includes/html/pages/eventlog.inc.php b/includes/html/pages/eventlog.inc.php deleted file mode 100644 index 3797d9453a15..000000000000 --- a/includes/html/pages/eventlog.inc.php +++ /dev/null @@ -1,111 +0,0 @@ - - -
    -
    - Eventlog -
    - - -
    - - diff --git a/includes/html/table/eventlog.inc.php b/includes/html/table/eventlog.inc.php deleted file mode 100644 index fc9a5bfed19a..000000000000 --- a/includes/html/table/eventlog.inc.php +++ /dev/null @@ -1,105 +0,0 @@ -hasGlobalRead()) { - $sql = " FROM `eventlog` AS E LEFT JOIN `devices` AS `D` ON `E`.`device_id`=`D`.`device_id` WHERE $where"; -} else { - $sql = " FROM `eventlog` AS E, devices_perms AS P WHERE $where AND E.device_id = P.device_id AND P.user_id = ?"; - $param[] = Auth::id(); -} - -if (isset($searchPhrase) && ! empty($searchPhrase)) { - $sql .= ' AND (`D`.`hostname` LIKE ? OR `D`.`sysName` LIKE ? OR `E`.`datetime` LIKE ? OR `E`.`message` LIKE ? OR `E`.`type` LIKE ? OR `E`.`username` LIKE ?)'; - $param[] = "%$searchPhrase%"; - $param[] = "%$searchPhrase%"; - $param[] = "%$searchPhrase%"; - $param[] = "%$searchPhrase%"; - $param[] = "%$searchPhrase%"; - $param[] = "%$searchPhrase%"; -} - -$count_sql = "SELECT COUNT(event_id) $sql"; -$total = dbFetchCell($count_sql, $param); -if (empty($total)) { - $total = 0; -} - -if (! isset($sort) || empty($sort)) { - $sort = 'datetime DESC'; -} - -$sql .= " ORDER BY $sort"; - -if (isset($current)) { - $limit_low = (($current * $rowCount) - $rowCount); - $limit_high = $rowCount; -} - -if ($rowCount != -1) { - $sql .= " LIMIT $limit_low,$limit_high"; -} - -$sql = "SELECT `E`.*,DATE_FORMAT(datetime, '" . \App\Facades\LibrenmsConfig::get('dateformat.mysql.compact') . "') as humandate,severity $sql"; - -foreach (dbFetchRows($sql, $param) as $eventlog) { - $dev = device_by_id_cache($eventlog['device_id']); - if ($eventlog['type'] == 'interface') { - $this_if = cleanPort(get_port_by_id($eventlog['reference'])); - $type = '' . generate_port_link($this_if, Rewrite::shortenIfName(strtolower((string) $this_if['label']))) . ''; - } else { - $type = $eventlog['type']; - } - $severity_colour = $eventlog['severity']; - - if ($eventlog['username'] == '') { - $eventlog['username'] = 'System'; - } - - $response[] = [ - 'datetime' => "" . $eventlog['humandate'], - 'hostname' => generate_device_link($dev, shorthost($dev['hostname'])), - 'type' => $type, - 'message' => htmlspecialchars((string) $eventlog['message']), - 'username' => $eventlog['username'], - ]; -} - -$output = [ - 'current' => $current, - 'rowCount' => $rowCount, - 'rows' => $response, - 'total' => $total, -]; -echo json_encode($output, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); diff --git a/resources/views/device/tabs/logs/eventlog.blade.php b/resources/views/device/tabs/logs/eventlog.blade.php index 0bb4f46dd2f7..22d86e485479 100644 --- a/resources/views/device/tabs/logs/eventlog.blade.php +++ b/resources/views/device/tabs/logs/eventlog.blade.php @@ -6,13 +6,15 @@
    - +
    - - - - + + + + +
    TimestampTypeMessageUser@lang('Timestamp')@lang('Type')@lang('Message')@lang('User')
    @@ -21,40 +23,121 @@ @endsection -@section('scripts') +@push('scripts') -@endsection \ No newline at end of file +@endpush + +@push('styles') + +@endpush \ No newline at end of file diff --git a/resources/views/device/tabs/logs/syslog.blade.php b/resources/views/device/tabs/logs/syslog.blade.php index 13166ce66a8d..1bc517785684 100644 --- a/resources/views/device/tabs/logs/syslog.blade.php +++ b/resources/views/device/tabs/logs/syslog.blade.php @@ -55,6 +55,8 @@ '
    ' + '  ' + '
    ' + + '' + + '  ' + '' + '
    ' + '  ' + diff --git a/resources/views/eventlog.blade.php b/resources/views/eventlog.blade.php new file mode 100644 index 000000000000..b6bcb64abb49 --- /dev/null +++ b/resources/views/eventlog.blade.php @@ -0,0 +1,152 @@ +@extends('layouts.librenmsv1') + +@section('title', __('Eventlog')) + +@section('content') +
    + + +

    @lang('Eventlog')

    +
    +
    + + + + + + + + + + + +
    @lang('Timestamp')@lang('Device')@lang('Type')@lang('Message')@lang('User')
    +
    +
    +
    +@endsection + +@push('scripts') + +@endpush + +@push('styles') + +@endpush \ No newline at end of file diff --git a/resources/views/layouts/menu.blade.php b/resources/views/layouts/menu.blade.php index 71c32d319d4f..eb8edbd541f4 100644 --- a/resources/views/layouts/menu.blade.php +++ b/resources/views/layouts/menu.blade.php @@ -82,7 +82,7 @@ class="tw:md:hidden tw:2xl:inline-block">{{ __('Overview') }} -
  • {{ __('Eventlog') }}
  • @config('enable_syslog')
  • name('alert.ack'); Route::resource('device-groups', DeviceGroupController::class); + Route::any('eventlog', App\Http\Controllers\EventlogController::class)->name('eventlog'); Route::any('inventory', App\Http\Controllers\InventoryController::class)->name('inventory'); Route::get('inventory/purge', [App\Http\Controllers\InventoryController::class, 'purge'])->name('inventory.purge'); Route::get('outages', [OutagesController::class, 'index'])->name('outages'); From dda87536e591c970096bc2ed2b21286166e8b6ac Mon Sep 17 00:00:00 2001 From: Wheel Date: Fri, 12 Dec 2025 14:28:13 +0100 Subject: [PATCH 20/30] Syslog pages --- .../Device/Tabs/SyslogController.php | 32 ++- app/Http/Controllers/SyslogController.php | 65 ++++++ .../Controllers/Table/SyslogController.php | 9 +- includes/html/common/syslog.inc.php | 52 ----- includes/html/pages/syslog.inc.php | 196 ---------------- .../views/device/tabs/logs/eventlog.blade.php | 3 + .../views/device/tabs/logs/syslog.blade.php | 210 +++++++++++------- resources/views/eventlog.blade.php | 3 + resources/views/layouts/menu.blade.php | 2 +- resources/views/syslog.blade.php | 162 ++++++++++++++ routes/web.php | 1 + 11 files changed, 394 insertions(+), 341 deletions(-) create mode 100644 app/Http/Controllers/SyslogController.php delete mode 100644 includes/html/common/syslog.inc.php delete mode 100644 includes/html/pages/syslog.inc.php create mode 100644 resources/views/syslog.blade.php diff --git a/app/Http/Controllers/Device/Tabs/SyslogController.php b/app/Http/Controllers/Device/Tabs/SyslogController.php index fa2751f42e4f..998a87a8189d 100644 --- a/app/Http/Controllers/Device/Tabs/SyslogController.php +++ b/app/Http/Controllers/Device/Tabs/SyslogController.php @@ -40,19 +40,41 @@ public function __invoke(Device $device, Request $request): View $request->validate([ 'program' => 'nullable|string', 'priority' => 'nullable|string', + 'device' => 'nullable|int', 'from' => 'nullable|string', 'to' => 'nullable|string', + 'level' => 'nullable|string', ]); + $syslog_program_filter = [ + 'field' => 'program', + 'device' => $device->device_id, + ]; + $syslog_priority_filter = [ + 'field' => 'priority', + 'device' => $device->device_id, + ]; + + $format = LibrenmsConfig::get('dateformat.byminute', 'Y-m-d H:i'); + $now = Carbon::now(); + $defaultFrom = (clone $now)->subDays(7); + $fromInput = $request->input('from'); + $toInput = $request->input('to'); + + if (empty($fromInput) && empty($toInput)) { + $fromInput = $defaultFrom->format($format); + $toInput = $now->format($format); + } return view('device.tabs.logs.syslog', [ 'device' => $device, - 'filter_device' => false, - 'now' => Carbon::now()->format(LibrenmsConfig::get('dateformat.byminute', 'Y-m-d H:i')), - 'default_date' => Carbon::now()->subDay()->format(LibrenmsConfig::get('dateformat.byminute', 'Y-m-d H:i')), + 'now' => $now->format($format), + 'default_date' => $defaultFrom->format($format), 'program' => $request->input('program', ''), 'priority' => $request->input('priority', ''), - 'from' => $request->input('from', ''), - 'to' => $request->input('to', ''), + 'from' => $fromInput, + 'to' => $toInput, + 'syslog_program_filter' => $syslog_program_filter, + 'syslog_priority_filter' => $syslog_priority_filter, ]); } } diff --git a/app/Http/Controllers/SyslogController.php b/app/Http/Controllers/SyslogController.php new file mode 100644 index 000000000000..cfbdacbda702 --- /dev/null +++ b/app/Http/Controllers/SyslogController.php @@ -0,0 +1,65 @@ +validate([ + 'program' => 'nullable|string', + 'priority' => 'nullable|string', + 'device' => 'nullable|int', + 'from' => 'nullable|string', + 'to' => 'nullable|string', + 'level' => 'nullable|string', + ]); + + $device = \App\Models\Device::hasAccess($request->user()) + ->select(['device_id', 'hostname', 'ip', 'sysName', 'display']) + ->firstWhere('device_id', $request->input('device')); + + $syslog_program_filter = ['field' => 'program']; + $syslog_priority_filter = ['field' => 'priority']; + $device_selected = ''; + if ($device) { + $device_selected = ['id' => $device->device_id, 'text' => $device->displayName()]; + $syslog_program_filter['device'] = $device->device_id; + $syslog_priority_filter['device'] = $device->device_id; + } + + $format = LibrenmsConfig::get('dateformat.byminute', 'Y-m-d H:i'); + $now = Carbon::now(); + $defaultFrom = (clone $now)->subDays(1); + $fromInput = $request->input('from'); + $toInput = $request->input('to'); + + if (empty($fromInput) && empty($toInput)) { + $fromInput = $defaultFrom->format($format); + $toInput = $now->format($format); + } + + return view('syslog', [ + 'device' => $device_selected, + 'filter' => [ + 'device' => $device, + 'filter_device' => false, + 'now' => $now->format($format), + 'default_date' => $defaultFrom->format($format), + 'program' => $request->input('program', ''), + 'priority' => $request->input('priority', ''), + 'from' => $fromInput, + 'to' => $toInput, + ], + 'syslog_program_filter' => $syslog_program_filter, + 'syslog_priority_filter' => $syslog_priority_filter, + ]); + } +} \ No newline at end of file diff --git a/app/Http/Controllers/Table/SyslogController.php b/app/Http/Controllers/Table/SyslogController.php index a1134a0bbf40..f82e13c5ba49 100644 --- a/app/Http/Controllers/Table/SyslogController.php +++ b/app/Http/Controllers/Table/SyslogController.php @@ -26,7 +26,9 @@ namespace App\Http\Controllers\Table; +use App\Facades\LibrenmsConfig; use App\Models\Syslog; +use Carbon\Carbon; use Illuminate\Support\Facades\Blade; use LibreNMS\Enum\SyslogSeverity; @@ -36,7 +38,6 @@ public function rules() { return [ 'device' => 'nullable|int', - 'device_group' => 'nullable|int', 'program' => 'nullable|string', 'priority' => 'nullable|string', 'to' => 'nullable|date', @@ -47,7 +48,7 @@ public function rules() public function searchFields($request) { - return ['msg']; + return ['program', 'msg']; } public function filterFields($request) @@ -100,7 +101,9 @@ public function formatItem($syslog) { return [ 'label' => $this->setLabel($syslog), - 'timestamp' => $syslog->timestamp, + 'timestamp' => (new Carbon($syslog->timestamp)) + ->setTimezone(session('preferences.timezone')) + ->format(LibrenmsConfig::get('dateformat.compact')), 'level' => htmlentities((string) $syslog->level), 'device_id' => Blade::render('', ['device' => $syslog->device]), 'program' => htmlentities((string) $syslog->program), diff --git a/includes/html/common/syslog.inc.php b/includes/html/common/syslog.inc.php deleted file mode 100644 index 10a25b897272..000000000000 --- a/includes/html/common/syslog.inc.php +++ /dev/null @@ -1,52 +0,0 @@ - - - - - - - - - - - - - -
    TimestampHostnameLevelProgramMessagePriority
    - - -'; diff --git a/includes/html/pages/syslog.inc.php b/includes/html/pages/syslog.inc.php deleted file mode 100644 index ca7ef5c4f143..000000000000 --- a/includes/html/pages/syslog.inc.php +++ /dev/null @@ -1,196 +0,0 @@ -hasGlobalAdmin()) { - \App\Models\Syslog::truncate(); - print_message('syslog truncated'); -} - -$pagetitle[] = 'Syslog'; -?> -
    -
    - Syslog -
    - - -
    - - diff --git a/resources/views/device/tabs/logs/eventlog.blade.php b/resources/views/device/tabs/logs/eventlog.blade.php index 22d86e485479..bde44c8cfc11 100644 --- a/resources/views/device/tabs/logs/eventlog.blade.php +++ b/resources/views/device/tabs/logs/eventlog.blade.php @@ -102,6 +102,9 @@ $("#eventlog_clear").on("click", function () { $("#eventtype").val(null).trigger("change"); + $("#eventlog").find(".search-field").val(""); + eventlog_grid.bootgrid("search", ""); + const fromPicker = $("#dtpickerfrom").data("DateTimePicker"); const toPicker = $("#dtpickerto").data("DateTimePicker"); diff --git a/resources/views/device/tabs/logs/syslog.blade.php b/resources/views/device/tabs/logs/syslog.blade.php index 1bc517785684..5820bb15935e 100644 --- a/resources/views/device/tabs/logs/syslog.blade.php +++ b/resources/views/device/tabs/logs/syslog.blade.php @@ -6,15 +6,16 @@
    - +
    - - - - - - + + + + + +
    TimestampLevelProgramMessagePriority@lang('Timestamp')@lang('Level')@lang('Program')@lang('Message')@lang('Priority')
    @@ -23,54 +24,49 @@ @endsection -@section('scripts') +@push('scripts') -@endsection \ No newline at end of file +@endpush + +@push('styles') + +@endpush \ No newline at end of file diff --git a/resources/views/eventlog.blade.php b/resources/views/eventlog.blade.php index b6bcb64abb49..6bcd82eb9013 100644 --- a/resources/views/eventlog.blade.php +++ b/resources/views/eventlog.blade.php @@ -111,6 +111,9 @@ $("#device").val(null).trigger("change"); $("#eventtype").val(null).trigger("change"); + $("#eventlog").find(".search-field").val(""); + eventlog_grid.bootgrid("search", ""); + const fromPicker = $("#dtpickerfrom").data("DateTimePicker"); const toPicker = $("#dtpickerto").data("DateTimePicker"); diff --git a/resources/views/layouts/menu.blade.php b/resources/views/layouts/menu.blade.php index eb8edbd541f4..7f95b9dcce08 100644 --- a/resources/views/layouts/menu.blade.php +++ b/resources/views/layouts/menu.blade.php @@ -85,7 +85,7 @@ class="tw:md:hidden tw:2xl:inline-block">{{ __('Overview') }}
  • {{ __('Eventlog') }}
  • @config('enable_syslog') -
  • {{ __('syslog.title') }}
  • @endconfig @config('graylog.server') diff --git a/resources/views/syslog.blade.php b/resources/views/syslog.blade.php new file mode 100644 index 000000000000..b21f82e7a2a3 --- /dev/null +++ b/resources/views/syslog.blade.php @@ -0,0 +1,162 @@ +@extends('layouts.librenmsv1') + +@section('title', __('Syslog')) + +@section('content') +
    + + +

    @lang('Syslog')

    +
    +
    + + + + + + + + + + + + +
    TimestampLevel@lang('Device')ProgramMessagePriority
    +
    +
    +
    +@endsection + +@push('scripts') + +@endpush +@push('styles') + +@endpush \ No newline at end of file diff --git a/routes/web.php b/routes/web.php index 28c5cd4dcb82..7c414a691582 100644 --- a/routes/web.php +++ b/routes/web.php @@ -84,6 +84,7 @@ Route::post('alert/{alert}/ack', [AlertController::class, 'ack'])->name('alert.ack'); Route::resource('device-groups', DeviceGroupController::class); Route::any('eventlog', App\Http\Controllers\EventlogController::class)->name('eventlog'); + Route::any('syslog', App\Http\Controllers\SyslogController::class)->name('syslog'); Route::any('inventory', App\Http\Controllers\InventoryController::class)->name('inventory'); Route::get('inventory/purge', [App\Http\Controllers\InventoryController::class, 'purge'])->name('inventory.purge'); Route::get('outages', [OutagesController::class, 'index'])->name('outages'); From 53b4ee9e1412cf1588cf09861940581f7c041595 Mon Sep 17 00:00:00 2001 From: Wheel Date: Sun, 14 Dec 2025 16:04:31 +0100 Subject: [PATCH 21/30] Graylog blades --- .../Device/Tabs/GraylogController.php | 5 + .../views/device/tabs/logs/graylog.blade.php | 165 ++++++++++-------- .../views/device/tabs/logs/syslog.blade.php | 2 +- resources/views/syslog.blade.php | 2 +- 4 files changed, 99 insertions(+), 75 deletions(-) diff --git a/app/Http/Controllers/Device/Tabs/GraylogController.php b/app/Http/Controllers/Device/Tabs/GraylogController.php index 3a79d3556c50..f9ef49a5cd05 100644 --- a/app/Http/Controllers/Device/Tabs/GraylogController.php +++ b/app/Http/Controllers/Device/Tabs/GraylogController.php @@ -41,6 +41,10 @@ public function __invoke(Device $device, Request $request): View 'range' => 'nullable|int', 'loglevel' => 'nullable|int', ]); + $graylog_filter = [ + 'field' => 'stream', + 'device' => $device->device_id, + ]; return view('device.tabs.logs.graylog', [ 'device' => $device, @@ -50,6 +54,7 @@ public function __invoke(Device $device, Request $request): View 'stream' => $request->input('stream', ''), 'range' => $request->input('range', '0'), 'loglevel' => $request->input('loglevel', ''), + 'graylog_filter' => $graylog_filter, ]); } } diff --git a/resources/views/device/tabs/logs/graylog.blade.php b/resources/views/device/tabs/logs/graylog.blade.php index 7b52a67a27bb..c67cbf386705 100644 --- a/resources/views/device/tabs/logs/graylog.blade.php +++ b/resources/views/device/tabs/logs/graylog.blade.php @@ -6,7 +6,8 @@
    - +
    @@ -24,79 +25,97 @@ @endsection -@section('scripts') +@push('scripts') -@endsection +@endpush + +@push('styles') + +@endpush \ No newline at end of file diff --git a/resources/views/device/tabs/logs/syslog.blade.php b/resources/views/device/tabs/logs/syslog.blade.php index 5820bb15935e..3f29a185bd79 100644 --- a/resources/views/device/tabs/logs/syslog.blade.php +++ b/resources/views/device/tabs/logs/syslog.blade.php @@ -27,7 +27,7 @@ @push('scripts') -@endsection ->>>>>>> 7fd69710a4e2b1683822b02661311ebe070d7790 diff --git a/resources/views/device/tabs/logs/syslog.blade.php b/resources/views/device/tabs/logs/syslog.blade.php index 9ff7f6a313bd..c04645ad01a8 100644 --- a/resources/views/device/tabs/logs/syslog.blade.php +++ b/resources/views/device/tabs/logs/syslog.blade.php @@ -27,11 +27,7 @@ @push('scripts') @endpush From fef79af053c4be3c31bcfb7a2f68728e5499095e Mon Sep 17 00:00:00 2001 From: Wheel Date: Sun, 14 Dec 2025 21:54:04 +0100 Subject: [PATCH 24/30] Device tab graylog --- .../Controllers/Table/GraylogController.php | 5 +- includes/html/common/graylog.inc.php | 153 ------------------ includes/html/pages/graylog.inc.php | 29 ---- .../views/device/tabs/logs/graylog.blade.php | 37 +++-- 4 files changed, 26 insertions(+), 198 deletions(-) delete mode 100644 includes/html/common/graylog.inc.php delete mode 100644 includes/html/pages/graylog.inc.php diff --git a/app/Http/Controllers/Table/GraylogController.php b/app/Http/Controllers/Table/GraylogController.php index aca7007910f0..bcef7acfae2f 100644 --- a/app/Http/Controllers/Table/GraylogController.php +++ b/app/Http/Controllers/Table/GraylogController.php @@ -28,6 +28,7 @@ use App\ApiClients\GraylogApi; use App\Facades\LibrenmsConfig; +use Carbon\Carbon; use App\Models\Device; use DateInterval; use DateTime; @@ -110,7 +111,9 @@ private function formatMessage($message) $graylogTime->add($timeInterval); $displayTime = $graylogTime->format('Y-m-d H:i:s'); } else { - $displayTime = $message['message']['timestamp']; + $displayTime = Carbon::parse($message['message']['timestamp']) + ->setTimezone(session('preferences.timezone')) + ->format(LibrenmsConfig::get('dateformat.compact')); } $level = $message['message']['level'] ?? ''; diff --git a/includes/html/common/graylog.inc.php b/includes/html/common/graylog.inc.php deleted file mode 100644 index 9a72c5681a22..000000000000 --- a/includes/html/common/graylog.inc.php +++ /dev/null @@ -1,153 +0,0 @@ - - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation, either version 3 of the License, or (at your - * option) any later version. Please see LICENSE.txt at the top level of - * the source code distribution for details. - * - * @package LibreNMS - * @subpackage webui - * @link https://www.librenms.org - * @copyright 2017 LibreNMS - * @author LibreNMS Contributors -*/ - -use App\Models\Device; - -if (empty($results_limit)) { - $results_limit = 25; -} -$tmp_output = ' - -
    -
    - - - - - - - - - - - -
    OriginTimestampLevelSourceMessageFacility
    -
    - - - -'; - -$common_output[] = $tmp_output; diff --git a/includes/html/pages/graylog.inc.php b/includes/html/pages/graylog.inc.php deleted file mode 100644 index 7eac9ef9d889..000000000000 --- a/includes/html/pages/graylog.inc.php +++ /dev/null @@ -1,29 +0,0 @@ - -
    - Graylog entries -
    '; - -require_once 'includes/html/common/graylog.inc.php'; -echo implode('', $common_output); - -echo ''; diff --git a/resources/views/device/tabs/logs/graylog.blade.php b/resources/views/device/tabs/logs/graylog.blade.php index d98dca2aa3f7..a563d17982fd 100644 --- a/resources/views/device/tabs/logs/graylog.blade.php +++ b/resources/views/device/tabs/logs/graylog.blade.php @@ -10,13 +10,12 @@ data-url="{{ route('table.graylog') }}" data-export="false"> - - Origin - Timestamp - Level - Source - Message - Facility + + @lang('Timestamp') + @lang('Source') + @lang('Level') + @lang('Message') + @lang('Facility') @@ -35,18 +34,19 @@ header: '
    ' + '
    ' + '
    ' + - '' + + '' + '
    ' + '
    ' + - '' + '' + '' + '' + '' + '' + '' + - '' + + '' + '' + '' + '
    ' + @@ -79,17 +79,24 @@ post: function () { return { device: {{ $device->device_id }}, - stream: $('#stream').val() || '', + stream: $('#graylog-streams').val() || '', + source: $('#graylog-source').val() || '', range: $('#range').val() || '', loglevel: $('#loglevel').val() || '', }; }, }); $("#graylog").on("loaded.rs.jquery.bootgrid", function () { - init_select2("#stream", "graylog", @json($graylog_filter), @json($stream),'All Messages'); + init_select2("#graylog-streams", "graylog-streams", @json($graylog_filter), @json($stream),'All Streams'); + $('[data-toggle="tooltip"]').tooltip(); + $("#graylog_filter").on("submit", function (e) { + e.preventDefault(); + graylog_grid.bootgrid("reload", true); + }); + $("#graylog_clear").on("click", function () { - $("#stream").val(null).trigger("change"); - $("#loglevel").val(null).trigger("change"); + $("#graylog-streams").val(null).trigger("change"); + $("#loglevel").val('6').trigger("change"); $("#range").val('0').trigger("change"); $("#graylog").find(".search-field").val(""); From 852e12c4952659d1516f1513c4eaf1123af00196 Mon Sep 17 00:00:00 2001 From: Wheel Date: Sun, 14 Dec 2025 23:53:04 +0100 Subject: [PATCH 25/30] Global graylog page --- app/Http/Controllers/GraylogController.php | 60 ++++++++ .../Controllers/Table/GraylogController.php | 2 +- .../views/device/tabs/logs/graylog.blade.php | 2 +- resources/views/graylog.blade.php | 138 ++++++++++++++++++ resources/views/layouts/menu.blade.php | 2 +- resources/views/syslog.blade.php | 6 +- routes/web.php | 1 + 7 files changed, 205 insertions(+), 6 deletions(-) create mode 100644 app/Http/Controllers/GraylogController.php create mode 100644 resources/views/graylog.blade.php diff --git a/app/Http/Controllers/GraylogController.php b/app/Http/Controllers/GraylogController.php new file mode 100644 index 000000000000..09f84f8e0bfa --- /dev/null +++ b/app/Http/Controllers/GraylogController.php @@ -0,0 +1,60 @@ +validate([ + 'stream' => 'nullable|string', + 'range' => 'nullable|int', + 'loglevel' => 'nullable|int', + ]); + + $device = \App\Models\Device::hasAccess($request->user()) + ->select(['device_id', 'hostname', 'ip', 'sysName', 'display']) + ->firstWhere('device_id', $request->input('device')); + + $graylog_filter = [ + 'field' => 'stream', + ]; + + $device_selected = ''; + if ($device) { + $device_selected = ['id' => $device->device_id, 'text' => $device->displayName()]; + $graylog_filter['device'] = $device->device_id; + } + + $format = LibrenmsConfig::get('dateformat.byminute', 'Y-m-d H:i'); + $now = Carbon::now(); + $defaultFrom = (clone $now)->subDays(1); + $fromInput = $request->input('from'); + $toInput = $request->input('to'); + + if (empty($fromInput) && empty($toInput)) { + $fromInput = $defaultFrom->format($format); + $toInput = $now->format($format); + } + + return view('graylog', [ + 'device' => $device_selected, + 'filter' => [ + 'timezone' => LibrenmsConfig::has('graylog.timezone'), + 'filter_device' => true, + 'show_form' => true, + 'stream' => $request->input('stream', ''), + 'range' => $request->input('range', '0'), + 'loglevel' => $request->input('loglevel', ''), + ], + 'graylog_filter' => $graylog_filter, + ]); + } +} \ No newline at end of file diff --git a/app/Http/Controllers/Table/GraylogController.php b/app/Http/Controllers/Table/GraylogController.php index bcef7acfae2f..219ade4f3968 100644 --- a/app/Http/Controllers/Table/GraylogController.php +++ b/app/Http/Controllers/Table/GraylogController.php @@ -72,7 +72,7 @@ public function __invoke(Request $request, GraylogApi $api) $loglevel = $request->get('loglevel') ?? LibrenmsConfig::get('graylog.loglevel'); $query = $api->buildSimpleQuery($search, $device) . - ($loglevel !== null ? ' AND level: <=' . $loglevel : ''); + ($loglevel !== null ? ' AND level:[0 TO ' . (int) $loglevel . ']' : ''); $sort = null; foreach ($request->get('sort', []) as $field => $direction) { diff --git a/resources/views/device/tabs/logs/graylog.blade.php b/resources/views/device/tabs/logs/graylog.blade.php index a563d17982fd..c9f91ee6db6b 100644 --- a/resources/views/device/tabs/logs/graylog.blade.php +++ b/resources/views/device/tabs/logs/graylog.blade.php @@ -12,8 +12,8 @@ @lang('Timestamp') - @lang('Source') @lang('Level') + @lang('Source') @lang('Message') @lang('Facility') diff --git a/resources/views/graylog.blade.php b/resources/views/graylog.blade.php new file mode 100644 index 000000000000..f695225f70a3 --- /dev/null +++ b/resources/views/graylog.blade.php @@ -0,0 +1,138 @@ +@extends('layouts.librenmsv1') + +@section('title', __('Graylog')) + +@section('content') +
    + + +

    @lang('Graylog')

    +
    +
    + + + + + + + + + + + + +
    @lang('Timestamp')@lang('Level')@lang('Origin')@lang('Source')@lang('Message')@lang('Facility')
    +
    +
    +
    +@endsection + +@push('scripts') + +@endpush + +@push('styles') + +@endpush \ No newline at end of file diff --git a/resources/views/layouts/menu.blade.php b/resources/views/layouts/menu.blade.php index 7f95b9dcce08..a818b9852d02 100644 --- a/resources/views/layouts/menu.blade.php +++ b/resources/views/layouts/menu.blade.php @@ -89,7 +89,7 @@ class="tw:md:hidden tw:2xl:inline-block">{{ __('Overview') }} aria-hidden="true">
    {{ __('syslog.title') }} @endconfig @config('graylog.server') -
  • {{ __('Graylog') }}
  • @endconfig diff --git a/resources/views/syslog.blade.php b/resources/views/syslog.blade.php index 09a5c5576435..4cc4b269b4b0 100644 --- a/resources/views/syslog.blade.php +++ b/resources/views/syslog.blade.php @@ -13,8 +13,8 @@ data-url="{{ route('table.syslog') }}" data-export="false"> - - Timestamp + + Timestamp Level @lang('Device') Program @@ -25,7 +25,7 @@
    - + @endsection @push('scripts') diff --git a/routes/web.php b/routes/web.php index 7c414a691582..0b220c3e1a05 100644 --- a/routes/web.php +++ b/routes/web.php @@ -85,6 +85,7 @@ Route::resource('device-groups', DeviceGroupController::class); Route::any('eventlog', App\Http\Controllers\EventlogController::class)->name('eventlog'); Route::any('syslog', App\Http\Controllers\SyslogController::class)->name('syslog'); + Route::any('graylog', App\Http\Controllers\GraylogController::class)->name('graylog'); Route::any('inventory', App\Http\Controllers\InventoryController::class)->name('inventory'); Route::get('inventory/purge', [App\Http\Controllers\InventoryController::class, 'purge'])->name('inventory.purge'); Route::get('outages', [OutagesController::class, 'index'])->name('outages'); From b5b18ac668d0640a2e01c7ffe56f28e6bb819e29 Mon Sep 17 00:00:00 2001 From: Wheel Date: Mon, 15 Dec 2025 00:40:18 +0100 Subject: [PATCH 26/30] Minors --- app/Http/Controllers/GraylogController.php | 6 ++---- resources/views/device/tabs/logs/eventlog.blade.php | 2 +- resources/views/device/tabs/logs/graylog.blade.php | 2 +- resources/views/device/tabs/logs/syslog.blade.php | 2 +- resources/views/eventlog.blade.php | 2 +- resources/views/graylog.blade.php | 2 +- resources/views/syslog.blade.php | 12 ++++++------ 7 files changed, 13 insertions(+), 15 deletions(-) diff --git a/app/Http/Controllers/GraylogController.php b/app/Http/Controllers/GraylogController.php index 09f84f8e0bfa..2a9294d72fcc 100644 --- a/app/Http/Controllers/GraylogController.php +++ b/app/Http/Controllers/GraylogController.php @@ -15,6 +15,7 @@ public function __invoke(Request $request): View { $request->validate([ 'stream' => 'nullable|string', + 'device' => 'nullable|int', 'range' => 'nullable|int', 'loglevel' => 'nullable|int', ]); @@ -23,10 +24,7 @@ public function __invoke(Request $request): View ->select(['device_id', 'hostname', 'ip', 'sysName', 'display']) ->firstWhere('device_id', $request->input('device')); - $graylog_filter = [ - 'field' => 'stream', - ]; - + $graylog_filter = ['field' => 'stream',]; $device_selected = ''; if ($device) { $device_selected = ['id' => $device->device_id, 'text' => $device->displayName()]; diff --git a/resources/views/device/tabs/logs/eventlog.blade.php b/resources/views/device/tabs/logs/eventlog.blade.php index bde44c8cfc11..8e139f180ccc 100644 --- a/resources/views/device/tabs/logs/eventlog.blade.php +++ b/resources/views/device/tabs/logs/eventlog.blade.php @@ -28,7 +28,7 @@ $(function () { const eventlog_grid = $("#eventlog").bootgrid({ ajax: true, - rowCount: [20, 50, 100, 250, -1], + rowCount: [20, 50, 100, 250], templates: { header: '
    ' + '' + diff --git a/resources/views/device/tabs/logs/graylog.blade.php b/resources/views/device/tabs/logs/graylog.blade.php index c9f91ee6db6b..359e2bf0a128 100644 --- a/resources/views/device/tabs/logs/graylog.blade.php +++ b/resources/views/device/tabs/logs/graylog.blade.php @@ -29,7 +29,7 @@ $(function () { const graylog_grid = $("#graylog").bootgrid({ ajax: true, - rowCount: [20, 50, 100, 250, -1], + rowCount: [20, 50, 100, 250], templates: { header: '
    ' + '' + diff --git a/resources/views/device/tabs/logs/syslog.blade.php b/resources/views/device/tabs/logs/syslog.blade.php index 2db8082d8b2f..007f7119fcfc 100644 --- a/resources/views/device/tabs/logs/syslog.blade.php +++ b/resources/views/device/tabs/logs/syslog.blade.php @@ -29,7 +29,7 @@ $(function () { const syslog_grid = $("#syslog").bootgrid({ ajax: true, - rowCount: [20, 50, 100, 250, -1], + rowCount: [20, 50, 100, 250], templates: { header: '
    ' + '' + diff --git a/resources/views/eventlog.blade.php b/resources/views/eventlog.blade.php index 6bcd82eb9013..e882bd4f6894 100644 --- a/resources/views/eventlog.blade.php +++ b/resources/views/eventlog.blade.php @@ -32,7 +32,7 @@ $(function () { const eventlog_grid = $("#eventlog").bootgrid({ ajax: true, - rowCount: [20, 50, 100, 250, -1], + rowCount: [20, 50, 100, 250], templates: { header: '
    ' + '' + diff --git a/resources/views/graylog.blade.php b/resources/views/graylog.blade.php index f695225f70a3..d64b65380ad7 100644 --- a/resources/views/graylog.blade.php +++ b/resources/views/graylog.blade.php @@ -33,7 +33,7 @@ $(function () { const graylog_grid = $("#graylog").bootgrid({ ajax: true, - rowCount: [20, 50, 100, 250, -1], + rowCount: [20, 50, 100, 250], templates: { header: '
    ' + '' + diff --git a/resources/views/syslog.blade.php b/resources/views/syslog.blade.php index 4cc4b269b4b0..861a065ef5a5 100644 --- a/resources/views/syslog.blade.php +++ b/resources/views/syslog.blade.php @@ -14,12 +14,12 @@ - Timestamp - Level + @lang('Timestamp') + @lang('Level') @lang('Device') - Program - Message - Priority + @lang('Program') + @lang('Message') + @lang('Priority') @@ -33,7 +33,7 @@ $(function () { const syslog_grid = $("#syslog").bootgrid({ ajax: true, - rowCount: [25, 50, 100, 250, -1], + rowCount: [25, 50, 100, 250], templates: { header: '
    ' + '' + From 744910a295f02f8018077dec48d1e014d0fab14a Mon Sep 17 00:00:00 2001 From: Wheel Date: Mon, 15 Dec 2025 11:37:37 +0100 Subject: [PATCH 27/30] Graylog absolute time filters --- app/ApiClients/GraylogApi.php | 37 +++++++++- .../Device/Tabs/GraylogController.php | 18 +++++ app/Http/Controllers/GraylogController.php | 6 ++ .../Controllers/Table/GraylogController.php | 50 +++++++++---- .../views/device/tabs/logs/eventlog.blade.php | 1 + .../views/device/tabs/logs/graylog.blade.php | 70 +++++++++++++++++-- .../views/device/tabs/logs/syslog.blade.php | 1 + resources/views/eventlog.blade.php | 2 +- resources/views/graylog.blade.php | 70 +++++++++++++++++-- 9 files changed, 229 insertions(+), 26 deletions(-) diff --git a/app/ApiClients/GraylogApi.php b/app/ApiClients/GraylogApi.php index cc337260f123..17f427dd13d1 100644 --- a/app/ApiClients/GraylogApi.php +++ b/app/ApiClients/GraylogApi.php @@ -66,9 +66,9 @@ public function getStreams(): array } /** - * Query the Graylog server + * Query the Graylog server relative time */ - public function query(string $query = '*', int $range = 0, int $limit = 0, int $offset = 0, ?string $sort = null, ?string $filter = null): array + public function queryRelative(string $query = '*', int $range = 0, int $limit = 0, int $offset = 0, ?string $sort = null, ?string $filter = null): array { if (! $this->isConfigured()) { return []; @@ -93,6 +93,39 @@ public function query(string $query = '*', int $range = 0, int $limit = 0, int $ return $response->json() ?: []; } + /** + * Query the Graylog server absolute time + */ + public function queryAbsolute( + string $query = '*', + string $from, + string $to, + int $limit = 0, + int $offset = 0, + ?string $sort = null, + ?string $filter = null + ): array { + if (! $this->isConfigured()) { + return []; + } + + $uri = $this->api_prefix . '/search/universal/absolute'; + + $data = [ + 'query' => $query, + 'from' => $from, + 'to' => $to, + 'limit' => $limit, + 'offset' => $offset, + 'sort' => $sort, + 'filter' => $filter, + ]; + + $response = $this->client->get($uri, $data)->throw(); + + return $response->json() ?: []; + } + /** * Build a simple query string that searches the messages field and/or filters by device */ diff --git a/app/Http/Controllers/Device/Tabs/GraylogController.php b/app/Http/Controllers/Device/Tabs/GraylogController.php index f9ef49a5cd05..0c5d485b85c7 100644 --- a/app/Http/Controllers/Device/Tabs/GraylogController.php +++ b/app/Http/Controllers/Device/Tabs/GraylogController.php @@ -29,6 +29,7 @@ use App\Facades\LibrenmsConfig; use App\Http\Controllers\Controller; use App\Models\Device; +use Carbon\Carbon; use Illuminate\Http\Request; use Illuminate\View\View; @@ -40,12 +41,25 @@ public function __invoke(Device $device, Request $request): View 'stream' => 'nullable|string', 'range' => 'nullable|int', 'loglevel' => 'nullable|int', + 'to' => 'nullable|string', + 'level' => 'nullable|string', ]); $graylog_filter = [ 'field' => 'stream', 'device' => $device->device_id, ]; + $format = LibrenmsConfig::get('dateformat.byminute', 'Y-m-d H:i'); + $now = Carbon::now(); + $defaultFrom = (clone $now)->subDays(7); + $fromInput = $request->input('from'); + $toInput = $request->input('to'); + + if (empty($fromInput) && empty($toInput)) { + $fromInput = $defaultFrom->format($format); + $toInput = $now->format($format); + } + return view('device.tabs.logs.graylog', [ 'device' => $device, 'timezone' => LibrenmsConfig::has('graylog.timezone'), @@ -54,6 +68,10 @@ public function __invoke(Device $device, Request $request): View 'stream' => $request->input('stream', ''), 'range' => $request->input('range', '0'), 'loglevel' => $request->input('loglevel', ''), + 'from' => $fromInput, + 'to' => $toInput, + 'default_date' => $defaultFrom->format($format), + 'now' => $now->format($format), 'graylog_filter' => $graylog_filter, ]); } diff --git a/app/Http/Controllers/GraylogController.php b/app/Http/Controllers/GraylogController.php index 2a9294d72fcc..8ebbaaee563d 100644 --- a/app/Http/Controllers/GraylogController.php +++ b/app/Http/Controllers/GraylogController.php @@ -18,6 +18,8 @@ public function __invoke(Request $request): View 'device' => 'nullable|int', 'range' => 'nullable|int', 'loglevel' => 'nullable|int', + 'to' => 'nullable|string', + 'level' => 'nullable|string', ]); $device = \App\Models\Device::hasAccess($request->user()) @@ -51,6 +53,10 @@ public function __invoke(Request $request): View 'stream' => $request->input('stream', ''), 'range' => $request->input('range', '0'), 'loglevel' => $request->input('loglevel', ''), + 'from' => $fromInput, + 'to' => $toInput, + 'default_date' => $defaultFrom->format($format), + 'now' => $now->format($format), ], 'graylog_filter' => $graylog_filter, ]); diff --git a/app/Http/Controllers/Table/GraylogController.php b/app/Http/Controllers/Table/GraylogController.php index 219ade4f3968..f54e82053bc7 100644 --- a/app/Http/Controllers/Table/GraylogController.php +++ b/app/Http/Controllers/Table/GraylogController.php @@ -30,8 +30,6 @@ use App\Facades\LibrenmsConfig; use Carbon\Carbon; use App\Models\Device; -use DateInterval; -use DateTime; use DateTimeZone; use Illuminate\Http\Request; use Illuminate\Support\Facades\Blade; @@ -60,6 +58,8 @@ public function __invoke(Request $request, GraylogApi $api) 'device' => 'nullable|int', 'range' => 'nullable|int', 'loglevel' => 'nullable|int|min:0|max:7', + 'from' => 'nullable|date_format:Y-m-d H:i', + 'to' => 'nullable|date_format:Y-m-d H:i', ]); $search = $request->get('searchPhrase'); @@ -71,6 +71,18 @@ public function __invoke(Request $request, GraylogApi $api) $offset = (int) (($page - 1) * $limit); $loglevel = $request->get('loglevel') ?? LibrenmsConfig::get('graylog.loglevel'); + $from = null; + $to = null; + $fromInput = $request->get('from'); + $toInput = $request->get('to'); + $userTz = $this->timezone ? $this->timezone->getName() : (session('preferences.timezone') ?: config('app.timezone')); + + + if ($range === 0 && $fromInput && $toInput) { + $from = Carbon::createFromFormat('Y-m-d H:i', (string) $fromInput, $userTz); + $to = Carbon::createFromFormat('Y-m-d H:i', (string) $toInput, $userTz); + } + $query = $api->buildSimpleQuery($search, $device) . ($loglevel !== null ? ' AND level:[0 TO ' . (int) $loglevel . ']' : ''); @@ -83,7 +95,22 @@ public function __invoke(Request $request, GraylogApi $api) $filter = $stream ? "streams:$stream" : null; try { - $data = $api->query($query, $range, $limit, $offset, $sort, $filter); + if ($from && $to) { + $fromUtc = $from->clone()->setTimezone('UTC')->format('Y-m-d\TH:i:s.v\Z'); + $toUtc = $to->clone()->setTimezone('UTC')->format('Y-m-d\TH:i:s.v\Z'); + + $data = $api->queryAbsolute( + $query, + $fromUtc, + $toUtc, + $limit, + $offset, + $sort, + $filter + ); + } else { + $data = $api->queryRelative($query, $range, $limit, $offset, $sort, $filter); + } $messages = $data['messages'] ?? []; return $this->formatResponse( @@ -103,18 +130,11 @@ public function __invoke(Request $request, GraylogApi $api) private function formatMessage($message) { - if ($this->timezone) { - $graylogTime = new DateTime($message['message']['timestamp']); - $offset = $this->timezone->getOffset($graylogTime); - - $timeInterval = DateInterval::createFromDateString((string) $offset . 'seconds'); - $graylogTime->add($timeInterval); - $displayTime = $graylogTime->format('Y-m-d H:i:s'); - } else { - $displayTime = Carbon::parse($message['message']['timestamp']) - ->setTimezone(session('preferences.timezone')) - ->format(LibrenmsConfig::get('dateformat.compact')); - } + $displayTz = $this->timezone ? $this->timezone->getName() : (session('preferences.timezone') ?: config('app.timezone')); + + $displayTime = Carbon::parse($message['message']['timestamp']) + ->setTimezone($displayTz) + ->format(LibrenmsConfig::get('dateformat.compact')); $level = $message['message']['level'] ?? ''; $facility = $message['message']['facility'] ?? ''; diff --git a/resources/views/device/tabs/logs/eventlog.blade.php b/resources/views/device/tabs/logs/eventlog.blade.php index 8e139f180ccc..6286880ff534 100644 --- a/resources/views/device/tabs/logs/eventlog.blade.php +++ b/resources/views/device/tabs/logs/eventlog.blade.php @@ -32,6 +32,7 @@ templates: { header: '
    ' + '' + + '{!! addslashes(csrf_field()) !!}' + '
    ' + '' + '
    ' + diff --git a/resources/views/device/tabs/logs/graylog.blade.php b/resources/views/device/tabs/logs/graylog.blade.php index 359e2bf0a128..29f2da75fc33 100644 --- a/resources/views/device/tabs/logs/graylog.blade.php +++ b/resources/views/device/tabs/logs/graylog.blade.php @@ -33,6 +33,7 @@ templates: { header: '
    ' + '' + + '{!! addslashes(csrf_field()) !!}' + '
    ' + '' + '
    ' + @@ -51,7 +52,9 @@ '' + '
    ' + '
    ' + - '' + '' + '' + '' + @@ -67,6 +70,16 @@ '' + '' + '
    ' + + '
    ' + + '' + + '
    ' + + '
    ' + + '' + + '
    ' + '' + '' + '' + @@ -83,17 +96,50 @@ source: $('#graylog-source').val() || '', range: $('#range').val() || '', loglevel: $('#loglevel').val() || '', + from: $('#dtpickerfrom').val() || '', + to: $('#dtpickerto').val() || '', }; }, }); + + const dtIcons = { + time: 'fa fa-clock-o', + date: 'fa fa-calendar', + up: 'fa fa-chevron-up', + down: 'fa fa-chevron-down', + previous: 'fa fa-chevron-left', + next: 'fa fa-chevron-right', + today: 'fa fa-calendar-check-o', + clear: 'fa fa-trash-o', + close: 'fa fa-close' + }; $("#graylog").on("loaded.rs.jquery.bootgrid", function () { - init_select2("#graylog-streams", "graylog-streams", @json($graylog_filter), @json($stream),'All Streams'); - $('[data-toggle="tooltip"]').tooltip(); + $("#dtpickerfrom").datetimepicker({ + icons: dtIcons, + defaultDate: '{{ $default_date }}' + }); + $("#dtpickerfrom").on("dp.change", function (e) { + $("#dtpickerto").data("DateTimePicker").minDate(e.date); + }); + $("#dtpickerto").datetimepicker({ + icons: dtIcons, + }); + $("#dtpickerto").on("dp.change", function (e) { + $("#dtpickerfrom").data("DateTimePicker").maxDate(e.date); + }); + if ($("#dtpickerfrom").val() !== '') { + $("#dtpickerto").data("DateTimePicker").minDate($("#dtpickerfrom").val()); + } + if ($("#dtpickerto").val() !== '') { + $("#dtpickerfrom").data("DateTimePicker").maxDate($("#dtpickerto").val()); + } else { + $("#dtpickerto").data("DateTimePicker").maxDate('{{ $now }}'); + } $("#graylog_filter").on("submit", function (e) { e.preventDefault(); graylog_grid.bootgrid("reload", true); }); - + init_select2("#graylog-streams", "graylog-streams", @json($graylog_filter), @json($stream),'All Streams'); $("#graylog_clear").on("click", function () { $("#graylog-streams").val(null).trigger("change"); $("#loglevel").val('6').trigger("change"); @@ -101,8 +147,24 @@ $("#graylog").find(".search-field").val(""); graylog_grid.bootgrid("search", ""); + + const fromPicker = $("#dtpickerfrom").data("DateTimePicker"); + const toPicker = $("#dtpickerto").data("DateTimePicker"); + + const now = moment(); + const from = moment(now).subtract(1, 'day'); + + fromPicker.minDate(false); + fromPicker.maxDate(now); + toPicker.minDate(from); + toPicker.maxDate(now); + + fromPicker.date(from); + toPicker.date(now); + graylog_grid.bootgrid("reload", true); }); + $('[data-toggle="tooltip"]').tooltip(); }); }); diff --git a/resources/views/device/tabs/logs/syslog.blade.php b/resources/views/device/tabs/logs/syslog.blade.php index 007f7119fcfc..da3995930257 100644 --- a/resources/views/device/tabs/logs/syslog.blade.php +++ b/resources/views/device/tabs/logs/syslog.blade.php @@ -33,6 +33,7 @@ templates: { header: '
    ' + '
    ' + + '{!! addslashes(csrf_field()) !!}' + '
    ' + '' + '
    ' + diff --git a/resources/views/eventlog.blade.php b/resources/views/eventlog.blade.php index e882bd4f6894..13b417f6b13b 100644 --- a/resources/views/eventlog.blade.php +++ b/resources/views/eventlog.blade.php @@ -17,7 +17,7 @@ @lang('Timestamp') @lang('Device') @lang('Type') - @lang('Message') + @lang('Message') @lang('User') diff --git a/resources/views/graylog.blade.php b/resources/views/graylog.blade.php index d64b65380ad7..cc9cf1315449 100644 --- a/resources/views/graylog.blade.php +++ b/resources/views/graylog.blade.php @@ -59,7 +59,9 @@ '' + '
    ' + '
    ' + - '' + '' + '' + '' + @@ -75,6 +77,16 @@ '' + '' + '
    ' + + '
    ' + + '' + + '
    ' + + '
    ' + + '' + + '
    ' + '' + '' + '' + @@ -91,18 +103,52 @@ source: $('#graylog-source').val() || '', range: $('#range').val() || '', loglevel: $('#loglevel').val() || '', + from: $('#dtpickerfrom').val() || '', + to: $('#dtpickerto').val() || '', }; }, }); + + const dtIcons = { + time: 'fa fa-clock-o', + date: 'fa fa-calendar', + up: 'fa fa-chevron-up', + down: 'fa fa-chevron-down', + previous: 'fa fa-chevron-left', + next: 'fa fa-chevron-right', + today: 'fa fa-calendar-check-o', + clear: 'fa fa-trash-o', + close: 'fa fa-close' + }; $("#graylog").on("loaded.rs.jquery.bootgrid", function () { - init_select2("#device", "device", {limit: 100}, @json($device) , "@lang('All Devices')"); - init_select2("#graylog-streams", "graylog-streams", @json($graylog_filter), @json($filter['stream']),'All Streams'); - $('[data-toggle="tooltip"]').tooltip(); + $("#dtpickerfrom").datetimepicker({ + icons: dtIcons, + defaultDate: '{{ $filter['default_date'] }}' + }); + $("#dtpickerfrom").on("dp.change", function (e) { + $("#dtpickerto").data("DateTimePicker").minDate(e.date); + }); + $("#dtpickerto").datetimepicker({ + icons: dtIcons, + }); + $("#dtpickerto").on("dp.change", function (e) { + $("#dtpickerfrom").data("DateTimePicker").maxDate(e.date); + }); + if ($("#dtpickerfrom").val() != "") { + $("#dtpickerto").data("DateTimePicker").minDate($("#dtpickerfrom").val()); + } + if ($("#dtpickerto").val() != "") { + $("#dtpickerfrom").data("DateTimePicker").maxDate($("#dtpickerto").val()); + } else { + $("#dtpickerto").data("DateTimePicker").maxDate('{{ $filter['now'] }}'); + } $("#graylog_filter").on("submit", function (e) { e.preventDefault(); graylog_grid.bootgrid("reload", true); }); + init_select2("#device", "device", {limit: 100}, @json($device) , "@lang('All Devices')"); + init_select2("#graylog-streams", "graylog-streams", @json($graylog_filter), @json($filter['stream']),'All Streams'); $("#graylog_clear").on("click", function () { $("#device").val(null).trigger("change"); $("#graylog-streams").val(null).trigger("change"); @@ -111,8 +157,24 @@ $("#graylog").find(".search-field").val(""); graylog_grid.bootgrid("search", ""); + + const fromPicker = $("#dtpickerfrom").data("DateTimePicker"); + const toPicker = $("#dtpickerto").data("DateTimePicker"); + + const now = moment(); + const from = moment(now).subtract(7, 'day'); + + fromPicker.minDate(false); + fromPicker.maxDate(now); + toPicker.minDate(from); + toPicker.maxDate(now); + + fromPicker.date(from); + toPicker.date(now); + graylog_grid.bootgrid("reload", true); }); + $('[data-toggle="tooltip"]').tooltip(); }); }); From 144773a85fd16dfe454f7af012f186c060a70868 Mon Sep 17 00:00:00 2001 From: Wheel Date: Mon, 15 Dec 2025 13:33:57 +0100 Subject: [PATCH 28/30] Event and Syslog export functions --- .../Controllers/Table/EventlogController.php | 34 ++++++++++++++++++- .../Controllers/Table/SyslogController.php | 28 +++++++++++++-- .../views/device/tabs/logs/eventlog.blade.php | 2 +- .../views/device/tabs/logs/syslog.blade.php | 2 +- resources/views/eventlog.blade.php | 2 +- resources/views/syslog.blade.php | 2 +- routes/web.php | 2 ++ 7 files changed, 65 insertions(+), 7 deletions(-) diff --git a/app/Http/Controllers/Table/EventlogController.php b/app/Http/Controllers/Table/EventlogController.php index 90e18d9712a6..f98de3626601 100644 --- a/app/Http/Controllers/Table/EventlogController.php +++ b/app/Http/Controllers/Table/EventlogController.php @@ -150,4 +150,36 @@ private function severityLabel($eventlog_severity) default => 'label-default', // Unknown }; } -} + + /** + * Get headers for CSV export + * + * @return array + */ + protected function getExportHeaders() + { + return [ + 'Timestamp', + 'Device', + 'Type', + 'Message', + 'User', + ]; + } + /** + * Format a row for CSV export + * + * @param EventLog $eventlog + * @return array + */ + protected function formatExportRow($eventlog) + { + return [ + Carbon::createFromTimestamp($eventlog->datetime)->toISOString(), + $eventlog->device ? $eventlog->device->displayName() : '', + $eventlog->type, + (string) $eventlog->message, + $eventlog->username ?: 'System', + ]; + } +} \ No newline at end of file diff --git a/app/Http/Controllers/Table/SyslogController.php b/app/Http/Controllers/Table/SyslogController.php index f82e13c5ba49..bbf4958106ee 100644 --- a/app/Http/Controllers/Table/SyslogController.php +++ b/app/Http/Controllers/Table/SyslogController.php @@ -140,6 +140,30 @@ private function priorityLabel($syslog_priority) default => '', }; } - - // end syslog_priority + protected function getExportHeaders() + { + return [ + 'Timestamp', + 'Level', + 'Device', + 'Program', + 'Message', + ]; + } + /** + * Format a row for CSV export + * + * @param Syslog $syslog + * @return array + */ + protected function formatExportRow($syslog) + { + return [ + Carbon::createFromTimestamp($syslog->timestamp)->toISOString(), + $syslog->priority, + $syslog->device ? $syslog->device->displayName() : '', + (string) $syslog->program, + (string) $syslog->msg, + ]; + } } diff --git a/resources/views/device/tabs/logs/eventlog.blade.php b/resources/views/device/tabs/logs/eventlog.blade.php index 6286880ff534..63d4579c179d 100644 --- a/resources/views/device/tabs/logs/eventlog.blade.php +++ b/resources/views/device/tabs/logs/eventlog.blade.php @@ -7,7 +7,7 @@
    + data-url="{{ route('table.eventlog') }}"> diff --git a/resources/views/device/tabs/logs/syslog.blade.php b/resources/views/device/tabs/logs/syslog.blade.php index da3995930257..3fb065945a7f 100644 --- a/resources/views/device/tabs/logs/syslog.blade.php +++ b/resources/views/device/tabs/logs/syslog.blade.php @@ -7,7 +7,7 @@
    + data-url="{{ route('table.syslog') }}"> diff --git a/resources/views/eventlog.blade.php b/resources/views/eventlog.blade.php index 13b417f6b13b..d00be7b9c69a 100644 --- a/resources/views/eventlog.blade.php +++ b/resources/views/eventlog.blade.php @@ -10,7 +10,7 @@
    + data-url="{{ route('table.eventlog') }}"> diff --git a/resources/views/syslog.blade.php b/resources/views/syslog.blade.php index 861a065ef5a5..4fd458dc036b 100644 --- a/resources/views/syslog.blade.php +++ b/resources/views/syslog.blade.php @@ -10,7 +10,7 @@
    + data-url="{{ route('table.syslog') }}"> diff --git a/routes/web.php b/routes/web.php index 0b220c3e1a05..f27efa3e1b81 100644 --- a/routes/web.php +++ b/routes/web.php @@ -296,6 +296,7 @@ Route::get('device/export', [Table\DeviceController::class, 'export']); Route::post('edit-ports', Table\EditPortsController::class); Route::post('eventlog', Table\EventlogController::class)->name('table.eventlog'); + Route::get('eventlog/export', [Table\EventlogController::class, 'export']); Route::post('fdb-tables', Table\FdbTablesController::class); Route::post('graylog', Table\GraylogController::class)->name('table.graylog'); Route::post('inventory', Table\InventoryController::class)->name('table.inventory'); @@ -318,6 +319,7 @@ Route::post('storages', Table\StoragesController::class)->name('table.storages'); Route::get('storages/export', [Table\StoragesController::class, 'export']); Route::post('syslog', Table\SyslogController::class)->name('table.syslog'); + Route::get('syslog/export', [Table\SyslogController::class, 'export']); Route::post('printer-supply', Table\PrinterSupplyController::class)->name('table.printer-supply'); Route::post('tnmsne', Table\TnmsneController::class)->name('table.tnmsne'); Route::post('wireless', Table\WirelessSensorController::class)->name('table.wireless'); From 5ff93cc8e974c77a6a497248dd29e09c700f0f9c Mon Sep 17 00:00:00 2001 From: Wheel Date: Mon, 15 Dec 2025 13:37:31 +0100 Subject: [PATCH 29/30] Consistency --- app/ApiClients/GraylogApi.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/ApiClients/GraylogApi.php b/app/ApiClients/GraylogApi.php index 17f427dd13d1..93f78e7c512f 100644 --- a/app/ApiClients/GraylogApi.php +++ b/app/ApiClients/GraylogApi.php @@ -68,8 +68,14 @@ public function getStreams(): array /** * Query the Graylog server relative time */ - public function queryRelative(string $query = '*', int $range = 0, int $limit = 0, int $offset = 0, ?string $sort = null, ?string $filter = null): array - { + public function queryRelative( + string $query = '*', + int $range = 0, + int $limit = 0, + int $offset = 0, + ?string $sort = null, + ?string $filter = null + ): array { if (! $this->isConfigured()) { return []; } From 3ef29a3de1c3f9bb641dc6a6ed3edae1335f16e8 Mon Sep 17 00:00:00 2001 From: Wheel Date: Mon, 15 Dec 2025 13:41:27 +0100 Subject: [PATCH 30/30] Fix deprecation warning --- app/ApiClients/GraylogApi.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/ApiClients/GraylogApi.php b/app/ApiClients/GraylogApi.php index 93f78e7c512f..3f9d55fcd4c6 100644 --- a/app/ApiClients/GraylogApi.php +++ b/app/ApiClients/GraylogApi.php @@ -104,8 +104,8 @@ public function queryRelative( */ public function queryAbsolute( string $query = '*', - string $from, - string $to, + string $from = '', + string $to = '', int $limit = 0, int $offset = 0, ?string $sort = null,