Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alessandromaggio/quicksnmp
A simple way to use SNMP in your Python Scripts
https://github.com/alessandromaggio/quicksnmp
Last synced: about 2 months ago
JSON representation
A simple way to use SNMP in your Python Scripts
- Host: GitHub
- URL: https://github.com/alessandromaggio/quicksnmp
- Owner: alessandromaggio
- License: mit
- Created: 2018-05-18T10:32:04.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-05-18T10:40:41.000Z (over 6 years ago)
- Last Synced: 2024-07-27T16:45:16.780Z (about 2 months ago)
- Language: Python
- Size: 2.93 KB
- Stars: 22
- Watchers: 3
- Forks: 9
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Quick SNMP (quicksnmp)
A simple way to use SNMP in your Python Scripts. Requires PySNMP.This is not a python module, but just a script. With it, you can implement SNMP in your python scripts rapidly. Just copy this file into your project and use it as needed. *QuickSNMP is for quick scripts, don't use it in an application!*
```python
from pysnmp import hlapi
from . import quicksnmp# Using SNMPv2c, we set the hostname of the remote device to 'SNMPHost'
quicksnmp.set('10.0.0.1', {'1.3.6.1.2.1.1.5.0': 'SNMPHost'}, hlapi.CommunityData('ICTSHORE'))# Using SNMPv2c, we retrieve the hostname of the remote device
print(get('10.0.0.1', ['1.3.6.1.2.1.1.5.0'], hlapi.CommunityData('ICTSHORE')))# We get interface name and Cisco interface description for all interfaces
# The last parameter is the OID containing the number of interfaces, so we can loop 'em all!
its = get_bulk_auto('10.0.0.1', [
'1.3.6.1.2.1.2.2.1.2 ',
'1.3.6.1.2.1.31.1.1.1.18'
], hlapi.CommunityData('ICTSHORE'), '1.3.6.1.2.1.2.1.0')
# We print the results in format OID=value
for it in its:
for k, v in it.items():
print("{0}={1}".format(k, v))
# We leave a blank line between the output of each interface
print('')
```