snmp_get_next()
Return variables from the SNMP Management Information Base (MIB) that are lexicographically next to the specified variable names 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-next-request is submitted The session is the ID returned when an snmp_open() function is executed. |
variablen | variable name that is to receive a value from the SNMP MIB for session The string variablen is used to find the variable in the MIB whose name is the nearest alphabetically greater name than variablen. The value of that variable is returned. One variable name is required; additional variable names are optional. |
Description
The snmp_get_next() sends an SNMP get-next-request to session to retrieve the value of the Management Information Base (MIB) variable whose name is lexicographically next to the name variablen. The snmp_get_next() function returns a space-separated list of the variables and their MIB names or the NULL string if an error occurs.
The snmp_get_next() 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_next() function is a s list of SNMP variables in the following format:
name type length value
Field | Definition |
---|---|
name | name of an SNMP MIB variable |
type | character string indicating the name type |
length | length of value |
value | value of name |
Example
The following example uses the snmp_get_next() function to retrieve and print all the application instances in the PATROL MIB. The application instance names can also be retrieved (much more easily) using the snmp_walk() function (see snmp_walk()):
local myhost,session,app_start,MIB_entry,address;
myhost = get("/hostname");
session = snmp_open(myhost,"1","","","",8161);
app_start = ".1.3.6.1.4.1.1031.1.1.1.7.1.1";
MIB_entry = trim(snmp_get_next(session,app_start),"\n");
address = nthargf(MIB_entry,1," ");
while (nthargf(MIB_entry,14,".") == "applInstName") {
printf("%s\n",MIB_entry);
MIB_entry = trim(snmp_get_next(session,address),"\n");
address = nthargf(MIB_entry,1," ");
}
printf("\n");
snmp_close(session);
return;
}