An opensource library to use SNMP get/bulk/set/walk in Python

Related tags

NetworkingSNMP-UTILS
Overview

SNMP-UTILS

heart foryou license

An opensource library to use SNMP get/bulk/set/walk in Python

Features

OIDS List

Change PATH_TO_LIST to your OIDS list if you want to use it.

Example for OIDS.json

{
    "system": {
        "name": "1.3.6.1.2.1.1.5",
        "uptime": "1.3.6.1.2.1.1.3",
        "mac_address": "1.3.6.1.2.1.2.2.1.6",
        "temperature": "1.3.6.1.4.1.6296.9.1.1.2.5.1.3"
    }
}

When constructor SnmpUtils() is called, the method defineOIDsList() is automaticaly called. So you can use the list like this:

switch = SnmpUtils("10.0.0.1")
print(switch.oids.system.name) #return 1.3.6.1.2.1.1.5

GET

GET SNMP Command return the value of a specific OID.
get(oid)

switch = SnmpUtils("10.0.0.1")
switch_name = switch.get(switch.oids.system.name)

You can also use getByID(oid, id) which returns the value of the inferior OID.

switch = SnmpUtils("10.0.0.1")
switch_interface_3_description = switch.getByID(switch.oids.interfaces.description, 3) # return the description of the third interface

SET

SET SNMP is use for set value of a specific OID.
set(oid, value)

switch = SnmpUtils("10.0.0.1")
switch_name = switch.set(switch.oids.system.name, "Test")

WALK

WALK SNMP Command return a dict of all values of inferiors OIDs.
walk(oid, numberOfIterations, dotPrefix)

You can specify the number of value do you want in second parameter. dotPrefix is used for add . in front of OID.

switch = SnmpUtils("10.0.0.1")
switch_10_interfaces_description = switch.walk(switch.oids.interfaces.description, 10) # return a dict with key/value
for k,v in switch_10_interfaces_description.items():
    print(k,v)

BULK

BULK SNMP returns all following items up to a limit for an/several item(s).
bulk(*oids_list)

switch = SnmpUtils("10.0.0.1")
switch_interfaces_description = switch.bulk(switch.oids.interfaces.description) #return a dict with description for all interfaces

CHECK

You can easily check if a device is online
isConnected()

switch = ("10.0.0.1")
if switch.isConnected():
    print("Switch online")

Dependencies

Contributors

You might also like...
A simple, configurable application and set of services to monitor multiple raspberry pi's on a network.
A simple, configurable application and set of services to monitor multiple raspberry pi's on a network.

rpi-info-monitor A simple, configurable application and set of services to monitor multiple raspberry pi's on a network. It can be used in a terminal

Easy-to-use sync library for handy proxy parse

Proxy Parser About Synchronous library, for convenient and fast parsing of proxies from different sources. Uses Scrapy as a parser. At the moment the

Get Your Localhost Online - Ngrok Alternative
Get Your Localhost Online - Ngrok Alternative

Get Your Localhost Online - Ngrok Alternative

Fast and configurable script to get and check free HTTP, SOCKS4 and SOCKS5 proxy lists from different sources and save them to files

Fast and configurable script to get and check free HTTP, SOCKS4 and SOCKS5 proxy lists from different sources and save them to files. It can also get geolocation for each proxy and check if proxies are anonymous.

GitHub action for sspanel automatically checks in to get free traffic quota

SSPanel_Checkin This is a dish chicken script for automatic check-in of sspanel for GitHub action, It is only applicable when there is no verification

ip2domain - get ip to domain, Know the domian corresponding to the local network connection IP
ip2domain - get ip to domain, Know the domian corresponding to the local network connection IP

What is Sometimes, we need to know what connections our local machine has, and what are their IP, domain name, program and parameters? get ip to domai

Tool to get the top 100 of the fastest nodes in the Tor network. Based on Kirzahk tool.
Tool to get the top 100 of the fastest nodes in the Tor network. Based on Kirzahk tool.

Tor Network Top 100 IPs Tool to get the top 100 of the fastest nodes in the Tor network. Based on Kirzahk tool. Just execute top100ipstor.py to get th

