SNMP Operations
The routines for performing SNMP operations correspond to the standard SNMP Version 1 operations[78] and have the following parameters in common:
- community (optional)
The community string. If no community string is specified, public is used.
- host (required)
The hostname or IP address of the device you want to query.
- port (optional)
The port number to which to send the query or trap. The default for all routines except
snmptrap()is 161. The default forsnmptrap()is 162.
- timeout (optional)
The timeout in seconds; if no response is received within this period, the operation is considered to have failed and is retried. The default is 2 seconds.
- retries (optional)
The number of retries before the routine returns failure. The default is 5.
- backoff (optional)
The backoff value; for each successive retry, the new timeout period is obtained by multiplying the current timeout with the backoff. The default is 1.
- OID (required)
The object ID or textual name of the object you are querying.
snmpget( )
The syntax of the
snmpget() routine is:
snmpget(community@host:port:timeout:retries:backoff, OID, [OID...])If snmpget() fails, it returns
undef.
Recall that all the MIB-II objects are preloaded into this Perl module, so the following code is legal:
@sysDescr = snmpget("public\@cisco.ora.com", "sysDescr");We did not specify any of the optional parameters
(timeout, backoff, etc.);
the default values will be used. This routine lets us request
"sysDescr" as shorthand for
sysDescr.0. When ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access