Python SNMP Tester v2

Reading Time: 2 minutes

I had started this some years back and never finished it. I was sifting through my old storage on my NAS and came across it. It’s initial start was at a company that did consulting and each environment was different. Naturally it needed to be converted from Python 2 to Python 3 due to Apples upgrade to Python 3. I figured last weekend, being bored in nonsense heat and humidity, why not convert it and try and get it to a functional nearly finished app? (I say nearly finished because there are things I want to re-write and tweak but it’s none-the-less functional).

So I did just that. One thing to keep in mind is that I have no formal training in Python programming let alone creating a GUI. So I went down that winding road of rabbit holes and tornado’s with a goal. Create a working GUI for the snmpget command on Mac to allow quick testing of read and write functionality of a Cisco devices SNMP configuration. Why a GUI? Simple! So I could launch it and not have to memorize all the different command switches to run a quick test and also quickly adjust the settings and values of those switches and just click a button.

After the initial conversion of the old app I remembered I never finished it. I had only started and had it set to run SNMP v2c and v3 authPriv. This starts down the rabbit hole (and included tornado’s of chaos) of getting the v3 noAuthNoPriv and authNoPriv. This was an adventure in getting the logic to work. Also, the logic is a part I want to clean up eventually as again I was piecing this together with all sorts of searches and demo codes pieced together so I know it can be much cleaner but oh well, it works.

Then, I decided I really didn’t like the way the results were being displayed. Back in the original I had the results display in a hidden entry field that would move into place after the Test Read or Test Write button was clicked. I didn’t like that anymore and decided to figure out how to make a pop up box appear with the results. After some trial and error that was working. I then thought “wouldn’t it be nice to have a copy to clipboard button” so you could copy the results for storing and documenting.

This all came with the adventure of trying to piece together code examples into something functional I wanted including but not limited to things such as installing packages, upgrading net-snmp which includes the snmpget command. Installing Tkinter for the GUI aspect. Then running through all the python code of reading inputs (RadioButtons, Entry Fields, obtaining output from the os command initiated, etc).

All in all, the short story is, if you understand the logic idea of programming and can piece an idea together, even without formal training you can get your idea to happen. First off it was fun to go down my rabbit hole. I got to leverage my knowledge of SNMP on Cisco devices, and dig and learn things I didn’t know how to do. I’ve attached a demo video of it below. Still more work to do but it functions and was a fun accomplishment. Keep on pushing all. We are never to old to learn, or use what’s at our fingertips to do and make better!

*Note, intentional mistakes were made in authentication to show how a blank return is issued if values are mistyped.


Share this article:

Permanent link to this article: https://www.packetpilot.com/python-snmp-tester-v2/

Leave a Reply

Your email address will not be published.