snmp_open()
Open a PATROL Agent SNMP session with a PATROL Agent.
Syntax
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* |
community | name of the character string used as a community string for SNMP operations *Default* |
timeout | session timeout parameter in milliseconds (ms)Default |
retries | number of retries to attempt when a timeout occurs *Default* |
port | user Datagram Protocol (UDP) port number on which to open the SNMP session *Default* |
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:
session = snmp_open(myhost,"","","","",8161);