gohopper / jmxquery

Automatically exported from code.google.com/p/jmxquery
0 stars 0 forks source link

Can we use a wildcard objectname in the JMX query request. #12

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
We want to use jmxquery to grab C3P0 connection pool parameters, unfortunately, 
the objectname JMX Bean is randomly generated/picked by C3P0 like 
com.mchange.v2.c3p0:type=PooledDataSource[1hge1ca8bna6zgq1fj33q6|77a3e2f7]

Seems like there's no way we can set this name up at deployment time, I would 
appreciate a way we can define a wild card pattern instead of a specific 
objectname in the command, and dump the content of the first match element.

So the changes will be something like this:

        Object attr = null;

        if(wildcard){
            Set<ObjectName> names = connection.queryNames(new ObjectName(object),null );
            if(names!=null&& names.size()>0){
                ObjectName name = names.iterator().next();
                attr = connection.getAttribute(name, attribute);
            }
        }else
            attr = connection.getAttribute(new ObjectName(object), attribute);

Would you please let me know your thoughts?

Thanks a lot

Eric

Original issue reported on code.google.com by eric.sun...@gmail.com on 27 Sep 2010 at 8:16

GoogleCodeExporter commented 9 years ago
Eric,

Could you let me know when you found a workarround for this? I have the same 
problem here.

Original comment by bertusla...@hotmail.com on 11 Oct 2010 at 11:11

GoogleCodeExporter commented 9 years ago
Guys, I wanted this too.  I'll add the feature in.  I thought it would work if 
using java 6 but perhaps I was wrong.  Give me a day or two.

Original comment by snoop...@gmail.com on 21 Oct 2010 at 8:04

GoogleCodeExporter commented 9 years ago
bertuslambertus

I don't have a workaround for this, what I did is changing the source code and 
build a jar myself. And I want to contribute the changes to the project.

Original comment by eric.sun...@gmail.com on 3 Nov 2010 at 7:02

GoogleCodeExporter commented 9 years ago
snooplsm seems busy.
Is it possible that someone can grant me a committer. Just want this to move 
forward.
Many Thanks!

Original comment by eric.sun...@gmail.com on 3 Nov 2010 at 7:06

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Here is a patch to add support for wildcard queries. 

I added a parameter -N that allows you to specify the index of the object 
returned that you wish to reference. In my case there are a couple C3P0 pools I 
want to monitor.

Here is an example for getting the number of used connections for the first 
pool:
-O com.mchange.v2.c3p0:type=PooledDataSource* -N 1 -A numBusyConnections -w 20 
-c 40 

Thanks for your code, Eric. It helped.

I hope the code is clean enough that it can be included. I updated the help 
file with the new parameter.

Sarel

Original comment by sareljbo...@gmail.com on 17 May 2011 at 7:53

Attachments:

GoogleCodeExporter commented 9 years ago
can someone please tell me how to use this diff file so I can patch the source 
and build the wildcard friendly version?

Original comment by d4v3y0rk on 2 Aug 2013 at 2:43

GoogleCodeExporter commented 9 years ago
I also would like to know how i can apply this patch :-)

Original comment by moar...@gmail.com on 15 Apr 2014 at 7:31

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
So, i pachted it like described here -> 
http://stackoverflow.com/a/18065052/3536396

But if i want to execute the command i'll get a null pointer exception.

# ./check_jmx -U service:jmx:rmi:///jndi/rmi://<hostname>:9001/jmxrmi -O 
com.mchange.v2.c3p0:type=PooledDataSource[2rw2h791s54j7c1o94fa1\|ba85af4] -A 
numConnectionsAllUsers -I numConnectionsAllUsers -vvvv -username monitorRole 
-password **************
JMX CRITICAL - NullPointerException: null connecting to 
com.mchange.v2.c3p0:type=PooledDataSource[2rw2h791s54j7c1o94fa1|ba85af4] by URL 
service:jmx:rmi:///jndi/rmi://<hostname>:9001/jmxrmijava.lang.NullPointerExcepti
on
      at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1008)
      at java.lang.Double.parseDouble(Double.java:540)
      at jmxquery.JMXQuery.compare(JMXQuery.java:199)
      at jmxquery.JMXQuery.report(JMXQuery.java:147)
      at jmxquery.JMXQuery.main(JMXQuery.java:93)

Original comment by moar...@gmail.com on 15 Apr 2014 at 2:39