{"id":20237697,"url":"https://github.com/qualisystems/cloudshell-snmp","last_synced_at":"2025-04-10T19:12:11.068Z","repository":{"id":48875674,"uuid":"51309804","full_name":"QualiSystems/cloudshell-snmp","owner":"QualiSystems","description":null,"archived":false,"fork":false,"pushed_at":"2023-12-05T18:53:40.000Z","size":775,"stargazers_count":0,"open_issues_count":0,"forks_count":4,"subscribers_count":16,"default_branch":"master","last_synced_at":"2025-03-24T16:53:36.288Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/QualiSystems.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-02-08T16:29:38.000Z","updated_at":"2022-09-21T16:18:47.000Z","dependencies_parsed_at":"2023-12-05T19:51:08.064Z","dependency_job_id":null,"html_url":"https://github.com/QualiSystems/cloudshell-snmp","commit_stats":null,"previous_names":[],"tags_count":27,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/QualiSystems%2Fcloudshell-snmp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/QualiSystems%2Fcloudshell-snmp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/QualiSystems%2Fcloudshell-snmp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/QualiSystems%2Fcloudshell-snmp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/QualiSystems","download_url":"https://codeload.github.com/QualiSystems/cloudshell-snmp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248279825,"owners_count":21077408,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-14T08:28:22.563Z","updated_at":"2025-04-10T19:12:11.050Z","avatar_url":"https://github.com/QualiSystems.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Cloudshell SNMP\n\n[![Build status](https://github.com/QualiSystems/cloudshell-snmp/workflows/CI/badge.svg?branch=master)](https://github.com/QualiSystems/cloudshell-snmp/actions?query=branch%3Amaster)\n[![codecov](https://codecov.io/gh/QualiSystems/cloudshell-snmp/branch/master/graph/badge.svg)](https://codecov.io/gh/QualiSystems/cloudshell-snmp)\n[![PyPI version](https://shields.io/pypi/v/cloudshell-snmp)](https://pypi.org/project/cloudshell-snmp)\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/python/black)\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"https://github.com/QualiSystems/devguide_source/raw/master/logo.png\"\u003e\u003c/img\u003e\n\u003c/p\u003e\n\n## Overview\nThe cloudshell-snmp open source Python package provides an easy-to-use interface for SNMP access and communication to a networking devices.\n\n**Note:** We use tox and pre-commit for testing. For details, see [Services description](https://github.com/QualiSystems/cloudshell-package-repo-template#description-of-services).\n\n## Installation\n```bash\npip install cloudshell-snmp\n```\n\n### Contributing \n\nWe welcome community ideas and contributions, so if you have any feedback or would like to request enhancements, feel free to create an **Issue** in the repository. \n\n#### Contributing code\n\n1. Fork the repository. \n\n2. Make the code change. Make sure the tests pass. Add unit tests to cover any new behavior. We do require that the coverage does not decrease with the new code.\n\n3. Submit a **Pull Request**.\n\n## Usage\n\n### Key components\n\nCloudShell SNMP offers the following key features: \n* `SnmpMibOid` and `SnmpRawOid` - entities used to build a request\n* `SnmpResponse`and `QualiMibTable` - types of objects we recieve in response from all communication methods (get, walk, get_table, etc.)\n* **snmp service** allows CloudShell SNMP to communicate with target device.\n\u003cbr\u003e*CloudShell SNMP uses the `with` statement to establish a connection to the device.*\n\nCloudShell SNMP is highly modular and implements many programming interfaces. \n\n### SNMP service\n**snmp service** is the service that manages communication with the device. Allowing you to `set`, `get`, `walk` and `get_table` to/from the device.\nAdditionally it allows you to add more snmp MIB files by running `update_mib_sources` method, or load mib information using `load_mib_tables`.\nMost communication methods requires you to pass either `SnmpMibOid` or `SnmpRawOid`, \ni.e: `SnmpMibOid('SNMPv2-MIB', 'sysContact', 0)` or `SnmpRawOid('1.3.6.1.2.1.1.4.0')`\nAnd in the result most of the commands return single or list of `SnmpResponse`, except get_table, since it returns table like dictionary: `QualiMibTable`.\n\n**Example - Executing 'update_mib_sources' and 'set' command**\n\n```python\nfrom cloudshell.logging.qs_logger import get_qs_logger\nfrom cloudshell.snmp.cloudshell_snmp import Snmp\nfrom cloudshell.snmp.core.domain.snmp_oid import SnmpMibObject, SnmpSetMibName\nfrom cloudshell.snmp.snmp_parameters import SNMPWriteParameters\n\nsnmp_params = SNMPWriteParameters(ip, community, \"v2\")\nlogger = get_qs_logger()\nlogger.info(\"started\")\n\nsnmp_handler = Snmp()\n\nwith snmp_handler.get_snmp_service(snmp_parameters=snmp_params, logger=logger) as snmp_service:\n    snmp_service.add_mib_folder_path(\"D:\\\\cisco\\\\mibs\")\n    set_id = 1 # Represents a row id, should be incremented.\n    response = snmp_service.set([SnmpSetMibName(\"CISCO-CONFIG-COPY-MIB\", \"ccCopyProtocol\", set_id, 1),\n                                 SnmpSetMibName(\"CISCO-CONFIG-COPY-MIB\", \"ccCopySourceFileType\", set_id, 3),\n                                 SnmpSetMibName(\"CISCO-CONFIG-COPY-MIB\", \"ccCopyDestFileType\", set_id, 1),\n                                 SnmpSetMibName(\"CISCO-CONFIG-COPY-MIB\", \"ccCopyServerAddress\", set_id, \"192.168.105.3\"),\n                                 SnmpSetMibName(\"CISCO-CONFIG-COPY-MIB\", \"ccCopyFileName\", set_id, \"test_snmp_running_config_save\"),\n                                 SnmpSetMibName(\"CISCO-CONFIG-COPY-MIB\", \"ccCopyEntryRowStatus\", set_id, 4)])\n```\n\n**Example - Executing 'get', 'get_next', 'get_list' and 'get_property' command**\n\n```python\nfrom cloudshell.logging.qs_logger import get_qs_logger\nfrom cloudshell.snmp.cloudshell_snmp import Snmp\nfrom cloudshell.snmp.core.domain.snmp_oid import SnmpMibObject, SnmpSetMibName\nfrom cloudshell.snmp.snmp_parameters import SNMPWriteParameters\n\nsnmp_params = SNMPWriteParameters(ip, community, \"v2\")\nlogger = get_qs_logger()\nlogger.info(\"started\")\n\nsnmp_handler = Snmp()\n\nwith snmp_handler.get_snmp_service(snmp_parameters=snmp_params, logger=logger) as snmp_service:\n    response = snmp_service.get_property(SnmpMibObject(\"SNMPv2-MIB\", \"sysDescr\", 0))  # Retruns empty SnmpResponse in case get command failed to retrieve data\n    response = snmp_service.get(SnmpMibObject(\"SNMPv2-MIB\", \"sysDescr\", 0))  # Raises an exception in case requested oid is not found\n    response = snmp_service.get_next(SnmpMibObject(\"SNMPv2-MIB\", \"sysDescr\", 0))  # same as get\n    response = snmp_service.get_list(SnmpMibObject(\"SNMPv2-MIB\", \"sysDescr\", 0))  # same as get\n\n\n```\n\n**Example - Executing 'walk' and 'get_table' command**\n\n```python\nfrom cloudshell.logging.qs_logger import get_qs_logger\nfrom cloudshell.snmp.cloudshell_snmp import Snmp\nfrom cloudshell.snmp.core.domain.snmp_oid import SnmpMibObject, SnmpSetMibName\nfrom cloudshell.snmp.snmp_parameters import SNMPWriteParameters\n\nsnmp_params = SNMPWriteParameters(ip, community, \"v2\")\nlogger = get_qs_logger()\nlogger.info(\"started\")\n\nsnmp_handler = Snmp()\n\nwith snmp_handler.get_snmp_service(snmp_parameters=snmp_params, logger=logger) as snmp_service:\n    response = snmp_service.walk(SnmpMibObject('IF-MIB', 'ifTable'))  # Retruns empty SnmpResponse in case get command failed to retrieve data\n    response = snmp_service.get_table(SnmpMibObject('IF-MIB', 'ifTable'))  # Raises an exception in case requested oid is not found\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqualisystems%2Fcloudshell-snmp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fqualisystems%2Fcloudshell-snmp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqualisystems%2Fcloudshell-snmp/lists"}