Want to monitor a Java application not deployed to an Application Server from SCOM?
BeanSpy from Microsoft bridges JMX to SCOM nicely, but the associated SCOM Management Pack expects to interrogate an Application Server for a list of applications before it allows access to general JMX attributes.
This is a simple web application that can be loaded using (say) an embedded Jetty engine into any Java application. It emulates some Tomcat Catalina MBeans so that SCOM thinks it's talking to Tomcat. Once you're over that hurdle, all JMX attribtues on that JVM are available to you.
cd beanspy-tomcat-emulator
mvn clean package
Resulting package is in target/beanspy-tomcat-emulator.war
The following instructions assume ActiveMQ is installed in ${activemq.home}
beanspy-web.xml
from this repo, then runwget https://github.com/downloads/liupeirong/BeanSpy/BeanSpy_binary.zip
unzip BeanSpy_binary.zip BeanSpy.HTTP.NoAuth.war
zip BeanSpy.HTTP.NoAuth.war -d META-INF/*
unzip BeanSpy.HTTP.NoAuth.war WEB-INF/web.xml
cp beanspy-web.xml WEB-INF/web.xml
jar -uf BeanSpy.HTTP.NoAuth.war WEB-INF/web.xml
BeanSpy.HTTP.NoAuth.war
to ${activemq.home}/webapps
${activemq.home}/conf/jetty.xml
<bean class="org.eclipse.jetty.webapp.WebAppContext">
<property name="contextPath" value="/BeanSpy"/>
<property name="war" value="${activemq.home}/webapps/BeanSpy.HTTP.NoAuth.war" />
<property name="logUrlOnStart" value="true" />
</bean>
beanspy-tomcat-emulator.war
to ${activemq.home}/webapps
${activemq.home}/conf/jetty.xml
before the BeanSpy webapp added above (the emulation must be running before BeanSpy is loaded to ensure it believes the Tomcat container illusion)<bean class="org.eclipse.jetty.webapp.WebAppContext">
<property name="contextPath" value="/tomcat-emulator" />
<property name="war" value="${activemq.home}/webapps/beanspy-tomcat-emulator.war" />
<property name="logUrlOnStart" value="true" />
<property name="overrideDescriptor" value="${activemq.home}/conf/beanspy-tomcat-emulator-apps.xml" />
</bean>
beanspy-tomcat-emulator-apps.xml
from this repo to ${activemq.home}/webapps
${activemq.home}/conf/log4j.properties
contains the line log4j.logger.org.eclipse.jetty=INFO
(default level is WARN)activemq.log
:2013-11-08 10:03:36,376 | INFO | ---> bean context listener started | com.sixtree.esb.monitoring.BeanSpyTomcatEmulator | main
2013-11-08 10:03:36,376 | INFO | ---> Loading application: App1 | com.sixtree.esb.monitoring.BeanSpyTomcatEmulator | main
2013-11-08 10:03:36,377 | INFO | ------> created ContextMBean | org.apache.catalina.mbeans.ContextMBean | main
2013-11-08 10:03:36,377 | INFO | ------> registerMBean ok | com.sixtree.esb.monitoring.BeanSpyTomcatEmulator | main
2013-11-08 10:03:36,378 | INFO | ---> Loading application: App2 | com.sixtree.esb.monitoring.BeanSpyTomcatEmulator | main
2013-11-08 10:03:36,378 | INFO | ------> created ContextMBean | org.apache.catalina.mbeans.ContextMBean | main
2013-11-08 10:03:36,378 | INFO | ------> registerMBean ok | com.sixtree.esb.monitoring.BeanSpyTomcatEmulator | main
2013-11-08 10:03:36,379 | INFO | ---> Loading application: App3 | com.sixtree.esb.monitoring.BeanSpyTomcatEmulator | main
2013-11-08 10:03:36,379 | INFO | ------> created ContextMBean | org.apache.catalina.mbeans.ContextMBean | main
2013-11-08 10:03:36,379 | INFO | ------> registerMBean ok | com.sixtree.esb.monitoring.BeanSpyTomcatEmulator | main
2013-11-08 10:03:36,379 | INFO | started o.e.j.w.WebAppContext{/tomcat-emulator,file:/Users/yamen/Coding/beanspy-tomcat-emulator/activemq/apache-activemq-5.9.0/webapps/beanspy-tomcat-emulator/} | org.eclipse.jetty.server.handler.ContextHandler | main
Check that the applications have been correctly loaded at http://localhost:8161/tomcat-emulator/
Check out the output for the relevant BeanSpy query at http://localhost:8161/BeanSpy/MBeans?JMXQuery=Catalina:j2eeType=WebModule,*&MaxDepth=0