JET Notification API
The JET Notification API allows you to subscribe to events and designate a callback function to receive events when they occur. These Python interfaces provide an interface to the MQTT notification system that, for languages other than Python, must be handled outside of JET (see Programming JET Notification for Non-Python Languages). For details about MQTT and Python, see https://mosquitto.org/ .
JSON Format of JET Notification Messages
JET notification is delivered in JSON format. The JSON message has two parts: the header and the attributes. The header is common for all events. It contains the event ID, hostname, time, severity, and facility of the event. The attributes contain information about the event and vary depending event’s topic name.
All kernel rtsock events will have info
as the severity and KERNEL
as the facility.
For syslog events, the severity and facility will be same as that
of the Junos OS syslog messages.
The following is an example event JSON file.
“jet-event”: { “event-id”: “KERNEL_EVENT_IFD_ADD” “hostname”: “mydevice”, “time”: “2016-01-07”, “severity”: “info”, “facility”: “KERNEL”, “attributes”: { “name”: “ge-0/0/0”, “snmp-id”: 520, “flags”: 8 } }
See Package JET Applications for more information about JSON.
Subscribing to Events
Applications developed using JET can subscribe to the events listed in Table 1. A topic is an endpoint to which the clients connect. A topic acts as the central distribution hub for publishing and subscribing messages. Topics are simple, hierarchical strings, encoded in UTF-8, delimited by a forward slash.
Events |
Topic |
Event Information Returned |
---|---|---|
Physical Interface (IFD) |
|
name, snmp-id, flags |
Logical Inteface (IFL) |
|
name, subunit, snmp-id, flags |
Family (IFF) |
|
name, subunit, family, table-name, flags |
Address |
|
name, subunit, family, local-address, destination-address, broadcast-address, flags |
Firewall |
|
name, version, client-id, filter-type, protocol, interface-name, flags |
Route |
|
table-name, logical-router-name, address-family, route-type, route-prefix, arrayof(nexthop-address), flags |
Route-table |
|
name, logical-router-name, address-family, flags |
Syslog |
/junos/events/syslog/event-id |
arrayof(attribute-value pairs) |
Programming JET Notification for Non-Python Languages
Many of high-level languages have an MQTT library available. A JET application can use the corresponding library to connect to the MQTT broker running on Junos OS and subscribe to events. For example, here is a sample JAVA program connecting to an MQTT broker and subscribing to events: Example MQTT Messaging in Java.
For details on example MQTT libraries for different languages, see Table 2.
Language Name |
License Link |
---|---|
C, Mosquitto |
|
C++, Mosquitto |
|
Python, Mosquitto |
|
Ruby, Ruby-mqtt |
|
Java, Eclipse Paho Java |
|
Go, Eclipse Paho Go |
|
C#, MqttDotNet |