| Method from org.jboss.jmx.adaptor.snmp.agent.SnmpAgentService Detail: |
public String getBindAddress() {
String address = null;
if (this.bindAddress != null)
address = this.bindAddress.getHostAddress();
return address;
}
Gets the agent bind address |
public boolean getDynamicSubscriptions() {
return this.dynamicSubscriptions;
}
Gets the dynamic subscriptions status |
public int getHeartBeatPeriod() {
return this.heartBeatPeriod;
}
Gets the heartbeat switch |
public long getInstantiationTime() {
return this.clock.instantiationTime();
}
Returns the difference, measured in milliseconds, between the
instantiation time and midnight, January 1, 1970 UTC. |
public String getManagersResName() {
return this.managersResName;
}
Gets the name of the file containing SNMP manager specifications |
public String getNotificationMapResName() {
return this.notificationMapResName;
}
Gets the name of the file containing the notification/trap mappings |
public int getNumberOfThreads() {
return numberOfThreads;
}
Gets the number of threads in the agent requests processing thread pool |
public int getPort() {
return port;
}
Gets the agent listening port number |
public String getRequestHandlerClassName() {
return requestHandlerClassName;
}
Gets the RequestHandler implementation class |
public String getRequestHandlerResName() {
return requestHandlerResName;
}
Gets the resource file name containing get/set mappings |
public int getSnmpVersion() {
return snmpVersion;
}
Gets the snmp protocol version |
public ObjectName getTimerName() {
return this.timerName;
}
Gets the utilised timer MBean name |
public long getTrapCount() {
return this.trapCounter.peek();
}
Returns the current trap counter reading |
public String getTrapFactoryClassName() {
return this.trapFactoryClassName;
}
Gets the utilised trap factory name |
public long getUptime() {
return this.clock.uptime();
}
|
public void handleNotification2(Notification n,
Object handback) {
if (log.isTraceEnabled()) {
log.trace("Received notification: < " + n + " > Payload " +
"TS: < " + n.getTimeStamp() + " > " +
"SN: < " + n.getSequenceNumber() + " > " +
"T: < " + n.getType() + " >");
}
try {
this.trapEmitter.send(n);
}
catch (Exception e) {
log.error("Sending trap", e);
}
}
All notifications are intercepted here and are routed for emission. |
public void reconfigureRequestHandler() throws Exception {
if (requestHandler instanceof Reconfigurable)
((Reconfigurable)requestHandler).reconfigure(getRequestHandlerResName());
else
throw new UnsupportedOperationException("Request handler is not Reconfigurable");
}
Reconfigures the RequestHandler, reponsible for handling get requests etc. |
public void setBindAddress(String bindAddress) throws UnknownHostException {
this.bindAddress = toInetAddress(bindAddress);
}
Sets the agent bind address |
public void setDynamicSubscriptions(boolean dynamicSubscriptions) {
this.dynamicSubscriptions = dynamicSubscriptions;
}
Enables/disables dynamic subscriptions |
public void setHeartBeatPeriod(int heartBeatPeriod) {
this.heartBeatPeriod = heartBeatPeriod;
}
Sets the heartbeat period (in seconds) switch |
public void setManagersResName(String managersResName) {
this.managersResName = managersResName;
}
Sets the name of the file containing SNMP manager specifications |
public void setNotificationMapResName(String notificationMapResName) {
this.notificationMapResName = notificationMapResName;
}
Sets the name of the file containing the notification/trap mappings |
public void setNumberOfThreads(int numberOfThreads) {
if (numberOfThreads > 0 && numberOfThreads < = 12)
{
this.numberOfThreads = numberOfThreads;
}
}
Sets the number of threads in the agent request processing thread pool |
public void setPort(int port) {
if (port >= 0)
{
this.port = port;
}
}
Sets the agent listening port number |
public void setReadCommunity(String readCommunity) {
if (readCommunity != null && readCommunity.length() > 0)
{
this.readCommunity = readCommunity;
}
}
Sets the read community (no getter) |
public void setRequestHandlerClassName(String requestHandlerClassName) {
this.requestHandlerClassName = requestHandlerClassName;
}
Sets the RequestHandler implementation class |
public void setRequestHandlerResName(String requestHandlerResName) {
this.requestHandlerResName = requestHandlerResName;
}
Sets the resource file name containing get/set mappings |
public void setSnmpVersion(int snmpVersion) {
switch (snmpVersion)
{
case SNMPV2:
this.snmpVersion = SNMPV2;
break;
default:
this.snmpVersion = SNMPV1;
break;
}
}
Sets the snmp protocol version |
public void setTimerName(ObjectName timerName) {
this.timerName = timerName;
}
Sets the utilised timer MBean name |
public void setTrapFactoryClassName(String name) {
this.trapFactoryClassName = name;
}
Sets the utilised trap factory name |
public void setWriteCommunity(String writeCommunity) {
if (writeCommunity != null && writeCommunity.length() > 0)
{
this.writeCommunity = writeCommunity;
}
}
Sets the write community (no getter) |
protected void startService() throws Exception {
// initialize clock and trapCounter
this.clock = new Clock();
this.trapCounter = new Counter(0);
// Notification subscription are handled by
// ListenerServiceMBeanSupport baseclass
log.debug("Instantiating trap emitter ...");
this.trapEmitter = new TrapEmitter(this.getTrapFactoryClassName(),
this.trapCounter,
this.clock,
this.getManagersResName(),
this.getNotificationMapResName());
// Start trap emitter
log.debug("Starting trap emitter ...");
this.trapEmitter.start();
// Get the heartbeat going
this.heartbeat = new Heartbeat(this.getServer(),
this.getTimerName(),
this.getHeartBeatPeriod());
log.debug("Starting heartbeat controller ...");
heartbeat.start();
// subscribe for notifications, with the option for dynamic subscriptions
super.subscribe(this.dynamicSubscriptions);
// initialise the snmp agent
log.debug("Starting snmp agent ...");
startAgent();
log.info("SNMP agent going active");
// Send the cold start!
this.sendNotification(new Notification(EventTypes.COLDSTART, this,
getNextNotificationSequenceNumber()));
}
|
protected void stopService() throws Exception {
// unsubscribe for notifications
super.unsubscribe();
log.debug("Stopping heartbeat controller ...");
this.heartbeat.stop();
this.heartbeat = null; // gc
log.debug("Stopping trap emitter ...");
this.trapEmitter.stop();
this.trapEmitter = null;
log.debug("Stopping snmp agent ...");
this.agentSession.close();
this.agentSession = null;
log.info("SNMP agent stopped");
}
|