|
RMI applications with JDK 1.2 throw SecurityException. How do I avoid this?
Our product currently uses the com.adventnet.snmp.rmi package, the SnmpTarget, and the snmpGet method for data retrieval. Can I combine multiple varbinds into a single SNMP GET message? Can I use snmpGetList or snmpGetAllList? How are they different? How do I control the size without exceeding the 484 byte SNMP payload limit when I add varbinds?
RMI requests are slow in Windows NT and Windows 2000 machines. Why is this so?
I always get "Request Timed Out to 10.0.14.79" and 10.0.14.79 is our simulator. However, it works fine while using snmpget in applications directory.
1. RMI applications with JDK 1.2 throw SecurityException. How do I avoid this?
To run rmi in JDK1.2 environment, you need to set the security permission and file permission as follows.
|
grant { // allows anyone to listen on un-privileged ports permission java.net.SocketPermission "localhost:161-65535", "listen,accept,connect,resolve";
// Assuming mibs directory is present in the c Drive. permission java.io.FilePermission "c:\\mibs\\-","read, write"; }; |
A sample SNMPRmi.policy file is available in the rmiclient sub directory in the examples directory.
To run the AdventNetSNMP rmi server, give the following command from the rmiclient directory.
|
java -Djava.security.policy=SNMPRmi.policy com.adventnet.snmp.rmi.SnmpFactoryImpl |
Alternatively, you can use the files start_rmi_server.bat (Windows) or start_rmi_server.sh (Linux/Solaris) present in rmiclient directory.
|
|
Note: For granting file permissions to different directories, you may need to edit the SNMPRmi.policy and include the directory names in the policy file. |
2. Our product currently uses the com.adventnet.snmp.rmi package, the SnmpTarget interface, and the snmpGet method for data retrieval. Can I combine multiple varbinds into a single SNMP GET message? Can I use snmpGetList or snmpGetAllList? How are they different? How do I control the size without exceeding the 484 byte SNMP payload limit when I add varbinds?
The snmpGetList method makes a get request for a list of OIDs while the snmpGetAllList walks from a particular OID. You can use the snmpGetList to combine multiple varbinds and perform a GET operation.
While constructing a PDU, you have to check its size. If it exceeds the limit, it has to be reconstructed by splitting the PDU. You can get the length of the PDU by using the method pdu.getEncodedLength(). However, you have to set the community on the PDU to get the right encoded length. If the length exceeds the limit, split the number of varbinds to be sent into two sets and construct two PDUs.
3. RMI requests are slow in Windows NT and Windows 2000 machines. Why is this so?
This is because, in Windows NT and Windows 2000, while making SNMP requests through RMI, the RMI Registry does a DNS lookup for the IP address specified.
The following workaround should solve the problem.
Open the 'hosts' file present at <WINNT_HOME>\system32\drivers\etc directory, where '<WINNT_HOME>' is the directory in which Win NT was installed.
Add the IP Address and the hostname of the machine where the agent runs. It has to be separated by a space as a new entry at the end of the file.
For example, 192.168.7.232 AgentMachine
Save this file.
4. I always get "Request Timed Out to 10.0.14.79" and 10.0.14.79 is our simulator. However, it works fine while using snmpget in applications directory.
This error might occur due to the following reasons.
The agent might be down: This reason is ruled out because nondistributed examples work for the same agent.
The agent is slow in responding to the request: Increase the timeout value. By default, it is 5 seconds.
The port at which the agent listens might be different: Set the port by using the '-p' option.
SocketPermission for accepting connections may not be set: In the java.policy file in <Java-Home>\jre\lib\security directory, modify the code as follows.
|
java.net.SocketPermission "*:161-60000", "listen,connect,accept"; |
If you do not have the entry "accept", then you might face the timeout problem. Assuming that you have permissions to listen and connect to the socket, create the SnmpTarget and send the requests. The timeout occurs if you do not have permission to accept messages through the socket. Verify the entry in your policy file.
|