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

Implement SNMP trap reception mechanism #173

Closed
14 tasks done
lunkwill42 opened this issue Mar 11, 2024 · 6 comments
Closed
14 tasks done

Implement SNMP trap reception mechanism #173

lunkwill42 opened this issue Mar 11, 2024 · 6 comments
Assignees
Labels
enhancement New feature or request

Comments

@lunkwill42
Copy link
Member

lunkwill42 commented Mar 11, 2024

Design considerations

Zino 1 uses a trap daemon model taken from Scotty, wherein an SNMP trap multiplexer daemon (straps or nmtrapd) is run as root, and any Scotty program (like Zino) that wants a copy of all received traps can run as unprivileged users and connect to a UNIX socket to receive a stream of the received trap messages.

While this is a really nice model for both debugging and for having multiple small and independent programs that can run on the same machine and react to traps, we don't see this as an essential model to replicate.

In Zino 2, we will instead opt for a model where the Zino program itself will listen for incoming SNMP trap messages (on UDP port 162). This does have the side-effect that the Zino program must be started by root, and needs to be able to switch to a less privileged user immediately after opening the privileged port 162.

A model where Zino connects to a trap message multiplexer can be added later if deemed necessary.

Sub-tasks

@lunkwill42
Copy link
Member Author

The straps SNMP trap multiplexer is described here: https://linuxcertif.com/man/8/straps/ - but I am hard pressed to find the actual package or source code, at the moment...

@lunkwill42
Copy link
Member Author

lunkwill42 commented Mar 13, 2024

Some more digging, and it turns out straps was renamed to nmtrapd in 1996 (!). Source code seems to be available here: https://github.com/flightaware/scotty/blob/23645564467704119dca051b6c8b16a4c56b74af/tnm/unix/nmtrapd.c

The man page source corresponding to the link above is here: https://github.com/flightaware/scotty/blob/23645564467704119dca051b6c8b16a4c56b74af/tnm/doc/nmtrapd.8 . The manpage describes the output format from the multiplexer's UNIX socket; the original SNMP trap packets can be gotten from this, and if PySNMP can be made to process raw packets, Zino 2.0 could be adapted to support both a built-in trap daemon, or fetch data from a multiplexer daemon like nmtrapd.

@lunkwill42
Copy link
Member Author

@he32
Copy link

he32 commented Mar 22, 2024

Design considerations

Zino 1 uses a trap daemon model taken from Scotty, wherein an SNMP trap multiplexer daemon (straps or nmtrapd) is run as root, and any Scotty program (like Zino) that wants a copy of all received traps can run as unprivileged users and connect to a UNIX socket to receive a stream of the received trap messages.

While this is a really nice model for both debugging and for having multiple small and independent programs that can run on the same machine and react to traps, we don't see this as an essential model to replicate.

In Zino 2, we will instead opt for a model where the Zino program itself will listen for incoming SNMP trap messages (on UDP port 162). This does have the side-effect that the Zino program must be started by root, and needs to be able to switch to a less privileged user immediately after opening the privileged port 162.

A model where Zino connects to a trap message multiplexer can be added later if deemed necessary.

Please note that we're already using this multiplexing method actively.
We have a separate SNMP trap listening program running on our main
status monitoring host which takes note of configuration change trap
messages, and appropriately delayed posts messages using curl to our
oxidized instance to pick up the newly modified configuration in a somewhat
timely manner.

The above method means that you can only have a single program listening
for SNMP trap messages on this host, and you need to "burn a new IP address"
for another host and configure all your routers to also send trap messages that
direction if you want to consume SNMP trap messages for more than one single
purpose. I know also that in the past there has been bugs in our preferred router
OS when more than N (where N was 2?) trap recipients were configured.

@lunkwill42
Copy link
Member Author

The above method means that you can only have a single program listening for SNMP trap messages on this host, and you need to "burn a new IP address" for another host and configure all your routers to also send trap messages that direction if you want to consume SNMP trap messages for more than one single purpose. I know also that in the past there has been bugs in our preferred router OS when more than N (where N was 2?) trap recipients were configured.

We definitely understand the advantages, @he32, but we don't want to make Zino 2 immediately depend on this 3rd party software for trap reception as its default implementation. This is why we've made the basic trap daemon from scratch, so that we can concentrate on the actual trap management code - and then down the road, we can add support for a trap multiplexer as an alternative mode of operation. An interesting question in that regard: Could the nmtrapd program be easily forked out of the Scotty codebase without having lots of dependencies back into that codebase? Or must the full Scotty package be compiled to build nmtrapd?

@lunkwill42 lunkwill42 pinned this issue Jul 18, 2024
@lunkwill42 lunkwill42 added enhancement New feature or request and removed discussion labels Aug 27, 2024
@lunkwill42
Copy link
Member Author

All associated sub-tasks have been closed, this can now also be closed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants