Skip to content

Instantly share code, notes, and snippets.

@aewallin
Created April 6, 2018 10:40
Show Gist options
  • Save aewallin/e6e1f75f105fd1f694c0ab13171f7a5b to your computer and use it in GitHub Desktop.
Save aewallin/e6e1f75f105fd1f694c0ab13171f7a5b to your computer and use it in GitHub Desktop.
White Rabbit Switch SNMP monitoring example
from snmp_helper import snmp_get_oid, snmp_extract
import numpy
# WR-switch management port, fixed ip for delpoyment
ip='192.168.0.10'
# SNMP parameters
community = 'public'
port = 161
device = (ip, community, port)
wrsPtpClockOffsetPs = 'iso.3.6.1.4.1.96.100.7.5.1.10.1'
wrsPtpRTT = 'iso.3.6.1.4.1.96.100.7.5.1.13.1'
wrsPtpServoUpdates = 'iso.3.6.1.4.1.96.100.7.5.1.15.1'
def get_oid(oid):
"""
get a specific OID from the switch, return as int
"""
data = snmp_get_oid( device, oid= oid, display_errors=True)
return int( snmp_extract(data) )
def wrs_data():
"""
get the round-trip-time and the uptime
"""
return "%d %d" % (get_oid(wrsPtpRTT), get_oid(wrsPtpServoUpdates) )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment