本文整理了Java中org.snmp4j.PDU.<init>()
方法的一些代码示例,展示了PDU.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。PDU.<init>()
方法的具体详情如下:
包路径:org.snmp4j.PDU
类名称:PDU
方法名:<init>
[英]Default constructor.
[中]默认构造函数。
代码示例来源:origin: apache/nifi
/**
* Construct the PDU to perform the SNMP Get request and returns
* the result in order to create the flow file.
* @return {@link ResponseEvent}
*/
public ResponseEvent get() {
try {
PDU pdu = null;
if(this.target.getVersion() == SnmpConstants.version3) {
pdu = new ScopedPDU();
} else {
pdu = new PDU();
}
pdu.add(new VariableBinding(this.oid));
pdu.setType(PDU.GET);
return this.snmp.get(pdu, this.target);
} catch (IOException e) {
logger.error("Failed to get information from SNMP agent; " + this, e);
throw new ProcessException(e);
}
}
代码示例来源:origin: apache/nifi
pdu = new ScopedPDU();
} else {
pdu = new PDU();
代码示例来源:origin: stackoverflow.com
public static void main(String[] args) throws Exception {
// Create PDU
PDU trap = new PDU();
trap.setType(PDU.TRAP);
OID oid = new OID("1.2.3.4.5");
trap.add(new VariableBinding(SnmpConstants.snmpTrapOID, oid));
trap.add(new VariableBinding(SnmpConstants.sysUpTime, new TimeTicks(5000))); // put your uptime here
trap.add(new VariableBinding(SnmpConstants.sysDescr, new OctetString("System Description")));
//Add Payload
Variable var = new OctetString("some string");
trap.add(new VariableBinding(oid, var));
// Specify receiver
Address targetaddress = new UdpAddress("10.101.21.32/162");
CommunityTarget target = new CommunityTarget();
target.setCommunity(new OctetString("public"));
target.setVersion(SnmpConstants.version2c);
target.setAddress(targetaddress);
// Send
Snmp snmp = new Snmp(new DefaultUdpTransportMapping());
snmp.send(trap, target, null, null);
}
代码示例来源:origin: org.snmp4j/snmp4j
@Override
public PDU createPDU(Target target) {
return new PDU();
}
@Override
代码示例来源:origin: org.kaazing/snmp4j
public PDU createPDU(Target target) {
return new PDU();
}
};
代码示例来源:origin: net.itransformers.snmp2xml4j/snmptoolkit
/** {@inheritDoc} */
@Override
protected PDU createPDU() {
return new PDU();
}
代码示例来源:origin: net.itransformers.snmp2xml4j/snmptoolkit
/** {@inheritDoc} */
@Override
protected PDU createPDU() {
return new PDU();
}
代码示例来源:origin: net.itransformers.snmp2xml4j/snmptoolkit
/** {@inheritDoc} */
@Override
protected PDU createPDU() {
return new PDU();
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.snmp4j
@Override
public PDU createPDU(Target target) {
return new PDU();
}
@Override
代码示例来源:origin: net.itransformers.snmp2xml4j/snmptoolkit
/** {@inheritDoc} */
@Override
protected PDU createPDU() {
return new PDU();
}
代码示例来源:origin: org.snmp4j/snmp4j
@Override
public PDU createPDU(MessageProcessingModel messageProcessingModel) {
return new PDU();
}
代码示例来源:origin: stackoverflow.com
import org.snmp4j.*;
import org.snmp4j.event.*;
...
CommunityTarget target = new CommunityTarget();
target.setCommunity(new OctetString("public"));
target.setAddress(targetAddress);
target.setVersion(SnmpConstants.version2c);
PDU request = new PDU();
request.setType(PDU.V2TRAP);
request.setGenericTrap(PDUv2.COLDSTART);
Snmp snmp = new Snmp(new DefaultUdpTransportMapping());
snmp.listen();
snmp.sendPDU(request, target, null, listener);
代码示例来源:origin: apache/cloudstack
private PDU createPDU(SnmpTrapInfo snmpTrapInfo) {
PDU trap = new PDU();
trap.setType(PDU.TRAP);
代码示例来源:origin: stackoverflow.com
PDU request = new PDU();
request.setType(PDU.GET);
OID oid= new OID("1.3.6.1.2.1.1.1.0");
request.add(new VariableBinding(oid));
代码示例来源:origin: com.rogueai/snmp2bean
private PDU buildDeletPDU(Object entry) throws IllegalArgumentException, IllegalAccessException, SnmpAnnotationException {
PDU pdu = new PDU();
pdu.setType(PDU.SET);
pdu.add(buildDeleteVariableBinding(entry));
return pdu;
}
}
代码示例来源:origin: org.opennms.lib.snmp/org.opennms.lib.snmp.snmp4j
/**
* Creates an SNMP4J PDU based on the SNMP4J version constants.
* A v3 request requires a ScopedPDU.
*
* @param type
* @return
*/
public PDU createPdu(int type) {
PDU pdu = getVersion() == SnmpConstants.version3 ? new ScopedPDU() : new PDU();
pdu.setType(type);
return pdu;
}
代码示例来源:origin: jrask/snmp-blog
private PDU getPDU(OID oids[]) {
PDU pdu = new PDU();
for (OID oid : oids) {
pdu.add(new VariableBinding(oid));
}
pdu.setType(PDU.GET);
return pdu;
}
代码示例来源:origin: com.rogueai/snmp2bean
public PDU buildGetPDU(Class scalarClass, String[] fields) throws SecurityException, NoSuchFieldException {
PDU pdu = new PDU();
pdu.setType(PDU.GET);
for (String fn : fields) {
Field field = scalarClass.getDeclaredField(fn);
MibObjectType mib = field.getAnnotation(MibObjectType.class);
pdu.add(new VariableBinding(new OID(mib.oid())));
}
return pdu;
}
代码示例来源:origin: griddynamics/jagger
public ResponseEvent get(List<OID> oids) throws IOException {
PDU pdu = new PDU();
for (OID oid : oids) {
pdu.add(new VariableBinding(oid));
}
pdu.setType(PDU.GET);
ResponseEvent event = snmp.send(pdu, getTarget(), null);
if(event != null) {
return event;
}
throw new RuntimeException("GET timed out");
}
代码示例来源:origin: com.rogueai/snmp2bean
public PDU buildGetPDU(Class scalarClass) {
PDU pdu = new PDU();
pdu.setType(PDU.GET);
Field[] propFields = SnmpServiceUtil.getPropFields(scalarClass);
for (Field propField : propFields) {
MibObjectType mib = propField.getAnnotation(MibObjectType.class);
pdu.add(new VariableBinding(new OID(mib.oid())));
}
return pdu;
}
内容来源于网络,如有侵权,请联系作者删除!