Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'/junos/events' sensor path does not work in subscribe2() #106

Open
Menotomy opened this issue Nov 29, 2022 · 1 comment
Open

'/junos/events' sensor path does not work in subscribe2() #106

Menotomy opened this issue Nov 29, 2022 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@Menotomy
Copy link

Menotomy commented Nov 29, 2022

Hello,

I'm encountering an issue where '/junos/events' sensor path does not work with the subscribe2() function, even though it does with subscribe(). This is a Juniper specific sensor path on Junos 21.4R3-Evo. Other OpenConfig sensor paths work (although they are using "once" method, not "on_change"). I included an example when using the older subscribe() function which I understand will be deprecated. I am currently using pygnmi 0.8.5 as later versions include the qos feature which doesn't work in this Juniper code version, I'm waiting for a later pygnmi release that includes pull request #103.

I added debug=True when using subscribe2() but I get TypeError: argument of type 'NoneType' is not iterable. I don't think it would be much use though as when using subscribe2() you can't use telemetryParser() which is what displays the gNMI Response when debugging is enabled.

Example output with subscribe and json encoding

There are dozens of these being sent in just a few seconds, so I just picked one random one but they're all the same format.

update {
  timestamp: 1669763789626942414
  prefix {
    elem {
      name: "junos"
    }
    elem {
      name: "events"
    }
    elem {
      name: "event"
      key {
        key: "facility"
        value: "3"
      }
      key {
        key: "id"
        value: "SYSTEM"
      }
      key {
        key: "type"
        value: "3"
      }
    }
  }
  update {
    path {
      elem {
        name: "logoptions"
      }
    }
    val {
      int_val: 1
    }
  }
}
extension {
  registered_ext {
    id: 1
    msg: "\n\021HOSTNAME\020\377\377\003\"\013sensor_1000*\016/junos/events/2\016/junos/events/:\021re0/master-eventd@JH\273\346\265\255\3140P\272\346\265\255\3140`\273\346\265\255\3140x\273\346\265\255\3140\200\001\001"
  }
}

pip freeze

cffi==1.14.5
cryptography==3.4.7
dictdiffer==0.9.0
grpcio==1.38.1
grpcio-tools==1.38.1
kthread==0.2.2
pkg_resources==0.0.0
protobuf==3.17.3
pycparser==2.20
pygnmi==0.8.5
python-dotenv==0.20.0
six==1.16.0

Code

Note that the code below is subscribe2() and does not show any data. To get it to show data, I just need to remove the 2 so it's using subscribe(). Example:
telemetry_pull = gc.subscribe2(subscribe=subscribe)

#!/usr/bin/env python3

import grpc
from pygnmi.client import gNMIclient, telemetryParser
import json
from dotenv import load_dotenv
import os

ip='[omitted]'
port='32767'
load_dotenv()
username=os.getenv('TEST_USER')
password=os.getenv('TEST_PW')

sensor_path = '/junos/events'

subscribe = {
    'subscription': [
        {
            'path': f'{sensor_path}',
            'mode': 'ON_CHANGE'
        }
    ],
    'use_aliases': False,
    'mode': 'stream',
    'encoding': 'json'
}

def pull_telemetry_sub(ip, port, username, password, subscribe):
    try:
        with gNMIclient(target=(ip, port), username=username, password=password, insecure=True) as gc:
            telemetry_pull = gc.subscribe2(subscribe=subscribe)
            for telemetry_entry in telemetry_pull:
                print(telemetry_entry)

    except grpc.FutureTimeoutError as e:
        print('Failed connecting to', ip, e)

    except ValueError as e:
        print(e)
        pass

def main():
    pull_telemetry_sub(ip, port, username, password, subscribe)

if __name__ == '__main__':
    main()

Thanks,

Chris

@akarneliuk akarneliuk added the bug Something isn't working label Dec 1, 2022
@akarneliuk akarneliuk self-assigned this Dec 1, 2022
@akarneliuk
Copy link
Owner

Hey @Menotomy ,
Thanks for raising that one. I don't have a Juniper to test against, but I shall finally have some time this week to look into this and other requests.
Best,
Anton

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants