From a42a87dffea0e5bdd19e5a4c9d5796114779f5d7 Mon Sep 17 00:00:00 2001 From: alejandro Date: Fri, 18 Aug 2023 10:41:39 +0200 Subject: [PATCH] added snmp in __init__.py --- .../extras/pandoraPlugintools/__init__.py | 3 ++- .../extras/pandoraPlugintools/snmp.py | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/pandora_server/extras/pandoraPlugintools/__init__.py b/pandora_server/extras/pandoraPlugintools/__init__.py index f9360683ba..e52f6cc12d 100644 --- a/pandora_server/extras/pandoraPlugintools/__init__.py +++ b/pandora_server/extras/pandoraPlugintools/__init__.py @@ -6,4 +6,5 @@ from .agents import * from .modules import * from .transfer import * from .discovery import * -from .http import * \ No newline at end of file +from .http import * +from .snmp import * \ No newline at end of file diff --git a/pandora_server/extras/pandoraPlugintools/snmp.py b/pandora_server/extras/pandoraPlugintools/snmp.py index 5730c8ded7..45bd487f74 100644 --- a/pandora_server/extras/pandoraPlugintools/snmp.py +++ b/pandora_server/extras/pandoraPlugintools/snmp.py @@ -20,7 +20,16 @@ _GLOBAL_VARIABLES = { 'remote_port' : 161, } +#### +# Creates an SNMP session based on the global configuration variables. +######################################################################################### def create_snmp_session(): + """ + Creates an SNMP session based on the global configuration variables. + + Returns: + Session: An SNMP session configured based on the global variables. + """ host = _GLOBAL_VARIABLES['hostname'] version = _GLOBAL_VARIABLES['version'] community = _GLOBAL_VARIABLES['community'] @@ -67,6 +76,10 @@ def create_snmp_session(): return Session(**session_kwargs) + +#### +# Performs an SNMP GET operation to retrieve the value of a specified OID. +######################################################################################### def snmp_get( session: Session, oid: str @@ -83,6 +96,9 @@ def snmp_get( """ return session.get(oid) +#### +# Performs an SNMP WALK operation to retrieve a list of values from a subtree of the MIB. +######################################################################################### def snmp_walk( session: Session, oid: str @@ -99,6 +115,9 @@ def snmp_walk( """ return session.walk(oid) +#### +# Sends an SNMP trap to the specified destination IP using the given OID, value, and community. +######################################################################################### def send_trap( trap_oid: str, trap_value: str,