Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

Navigation
Guide That Contains This Content
[+] Expand All
[-] Collapse All

    Alarm Notification and Forwarding APIs

    Alarm notification and forwarding APIs use notification profiles for forwarding events for alarms relating to all categories and severities.

    This topic describes:

    Alarm Notification and Forwarding

    To receive forwarded alarms:

    • Send the following URI to establish the connection to the Network Director server:
      https://<ip-addr>/api/juniper/nd/live-feed/alarms

      where the <ip-addr> is the Web UI address of the corresponding Network Director server.

    • Include the following fields in the HTTP header of the request:
      "Authorization":"Basic authKey = base64.b64encode("<username>:<password>".encode('utf-8')).decode('utf-8')"

      where the <username>/<password> pair is the same as the login credential you use for Network Director UI.

    When an alarm is triggered on the server side, the alarm is forwarded to connected clients immediately. Each alarm is forwarded in JSON format, with the following fields in the body of the alarm:

    Note: Because alarms are forwarded immediately, there is a possibility that multiple identical alarms might be sent over time, depending on how often SNMP notifications on the reported devices are triggered for corresponding events. You must decide how duplicate events are handled or suppressed.

    • "name"

      Name of the forwarded alarm.

    • “category”

      The category of the alarm.

    • “severity”

      The severity of the alarm.

    • “state”

      Current state of the forwarded alarm.

    • “entityId”

      The corresponding entity ID of the forwarded alarm.

    • “source”

      The IP address of the host or device generating the alarm.

    • “creationTime”

      Time when the alarm is created.

    Here is an example of a forwarded alarm:

    {     
            "name":"PowerSupplyFailureAlarm",    
             "catergory":"Chassis",     
             "severity":"CRITICAL",    
             "state":"ACTIVE", 
             "entityId":"10.94.45.171",    
             "source":"10.94.45.171",     
             "creationTime":"Mon Jun 16 22:48:20 UTC 2014" 
    } 

    Here is the simplified version of the sample script that can be used on a client running Python 2.7 to establish a connection to the Network Director API alarm forwarding engine, and print out the corresponding body of incoming alarms when they are forwarded out.

    import base64
    import sys
    from sseclient import SSEClient
    
    '''
    Authentication credential for connecting to the NDAPI forwarding engine.
    '''
    authKey = base64.b64encode("username:password".encode('utf-8')).decode('utf-8')
    headers = {"Authorization":"Basic " + authKey}
    '''
    URL to connect to NDAPI alarm forwarding engine.
    '''
    url = "https://10.20.30.40/api/juniper/nd/live-feed/alarms"
    
    def main():
    
        print("Creating  client" )                      
        kwargs = {}
        kwargs['verify'] = False
        kwargs['headers'] = headers
        '''
        Create alarm forwarding client and connect to the forwarding server using provided credentials and URL.
        '''
        messages = SSEClient(url, **kwargs)
        for msg in messages:
            print msg.data
            
    if __name__ == "__main__":
        sys.exit(main())
    

    Modified: 2016-12-15