snmp_get()
Request SNMP variables from the PATROL SNMP Management Information Base (MIB) on the agent that the SNMP session is opened with.
Syntax
Parameter
Parameter | Definition |
---|---|
session | ID of the SNMP session to which the SNMP get-request command is submitted The session is the ID returned when an snmp_open() function is executed. |
variablen | name of an SNMP MIB variable The variablen can be specified in numeric form or in symbolic form if the MIB is known to the PATROL Agent. One variable name is required; additional variable names are optional. |
Description
The snmp_get() function sends an SNMP get-request command to session to retrieve the values of variable1, . . . variablenfrom the SNMP Management Information Base (MIB). The snmp_get() function returns a space-separated list of the variables or the NULL string if an error occurs.
The snmp_get() function can set the PSL errno value to one of the following values:
errno Value | Description |
---|---|
95 | E_PSL_TIMEOUT-- request timed out |
93 | E_PSL_NO_SUCH_ID --bad session id or no session ID |
100 | E_PSL_SNMP_ERROR -- error is returned in the response packet from the SNMP session |
Output Format
The output of the snmp_get() function depends on the data type of the parameters that are used to call this function. Using string parameters returns information in the following format:
Field | Definition |
---|---|
name | name of an SNMP MIB variable |
length | length of value |
type | character string indicating the name type |
value | value of name |
Calling the snmp_get() function with parameters of any other data type returns information in the following format:
Field | Definition |
---|---|
name | name of an SNMP MIB variable |
type | character string indicating the name type |
value | value of name |
Example
This script uses the snmp_get() function to return a value from PATROL SNMP MIB:
session = snmp_open(myhost,"","","","","");
value = snmp_get(session,".1.3.6.1.4.1.1031.1.1.1.6.1.1.0");
if (errno == 0) {
print("snmp_get() for PatrolAgent <platform>.km:\n");
print(value);
} else {
print("snmp_get() failed... errno = ".errno.".\n");
}
snmp_close(session);
The previous example produces the following output:
1.3.6.1.4.1.1031.1.1.1.6.1.1.0 2 string HP