C# Класс SnmpSharpNet.SimpleSnmp

Utility class to enable simplified access to SNMP version 1 and version 2 requests and replies.
Use this class if you are not looking for "deep" SNMP functionality. Design of the class is based around providing simplest possible access to SNMP operations without getting stack into details. If you are using the simplest way, you will leave SuppressExceptions flag to true and get all errors causing methods to return "null" result which will not tell you why operation failed. You can change the SuppressExceptions flag to false and catch any and all exception throwing errors. Either way, have fun.
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
_community string
_maxRepetitions int
_nonRepeaters int
_peerIP System.Net.IPAddress
_peerName string
_peerPort int
_retry int
_suppressExceptions bool
_target UdpTarget
_timeout int

Открытые методы

Метод Описание
Get ( SnmpVersion version, Pdu pdu ) : AsnType>.Dictionary

SNMP GET request

Get ( SnmpVersion version, string oidList ) : AsnType>.Dictionary

SNMP GET request

GetBulk ( Pdu pdu ) : AsnType>.Dictionary

SNMP GET-BULK request

GetBulk request type is only available with SNMP v2c agents. SNMP v3 also supports the request itself but that version of the protocol is not supported by SimpleSnmp. GetBulk method will return a dictionary of Oid to value mapped values as returned form a single GetBulk request to the agent. You can change how the request itself is made by changing the SimpleSnmp.NonRepeaters and SimpleSnmp.MaxRepetitions values. SimpleSnmp properties are only used when values in the parameter Pdu are set to 0.

GetBulk ( string oidList ) : AsnType>.Dictionary

SNMP GET-BULK request

Performs a GetBulk SNMP v2 operation on a list of OIDs. This is a convenience function that calls GetBulk(Pdu) method.

GetNext ( SnmpVersion version, Pdu pdu ) : AsnType>.Dictionary

SNMP GET-NEXT request

GetNext ( SnmpVersion version, string oidList ) : AsnType>.Dictionary

SNMP GET-NEXT request

Set ( SnmpVersion version, Pdu pdu ) : AsnType>.Dictionary

SNMP SET request

Set ( SnmpVersion version, Vb vbs ) : AsnType>.Dictionary

SNMP SET request

SimpleSnmp ( ) : System

Constructor.

Class is initialized to default values. Peer IP address is set to loopback, peer port number to 161, timeout to 2000 ms (2 seconds), retry count to 2 and community name to public.

SimpleSnmp ( string peerName ) : System

Constructor.

Class is initialized with default values with the agent name set to the supplied DNS name (or IP address). If peer name is a DNS name, DNS resolution will take place in the constructor attempting to resolve it an IP address.

SimpleSnmp ( string peerName, int peerPort, string community ) : System

Constructor.

SimpleSnmp ( string peerName, int peerPort, string community, int timeout, int retry ) : System

Constructor.

SimpleSnmp ( string peerName, string community ) : System

Constructor

Walk ( SnmpVersion version, string rootOid ) : AsnType>.Dictionary

SNMP WALK operation

When using SNMP version 1, walk is performed using GET-NEXT calls. When using SNMP version 2, walk is performed using GET-BULK calls.

Walk ( bool tryGetBulk, SnmpVersion version, string rootOid ) : AsnType>.Dictionary

SNMP WALK operation

When using SNMP version 1, walk is performed using GET-NEXT calls. When using SNMP version 2, walk is performed using GET-BULK calls.

Приватные методы

Метод Описание
Resolve ( ) : bool

Resolve peer name to an IP address

This method will not throw any exceptions, even on failed DNS resolution. Make sure you call SimpleSnmp.Valid property to verify class state.

Описание методов

Get() публичный Метод

SNMP GET request
public Get ( SnmpVersion version, Pdu pdu ) : AsnType>.Dictionary
version SnmpVersion SNMP protocol version. Acceptable values are SnmpVersion.Ver1 and SnmpVersion.Ver2
pdu Pdu Request Protocol Data Unit
Результат AsnType>.Dictionary

Get() публичный Метод

SNMP GET request
public Get ( SnmpVersion version, string oidList ) : AsnType>.Dictionary
version SnmpVersion SNMP protocol version number. Acceptable values are SnmpVersion.Ver1 and SnmpVersion.Ver2
oidList string List of request OIDs in string dotted decimal format.
Результат AsnType>.Dictionary

GetBulk() публичный Метод

SNMP GET-BULK request
GetBulk request type is only available with SNMP v2c agents. SNMP v3 also supports the request itself but that version of the protocol is not supported by SimpleSnmp. GetBulk method will return a dictionary of Oid to value mapped values as returned form a single GetBulk request to the agent. You can change how the request itself is made by changing the SimpleSnmp.NonRepeaters and SimpleSnmp.MaxRepetitions values. SimpleSnmp properties are only used when values in the parameter Pdu are set to 0.
public GetBulk ( Pdu pdu ) : AsnType>.Dictionary
pdu Pdu Request Protocol Data Unit
Результат AsnType>.Dictionary

GetBulk() публичный Метод

SNMP GET-BULK request
Performs a GetBulk SNMP v2 operation on a list of OIDs. This is a convenience function that calls GetBulk(Pdu) method.
public GetBulk ( string oidList ) : AsnType>.Dictionary
oidList string List of request OIDs in string dotted decimal format.
Результат AsnType>.Dictionary

