snmp_open()

Open a PATROL Agent SNMP session with a PATROL Agent.

Syntax

snmp_open(host,version,community,timeout,retries,port)

Parameter

Parameter

Definition

host

name of the computer to open a session with the SNMP agent 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.

version

SNMP version

*Valid Values* 
1 (this function does not currently support SNMP Version 2)

community

name of the character string used as a community string for SNMP operations

*Default* 
value of the /snmp/default_r_community agent configuration variable or public

timeout

session timeout parameter in milliseconds (ms)Default 
value of the /snmp/default_timeout agent configuration variable or 500 ms (0.5 second)

retries

number of retries to attempt when a timeout occurs

*Default* 
value of the /snmp/default_retries agent configuration variable or 3

port

user Datagram Protocol (UDP) port number on which to open the SNMP session

*Default* 
value of the /snmp/default_port agent configuration variable or 8161

Description

The snmp_open() function opens a session to the SNMP agent on host using User Datagram Protocol port, specifying the indicated session parameters. The snmp_open() function returns the session id if successful and the NULL string if unsuccessful. 

The session ID consists of the characters "sess" followed by a numeric value as follows: 

sess1 

The snmp_open() function does not verify that it can reach the host or that an SNMP agent exists on host--it just creates its internal data structure with the parameters to be used in SNMP transactions. 

All sessions to an SNMP agent share a single socket opened by the first snmp_open() function call and closed by the last snmp_close() function call. The snmp_open function sets the PSL errno variable to E_PSL_SOCKET_BUSY if the call is the first call to open a session and the socket cannot be opened. The condition may indicate that the SNMP agent has no more available file descriptors.

Example

The following PSL script presents a common way to open a session with the PATROL SNMP Agent service on your local machine:

myhost = get("/hostname");
session = snmp_open(myhost,"","","","",8161);


Was this page helpful? Yes No Submitting... Thank you

Comments