# 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