29 Commits

Author SHA1 Message Date
Ad Schellevis
0adece8d3e System/Logging - add log search time constraint (valid_from) to limit searches when only a few lines match.
When searching large log files for messages that do not frequently occur, there is a large risk of reading all collected lines before returning the first results.
In most cases recent items are required, in which case going back for days of logs might not make sense.

This commit adds a simple "history" selection which translates into a "valid_from" filter on the log data. When timestamps are not parseable for whatever reason, the filter is ignored.

Only small downside is that we do need to translate timestamp again, when needed we could improve performance a bit by storing the original datetime value in NewBaseLogFormat so we don't have to parse it twice.
2024-08-24 20:55:12 +02:00
Ad Schellevis
798170b612 System/Logging - unify how search clauses work, when multiple clauses are specified, we should perform a lowercase compare on each clause (AND).
With this change in place, search behavior should be equal to model searches and searchRecordsetBase() consumers.
2024-08-24 18:12:25 +02:00
Stephan de Wit
44a1ea3096 syslog: regression in c522ecac65, wrong variable assignment. Fixes https://github.com/opnsense/core/issues/7778 2024-08-16 10:59:57 +02:00
Ad Schellevis
6e409a0a2f System: Log Files: Boot - empty log view due to minor regression in c522ecac65 2024-07-03 18:23:26 +02:00
Stephan de Wit
ce465dd2dc configd: send keepalives from streaming actions to enforce client disconnects 2024-07-01 22:07:05 +02:00
Franco Fichtner
0f73da02ad system: fix permission 2024-06-22 17:40:08 +02:00
Stephan de Wit
de1f9a0852 dashboard: add basic live log widget 2024-06-21 15:03:42 +02:00
Stephan de Wit
c522ecac65 configd: extend log query mechanism with streaming capability 2024-06-21 12:31:54 +02:00
MaxXor
e21159a973
src: resolve deprecation warnings for sre_constants (#7460)
ref https://github.com/python/cpython/issues/91308
2024-05-16 19:28:50 +02:00
Ad Schellevis
73c3b88eb0 System: Settings: Logging - maximum log file size ignored when there's only one file in the directory. closes https://github.com/opnsense/core/issues/7397
The rotate function needed the next file to calculate the suffix, which is problematic if someone just cleaned all logs. This patch improves the match a bit (last _ instead of assuming _ doesn't exist in the name) and uses "1" for the first rotate action.
2024-04-20 09:53:00 +02:00
Franco Fichtner
8ea6e7be9b system: fix use after migration #6830 2024-02-29 14:14:49 +01:00
Franco Fichtner
83b7cd7213 src: style sweep 2024-01-26 09:37:26 +01:00
Ad Schellevis
528b7df875 Syslog / archive - add maxfilesize option to enforce a log rotate when files exceed their limit.
The combination of preserve logs and max file size help to guard the boundaries of the log storage being used, an archive action is already being performed hourly, which should be enough in normal situations (although that would be easy to change if needed).

In order to make room for the new additional files per day, we add a sequence to the file, for example the first rotate of a filter log exceeding its limit named /var/log/filter/filter_20231204.log  would be moved to /var/log/filter/filter_20231204.0001.log . The syslog-ng reload handles the flush to a new file, which automatically would result in a new filter_20231204.log file after rotate.
2024-01-25 17:14:11 +01:00
Franco Fichtner
8226c84a2f web proxy: move all files to plugin #7030 2023-12-19 15:11:20 +01:00
Ad Schellevis
cee33f5393 Firewall log - prevent memory exhaustion using the new streaming functions. closes https://github.com/opnsense/core/issues/6680 2023-11-22 21:56:50 +01:00
Franco Fichtner
b7db4316fd src: legacy_bindings.inc already included by config.inc
client_connect.php also includes it but not config.inc.  Try to leave
it at that to not pollute it unnecessarily.  The other scripts might
be able to do it as well this way but don't fix something that is not
broken either.
2023-07-24 08:38:24 +02:00
Ad Schellevis
038d5b9bcf Services: Web Proxy: Access Log - syslog parsing cleanup. closes https://github.com/opnsense/core/issues/6588 2023-06-01 08:34:15 +02:00
Ad Schellevis
3a6c79d4bc MVC/Trust - Implement new Trust class usage for the following components:
o OpenVPN Client Export
o Captive portal
o Syslog-NG
2023-05-17 16:29:32 +02:00
Ad Schellevis
4082fb4283 System/Logging - timezone parsing issue for zones west of UTC [-]. closes https://github.com/opnsense/core/pull/6443 2023-03-24 09:27:42 +01:00
Ad Schellevis
6f46fe3080 System/Log Files - add "Service Log (this boot)" including parser as an option to provide access to entries collected in https://github.com/opnsense/core/issues/6099 (proposal for 23.1) 2022-12-19 10:08:44 +01:00
Ad Schellevis
ae8e0ce4a4 syslog/lockout handler - better trap ssh messages and improve lockout behaviour.
As the client still might have a state when being kicked-out, we should kill any state the client has while adding it to the alias. Apparantly our ssh messages are only catched partially, so add ".*Authentication error for .*" to the list as well. To ease testing, better detect the location of the timestamp so we can use a construction like this to feed amn existing log:

lockout_handler < /var/log/audit/audit_20221205.log
2022-12-05 14:52:16 +01:00
Franco Fichtner
fe21864884 health: clean up scripts/systemheath location #5877
Unfortunately this requires relocating the logging plugins to its
proper location which also affects plugins using that location.
2022-11-04 09:45:10 +01:00
Ad Schellevis
aba58e5ee4 Logging: Add a symlink for e.g. system.log to system_todaysdate.log for log parsing (https://github.com/opnsense/core/issues/4993)
same same as dd6a04a68a, but different.
Concerns fixed in this commit:

o archive shouldn't generate files so old "archived" files remain untouched
o "latest.log" should point to the latest version know, which could be todays or a file from the past
o better to not remove links when unchanged to prevent excessive writes
2021-11-18 17:06:40 +01:00
Franco Fichtner
dd6a04a68a system: add "latest.log" symlink and make sure new log is created
We shuffle the cron jobs around a bit to let the script start at
minute 1 of every hour which is close enough.

We might consider a soft-update of the link instead of removing
it every hour depending on how tail -f and such work, but for now
use what PHP has to offer.

PR: https://github.com/opnsense/core/issues/4993
2021-11-18 09:14:25 +01:00
Ad Schellevis
2b976a491d System / Settings / Logging - targets: TLS trasnport, fix previous for https://github.com/opnsense/core/issues/4937
(use generic system ca file)
2021-04-30 18:52:47 +02:00
Ad Schellevis
64c2e02b0b System / Settings / Logging - targets: add TLS transport option
closes https://github.com/opnsense/core/issues/4937
2021-04-30 17:54:29 +02:00
Ad Schellevis
31d3044388 syslog-ng: lockout-handler, exit when syslog-ng exits. closes https://github.com/opnsense/core/issues/4195 2020-07-16 17:54:05 +02:00
Ad Schellevis
faf650e7ca
Syslog: optionally disable legacy (clog) logging (#4101)
* Syslog-NG replacement for legacy syslog local logs:

Part of this commit:

- support both formats in query log, which is used by our log api
- sample local syslog-ng target for configd

for https://github.com/opnsense/core/issues/4068

* syslog: add disable clog toggle + preserve number of log (days) setting when only using syslog-ng. for https://github.com/opnsense/core/issues/4068

* syslog: include local syslog-ng files when clog is disabled. for https://github.com/opnsense/core/issues/4068

* Syslog-NG: change local handling, add relayd file to test the concept.

The local directory contains filters for local targets, which should replace the <plugin>_syslog() construction eventually, everything relevant and not matched is send to system

for https://github.com/opnsense/core/issues/4068

* Syslog-NG: minor update to local template to support module/file format as the query log handler supports it (e.g. /var/log/squid/access/) and add local templates

* Syslog-NG: change flush log actions to support new format, while here make sure "flush all" actuallly flushes all logs (including plugins). for https://github.com/opnsense/core/issues/4068

* Syslog-NG: missing level in system log, for https://github.com/opnsense/core/issues/4068

* fix typo for https://github.com/opnsense/core/issues/4068

* syslog-ng: filter live log support for https://github.com/opnsense/core/issues/4068

* Syslog-NG: replace diag_logs_filter_summary.php for mvc enabled version, using the same log output as live log, for https://github.com/opnsense/core/issues/4068

* Syslog-NG: add log cleanup script to enforce preservelogs setting. for https://github.com/opnsense/core/issues/4068

* Syslog-NG: webuser auth message should use LOG_AUTH facility. for https://github.com/opnsense/core/issues/4068

* Syslog-NG: ditch sshlockout_pf in favour for a small script that locks out ssh/web gui failed attempts for both IPv4 and IPv6. for https://github.com/opnsense/core/issues/4068

* ditch sshlockout_pf dependancy, for https://github.com/opnsense/core/issues/4068

* fix indent in ACL, for https://github.com/opnsense/core/issues/4068

* fix plist
2020-05-10 10:59:14 +02:00
Ad Schellevis
b0eeccb784 syslog, work in progress. add helper function to hook in configd to list registered applications so we can easily use these values in our mvc forms. 2019-06-10 20:28:54 +02:00