1 2 23 24 package net.fenyo.gnetwatch; 25 26 import org.apache.commons.logging.Log; 27 import org.apache.commons.logging.LogFactory; 28 29 import java.net.*; 30 import java.io.*; 31 32 import org.snmp4j.*; 33 import org.snmp4j.smi.*; 34 import org.snmp4j.mp.*; 35 import org.snmp4j.transport.*; 36 import org.snmp4j.event.*; 37 import org.snmp4j.security.*; 38 39 45 46 public class SNMPManager { 47 private static Log log = LogFactory.getLog(SNMPManager.class); 48 private final Snmp snmp; 49 50 55 public SNMPManager() throws IOException { 56 TransportMapping transport = new DefaultUdpTransportMapping(); 57 snmp = new Snmp(transport); 58 final USM usm = new USM(SecurityProtocols.getInstance(), new OctetString(MPv3.createLocalEngineID()), 0); 59 SecurityModels.getInstance().addSecurityModel(usm); 60 transport.listen(); 61 } 62 63 68 public SNMPQuerier getQuerier(final InetAddress address) { 69 return new SNMPQuerier(address, this); 70 } 71 72 77 protected Snmp getSNMP() { 78 return snmp; 79 } 80 } 81 | Popular Tags |