Skip to content

lib-snmp 库参考 ​

原文: https://finproducts.atlassian.net/wiki/spaces/JIDD3/pages/34793554432/FIN+5.3.1+lib-snmp 中文整理基于 FIN 5.3.1

导读: 本页为 lib-snmp 的 API / 标签 / 函数参考文档。

以下为 API 参考,保留英文以便对照源码;目录已列出(英文标题便于检索);概述已尽量中译。


目录(导读) ​

  • lib
  • meta
  • docs
  • tags
  • funcs
  • Overview
  • Agent Connectivity
    • Security
  • Management Information Base (MIB)
  • Current Points
  • Writable Points
  • snmpGet(conn, arg)
  • snmpPing(conn)
  • snmpReadTable(conn, table)
  • snmpSyncCur(points)

概述(中译) ​

SNMP 连接器


API 正文(英文) ​

docs ​

Overview • Agent Connectivity • Management Information Base (MIB) • Current Points • Writable Points


tags ​

snmpAuthProtocolIf the snmpSecurityLevel indicates that authentication is required, then this is the digest algorithm to use
snmpCommunityIf the snmpVersion is 2c, then this is the name of the SNMP community to use when messaging with the remote agent
snmpConnSNMP connector
snmpConnRefUsed on a proxy object to reference its parent snmpConn
snmpCurSNMP address to use for current-value subscription
snmpDescFor learned points, this is the description of the point as found in its MIB OBJECT-TYPE definition
snmpMibTypeFor learned points, this is the human-readable qualified name (qname) of the point
snmpMibsUriApplied to snmpConn to define the collection of MIB files to load
snmpPointPoint which synchronizes data via an SNMP connector
snmpPrivProtocolIf the snmpSecurityLevel indicates that message privacy is required, then this is the encryption algorithm to use
snmpProtocolApplied to snmpConn to indicate the network protocol to use for communicating with a remote agent
snmpSecurityLevelIf the snmpVersion is 3, then this is the security level to use for messaging with the remote agent
snmpVersionApplied to snmpConn to indicate the SNMP protocol version to use for messaging with the remote agent
snmpWriteSNMP address to use for writing a point

funcs ​

snmpGetSynchronously read the current value of the object-type specified by arg
snmpPingDeprecated - use connPing()
snmpReadTableSynchronously read an SNMP table and return it as a Grid
snmpSyncCurDeprecated - use connSyncCur()

lib snmp ​

Overview ​

The SnmpExt implements connector support for the Simple Network Management Protocol (SNMP).

Agent Connectivity ​

To access a remote SNMP agent, we use the snmp URI scheme. If you don't specify a port, the default is 161. The SnmpExt supports both UDP and TCP/IP connectivity. By default, TCP/IP is used. Use snmpProtocol to change the transport protocol.

uri: `snmp://agent.com`

Security ​

The connector supports two modes of security: 1) Community-based authentication (SNMPv2c) and 2) User-based Security Model - USM (SNMPv3). See the docs on snmpConn for details about the security-related tags.

Management Information Base (MIB) ​

SNMP connectors can be configured to load MIB module definitions from disk into a MIB database. The connector's snmpMibsUri tag indicates the directory to search for MIB files. All files not starting with a . are parsed as module definition files and loaded into the MIB. See that tag's doc for more details.

When the SnmpExt first starts, it will install a minimal, default set of MIBs into data/mibs/default/. You can add additional MIBs to this collection, or create your own collection.

The MIB is used primarily when learning a remote agent via the Builder App. Only object types specified in the MIB will be available for learning. Further, writable points are only supported if they correspond to a type in the MIB since we need the information from the MIB to know how to map its type in Haystack to the expected SNMP type on the agent.

Current Points ​

SNMP proxy points are configured with the snmpCur tag, which maps to the object identifier for the point in the MIB. For example, this point maps the HOST-RESOURCES-MIB::hrSystemUptime point in the remote agent and converts it from centiseconds to days:

point
snmpConnRef: @mySnmpConn
snmpCur: "1.3.6.1.2.1.25.1.1.0"
snmpMibType: "HOST-RESOURCES-MIB::hrSystemUptime"
curConvert: "cs => day"
unit: "day"

Writable Points ​

SNMP proxy points are configured to write to remote agent points via the snmpWrite tag. If you use the Builder App to learn SNMP points, it will automatically configure a point as writable if its object-type definition in the MIB has MAX-ACCESS of readWrite or higher.

point
writable
snmpConnRef: @mySnmpConn
snmpWrite: "1.3.6.1.2.1.1.4.0"
snmpMibType: "SNMPv2-MIB::sysContact"


def ​

func:snmpGet ​

snmpGet(conn, arg) ​

Synchronously read the current value of the object-type specified by arg.

Params:

  • conn: the SNMP connector to read against
  • arg: the OID of the object-type to read (e.g. "1.3.6.1.2.11.1.0")

NOTE: this function is incubating and subject to change.


meta ​

