What's new

[Beta] ModSyslogUI - seeking code reviewers and beta testers

kstamand

Regular Contributor
Long time user of Auswrt-Merlin and benefactor of numerous addons. First time attempt at contributing back to the community - be kind as I learn to work with Github.
Code reviewer feedback and suggestions requested - https://github.com/kstamand/modsyslogui/tree/v1.0.0-beta1

ModSyslogUI - Customize router's "System Log" page with custom filtering capabilities​

About:​

The default filtering capabilities on the System Log page of the router is limited to hardcoded text strings
in a file called "logFilter.json". This script adds a capability to edit that file to your likings.

This script also updates the System Log page of the Router UI to include dynamic filtering capabilities to:
  • Include all log records, which is the default function, including exclusions noted in logFilter.json
  • Include only log records containing the string or strings of text you chose (separate each by a comma)
    Example - to include all Skynet and Diversion log records only, enter Skynet,Diversion (no spaces after comma)
  • Exlude all log records containing the string or strings of text you chose (separate each by a comma)
    Example - to exlcude all Skynet log records that where blocked, enter the string BLOCKED

This script has been developed under Asuswrt-Merlin 3006.102.6 firmeware and tested on the following routers:
  • RT-BE96U
  • RT-AX88U Pro
  • GT-AX6000

This script DOES NOT equal or replace the functionality that the SCRIBE addon provides.
Instead, it is a simpler lightweight addon that only utilizes the native capabilities of the router.


IT IS NOT RECOMMENDED TO INSTALL THIS SCRIPT AND SCRIBE AT THE SAME TIME. CHOOSE ONE OR THE OTHER

Overview:​

  • Installs script onto router to add filtering capabilities to the routers "System Log" UI page
  • The script provides an interactive manu of options to perform various script maintenance functions
  • Custom System Log filtering capabilities added with this script include:
    1. Hardcoded Filtering - By default, the System Log page filters log records to display based on the contents of a "logFilter.json" file. This script includes an EDIT option that allows you to customize to your liking.
    2. Dynamic Filtering - The System Log page is modifed to allow you to interactively seltect which log records to INCLUDE or EXCLUDE, with the default action of filtering records based on the contents of the logFilter.json file

    Hardcoded Filtering changes are made from an SSH session to the router, and choosing option 5 from the modsyslogui menu

    Install:​

    Requires Asuswrt-Merlin, JFFS enabled, and entware installed via AMTM

    SSH to the router and enter:

    Code:
    /usr/sbin/curl --retry 3 "https://raw.githubusercontent.com/kstamand/modsyslogui/master/modsyslogui" -o "/tmp/modsyslogui" && chmod +x /tmp/modsyslogui && sh /tmp/modsyslogui install

    Configuration:​

    No configuration is required, unless you want to edit the default contents of the "logFilter.json" file --> option 5 from the modsyslogui menu.

    The default contents of the logFilter.json file are:
    Code:
          {
             "filter": [
             "already exist in UDB, can't add it",
             "not mesh client, can't update it's ip",
             "not exist in UDB, can't update it",
             "send_redir_page"
             ]
          }

    To edit this file, add one line for each string from a given log record you want to exclude assocated log records from being displayed
    - string needs to be enclosed in quotes ("")
    - each line, except the last line of the list of filtering strings, must end in a comma (,)

    Example custimized logFilter.json file, to exclude all wireless events ("wlceventd"), Diversion records ("Diversion:"), and Skynet BLOCKED records ("BLOCKED"):
    Code:
            {
            "filter": [
               "already exist in UDB, can't add it",
               "not mesh client, can't update it's ip",
               "not exist in UDB, can't update it",
               "send_redir_page",
               "wlceventd",
               "Diversion:",
               "BLOCKED"
               ]
            }

    TIPS
    ALL System log records, generally start with a script function name. Examples;
    • The majority of ADDON script contributors prefix their log records with the name of their script (e.g., Diversion, Skynet, Scribe, ...)
    • Other than that, scan log records for unique strings from a given record to inlude / exclude, such as
      - wireless events (leaving or joining) = wlcevented
      - ethernet connected devices powering on or shutting down (entering listening | learning | forwarding state)
      - specific addon scripts (e.g., log records starting with modsyslogui)

    Command line usage:​

    Once installed, from a terminal ssh session into the router, enter the command modsyslogui and choose from one of the menu options:

    1767185720195.png


    To skip displaying the menu, you can run select options directly by running modsyslogui with one of the following parameters;
    Code:
        - modsyslogui install
        - modsyslogui update
        - modsyslogui enable
        - modsyslogui disable
        - modsyslogui uninstall

    System Log page usage:​

    The System Log page is customized by this script to add a dynamic **Log Filtering Option** box, where you have three options:
    1. Show all log records (default option) - nothing need be entered in the dialog box under the three options. All system log records are displayed, minus those log records matching one of the strings in the logFilter.json file
    2. Include only - enter a string or series of strings separated by a comma, with no spaces, to only show log records matching the string(s)
    3. Exclude containing - enter a string or series of strings separated by a comma, with no spaces, to exclude log records matching the string(s)

    1767185843414.png
 
