Notification health events¶
The notification health event stream is process-wide. It reports notification queue pressure, dropped notifications, recovery, incomplete notifications, malformed notification stream data, and consumer wait timeouts.
Reading health events¶
import asyncio
import pyNetX
async def monitor():
while True:
event = await pyNetX.next_notification_event_async(timeout_ms=-1)
print(event.as_dict())
asyncio.run(monitor())
Synchronous helper:
event = pyNetX.next_notification_event(timeout_ms=1000)
print(event.as_dict())
Timeout behavior¶
timeout_ms=-1 waits indefinitely.
timeout_ms=0 returns immediately if no event is available.
Invalid negative values other than -1 raise an error.
If no event is available before the requested timeout, pyNetX returns a timeout event with:
{
"valid": False,
"type": "timeout",
"label": "None",
"message": "No notification health event available before timeout",
}
Timeout events are generated by the global event bus, not by a specific
NetconfClient, so their label is "None".
Event schema¶
NotificationHealthEvent exposes readonly fields:
Field |
Type |
Meaning |
|---|---|---|
|
|
|
|
|
Event type such as |
|
|
UTC ISO-8601 timestamp with millisecond precision, for example |
|
|
User-provided device label from |
|
|
Device hostname/IP when available. |
|
|
Device NETCONF port when available. |
|
|
Notification socket file descriptor when available. |
|
|
Human-readable message. |
|
|
Queue size at event creation time. |
|
|
Configured max queue size. |
|
|
Highest queue depth observed by the client. |
|
|
Total notifications successfully enqueued. |
|
|
Total notifications dropped because the queue was full. |
|
|
Drop delta represented by this event. |
|
|
Number of incomplete notifications observed. |
|
|
Partial or malformed notification bytes involved in a diagnostic event. |
|
|
Number of health events dropped by the bounded global event bus. |
event.as_dict() returns the same schema as a Python dictionary.
Event types¶
Event type |
Meaning |
|---|---|
|
A bounded queue first became full and pyNetX dropped a notification. |
|
Additional notifications were dropped while the queue remained full. |
|
A previously full queue has free capacity again. |
|
A partial notification did not receive the NETCONF EOM marker before a guard fired. |
|
No health event was available before the requested wait timeout. |
Production guidance¶
Use
labelto map events to inventory names, not just IP addresses.Run one or a small number of event monitor tasks per process.
Size
set_threadpool_size(n)with long-livednext_notification_event_async(timeout_ms=-1)consumers in mind.Monitor
notifications_dropped_queue_fullandhealth_events_dropped.Use bounded notification queues when memory limits are more important than lossless delivery.