steelthunder
steelthunder

Reputation: 438

performing an snmpget in python

I am trying to run a simple snmpget command using python. For example at the CLI I am using the below command. I want to know how to run this in python and store it in a variable.

snmpget -c public -v1 192.168.1.3 1.3.6.1.2.1.2.2.1.10.17

output: iso.3.6.1.2.1.2.2.1.5.17 = Gauge32: 100000000

Upvotes: 0

Views: 1466

Answers (2)

Vinod Sharma
Vinod Sharma

Reputation: 883

Use python subprocess modules check_output function

from subprocess import check_output
out = check_output(["ls", "-l"])
print out

General format: check_output(["cmd", "argument1", "argument2",..."argumentN"])

Upvotes: 2

snow8261
snow8261

Reputation: 1009

I usually do snmpget it in java with snmp4j. In python,there is library called snimpy and SNMP library for Python. There are examples in this post Snimpy: SNMP & Python.

Upvotes: 0

Related Questions