snmp_h_get()


Return variables from the PATROL SNMP Management Information Base (MIB) using a brief (local) session and default parameters from a specified agent.

Syntax

snmp_h_get(host,variable1,[...variablen])

Parameter

Parameter

Definition

host

name of the computer to which the SNMP get-request is submitted The host must be a name known to the local computer in the /etc/hosts file, the Domain Name System (DNS), the Network Information Service (NIS), or an IP address.

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_h_get() function is the equivalent of the following series of PSL function calls:

 

session = snmp_open(host);
snmp_get(session,variable1,...,variablen);
snmp_close(session);

The snmp_h_get() function performs the following tasks:

  • opens an SNMP session on host (For the default parameters used to open the session, see snmp_open().)
  • sends an SNMP get-request command to the session to retrieve the values of variable1, . . . variablen from the SNMP Management Information Base (MIB)
  • closes the SNMP session

The snmp_h_get() function returns a space-separated list of the variables or the NULL string if an error occurs. 

The snmp_h_get() function can set the PSL errno value to one of the following values:

errno Value

Description

95

E_PSL_TIMEOUT -- request timed out

100

E_PSL_SNMP_ERROR -- error is returned in the response packet from the SNMP session

Output Format

The output of the snmp_h_get() 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_h_get() function to retrieve the first application instance name from the PATROL MIB:

function main() {
local myhost,param_start;
myhost = get("/hostname");
param_start = ".1.3.6.1.4.1.1031.1.1.1.6.1.1.0";
printf("%s\n",trim(snmp_h_get(myhost,param_start),"\n"));
return;
}

 

Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*