This plugin utilizes the Netlink library to monitor network interface up/down status. Current configuration options include:
- Interface: A network interface to monitor for status changes.
If no interfaces are configured, then all interfaces will be monitored. While running, two threads are used:
- The main read thread, to read semaphore-protected shared memory.
- A blocking listening thread that waits for interface status messages on a Netlink socket.
A linked list of interface name and status combinations is stored in shared memory. The Netlink-listening thread waits for incoming messages and either:
- Ignores the message if it doesn't pertain to a monitored interface.
- If the interface is monitored and the name is not already in the linked list, adds the interface name and status to the aforementioned list.
- If the interface is monitored and the name is already in the linked list, updates the status for the corresponding entry.
Whenever a monitored interface's status changes, the corresponding entry is flagged as unsent. The read thread wakes at the plugin interval and loops through the linked list of interface names and statuses. Any unsent status change is dispatched via a notification, and the interface status is then marked as sent.