GetNext() публичный Метод

SNMP GET-NEXT request
public GetNext ( SnmpVersion version, Pdu pdu ) : AsnType>.Dictionary
version SnmpVersion SNMP protocol version. Acceptable values are SnmpVersion.Ver1 and SnmpVersion.Ver2
pdu Pdu Request Protocol Data Unit
Результат AsnType>.Dictionary

GetNext() публичный Метод

SNMP GET-NEXT request
public GetNext ( SnmpVersion version, string oidList ) : AsnType>.Dictionary
version SnmpVersion SNMP protocol version number. Acceptable values are SnmpVersion.Ver1 and SnmpVersion.Ver2
oidList string List of request OIDs in string dotted decimal format.
Результат AsnType>.Dictionary

Set() публичный Метод

SNMP SET request
public Set ( SnmpVersion version, Pdu pdu ) : AsnType>.Dictionary
version SnmpVersion SNMP protocol version number. Acceptable values are SnmpVersion.Ver1 and SnmpVersion.Ver2
pdu Pdu Request Protocol Data Unit
Результат AsnType>.Dictionary

Set() публичный Метод

SNMP SET request
public Set ( SnmpVersion version, Vb vbs ) : AsnType>.Dictionary
version SnmpVersion SNMP protocol version number. Acceptable values are SnmpVersion.Ver1 and SnmpVersion.Ver2
vbs Vb Vb array containing Oid/AsnValue pairs for the SET operation
Результат AsnType>.Dictionary

SimpleSnmp() публичный Метод

Constructor.
Class is initialized to default values. Peer IP address is set to loopback, peer port number to 161, timeout to 2000 ms (2 seconds), retry count to 2 and community name to public.
public SimpleSnmp ( ) : System
Результат System

SimpleSnmp() публичный Метод

Constructor.
Class is initialized with default values with the agent name set to the supplied DNS name (or IP address). If peer name is a DNS name, DNS resolution will take place in the constructor attempting to resolve it an IP address.
public SimpleSnmp ( string peerName ) : System
peerName string Peer name or IP address
Результат System

SimpleSnmp() публичный Метод

Constructor.
public SimpleSnmp ( string peerName, int peerPort, string community ) : System
peerName string Peer name or IP address
peerPort int Peer UDP port number
community string SNMP community name
Результат System

SimpleSnmp() публичный Метод

Constructor.
public SimpleSnmp ( string peerName, int peerPort, string community, int timeout, int retry ) : System
peerName string Peer name or IP address
peerPort int Peer UDP port number
community string SNMP community name
timeout int SNMP request timeout
retry int Maximum number of retries excluding the first request (0 = 1 request is sent)
Результат System

SimpleSnmp() публичный Метод

Constructor
public SimpleSnmp ( string peerName, string community ) : System
peerName string Peer name or IP address
community string SNMP community name
Результат System

Walk() публичный Метод

SNMP WALK operation
When using SNMP version 1, walk is performed using GET-NEXT calls. When using SNMP version 2, walk is performed using GET-BULK calls.
public Walk ( SnmpVersion version, string rootOid ) : AsnType>.Dictionary
version SnmpVersion SNMP protocol version. Acceptable values are SnmpVersion.Ver1 and /// SnmpVersion.Ver2
rootOid string OID to start WALK operation from. Only child OIDs of the rootOid will be /// retrieved and returned
Результат AsnType>.Dictionary

Walk() публичный Метод

SNMP WALK operation
When using SNMP version 1, walk is performed using GET-NEXT calls. When using SNMP version 2, walk is performed using GET-BULK calls.
public Walk ( bool tryGetBulk, SnmpVersion version, string rootOid ) : AsnType>.Dictionary
tryGetBulk bool this param is used to use get bulk on V2 requests
version SnmpVersion SNMP protocol version. Acceptable values are SnmpVersion.Ver1 and /// SnmpVersion.Ver2
rootOid string OID to start WALK operation from. Only child OIDs of the rootOid will be /// retrieved and returned
Результат AsnType>.Dictionary

Описание свойств

_community защищенное свойство

SNMP community name
protected string _community
Результат string

_maxRepetitions защищенное свойство

Maximum repetitions value used in SNMP GET-BULK requests
protected int _maxRepetitions
Результат int

_nonRepeaters защищенное свойство

Non repeaters value used in SNMP GET-BULK requests
protected int _nonRepeaters
Результат int

_peerIP защищенное свойство

SNMP Agents IP address
protected IPAddress,System.Net _peerIP
Результат System.Net.IPAddress

_peerName защищенное свойство

SNMP Agents name
protected string _peerName
Результат string

_peerPort защищенное свойство

SNMP Agent UDP port number
protected int _peerPort
Результат int

_retry защищенное свойство

Maximum retry count excluding the first request
protected int _retry
Результат int

_suppressExceptions защищенное свойство

Flag determines if exceptions are suppressed or thrown. When exceptions are suppressed, methods return null on errors regardless of what the error is.
protected bool _suppressExceptions
Результат bool

_target защищенное свойство

Target class
protected UdpTarget,SnmpSharpNet _target
Результат UdpTarget

_timeout защищенное свойство

Timeout value in milliseconds
protected int _timeout
Результат int