Open a PATROL Agent SNMP session with a PATROL Agent.







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.


SNMP version

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


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

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


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


number of retries to attempt when a timeout occurs

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


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

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


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: 


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.


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