Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend RFC3164 parser to support Cisco iOS logs #22

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

alistairking
Copy link

These devices seem to send non-standard logs that include a sequence number, and a couple of extra characters (for good luck, I assume).

For example:

    10.51.101.233.50433 > 10.51.101.164.514: SYSLOG, length: 112 Facility local7 (23), Severity notice (5)
        Msg: 485: *Jan  8 21:50:03.406: %LINEPROTO-5-UPDOWN: Line protocol on Interface Loopback100, changed state to up

Note the 485: * here. This is the sequence number (and a * -- no idea).

It also includes a ms-precision timestamp.

This is the first time I've ever written ragel code (first time I've even heard of it), so there's a pretty good chance that I got something wrong, or sub-optimal. I'm happy to make changes as you see fit.

These devices seem to send non-standard logs that include a sequence
number, and a couple of extra characters (for good luck, I assume).

For example:
```
    10.51.101.233.50433 > 10.51.101.164.514: SYSLOG, length: 112 Facility local7 (23), Severity notice (5)
        Msg: 485: *Jan  8 21:50:03.406: %LINEPROTO-5-UPDOWN: Line protocol on Interface Loopback100, changed state to up
```

Note the `485: *` here. This is the sequence number (and a `*` -- no
idea).

It also includes a ms-precision timestamp.
@leodido leodido self-requested a review January 25, 2025 16:06
Copy link
Owner

@leodido leodido left a comment

Choose a reason for hiding this comment

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

Thank you for your contribution!

Aside from the test errors (we'll focus on those later),

I think these sequence changes (not in the RFC3164 AFAIK) should be hidden behind a machine option.

Meaning, I would like to have a WithSequence() or WithCiscoSequence() machine option to expressly change the behavior of the parsing machine.

Can you please iterate on this? 🙏

@leodido
Copy link
Owner

leodido commented Jan 25, 2025

Another thing I'm noticing now is...

Where is the priority part in the example message you reported?

Msg: 485: *Jan  8 21:50:03.406: %LINEPROTO-5-UPDOWN: Line protocol on Interface Loopback100, changed state to up

I never saw (not that I remember) a Syslog message like this one...
It seems to be missing the priority (eg., <13>) part (which is mandatory in RFC3164)

Shouldn't it be something like the following one?

Msg: <13> 485: *Jan  8 21:50:03.406: %LINEPROTO-5-UPDOWN: Line protocol on Interface Loopback100, changed state to up

@alistairking
Copy link
Author

That seems reasonable. 4b1f2a2 makes this sequence parsing optional. I had to update the test structure a bit to allow options to be passed in -- let me know if you think there's a better way.

As for the missing priority, I think that's because I pasted output from tcpdump which itself parses the priority into facility and severity:

    10.51.101.233.50433 > 10.51.101.164.514: SYSLOG, length: 112 Facility local7 (23), Severity notice (5)

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.

2 participants