home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


Book HomeEssential SNMPSearch this book

E.2. SNMP Operations

The routines for performing SNMP operations correspond to the standard SNMP Version 1 operations[81] and have the following parameters in common:

[81]Simon Leinen's package supports both SNMP v1 and v2; Mike Mitchell's SNMP_util module supports only v1.

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 for snmptrap() 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.

E.2.5. snmptrap( )

The snmptrap() routine generates an SNMPv1 trap. Most of the arguments are familiar:

snmptrap(community@host:port:timeout:retries:backoff, 
         enterpriseOID, agent, generalID, specificID, 
         OID, type, value, [OID, type, value...])
The enterpriseOID, agent, generalID, and specificID arguments are discussed in
Chapter 10, "Traps". Each OID/type/value triplet defines a data binding to be included in the trap. OID is the object ID of the variable you want to send, value is the value you want to send for this object, and type is the object's datatype. type must be one of the following three strings:

string
Represents the string type

int
Represents the 32-bit integer type

oid
Represents the object identifier (OID) type

If snmptrap() fails, it returns undef. See Chapter 10, "Traps" for a more detailed discussion of SNMP traps.



Library Navigation Links

Copyright © 2002 O'Reilly & Associates. All rights reserved.