Following
https://docs.oracle.com/javase/8/docs/api/javax/management/monitor/package-summary.html
I tried to use an observedAttribute value of "HeapMemoryUsage.used",
but this gives the error:

javax.management.AttributeNotFoundException: No such attribute: 
HeapMemoryUsage.used
    at com.sun.jmx.mbeanserver.PerInterface.getAttribute (PerInterface.java:81)
    at com.sun.jmx.mbeanserver.MBeanSupport.getAttribute (MBeanSupport.java:206)
    at javax.management.StandardMBean.getAttribute (StandardMBean.java:372)
    at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.getAttribute 
(DefaultMBeanServerInterceptor.java:647)
    at com.sun.jmx.mbeanserver.JmxMBeanServer.getAttribute 
(JmxMBeanServer.java:678)
    at 
org.apache.camel.component.jmx.JMXMonitorConsumer.convertNumberToAttributeType 
(JMXMonitorConsumer.java:110)
    ...

Which seems odd :(

Andrew


On Mon, Jan 28, 2019 at 02:32:45PM -0300, andrew cooke wrote:
> 
> Hi,
> 
> I have a specific error I need help with, but I may also be
> approaching the problem incorrectly, so more general advice also
> appreciated.  Sorry for the length of this email - the questions are
> at the end, after all the background data.
> 
> (this is all with Camel 2.23.1, OpenJDK 1.8.0_111-b15, CentOS 7.2)
> 
> I want to read the local JVM heap usage and write it to a file (the
> final task is to write a variety of values for analysis later - the
> client has some problem that occurs from time to time and they want
> some way of looking back and trying to work out what happened).
> 
> I have the following Spring XML config:
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <beans ...>
> 
>   <camelContext xmlns="http://camel.apache.org/schema/spring";>
>     <route>
>       <from 
> uri="jmx:platform?objectDomain=java.lang&amp;key.type=Memory&amp;observedAttribute=HeapMemoryUsage&amp;monitorType=gauge&amp;thresholdHigh=0&amp;thresholdLow=0&amp;notifyHigh=True"/>
>       <log message="Got something"/>
>       <to uri="file:target/messages/dump"/>
>     </route>
>   </camelContext>
> 
> </beans>
> 
> The important part is the URI:
> 
>   jmx:platform?objectDomain=java.lang&
>       key.type=Memory&
>       observedAttribute=HeapMemoryUsage&
>       monitorType=gauge&
>       thresholdHigh=0
>       thresholdLow=0&
>       notifyHigh=True
> 
> This is giving the error (returned as an XML message):
> 
>   <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
>     <MonitorNotification xmlns="urn:org.apache.camel.component:jmx">
>       
> <source>java.lang:name=camel-jmx-monitor-613d8391-408a-4677-9687-afcbf434d7bc</source>
>       <message>The observed attribute value does not implement the Comparable 
> interface.</message>
>       <sequence>0</sequence>
>       <timestamp>1548695162038</timestamp>
>       <dateTime>2019-01-28T14:06:02.038-03:00</dateTime>
>       <type>jmx.monitor.error.type</type>
>       <derivedGauge>null</derivedGauge>
>       <observedAttribute>HeapMemoryUsage</observedAttribute>
>       <observedObject>java.lang:type=Memory</observedObject>
>       <trigger>null</trigger>
>     </MonitorNotification>
> 
> I suspect this is because the HeapMemoryUsage attribute is of type
> javax.management.openmbean.CompositeData.
> 
> So, finally, my questions are:
> 
>   * How do I access structured data like this?
> 
>   * If I just want the values every X seconds, can I just poll for
>     values?
> 
>   * Should I be doing something else?  Like maybe configuring my own
>     notification?  If so, is there some guide for dummies?  And can
>     this be automated for monitoring many different valeus?
> 
> Thanks,
> Andrew
> 

Reply via email to