public class DpSnmpNotifier extends Thread
This class implements SNMP notification. The purpose of this class to provide a mechanism for sending SNMP notifications.
Example: 1 - Send SNMP V1 Notification.
// int port = Conf.PORT for ConfD or Conf.NCS_PORT for NCS Socket s1 = new Socket("localhost", port); Dp dp1 = new Dp("snmp_MYNAME", s1); // Create notification notifier. // std_v1_trap must exist in notify_init.xml. DpSnmpNotifier notifier1 = dp1.createSnmpNotifier("std_v1_trap", ""); // Sense a cold start notification. notifier1.send("coldStart", new SnmpVarbind[] {});Example 2: - Send SNMP Inform Request Using the following Snmp inform response callback:
public class MySnmpInformResponseCallback { @SnmpInformResponseCallback(callPoint = "snmp_inform", callType = { SnmpInformResponseCBType.TARGETS }) public void targets(Integer ref, ConfETuple[] targets) throws DpCallbackException { // Add implementation here } @SnmpInformResponseCallback(callPoint = "snmp_inform", callType = { SnmpInformResponseCBType.RESULT }) public void result(Integer ref, ConfETuple target, Boolean gotResponse) throws DpCallbackException { // Add implementation here } }We can send an Snmp inform
// int port = Conf.PORT for ConfD or Conf.NCS_PORT for NCS Socket s2 = new Socket("localhost", port); Dp dp2 = new Dp("snmp_MYNAME", s2); // Register callback handling targets and result. MySnmpInformResponseCallback myCb = new MySnmpInformResponseCallback(); // Create notification notifier. std_v2_notification must exist in // notify_init.xml and support V2 DpSnmpNotifier notifier2 = dp2.createSnmpNotifier("std_v2_notification", "", myCb); // Send SNMP inform request. // notif1 must exist in a MIB in the configuration. notifier2.send("notif", new SnmpVarbind[] { new SnmpVarbind("Integer32", new ConfInt32(32))}, 10);
Thread.State, Thread.UncaughtExceptionHandler
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
Modifier and Type | Method and Description |
---|---|
String |
getContextName() |
int |
getFD()
file descriptor
|
DpSnmpInformResponseCallback |
getInformCb()
The inform callback.
|
String |
getNotifyName()
The notify_init.xml notify name.
|
Socket |
getSocket()
The worker socket which is connected to ConfD/NCS.
|
void |
send(String notification,
SnmpVarbind[] varbinds)
Send SNMP notification.
|
void |
send(String notification,
SnmpVarbind[] varbinds,
Integer ref)
Send SNMP notification with the option to receive an Inform Response.
|
void |
setFD(int fd) |
void |
setSocket(Socket socket) |
void |
setSourceAddress(ConfIP sourceIP)
Set the source IP address to be bound when sending notifications using
the send() method.
|
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, run, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
public Socket getSocket()
Dp.createSnmpNotifier(String, String, Object)
.public void setSocket(Socket socket)
public int getFD()
public void setFD(int fd)
public void setSourceAddress(ConfIP sourceIP)
sourceIP
- ConfIPv4 or ConfIPv6 addresspublic String getNotifyName()
public String getContextName()
public DpSnmpInformResponseCallback getInformCb()
public void send(String notification, SnmpVarbind[] varbinds) throws ConfException
notification
- is the notification name. For example "coldStart" or
"warmStart". This symbolic name of a notification must be
defined in a MIB that is loaded into the agent.varbinds
- An array of variable bindingsConfException
public void send(String notification, SnmpVarbind[] varbinds, Integer ref) throws ConfException
notification
- is the notification name. For example "coldStart" or
"warmStart". This symbolic name of a notification must be
defined in a MIB that is loaded into the agent.varbinds
- an array of variable bindingsref
- a reference provided by the caller. This reference is provided
provided in the callback methods on
DpSnmpInformResponseCallback
ConfException