Description
The application attached herewith snmp-servlet.zip showcase a basic web application that provides a web page which displays a counter, each time the page is refreshed the counter is incremented. Alternatively, a message can be set through JMX that will display on the web page as well. The application also register a MBean providing the following set of monitoring information :
-
counter : the current value of the counter
-
message : allows to retrieve and set the value of the message that will be displayed on the page along with the counter
-
messageHistory : all the values that have been set since the application is running returned as a java.util.List<String>
-
messageHistoryAsArray : all the values that have been set since the application is running returned as a String array.
-
countHistory : all the values that have been displayed since the application is running returned as a primitive int array.
-
messageCountHistory : a Map which have as a key the message and as a value the corresponding counter value that was present when the message was set.
The application also send will make use of the SNMP Agent MBean Service to send a SNMP trap on when the application is deployed.
All those information will be used for testing the different SNMP PDUs.
Mapping Application JMX Attributes and Notifications to SNMP
Similarly on how the The SNMP Adaptor JBoss Service allows to map the MBean and JMX Notifications from the JBoss Application Server and its components through the Attributes and Notifications configuration files, the The SNMP Adaptor JBoss Deployer will check for applications deployed within the JBoss Application Server if they contains either a snmp-attributes.xml file or a snmp-notifications.xml or both.
The Attributes configuration file
It is located at META-INF/attributes.xml and have the exact same schema as SNMP Adaptor Attributes configuration file
The configuration file for the example attached is the following and describes the mapping between the MBean and its attributes defined in the Description section above :
<?xml version="1.0"?>
<attribute-mappings>
<mbean name="test.com:service=SnmpTest" oid-prefix=".1.3.6.1.4.1.2312.100.10.11">
<attribute name="Message" oid=".1" mode="rw"/>
<attribute name="Count" oid=".2"/>
<attribute name="MessageHistory" oid=".3.1" table="true" mode="rw"/>
<attribute name="MessageHistoryAsArray" oid=".4.1" table="true" mode="rw"/>
<attribute name="CountHistory" oid=".5.1" table="true" mode="rw"/>
<attribute name="MessageCountHistory" oid=".6.1" table="true" mode="rw"/>
</mbean>
</attribute-mappings>
NOTE: OIDs used in example have been created "randomly" with RedHat OID prefix and example specific OID leafs!
The Notifications configuration file
It is located at META-INF/notifications.xml and have the exact same schema as SNMP Adaptor Notifications configuration File
The configuration file for the example attached is the following and describes the mapping between the notification that will be sent in the Description section above :
<?xml version="1.0"?>
<notification-map-list>
<mapping notification-type="snmp.servlet.test.coldstart" generic="6" specific="10" enterprise="1.3.6.1.4.1.2312.100.11" security-name="TEST">
<var-bind-list wrapper-class="org.jboss.jmx.adaptor.snmp.agent.NotificationWrapperSupport">
<var-bind tag="u:startTime" oid="1.3.6.1.4.1.2312.100.10.11.1" type="OctetString"/>
</var-bind-list>
</mapping>
</notification-map-list>