Finally a new script that is already amtm compatible during beta. And it looks to be useful.
Just remember @kstamand , when logging is enabled in Diversion, the Dnsmasq output goes to /opt/var/log/dnsmasq.log, not the SysLog.
 
Last edited:
Does it just filter the data in UI or also prevent the records being actually written to /jffs/syslog.log?
It only filters log records from displaying in the UI, no filtering or changes are applied to syslog.log itself.

Let me know if you have any other questions or if you have any suggestion on updated wording to use in the original posting of this thread to make this clearer
 
Last edited:
it is a simpler lightweight addon that only utilizes the native capabilities of the router.
Really like the concept here. Thank you!

Initially I though it wasn't working, but it just needed a moment.
Could it eventually support Boolean uppercase delimiters e.g. Error AND Get (I tried it but it did not seem to.. yet :-)).

Trial.jpg
 
Really like the concept here. Thank you!

Initially I though it wasn't working, but it just needed a moment.
Could it eventually support Boolean uppercase delimiters e.g. Error AND Get (I tried it but it did not seem to.. yet :-)).

View attachment 69786
Glad to hear you find it useful.

Regarding adding boolean capabilities, most definitely. First I'd like to get through the beta and see if there are any other feature requests / bugs to clean up.

Thanks for the feedback!!
 
@kstamand Just an academic question; Is it possible to remove the dependency on Entware and a USB drive? In other words have it run entirely standalone from /jffs.
Hmmm. I hadn't thought about that ... do you happen to know if would that prevent the script from being added to AMTM, if it gains enough interest or is that a question for @thelonelycoder?
 
I don't see why that would exclude it from amtm. amtm itself runs entirely from jffs as did some of the third party addons in the past, e.g. Skynet.

I'm guessing that your code isn't constantly writing to storage while it's working?

Like I said, it's only an academic question for me. But as a general principle I try to avoid introducing any unnecessary dependencies if possible.
 
Hmmm. I hadn't thought about that ... do you happen to know if would that prevent the script from being added to AMTM, if it gains enough interest or is that a question for @thelonelycoder?
Let me put your mind to rest, I have your script on radar.
 
Hmmm. I hadn't thought about that ... do you happen to know if would that prevent the script from being added to AMTM, if it gains enough interest or is that a question for @thelonelycoder?

MerlinAU as an example does not require USB or Entware and is apart of AMTM. Along with others.

Entware and USB dependencies is usually only if the script requires it but would not impact integration with AMTM.
 
Seeking assistance in trying to add Boolean logic support as @jksmurf asked in post #5 above.

- Can boolean search criteria (e.g., Get AND error) entered in a form input field be used "as-is" (meaning without any parsing/reconstruction) in a javascript .find or .includes method to filter the log records? If yes, can anyone point me to a working example?

- If the form input field can't be used 'as-is", is there another approach I can use other than using the split(" ") method into unique fields (e.g., string1, boolean_operator, string2), followed by some if then logic on the boolean_operator to build the appropriate .find or .includes method to filter the log records? If yes, kindly point me to some working examples for reference?

Thanks in advance
 
Seeking assistance in trying to add Boolean logic support as @jksmurf asked in post #5 above.

- Can boolean search criteria (e.g., Get AND error) entered in a form input field be used "as-is" (meaning without any parsing/reconstruction) in a javascript .find or .includes method to filter the log records? If yes, can anyone point me to a working example?

- If the form input field can't be used 'as-is", is there another approach I can use other than using the split(" ") method into unique fields (e.g., string1, boolean_operator, string2), followed by some if then logic on the boolean_operator to build the appropriate .find or .includes method to filter the log records? If yes, kindly point me to some working examples for reference?

Thanks in advance
My initial suggestion would be to first clearly define the syntax that the input field will accept as valid entries.

1) Define the keywords to be used as valid boolean operators.
Examples: all upper cases OR, AND, NOT (??).​

2) Define the basic syntax of the boolean expressions that the input field will accept as valid.
Examples:​
"string01" OR "string02"
"string01" AND "string02"
"string01" AND NOT "string02"

3) Define if the input field will accept compound boolean expressions.
Examples:​
"string01" OR "string02" OR "string03" OR "string04"
"string01" AND "string02" AND "string03" AND "string04"
"string01" AND "string02" AND "string03" AND NOT "string04"
("string01" AND "string02") OR ("string03" AND "string04")

Once you have settled on the valid syntax and grammar rules, those will dictate how you implement the code.

But in any case, accepting the input field "as is" "(meaning without any parsing/reconstruction)" is not really feasible or recommended because you will always need to parse the input strings anyway; first, just to check they contain a valid syntax for a boolean expression; and second, to "sanitize" the string values before feeding them to the appropriate JavaScript functions that will perform the logical operations.

Just my 2 cents.
 

Similar threads

Latest threads

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Back
Top