Consider doing this - its pretty easy (assuming you have or write MBeans that emit measurements for your app):
Just extend the jmx plugin to collect measurements from those MBeans by defining your MBean metadata in a plugin descriptor. We have a custom-jmx-plugin example that can get you started on that. There would be no Java code you'd have to write for your plugin - just some .xml metadata that you package as a plugin .jar. The only Java code you would write would be the MBean code that runs in your app (if you do not already have the MBeans).
That above is already a maven module, check it out and "mvn package" it and out comes a plugin jar that you should be able to deploy in your server (Administration>SystemConfiguration>Plugins from the server UI). Once in your server, restart your agent and it'll pull down the new plugin and start using it.
Thank you guys very much for pointing me to right direction ;)
one quick question regarding JMX:
In my JON 2.2.0, i have generic JMX plugin installed and active. I have several EAP 4.3 servers running and monitored, but i don't see anywhere any JMX subtree for monitoring. So my question is: what is proper way to connect to EAP's JMX and see all things that documentation mentions?
By "JMX Subtree" I assume yuo mean all the Java5 platform MBeans right? Things like the memory subsystem MBean, threading subsystem MBean, etc.
In order for JBossAS to expose them (and thus for the Jopr JMX plugin to monitor them) you need to pass the following system property to JBossAS when you start your app server:
This tells JBossAS to use the platform MBeanServer as ITS MbeanServer - thus, all MBeans - both JBoss's and the Java5 platform's MBeans will be in there.
Thanx, that setting showed new branch in server tree. It is not full JMX, but many important data mostly about JVM. I was looking into custom-jmx-plugin demo, but for me it only works for separate JMX servers like in this example.
I found out that JBossWS exposes MBean with needed statistics for every endpoint, so for my problem i only need to gather data from existing MBeans. So what i need to do is connect to JMX beans in JBoss AS, with name like this:
jboss.ws:context=wsexample,endpoint=personservice.PersonService (according to JMX console).
When i tried to add third service type in demo
<service name="THIRD Custom Service" description="Our THIRD MBean custom service whose 'id' is static" discovery="org.rhq.plugins.jmx.MBeanResourceDiscoveryComponent" class="org.rhq.plugins.jmx.MBeanResourceComponent"> <runs-inside> <parent-resource-type name="JBossAS Server" plugin="JBossAS"/> </runs-inside> <plugin-configuration> <c:simple-property name="objectName" readOnly="true" default="jboss.ws:context=wsexample,endpoint=personservice.PersonService"/> </plugin-configuration> </service>
no discovery happened. Is the config wrong or do i need to add something else?
1) are you sure the agent has your updated plugin? execute the "plugins update" agent prompt command to make sure
2) if you know your plugin is already up to date, you have to wait for the next service scan to execute. See http://jopr.org/confluence/display/JOPR2/FAQ#FAQ-Explainhowtheagentscansforresources. You can force a full scan via the agent prompt command "discovery -f".
3) and of course make sure you confirmed that your JBossAS instance has that MBean registered and accessible. You can use twiddle if you want to double check - for example: twiddle.sh -s jnp://localhost:1099 query jboss.ws:*
Last resource, see if your agent log is logging any error messages related to the discovery of this service.
Thanks for advices, but they didn't work for me.
When I deploy new version of plugin, i always undeploy current discovered server, scan for updated plugin (time in plugins list changes), call update on agent and after that go to auto-discovery.
This is my current version of plugin:
<?xml version="1.0" encoding="UTF-8" ?> <plugin name="CustomJmx" displayName="Custom JMX Plugin" version="1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:xmlns:rhq-plugin" xmlns:c="urn:xmlns:rhq-configuration"> <depends plugin="JMX" useClasses="true"/> <depends plugin="JBossAS"/> <service name="THIRD Custom Service" description="Our THIRD MBean custom service whose 'id' is static" discovery="org.rhq.plugins.jmx.MBeanResourceDiscoveryComponent" class="org.rhq.plugins.jmx.MBeanResourceComponent"> <runs-inside> <parent-resource-type name="JMX Server" plugin="JMX"/> <parent-resource-type name="JBossAS Server" plugin="JBossAS"/> </runs-inside> <plugin-configuration> <c:simple-property name="objectName" readOnly="true" default="jboss.ws:context=wsexample,endpoint=personservice.PersonService"/> </plugin-configuration> </service> </plugin>
Twiddle discovers this bean (port 1299 for me), when i query exact name there is no problem. With plugin mentioned above no auto-discovery happens, even when forcing agent with that command. No errors in agent log (only when i turned off separate jmx server and left original demo services there, he tried in discovery to connect to port 19988. How did he know the address? :)).
It knew the 19988 address because the JMX plugin's discovery component scans the process table, finds the running Java process and looks for the -Dcom.sun.management.jmxremote.port command line option - if it finds it, it uses that as the port it needs.
I would take a look at the rhq-server plugin code - we do exactly what you want to do for the server itself - the Jopr Server has special MBeans registered by Jopr and we created services for it. See here:
Look at the "RHQ Server Measurement Subsystem" service for example.