Here’s a couple of different ways you can use netsnmp in Python.
I had a hard time finding documentation, and what I did find was old and outdated. I figured most of it out just by playing around with the library.
#!/usr/bin/env python import netsnmp string = 'public' ver = 1 port = 161 host = '192.168.1.1' # uptime using method 1 bind1 = netsnmp.Varbind('sysUpTime.0') # 1 minute load using method 2 bind2 = netsnmp.Varbind('.188.8.131.52.4.1.2021.10.1.3.1') snmpget = netsnmp.snmpget(bind1, Version=ver, RemotePort=port, DestHost=host, Community=string) uptime_seconds = snmpget print uptime_seconds list = ( bind1, bind2 ) x = netsnmp.Session(DestHost=host, Version=ver, RemotePort=port, Timeout=400000, Retries=5, Community=string) output_list = x.get(list) if not output_list: print "FAILED TO CONNECT!!!" sys.exit(1) if output_list: uptime = output_list if output_list: load1 = output_list
Next I wrote a class to wrap it up as an AWN applet. If you’ve never heard of AWN or haven’t tried the avant-window-navigator you should definitely check it out and consider continuing development on it. It was the best app bar available; very pretty. It fit my needs at the time anyway.
I replaced the bottom gnome-panel with it. If you remove everything except the Launcher/Taskmanager applet and add the Show Desktop applet, it directly replaces gnome-panels functionality completely.