| | |
| | | import com.sun.management.snmp.manager.SnmpRequest; |
| | | import com.sun.management.snmp.manager.SnmpSession; |
| | | import java.net.InetAddress; |
| | | import java.util.ArrayList; |
| | | import java.util.Map.Entry; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.config.AbstractManagedObjectDefinition; |
| | | import org.forgerock.opendj.config.server.AdminTestCaseUtils; |
| | | import org.forgerock.opendj.server.config.meta.SNMPConnectionHandlerCfgDefn; |
| | | import org.forgerock.opendj.server.config.server.SNMPConnectionHandlerCfg; |
| | | import org.opends.server.core.ModifyOperationBasis; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.forgerock.opendj.config.server.ConfigChangeResult; |
| | | import org.opends.server.types.Control; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.opends.server.types.Modification; |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.testng.annotations.AfterClass; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.DataProvider; |
| | |
| | | // |
| | | agent.setParams(params); |
| | | |
| | | // Build the session. A session creates, controls and |
| | | // Build the session. A session creates, controls and |
| | | // manages one or more requests. |
| | | // |
| | | try { |
| | |
| | | final SnmpSession session = |
| | | new SnmpSession("SyncManager session"); |
| | | |
| | | // A default peer (agent) can be associated to a SnmpSession. |
| | | // A default peer (agent) can be associated to a SnmpSession. |
| | | // When invoking a service provided by the SnmpSession, if the |
| | | // agent is not specified, the session will perform the service |
| | | // using the default peer as the target of the service. |
| | |
| | | return; |
| | | } |
| | | |
| | | // Now we have a response. Check if the response contains |
| | | // Now we have a response. Check if the response contains |
| | | // an error. |
| | | // |
| | | final int errorStatus = request.getErrorStatus(); |
| | |
| | | // Specify the OidTable containing all the MIB II knowledge. |
| | | // Use the OidTable generated by mibgen when compiling MIB II. |
| | | // |
| | | final SnmpOidTableSupport oidTable = new |
| | | final SnmpOidTableSupport oidTable = new |
| | | DIRECTORY_SERVER_MIBOidTable(); |
| | | |
| | | SnmpOid.setSnmpOidTable(oidTable); |
| | |
| | | // At any time, it is possible to add knowledge in the OidTable |
| | | // using the SnmpOidDatabaseSupport. |
| | | // For instance, we could start the Manager API like that: |
| | | // SnmpOidDatabaseSupport oidDB = |
| | | // SnmpOidDatabaseSupport oidDB = |
| | | // new SnmpOidDatabaseSupport(); |
| | | // SnmpOid.setSnmpOidTable(oidDB); |
| | | // Then over time, MIB knowledge can be added as follows: |
| | | // oidDB.add(oidTable); |
| | | // |
| | | |
| | | // Create a SnmpPeer object for representing the entity to |
| | | // communicate with. |
| | | // Create a SnmpPeer object for representing the entity to |
| | | // communicate with. |
| | | // |
| | | final SnmpPeer agent = |
| | | new SnmpPeer(host, this.getSnmpPort()); |
| | |
| | | // with. |
| | | // When creating the parameter object, you can specify the read |
| | | // and write community to be used when querying the agent. |
| | | // |
| | | // |
| | | final SnmpParameters params = |
| | | new SnmpParameters(); |
| | | params.setRdCommunity(community); |
| | |
| | | // |
| | | agent.setParams(params); |
| | | |
| | | // Build the session. A session creates, controls and |
| | | // Build the session. A session creates, controls and |
| | | // manages one or more requests. |
| | | // |
| | | final SnmpSession session = |
| | | new SnmpSession("SyncManager session"); |
| | | |
| | | // A default peer (agent) can be associated to a SnmpSession. |
| | | // A default peer (agent) can be associated to a SnmpSession. |
| | | // When invoking a service provided by the SnmpSession, if the |
| | | // agent is not specified, the session will perform the service |
| | | // using the default peer as the target of the service. |
| | |
| | | return; |
| | | } |
| | | |
| | | // Now we have a response. Check if the response contains |
| | | // Now we have a response. Check if the response contains |
| | | // an error. |
| | | // |
| | | final int errorStatus = request.getErrorStatus(); |