minor changes

This commit is contained in:
alejandro 2023-08-18 10:35:59 +02:00
parent 932e171813
commit 66394f8ec4
1 changed files with 46 additions and 3 deletions

View File

@ -67,13 +67,56 @@ def create_snmp_session():
return Session(**session_kwargs)
def snmp_get(session, oid):
def snmp_get(
session: Session,
oid: str
) -> str:
"""
Performs an SNMP GET operation to retrieve the value of a specified OID.
Args:
session (Session): The SNMP session to use for the operation.
oid (str): The OID (Object Identifier) for the SNMP GET operation.
Returns:
str: The value retrieved from the specified OID.
"""
return session.get(oid)
def snmp_walk(session, oid):
def snmp_walk(
session: Session,
oid: str
) -> list:
"""
Performs an SNMP WALK operation to retrieve a list of values from a subtree of the MIB.
Args:
session (Session): The SNMP session to use for the operation.
oid (str): The OID (Object Identifier) representing the root of the subtree.
Returns:
list: A list of values retrieved from the specified subtree.
"""
return session.walk(oid)
def send_trap(trap_oid, trap_value, destination_ip, community):
def send_trap(
trap_oid: str,
trap_value: str,
destination_ip: str,
community: str
) -> None:
"""
Sends an SNMP trap to the specified destination IP using the given OID, value, and community.
Args:
trap_oid (str): The OID (Object Identifier) for the SNMP trap.
trap_value (str): The value associated with the trap.
destination_ip (str): The IP address of the trap's destination.
community (str): The SNMP community string for authentication.
Returns:
None
"""
trap = TrapSender()
trap.trap_oid = trap_oid