• index
  • modules |
  • next |
  • previous |
  • Project home »
  • pyroute2 0.9.1rc1 documentation »

Generic netlink events protocols¶

The only available method for the event sockets is get() -- it returns an iterator over broadcasted messages, following the generic pyroute2 API. Even though the event protocols provide one message per recv().

No manual bind() or discovery() required -- the event sockets run these methods authomatically.

Please keep in mind that you have to consume all the incoming messages in time, otherwise a buffer overflow happens on the socket and the only way to fix that is to close() the failed socket and to open a new one.

ACPI events¶

Monitor and receive ACPI events messages via generic netlink.

from pprint import pprint
from pyroute2 import AcpiEventSocket

acpi = AcpiEventSocket()
for message in acpi.get():
    pprint(message.get('ACPI_GENL_ATTR_EVENT'))
{'bus_id': b'LEN0268:00',
 'data': 1251328,
 'device_class': b'ibm/hotkey',
 'type': 32768}

Disk quota events¶

Disk quota events monitoring:

from pyroute2 import DQuotSocket

with DQuotSocket() as ds:
    for message in ds.get():
        uid = message.get('QUOTA_NL_A_EXCESS_ID')
        major = message.get('QUOTA_NL_A_DEV_MAJOR')
        minor = message.get('QUOTA_NL_A_DEV_MINOR')
        warning = message.get('QUOTA_NL_A_WARNING')
        print(f'quota warning {warning} for uid {uid} on {major}:{minor}')
quota warning 8 for uid 0 on 7:0

Table of Contents

  • Generic netlink events protocols
    • ACPI events
    • Disk quota events

Previous topic

WireGuard module

Next topic

MPLS howto

This Page

  • Show Source

Quick search

Navigation

  • index
  • modules |
  • next |
  • previous |
  • Project home »
  • pyroute2 0.9.1rc1 documentation »
  • Generic netlink events protocols
© Copyright pyroute2 team. Created using Sphinx 6.2.0.