admin✓
deffunc:snmpGet
isfunc
liblib:snmp
namesnmpGet

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function


def ​

func:snmpPing ​

snmpPing(conn) ​

Deprecated - use connPing()


meta ​

admin✓
deffunc:snmpPing
deprecated✓
isfunc
liblib:snmp
namesnmpPing

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function


def ​

func:snmpReadTable ​

snmpReadTable(conn, table) ​

Synchronously read an SNMP table and return it as a Grid.

Params:

  • conn: the SNMP connector to read against.
  • table: the qname of the table to read (e.g. "SNMPv2-MIB::sysORTable").

Each column's metadata includes tag snmpColIdentity which is the OID of the column object-type in the MIB. In addition to the columns specified in the MIB, each row will have a column snmpRowIndex. This value is the common OID suffix for each cell in the row. In other words, it represents the row index. Each table cell's OID is therefore:

col.meta["snmpColIdentity"] + "." + row["snmpRowIndex"]

Examples:

grid = read(snmpConn and dis=="SNMP Demo").snmpReadTable("SNMPv2-MIB::sysORTable")

NOTE: this function is incubating and subject to change.


meta ​

admin✓
deffunc:snmpReadTable
isfunc
liblib:snmp
namesnmpReadTable

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function


def ​

func:snmpSyncCur ​

snmpSyncCur(points) ​

Deprecated - use connSyncCur()


meta ​

admin✓
deffunc:snmpSyncCur
deprecated✓
isfunc
liblib:snmp
namesnmpSyncCur

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function


def ​

snmpAuthProtocol ​

If the snmpSecurityLevel indicates that authentication is required, then this is the digest algorithm to use.

The snmpConn password is used both for the auth pass phrase and the priv pass phrase.


meta ​

defsnmpAuthProtocol
enumSee below
isstr
liblib:snmp
tagOnsnmpConn

enum ​

MD5
SHA

supertypes ​

valData value type
scalarScalar is an atomic value kind
strUnicode string of characters


def ​

snmpCommunity ​

If the snmpVersion is 2c, then this is the name of the SNMP community to use when messaging with the remote agent.


meta ​

defsnmpCommunity
isstr
liblib:snmp
tagOnsnmpConn

supertypes ​

valData value type
scalarScalar is an atomic value kind
strUnicode string of characters


def ​

snmpConn ​

SNMP connector. See snmp.


meta ​

connFeatures
defsnmpConn
iconsnmp
isconn
liblib:snmp

usage ​

snmpConn  conn

supertypes ​

markerMarker labels a dict with typing information
entityTop-level dicts with a unique identifier
connConnector for communication to a remote system

tags ​

actorTimeoutTimeout for messages send to the connector's actor thread
connErrError message associated when connStatus indicates an error condition
connLingerLinger timeout used to keep a connector open
connOpenRetryFreqDuration used for connector open retries
connPingFreqDuration used to configure the auto-ping feature on a given connector
connStateCurrent connection state of a connector as one of the predefined strings
connStatusCurrent status of a connector as one of the predefined strings See Connectors
connTuningRefReference to a tuning configuration defined by a connTuning rec
disDisplay name for an entity
disabledIndicates the entity is in a disabled state
idDefines the unique identifier of an entity in system using a ref value type
passwordManages password which is hashed/stored to the password store
snmpAuthProtocolIf the snmpSecurityLevel indicates that authentication is required, then this is the digest algorithm to use
snmpCommunityIf the snmpVersion is 2c, then this is the name of the SNMP community to use when messaging with the remote agent
snmpMibsUriApplied to snmpConn to define the collection of MIB files to load
snmpPrivProtocolIf the snmpSecurityLevel indicates that message privacy is required, then this is the encryption algorithm to use
snmpProtocolApplied to snmpConn to indicate the network protocol to use for communicating with a remote agent
snmpSecurityLevelIf the snmpVersion is 3, then this is the security level to use for messaging with the remote agent
snmpVersionApplied to snmpConn to indicate the SNMP protocol version to use for messaging with the remote agent
uriUniversal resource identifier
usernameUsername for an authentication account


def ​

snmpConnRef ​

Used on a proxy object to reference its parent snmpConn


meta ​

defsnmpConnRef
isref
liblib:snmp
ofsnmpConn
tagOnsnmpPoint

supertypes ​

valData value type
scalarScalar is an atomic value kind
refReference to an entity


def ​

snmpCur ​

SNMP address to use for current-value subscription. It is formatted as the SNMP object identifier for that point.


meta ​

defsnmpCur
isstr
liblib:snmp
tagOnsnmpPoint

supertypes ​

valData value type
scalarScalar is an atomic value kind
strUnicode string of characters


def ​

snmpDesc ​

For learned points, this is the description of the point as found in its MIB OBJECT-TYPE definition.


meta ​

defsnmpDesc
isstr
liblib:snmp
tagOnsnmpPoint

supertypes ​

valData value type
scalarScalar is an atomic value kind
strUnicode string of characters


