Skip to content

Feat: Add syslog filter feature#2035

Closed
dlandon wants to merge 4 commits into
unraid:masterfrom
dlandon:add_syslog_filter_feature
Closed

Feat: Add syslog filter feature#2035
dlandon wants to merge 4 commits into
unraid:masterfrom
dlandon:add_syslog_filter_feature

Conversation

@dlandon

@dlandon dlandon commented Feb 21, 2025

Copy link
Copy Markdown
Contributor

This feature adds a syslog filter page at Settings->User Utilities->System Log Filter to add strings to filter messages from the syslog. The filter applies to all logs of the Syslog Server

How it works:

  • The textarea strings are converted to rsyslog filtering statements and stored in /boot/default/02-blocklist-extra.conf.
  • When the 'rc.rsyslogd start' script is run, it copies the /boot/default/02-blocklist-extra.conf if it exists to /etc/rsyslog.d/02-blocklist-extra.conf just before the rsyslog is started.
  • The additional filtering is applied along with the /etc/rsyslog.d/01-blocklist.conf built in filtering.

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features
    • Introduced a new interface that allows users to filter system logs by entering multiple log strings. The page provides clear guidance and controls for applying, resetting, and exiting filter settings.
  • Chores
    • Enhanced the underlying log management process by automatically processing filter settings and updating the logging service configuration to reflect user-defined rules.
    • Added a conditional check to improve the startup process of the logging service.

@coderabbitai

coderabbitai Bot commented Feb 21, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

This pull request introduces a new system log filtering feature. A web interface (SyslogFilter.page) allows users to load, modify, and submit log filter strings. A corresponding PHP script (syslogfilter) processes these settings by constructing rsyslog filtering rules, updates the rsyslog configuration, and restarts the rsyslog service as needed. Additionally, a change in the rsyslog startup script (rc.rsyslogd) adds a conditional check to copy an extra configuration file before starting the daemon.

Changes

File(s) Change Summary
emhttp/plugins/dynamix/SyslogFilter.page New UI page providing a form for inputting syslog filter strings. Loads existing settings from /boot/config/plugins/dynamix/syslog_filter.conf (if available) and submits data via POST to /update.php.
emhttp/plugins/dynamix/scripts/syslogfilter New PHP script that reads the filter configuration file, processes its contents to generate rsyslog filtering rules, updates the rsyslog configuration, and restarts the rsyslog service with error suppressed operations.
etc/rc.d/rc.rsyslogd Updated startup script now performs a conditional check for /boot/default/02-blocklist-extra.conf; if found, it copies the file to /etc/rsyslog.d/ before proceeding to start the rsyslog daemon.

Sequence Diagram(s)

sequenceDiagram
    participant U as User
    participant UI as SyslogFilter.page
    participant UP as /update.php
    participant SF as syslogfilter
    participant RS as rsyslogd

    U->>UI: Load filter settings from config file
    UI->>U: Display syslog filtering form
    U->>UI: Enter filter strings and submit form
    UI->>UP: POST filter settings and parameters
    UP->>SF: Process filter configuration file
    SF->>RS: Update rsyslog configuration with new rules
    SF->>RS: Restart rsyslog service if running
Loading
sequenceDiagram
    participant RC as rc.rsyslogd
    participant FS as File System
    participant RS as rsyslogd

    RC->>FS: Check existence of /boot/default/02-blocklist-extra.conf
    alt File exists
        FS-->>RC: File found
        RC->>FS: Copy file to /etc/rsyslog.d/
    else File not found
        FS-->>RC: File missing
    end
    RC->>RS: Start rsyslog daemon
Loading

Poem

I'm a little rabbit, hopping through the code,
Filtering out the logs, lightening up the load.
With a click and a script, the syslog dance begins,
Every rule in place makes my heart spin grins.
Code paths now are clear, a joyful debug spree,
Hoppin’ over changes—oh, how merry I be! 🐇


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ecce56a and 9c02fbb.

📒 Files selected for processing (2)
  • emhttp/plugins/dynamix/scripts/syslogfilter (1 hunks)
  • etc/rc.d/rc.rsyslogd (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • emhttp/plugins/dynamix/scripts/syslogfilter
  • etc/rc.d/rc.rsyslogd

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 7

🧹 Nitpick comments (2)
emhttp/plugins/dynamix/scripts/syslogfilter (1)

16-18: Consider using constants for file paths.

The script defines several file paths as variables. Consider defining these as constants using define() or const to prevent accidental modification.

-$rsyslog_conf		= "/etc/rsyslog.conf";
-$file				= "/boot/config/plugins/dynamix/syslog_filter.conf";
-$filter_file		= "/boot/default/02-blocklist-extra.conf";
+define('RSYSLOG_CONF', '/etc/rsyslog.conf');
+define('FILTER_CONFIG', '/boot/config/plugins/dynamix/syslog_filter.conf');
+define('FILTER_FILE', '/boot/default/02-blocklist-extra.conf');
emhttp/plugins/dynamix/SyslogFilter.page (1)

48-51: Add confirmation dialog for Apply action.

Consider adding a confirmation dialog before applying changes to prevent accidental modifications.

-			<input type="submit" value="_(Apply)_"><input type="button" value="_(Done)_" onclick="done()">
+			<input type="submit" value="_(Apply)_" onclick="return confirm('Are you sure you want to apply these filter changes?')">
+			<input type="button" value="_(Reset)_" onclick="this.form.reset()">
+			<input type="button" value="_(Done)_" onclick="done()">
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 57079c2 and e36a226.

⛔ Files ignored due to path filters (1)
  • emhttp/plugins/dynamix/icons/systemlogfilter.png is excluded by !**/*.png
📒 Files selected for processing (3)
  • emhttp/plugins/dynamix/SyslogFilter.page (1 hunks)
  • emhttp/plugins/dynamix/scripts/syslogfilter (1 hunks)
  • etc/rc.d/rc.rsyslogd (1 hunks)

Comment thread emhttp/plugins/dynamix/scripts/syslogfilter
Comment thread emhttp/plugins/dynamix/scripts/syslogfilter
Comment thread emhttp/plugins/dynamix/scripts/syslogfilter
Comment thread emhttp/plugins/dynamix/scripts/syslogfilter Outdated
Comment thread emhttp/plugins/dynamix/SyslogFilter.page
Comment thread emhttp/plugins/dynamix/SyslogFilter.page
Comment thread etc/rc.d/rc.rsyslogd
@dlandon dlandon closed this Mar 25, 2025
@dlandon dlandon deleted the add_syslog_filter_feature branch March 25, 2025 11:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant