def unicast_packets(argv, community="public"): """Display a set of strip charts, one for each set of parameters in argv. The set is a "host interface" pair. For example: device1 2 device2 4 """ win = gtk.Window(gtk.WINDOW_TOPLEVEL) win.set_title("Unicast Packets") vbox = gtk.VBox() vbox.show() win.add(vbox) sessions = {} while argv: host = argv.pop(0) ifindex = int(argv.pop(0)) if host in sessions: sess = sessions[host] else: sess = SNMP.get_session(host, community) sessions[host] = sess graph = rtgraph.HScrollLineGraph( scrollRate=2, pollInterval=1000, size=(384, 128), gridSize=32, channels=[ SNMPChannel(sess, IF_MIB.ifInUcastPkts, ifindex, color=(1, 0, 0)), SNMPChannel(sess, IF_MIB.ifOutUcastPkts, ifindex, color=(0, 1, 0)) ], bgColor=(0, 0, 0.3), gridColor=(0, 0, 0.5), range=(0, 19), ) graph.show() frame = gtk.Frame() frame.set_label("device %s ifindex %s" % (host, ifindex)) frame.add(graph) frame.show() vbox.pack_end(frame) del sessions win.show() win.connect("destroy", gtk.main_quit) gtk.main()
def unicast_packets(argv, community="public"): """Display a set of strip charts, one for each set of parameters in argv. The set is a "host interface" pair. For example: device1 2 device2 4 """ win = gtk.Window(gtk.WINDOW_TOPLEVEL) win.set_title("Unicast Packets") vbox = gtk.VBox() vbox.show() win.add(vbox) sessions = {} while argv: host = argv.pop(0) ifindex = int(argv.pop(0)) if host in sessions: sess = sessions[host] else: sess = SNMP.get_session(host, community) sessions[host] = sess graph = rtgraph.HScrollLineGraph( scrollRate = 2, pollInterval = 1000, size = (384,128), gridSize = 32, channels = [SNMPChannel(sess, IF_MIB.ifInUcastPkts, ifindex, color=(1,0,0)), SNMPChannel(sess, IF_MIB.ifOutUcastPkts, ifindex, color=(0,1,0))], bgColor = (0, 0, 0.3), gridColor = (0, 0, 0.5), range = (0, 19), ) graph.show() frame = gtk.Frame() frame.set_label("device %s ifindex %s" % (host, ifindex)) frame.add(graph) frame.show() vbox.pack_end(frame) del sessions win.show() win.connect("destroy", gtk.main_quit) gtk.main()
def get_manager(host, community): box = SNMP.get_session(host, community) device = DiscoverManager(box) device.add_mibs([SNMPv2_MIB, IF_MIB, IP_MIB, RFC1213_MIB]) device.add_mibs([CDP_MIB, LLDP_MIB]) return device
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. """ Demo SNMP API. Supply a host and community on the command line. """ import sys from pycopia.SNMP import SNMP # common code - get an SNMP session object. host = sys.argv[1] community = sys.argv[2] box = SNMP.get_session(host, community) # bug here... must import Python mibs so that OIDMAP gets created. from pycopia.mibs import SNMPv2_MIB from pycopia.mibs import IF_MIB print "Direct OID list method:" print box.get([1, 3, 6, 1, 2, 1, 1, 5, 0]) # get OID from some other source print print "MIB node and raw SNMP method:" try: from pycopia.SMI import SMI except ImportError, err: print err print "you need libsmi and the libsmi wrappers installed for this demo."
# See the License for the specific language governing permissions and # limitations under the License. """ Demo SNMP API. Supply a host and community on the command line. """ import sys from pycopia.SNMP import SNMP # common code - get an SNMP session object. host = sys.argv[1] ; community = sys.argv[2] box = SNMP.get_session(host, community) # bug here... must import Python mibs so that OIDMAP gets created. from pycopia.mibs import SNMPv2_MIB from pycopia.mibs import IF_MIB print "Direct OID list method:" print box.get([1, 3, 6, 1, 2, 1, 1, 5, 0]) # get OID from some other source print print "MIB node and raw SNMP method:" try: from pycopia.SMI import SMI except ImportError, err: print err print "you need libsmi and the libsmi wrappers installed for this demo."
def get_manager(host, community): box = SNMP.get_session(host, community) device = DiscoverManager(box) device.add_mibs([SNMPv2_MIB, IF_MIB, IP_MIB, RFC1213_MIB]) device.add_mibs([CDP_MIB, LLDP_MIB]) return device