You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by andrew cooke <an...@acooke.org> on 2019/01/28 17:32:45 UTC
JMX, Reading HeapMemoryUsage: Comparable error (altenaative?)
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&key.type=Memory&observedAttribute=HeapMemoryUsage&monitorType=gauge&thresholdHigh=0&thresholdLow=0&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
Re: JMX, Reading HeapMemoryUsage: Comparable error (altenaative?)
Posted by Claus Ibsen <cl...@gmail.com>.
Hi
I think these JMX monitoring capabilities in the JDK only allows to
monitor JMX attributes that are simple types like numbers, boolean
etc.
So I am not sure if you can do this via
https://github.com/apache/camel/blob/master/components/camel-jmx/src/main/java/org/apache/camel/component/jmx/JMXMonitorConsumer.java
with the GaugeMonitor.
On Mon, Jan 28, 2019 at 6:32 PM andrew cooke <an...@acooke.org> 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&key.type=Memory&observedAttribute=HeapMemoryUsage&monitorType=gauge&thresholdHigh=0&thresholdLow=0&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
--
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2
Re: JMX, Reading HeapMemoryUsage: Comparable error (altenaative?)
Posted by andrew cooke <an...@acooke.org>.
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&key.type=Memory&observedAttribute=HeapMemoryUsage&monitorType=gauge&thresholdHigh=0&thresholdLow=0&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
>