Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

 
 

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.

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.

Table 1: Junos Event Topics

Events

Topic

Event Information Returned

Physical Interface (IFD)

  • /junos/events/kernel/interfaces/ifd/add/ifdname

  • /junos/events/kernel/interfaces/ifd/change/ifdname

  • /junos/events/kernel/interfaces/ifd/delete/ifdname

name, snmp-id, flags

Logical Inteface (IFL)

  • /junos/events/kernel/interfaces/ifl/add/iflname

  • /junos/events/kernel/interfaces/ifl/change/iflname

  • /junos/events/kernel/interfaces/ifl/delete/iflname

name, subunit, snmp-id, flags

Family (IFF)

  • /junos/events/kernel/interfaces/iff/add/iflname/family-type

  • /junos/events/kernel/interfaces/iff/change/iflname/family-type

  • /junos/events/kernel/interfaces/iff/delete/iflname/family-type

name, subunit, family, table-name, flags

Address

  • /junos/events/kernel/interfaces/ifa/add/iflname/family-type/address

  • /junos/events/kernel/interfaces/ifa/change/iflname/family-type/address

  • /junos/events/kernel/interfaces/ifa/delete/iflname/family-type/address

name, subunit, family, local-address, destination-address, broadcast-address, flags

Firewall

  • /junos/events/kernel/firewall/filter/add/filtername

  • /junos/events/kernel/firewall/filter/change/filtername

  • /junos/events/kernel/firewall/filter/delete/filtername

name, version, client-id, filter-type, protocol, interface-name, flags

Route

  • /junos/events/kernel/route/add/family/prefix-with-length

  • /junos/events/kernel/route/change/family/prefix-with-length

  • /junos/events/kernel/route/delete/family/prefix-with-length

table-name, logical-router-name, address-family, route-type, route-prefix, arrayof(nexthop-address), flags

Route-table

  • /junos/events/kernel/route-table/add/tablename/lrname

  • /junos/events/kernel/route-table/change/tablename/lrname

  • /junos/events/kernel/route-table/delete/tablename/lrname

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.

Table 2: MQTT Libraries by Language

Language Name

License Link

C, Mosquitto

FreeBSD

C++, Mosquitto

FreeBSD

Python, Mosquitto

FreeBSD

Ruby, Ruby-mqtt

MIT License

Java, Eclipse Paho Java

Eclipse Public License

Go, Eclipse Paho Go

Eclipse Public License

C#, MqttDotNet

Custom License