Trap snmp

farahoo Messages postés 45 Date d'inscription vendredi 12 février 2010 Statut Membre Dernière intervention 9 mai 2010 - 13 avril 2010 à 21:06
farahoo Messages postés 45 Date d'inscription vendredi 12 février 2010 Statut Membre Dernière intervention 9 mai 2010 - 14 avril 2010 à 11:52
bonjour
expliquez moi svp ces lignes de codes
public class TrapReceiver implements CommandResponder
{
private MultiThreadedMessageDispatcher dispatcher;
private Snmp snmp = null;
private Address listenAddress;
private ThreadPool threadPool;
public String msg;
private GTrap g;


public TrapReceiver()
{
// BasicConfigurator.configure();
}

2 réponses

cs_DARKSIDIOUS Messages postés 15814 Date d'inscription jeudi 8 août 2002 Statut Membre Dernière intervention 4 mars 2013 130
13 avril 2010 à 21:26
Salut,

C'est des déclarations de variables membres de la classe TrapReceiver.
______________________________________

AVANT de poster votre message, veuillez lire, comprendre, et appliquer notre réglement
0
farahoo Messages postés 45 Date d'inscription vendredi 12 février 2010 Statut Membre Dernière intervention 9 mai 2010
14 avril 2010 à 11:52
et cette suite expliquer la moi svp
public TrapReceiver()
{
// BasicConfigurator.configure();
}

public void Aff_Gtrap(GTrap g)
{
this.g=g;
g.init_table();

}

private void init() throws UnknownHostException, IOException
{
try
{
threadPool = ThreadPool.create("Trap", 2);
dispatcher = new MultiThreadedMessageDispatcher(threadPool,new MessageDispatcherImpl());
listenAddress = GenericAddress.parse(System.getProperty("snmp4j.listenAddress", "udp:0.0.0.0/162"));
TransportMapping transport;

if (listenAddress instanceof UdpAddress)
{
transport = new DefaultUdpTransportMapping((UdpAddress) listenAddress);
}
else
{
transport = new DefaultTcpTransportMapping((TcpAddress) listenAddress);
}
snmp = new Snmp(dispatcher, transport);
snmp.getMessageDispatcher().addMessageProcessingModel(new MPv1());
snmp.getMessageDispatcher().addMessageProcessingModel(new MPv2c());
snmp.getMessageDispatcher().addMessageProcessingModel(new MPv3());
USM usm = new USM(SecurityProtocols.getInstance(), new OctetString(MPv3.createLocalEngineID()), 0);
SecurityModels.getInstance().addSecurityModel(usm);
snmp.listen();
}
catch(Exception e)
{
//System.out.println("Erreur");
}
}

public void run()
{
try
{
init();
snmp.addCommandResponder(this);
//System.out.println("Lancé!");
}
catch (Exception ex)
{
//ex.printStackTrace();
}
}

public void processPdu(CommandResponderEvent respEvnt)
{
if (respEvnt != null && respEvnt.getPDU() != null)
{
Address adr=respEvnt.getPeerAddress();
String ip=adr.toString();
ip=ip.substring(0, ip.indexOf("/"));
Vector<VariableBinding> recVBs = respEvnt.getPDU().getVariableBindings();
for (int i = 0; i < recVBs.size(); i++)
{
VariableBinding recVB = recVBs.elementAt(i);
msg=recVB.getOid()+ " : "+ ip + " = " + recVB.getVariable();

g.Load_table();
}

}
}
}
0
Rejoignez-nous