IP Rover - An Excellent OSINT tool to get information of any ip address
IP Rover - An Excellent OSINT tool to get information of any ip address

IP Rover - An Excellent OSINT tool to get information of any ip address. All details are explained in below screenshot

🔥 Minimal performant package to asynchronously make GET requests.

Minimal performant package to asynchronously make GET requests without any dependencies other than asyncio.

Comments
  • SNMP Set Issue

    SNMP Set Issue

    Hello, I'm trying an SNMP set based on your lib.

    Here's my code :

        def set_interface_vlan(self, interface_id, vlan_id):
            self.set(self.OIDS['interfaces']['sets']['vlan']+f'.{interface_id}', vlan_id)
    

    And here's the error :

    ERROR:    Exception in ASGI application
    Traceback (most recent call last):
      File "C:\Users\ALESTRIO\Documents\Projet\sdn-api\venv\lib\site-packages\uvicorn\protocols\http\h11_impl.py", line 373, in run_asgi
        result = await app(self.scope, self.receive, self.send)
      File "C:\Users\ALESTRIO\Documents\Projet\sdn-api\venv\lib\site-packages\uvicorn\middleware\proxy_headers.py", line 75, in __call__
        return await self.app(scope, receive, send)
      File "C:\Users\ALESTRIO\Documents\Projet\sdn-api\venv\lib\site-packages\uvicorn\middleware\debug.py", line 96, in __call__
        raise exc from None
      File "C:\Users\ALESTRIO\Documents\Projet\sdn-api\venv\lib\site-packages\uvicorn\middleware\debug.py", line 93, in __call__
        await self.app(scope, receive, inner_send)
      File "C:\Users\ALESTRIO\Documents\Projet\sdn-api\venv\lib\site-packages\fastapi\applications.py", line 208, in __call__
        await super().__call__(scope, receive, send)
      File "C:\Users\ALESTRIO\Documents\Projet\sdn-api\venv\lib\site-packages\starlette\applications.py", line 112, in __call__
        await self.middleware_stack(scope, receive, send)
      File "C:\Users\ALESTRIO\Documents\Projet\sdn-api\venv\lib\site-packages\starlette\middleware\errors.py", line 181, in __call__
        raise exc
      File "C:\Users\ALESTRIO\Documents\Projet\sdn-api\venv\lib\site-packages\starlette\middleware\errors.py", line 159, in __call__
        await self.app(scope, receive, _send)
      File "C:\Users\ALESTRIO\Documents\Projet\sdn-api\venv\lib\site-packages\starlette\exceptions.py", line 82, in __call__
        raise exc
      File "C:\Users\ALESTRIO\Documents\Projet\sdn-api\venv\lib\site-packages\starlette\exceptions.py", line 71, in __call__
        await self.app(scope, receive, sender)
      File "C:\Users\ALESTRIO\Documents\Projet\sdn-api\venv\lib\site-packages\starlette\routing.py", line 656, in __call__
        await route.handle(scope, receive, send)
      File "C:\Users\ALESTRIO\Documents\Projet\sdn-api\venv\lib\site-packages\starlette\routing.py", line 259, in handle
        await self.app(scope, receive, send)
      File "C:\Users\ALESTRIO\Documents\Projet\sdn-api\venv\lib\site-packages\starlette\routing.py", line 61, in app
        response = await func(request)
      File "C:\Users\ALESTRIO\Documents\Projet\sdn-api\venv\lib\site-packages\fastapi\routing.py", line 226, in app
        raw_response = await run_endpoint_function(
      File "C:\Users\ALESTRIO\Documents\Projet\sdn-api\venv\lib\site-packages\fastapi\routing.py", line 161, in run_endpoint_function
        return await run_in_threadpool(dependant.call, **values)
      File "C:\Users\ALESTRIO\Documents\Projet\sdn-api\venv\lib\site-packages\starlette\concurrency.py", line 39, in run_in_threadpool
        return await anyio.to_thread.run_sync(func, *args)
      File "C:\Users\ALESTRIO\Documents\Projet\sdn-api\venv\lib\site-packages\anyio\to_thread.py", line 28, in run_sync
        return await get_asynclib().run_sync_in_worker_thread(func, *args, cancellable=cancellable,
      File "C:\Users\ALESTRIO\Documents\Projet\sdn-api\venv\lib\site-packages\anyio\_backends\_asyncio.py", line 805, in run_sync_in_worker_thread
        return await future
      File "C:\Users\ALESTRIO\Documents\Projet\sdn-api\venv\lib\site-packages\anyio\_backends\_asyncio.py", line 743, in run
        result = func(*args)
      File "C:\Users\ALESTRIO\Documents\Projet\sdn-api\api\api_run.py", line 65, in set_vlan_on_interface
        if gateway.set_interface_vlan(if_id, body.vlan_id):
      File "C:\Users\ALESTRIO\Documents\Projet\sdn-api\api\snmp\snmpGateway.py", line 104, in set_interface_vlan
        self.set(self.OIDS['interfaces']['sets']['vlan']+f'.{interface_id}', vlan_id)
      File "C:\Users\ALESTRIO\Documents\Projet\sdn-api\api\snmp\snmp_utils.py", line 60, in set
        errorIndication, errorStatus, errorIndex, varBinds = cmdgen.CommandGenerator().setCmd(
      File "C:\Users\ALESTRIO\Documents\Projet\sdn-api\venv\lib\site-packages\pysnmp\entity\rfc3413\oneliner\cmdgen.py", line 193, in setCmd
        for (errorIndication,
      File "C:\Users\ALESTRIO\Documents\Projet\sdn-api\venv\lib\site-packages\pysnmp\hlapi\asyncore\sync\cmdgen.py", line 214, in setCmd
        cmdgen.setCmd(snmpEngine, authData, transportTarget,
      File "C:\Users\ALESTRIO\Documents\Projet\sdn-api\venv\lib\site-packages\pysnmp\hlapi\asyncore\cmdgen.py", line 241, in setCmd
        contextData.contextName, vbProcessor.makeVarBinds(snmpEngine, varBinds),
      File "C:\Users\ALESTRIO\Documents\Projet\sdn-api\venv\lib\site-packages\pysnmp\hlapi\varbinds.py", line 34, in makeVarBinds
        elif isinstance(varBind[0][0], tuple):  # legacy
      File "C:\Users\ALESTRIO\Documents\Projet\sdn-api\venv\lib\site-packages\pysnmp\smi\rfc1902.py", line 708, in __getitem__
        raise SmiError('%s object not fully initialized' % self.__class__.__name__)
    pysnmp.smi.error.SmiError: ObjectType object not fully initialized
    

    What's the cause of this adn how to fix it ?

    Thanks,

    opened by Alestrio 1
Releases(1.0.1)
Owner
Alexandre Gossard
We need to talk about my power.
Alexandre Gossard
A fully automated, accurate, and extensive scanner for finding log4j RCE CVE-2021-44228

log4j-scan A fully automated, accurate, and extensive scanner for finding vulnerable log4j hosts Features Support for lists of URLs. Fuzzing for more

FullHunt 3.2k Jan 02, 2023
A Simple but Powerful cross-platform port scanning & and network automation tool.

DEDMAP is a Simple but Powerful, Clever and Flexible Cross-Platform Port Scanning tool made with ease to use and convenience in mind. Both TCP

Anurag Mondal 30 Dec 16, 2022
A Python library to utilize AWS API Gateway's large IP pool as a proxy to generate pseudo-infinite IPs for web scraping and brute forcing.

A Python library to utilize AWS API Gateway's large IP pool as a proxy to generate pseudo-infinite IPs for web scraping and brute forcing.

George O 929 Jan 01, 2023
Process incoming JSON-RPC requests in Python

August 16, 2021: Version 5 has been released. Read about the changes in version 5, or read the full documentation. Version 5 is for Python 3.8+ only.

Exploding Labs 156 Dec 31, 2022
Very simple FTP client, sync folder to FTP server, use python, opensource

ftp-sync-python Opensource, A way to safe your data, avoid lost data by Virus, Randsomware Some functions: Upload a folder automatically to FTP server

4 Sep 13, 2022
PyBERT is a serial communication link bit error rate tester simulator with a graphical user interface (GUI).

PyBERT PyBERT is a serial communication link bit error rate tester simulator with a graphical user interface (GUI). It uses the Traits/UI package of t

David Banas 59 Dec 23, 2022
Docker container for demoing Wi-Fi calling stack.

VoWiFiLocalDemo - Docker container that runs StrongSwan and Kamailio to demonstrate how Wi-Fi calling works on smartphones.

18 Nov 12, 2022
Linux SBC featuring two wifi radios, masquerading as a USB charger.

The WiFiWart is an open source WiFi penetration device masquerading as a regular wall charger. It features a 1.2Ghz Cortex A7 MPU with two WiFi chips onboard.

Walker 151 Dec 26, 2022
ARTEMIS: Real-Time Detection and Automatic Mitigation for BGP Prefix Hijacking.

ARTEMIS: Real-Time Detection and Automatic Mitigation for BGP Prefix Hijacking. This is the main ARTEMIS repository that composes artemis-frontend, artemis-backend, artemis-monitor and other needed c

INSPIRE Group @FORTH-ICS 273 Jan 01, 2023
🐛 Self spreading Botnet based on Mirai C&C Arch, spreading through SSH and Telnet protocol.

HBot Self spreading Botnet based on Mirai C&C Arch, spreading through SSH and Telnet protocol. Modern script fullly written in python3. Warning. This

Ѵιcнч 137 Nov 14, 2022
Converts from PC formatted MAC addresses (hardware addresses) to Cisco format or vice-versa

MAC-Converter Converts from PC formatted MAC addresses (hardware addresses) to Cisco format or vice-versa Stores the results to a file in the same dir

Stew Alexander 0 Dec 24, 2022
Socket programming is a way of connecting two nodes on a network to communicate with each other

Socket Programming in Python Socket programming is a way of connecting two nodes on a network to communicate with each other. One socket(node) listens

Janak raikhola 1 Jul 05, 2022
Ip-Tracker: a script written in python for tracking Someone using targets ip-Tracker address

🔰 𝕀𝕡-𝕋𝕣𝕒𝕔𝕜𝕖𝕣 🔰 Ip-Tracker is a script written in python for tracking Someone using targets ip-Tracker address It was made by Spider Anongre

Spider Anongreyhat 15 Dec 02, 2022
nettrace is a powerful tool to trace network packet and diagnose network problem inside kernel.

nettrace nettrace is is a powerful tool to trace network packet and diagnose network problem inside kernel on TencentOS. It make use of eBPF and BCC.

84 Jan 01, 2023
Edge static generator. Also Edge means: the outside limit of an object, area, or surface.

Edge Edge is a new static generator. Edge is onworking. Do not clone or do any changes. No P.R will be merged Also Edge means: the outside limit of an

AmirHossein Mohammadi 12 Jan 16, 2022
A web-based app that allows easy, simple - and if desired high-throughput - analysis of qPCR data

qpcr-Analyser A web-based GUI for the qpcr package that allows easy, simple and high-throughput analysis of qPCR data. As is described in more detail

1 Sep 13, 2022
Nautobot is a Network Source of Truth and Network Automation Platform.

Nautobot is a Network Source of Truth and Network Automation Platform. Nautobot was initially developed as a fork of NetBox (v2.10.4). Nautobot runs as a web application atop the Django Python framew

Nautobot 549 Dec 31, 2022
A Powerful, Smart And Simple Userbot In Telethon

Owner: KeinShin 🇮🇳 BLACK LIGHTNING A Powerful, Smart And Simple Userbot In Telethon. Credits This is A Remix Bot Of Many UserBot. DARKCOBRA FridayUs

Akki ThePro 1 Nov 29, 2021
Python code that get the name and ip address of a computer/laptop

IP Address This is a python code that provides the name and the internet protocol address of the computer. You need to install socket pip install sock

CODE 2 Feb 21, 2022
Decentra Network is an open source blockchain that combines speed, security and decentralization.

Decentra Network is an open source blockchain that combines speed, security and decentralization. Decentra Network has very high speeds, scalability, asymptotic security and complete decentralization

Decentra Network 74 Nov 22, 2022