def ​

snmpMibType ​

For learned points, this is the human-readable qualified name (qname) of the point. It is formatted as <module-name>::<type-name>.


meta ​

defsnmpMibType
isstr
liblib:snmp
tagOnsnmpPoint

supertypes ​

valData value type
scalarScalar is an atomic value kind
strUnicode string of characters


def ​

snmpMibsUri ​

Applied to snmpConn to define the collection of MIB files to load. This URI must be a path relative to the project's home directory, and it must be a directory. The directory tree at this uri will be searched and all files will be loaded as MIB module definitions.


meta ​

defsnmpMibsUri
isuri
liblib:snmp
tagOnsnmpConn

supertypes ​

valData value type
scalarScalar is an atomic value kind
uriUniversal resource identifier


def ​

snmpPoint ​

Point which synchronizes data via an SNMP connector.


meta ​

defsnmpPoint
isconnPoint
liblib:snmp

usage ​

snmpPoint  point

supertypes ​

markerMarker labels a dict with typing information
entityTop-level dicts with a unique identifier
pointData point such as a sensor or actuator
connPointPoint associated with a connector for data synchronization with a remote system

tags ​

connTuningRefReference to a tuning configuration defined by a connTuning rec
curSupports current value
curCalibrationCalibration value to apply to adjust the value read from the connector before updating curVal
curConvertConversion to apply when reading curVal from connector
disDisplay name for an entity
disMacroDisplay name using macro syntax
disabledIndicates the entity is in a disabled state
enumDefines an eumeration of string key names
equipRefReference to equip which contains this entity
ghgFactorHisIdentifies point record with interval emission factor data that the Greenhouse Gas Emission Engine uses to calculate emissions
hisSupports historization of data
hisConvertConversion to apply when reading history data from connector
idDefines the unique identifier of an entity in system using a ref value type
kindKind name used to identity a value data type
maxValInclusive maximum for a numeric value
minValInclusive minimum for a numeric value
navNameNavigation name commonly used with disMacro to create computed display strings
pointFunctionClassifies the point as a sensor, command, or setpoint
pointQuantityQuantity the point senses or controls
pointSubjectWhat the point senses or controls
siteRefReference to site which contains the entity
snmpConnRefUsed on a proxy object to reference its parent snmpConn
snmpCurSNMP address to use for current-value subscription
snmpDescFor learned points, this is the description of the point as found in its MIB OBJECT-TYPE definition
snmpMibTypeFor learned points, this is the human-readable qualified name (qname) of the point
snmpWriteSNMP address to use for writing a point
spaceRefReference to space which contains this entity
systemRefReference to system
tzTimezone identifier from standard timezone database
unitUnit identifier from standard unit database
writableSupports writing data
writeConvertConversion to apply when writing writeVal to the connector


def ​

snmpPrivProtocol ​

If the snmpSecurityLevel indicates that message privacy is required, then this is the encryption algorithm to use.

The snmpConn password is used both for the auth pass phrase and the priv pass phrase.


meta ​

defsnmpPrivProtocol
enumSee below
isstr
liblib:snmp
tagOnsnmpConn

enum ​

DES
AES

supertypes ​

valData value type
scalarScalar is an atomic value kind
strUnicode string of characters


def ​

snmpProtocol ​

Applied to snmpConn to indicate the network protocol to use for communicating with a remote agent. Valid values are udp and tcp. If not specified, then tcp is used.


meta ​

defsnmpProtocol
enumSee below
isstr
liblib:snmp
tagOnsnmpConn

enum ​

tcp
udp

supertypes ​

valData value type
scalarScalar is an atomic value kind
strUnicode string of characters


def ​

snmpSecurityLevel ​

If the snmpVersion is 3, then this is the security level to use for messaging with the remote agent.


meta ​

defsnmpSecurityLevel
enumSee below
isstr
liblib:snmp
tagOnsnmpConn

enum ​

authPrivIndicates both user authentication and privacy (encryption) for the mesages.
authNoPrivIndicates user authentication, but no privacy for the messages.
noAuthNoPrivIndicates no user authentication or privacy for the messages.

supertypes ​

valData value type
scalarScalar is an atomic value kind
strUnicode string of characters


def ​

snmpVersion ​

Applied to snmpConn to indicate the SNMP protocol version to use for messaging with the remote agent. The version will dictate additional required tags on the connector. See snmpConn for details.


meta ​

defsnmpVersion
enumSee below
isstr
liblib:snmp
tagOnsnmpConn

enum ​

2cSNMPv2C - Community-based authentication
3SNMPv3 - User-based security model (USM)

supertypes ​

valData value type
scalarScalar is an atomic value kind
strUnicode string of characters


def ​

snmpWrite ​

SNMP address to use for writing a point. It is formatted as the SNMP object identifier for that point.


meta ​

defsnmpWrite
isstr
liblib:snmp
tagOnsnmpPoint

supertypes ​

valData value type
scalarScalar is an atomic value kind
strUnicode string of characters