Marty,
Thanks for the suggestion, much cleaner and what I thought should be available. However, this appears to be a Spring 3.x feature as the @ManagedMetric is not available in 2.5.x unless one is using the instrumented Spring Jars provide by SpringSource. I'm sure we can obtain them but was trying to avoid to much change at one time if possible. With that said, I thought I would try your suggestion.
I have tried to get a simple POC to work with 3.0.0 of Spring and Hyperic 4.2.0.7-EE. I have annotated the mbean as shown below:
/**
* POC - Server manager implementation.
*/
@Component
@ManagedResource(objectName="com.tsintech.crm.monitoring.jmx:name=ServerManager,type=ServerManager, name=serverManager",
description="Server manager.")
public class ServerManagerImpl implements ServerManager {
final Logger logger = LoggerFactory.getLogger(ServerManagerImpl.class);
private String serverName = "springServer";
private boolean serverRunning = true;
private int minPoolSize = 5;
private int maxPoolSize = 10;
private int currentSize = 0;
private int invocationCount = 0;
/**
* Gets Current pool size.
*/
@ManagedMetric(category="utilization", displayName="DB Connection Pool Size",
description="The size of the DB Connection Pool",
metricType = MetricType.COUNTER, unit="connections")
public int getCurrentPoolSize() {
return currentSize;
}
/**
* Gets Invocation count.
*/
@ManagedMetric(category="utilization", displayName="Invocations per second",
description="The total count of invocations",
metricType = MetricType.COUNTER, unit="invocations")
public int getInvocationCount() {
return invocationCount;
}
...
I start the application as follows:
java -Dspring.managed.application.name=ServerManager -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=6969 -Dcom.sun.management.jremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -jar spring-jmx-1.0.0.jar
The mbean shows up fine via jConsole and VisualVM.
When I run the following from the hyperic-agent-home:
java -jar ./bundles/agent-*/pdk/lib/hq-product.jar -Dlog=DEBUG -m discover -a metrics > disover.txt
I see the following entry in the discover.txt file:
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Server: localhost ServerManager Spring Application []
AIID.....localhost ServerManager Spring Application
config...
product..{ptql=State.Name.eq=java,Args.*.ct=spring.managed.application.name, jmx.username=system, jmx.url=service:jmx:rmi:///jndi/rmi://localhost:6969/jmxrmi, jmx.port=6969}
metric...{}
control..null
DEBUG [main] [PluginDiscoverer] Runtime discover for localhost ServerManager Spring Application, config={ptql=State.Name.eq=java,Args.*.ct=spring.managed.application.name, jmx.username=system, jmx.url=service:jmx:rmi:///jndi/rmi://localhost:6969/jmxrmi, jmx.port=6969, installpath=}
DEBUG [main] [ProductPluginManager] No ProductPlugin found for: Spring Application
DEBUG [main] [SpringStandaloneApplicationDetector] discovered 0 services
DEBUG [main] [SpringStandaloneApplicationDetector] discovered 0 services
Runtime Resource Report...
Platform=Linux, fqdn=theseus.hiw.com (Fedora 13)
config...
product..null
metric...{platform.log_track.level=Warn, platform.log_track.enable=true, platform.config_track.enable=true}
control..null
cprops...{cpuSpeed=8 @ 1734 MHz (8x16), secondaryDNS=10.161.19.10, defaultGateway=10.161.25.1, arch=x86_64, ram=16016 MB, vendor=Fedora, vendorVersion=13, primaryDNS=127.0.0.1, ip=10.161.25.175, version=2.6.33.6-147.fc13.x86_64}
localhost ServerManager Spring Application cprops: {}
[No services discovered]
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
The agent does discover the service and makes it available to Hyperic HQ to be added to the inventory. But when I click on add to inventory I get the following exception:
Unable to import platform : java.rmi.ServerException: RuntimeException; nested exception is: org.hyperic.hq.common.SystemException: javax.ejb.TransactionRolledbackLocalException
So I have several questions:
1. Is there something wrong with the mbean class?
2. The discover.txt file seems to indicate that while it saw the service that 0 services were discovered, or am I reading this wrong:
DEBUG [main] [SpringStandaloneApplicationDetector] discovered 0 services
(See above for complete entry)
3. The agent does make the service available for adding as a resource in Hyper but then throws an exception when I try to add the resource; is there something obvious here that I am missing
4. Is there any way to achieve the same in 2.5.x by adding some attributes to the @ManagedAttribute tag by applying some naming convention?
TIA for any assistance.
Regards,
Todd