public void doSnmpTrapTest() { // host = hosttext.getText(); // oid = oidtext.getText(); SnmpProperty sp = new SnmpProperty(); sp.setComponent(this); sp.setTargetHost(host); sp.setLocalPort("4009"); sp.setObjectID("1.5.0"); String[] str = {"java.lang.String"}; Object[] obj = new Object[1]; try { eventId = mc.registerForNotification(sp); } catch (Exception ep) { System.out.println("Exceep is " + ep); } }
public void doSnmpNmsTest() { // Instantiating Management Server. String a[] = {"", "com.adventnet.nms.client.ms.MSClientTransporter", "", ""}; mc = ManagementClient.getInstance(a); // Instantiating SnmpProperty. SnmpProperty sp = new SnmpProperty(); // Setting SNMP properties. sp.setTargetHost(host); sp.setObjectID(oid); sp.setOperationType(com.adventnet.management.Property.OP_READ); ManagementServerResultEvent re = null; try { re = mc.syncSend(sp); } catch (Exception e) { System.out.println("Exception at syncSend " + e); } if (re.getErrString() != null) { // System.err.println("Error="+re.getErrString() ); MSSnmpTestPanel.setMSTextArea(re.getErrString()); return; } if (re != null) { String result = re.getStringResult(); if (re.getResult() instanceof Object[]) { Object[] objarr = (Object[]) re.getResult(); for (int i = 0; i < objarr.length; i++) { // System.out.println("Result "+i+"==" + objarr[i]); MSSnmpTestPanel.setMSTextArea(objarr[i].toString()); } } } else { System.err.println("Could not able to get the reply"); } }