![]() |
Hi,
I want my script to get the some attributes of a Tomcat6.0 Application Server on a Debian Squeeze. I deployed jolokia.jar 1.0.2 and use jmx4perl 1.04. For many mbeans, there is no problem, I can read the attribute which interest me, but for the datasource, I have a syntaxe problem : The search command returns the mbean name : bash$ /usr/local/bin/jmx4perl http://localhost:20000/jolokia search Catalina:class=javax.sql.DataSource,name=*,type=DataSource Catalina:class=javax.sql.DataSource,name="jdbc/xxxxxxx",type=DataSource But the read command, for this mbean doesn't work : bash$ /usr/local/bin/jmx4perl http://localhost:20000/jolokia read Catalina:class=javax.sql.DataSource,name="jdbc/xxxxxxx",type=DataSource ERROR: javax.management.InstanceNotFoundException : No MBean with ObjectName Catalina:class=javax.sql.DataSource,name=jdbc/xxxxxxx,type=DataSource found in any MBeanServer I verified in jconsole and saw that this mbean exists, but with the name : Catalina:type=DataSource,class=javax.sql.DataSource,name="jdbc/xxxxxxx". The order of the arguments is different. I tried with this name and had the same error. I tired to escape the '"' caracter but all my test failed. ex : bash$ /usr/local/bin/jmx4perl http://localhost:20000/jolokia read Catalina:class=javax.sql.DataSource,name=\"jdbc/xxxxxxx\",type=DataSource ERROR: javax.management.RuntimeOperationsException : Exception invoking method loginTimeout Have you an idea, please ? Thanks. |
![]() |
Sounds like a shell issue. Please try
/usr/local/bin/jmx4perl http://localhost:20000/jolokia read 'Catalina:class=javax.sql.DataSource,name="jdbc/xxxxxxx",type=DataSource'(note the single quotes for the last argument). Does this work ? BTW, the order of the key-value pairs after the colon is insignificant.
... roland
|
![]() |
Hello,
Thanks. That's one of the solutions I tried to protect the '"' carater but this is the result : bash$ /usr/local/bin/jmx4perl http://localhost:20000/jolokia read 'Catalina:class=javax.sql.DataSource,name="jdbc/xxxxxxx",type=DataSource' ERROR: javax.management.InstanceNotFoundException : No MBean with ObjectName Catalina:class=javax.sql.DataSource,name="jdbc/xxxxxxx",type=DataSource found in any MBeanServer It is the same with something like : /usr/local/bin/jmx4perl http://localhost:20000/jolokia read Catalina:class=javax.sql.DataSource,name='"'jdbc/xxxxxxx'"',type=DataSource ERROR: javax.management.InstanceNotFoundException : No MBean with ObjectName Catalina:class=javax.sql.DataSource,name="jdbc/xxxxxxx",type=DataSource found in any MBeanServer You can see here that the mbean name is correctly returned by the error message. But if I replace the "xxxxxx" mask by the real name of my datasource, "mydatasource", the error is different : /usr/local/bin/jmx4perl http://localhost:20000/jolokia read 'Catalina:class=javax.sql.DataSource,name="jdbc/mydatasource",type=DataSource' ERROR: javax.management.RuntimeOperationsException : Exception invoking method loginTimeout the --verbose option gives : GET http://localhost:20000/jolokia/read/Catalina%3Aclass%3Djavax.sql.DataSource%2Cname%3D%22jdbc!/mydatasource%22%2Ctype%3DDataSource/ =========================================================== HTTP/1.1 200 OK Connection: close Date: Tue, 10 Jul 2012 07:58:22 GMT Server: Apache-Coyote/1.1 Content-Length: 3494 Content-Type: text/plain;charset=utf-8 Client-Date: Tue, 10 Jul 2012 07:58:22 GMT Client-Peer: 127.0.0.1:20000 Client-Response-Num: 1 =========================================================== ERROR: javax.management.RuntimeOperationsException : Exception invoking method loginTimeout Server Stacktrace: javax.management.RuntimeOperationsException: Exception invoking method loginTimeout at org.apache.tomcat.util.modeler.BaseModelMBean.getAttribute(BaseModelMBean.java:196) at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.getAttribute(DefaultMBeanServerInterceptor.java:666) at com.sun.jmx.mbeanserver.JmxMBeanServer.getAttribute(JmxMBeanServer.java:638) at org.jolokia.handler.ReadHandler.getAttribute(ReadHandler.java:223) at org.jolokia.handler.ReadHandler.fetchAttributes(ReadHandler.java:162) at org.jolokia.handler.ReadHandler.doHandleRequest(ReadHandler.java:91) at org.jolokia.handler.ReadHandler.doHandleRequest(ReadHandler.java:34) at org.jolokia.handler.JsonRequestHandler.handleRequest(JsonRequestHandler.java:157) at org.jolokia.backend.MBeanServerHandler.dispatchRequest(MBeanServerHandler.java:99) at org.jolokia.backend.LocalRequestDispatcher.dispatchRequest(LocalRequestDispatcher.java:83) at org.jolokia.backend.BackendManager.callRequestDispatcher(BackendManager.java:197) at org.jolokia.backend.BackendManager.handleRequest(BackendManager.java:175) at org.jolokia.http.HttpRequestHandler.executeRequest(HttpRequestHandler.java:148) at org.jolokia.http.HttpRequestHandler.handleGetRequest(HttpRequestHandler.java:78) at org.jolokia.http.AgentServlet$3.handleRequest(AgentServlet.java:269) at org.jolokia.http.AgentServlet.handle(AgentServlet.java:213) at org.jolokia.http.AgentServlet.doGet(AgentServlet.java:195) at javax.servlet.http.HttpServlet.service(HttpServlet.java:617) at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:589) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:291) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489) at java.lang.Thread.run(Thread.java:662) Caused by: java.lang.UnsupportedOperationException: Not supported by BasicDataSource at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getLoginTimeout(BasicDataSource.java:1083) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.tomcat.util.modeler.BaseModelMBean.getAttribute(BaseModelMBean.java:189) ... 31 more Have you ever seen such a problem? Regards. |
![]() |
You must of course use an existing DataSource name for accessing theses MBEans, for 'xxxxx' it will return InstanceNotFound for obvious reasons.
When you read all attributes of an MBean as you does in your last example, the request fails as soon as the read of a single attribute fails (as it is for 'LoginTimeout' in your case). You should specifcy the specific attribute you want to read as last argument. Or you can use the 'ignoreErrors=true' option, which unfortunately is not yet supported by jmx4perl (but by the agent). You can try it by putting this URL in your browser: http://localhost:20000/jolokia/read/Catalina%3Aclass%3Djavax.sql.DataSource%2Cname%3D%22jdbc!/mydatasource%22%2Ctype%3DDataSource?ignoreErrors=true
... roland
|
![]() |
It's perfect when I search for one specific attribute.
Thank you for your help. This tools will be very usefull for me. Regards. Fred. |
![]() ![]() |
Geoff Clitheroe |
![]() |
Just to chime in a little late on this thread; here's how to do it with a post in curl. Note the single quotes on the data parameter and the escaped double quotes around the bean name.
curl --data '{"type" : "read", "mbean" : "Catalina:type=DataSource,class=javax.sql.DataSource,name=\"jdbc/QuakeDataAccessDataSource\"", "attribute" : "numActive"}' http://localhost:8080/jolokia/read |
![]() |
Muito bom! com a syntax "Catalina:type=DataSource,class=javax.sql.DataSource,name=\"jdbc/PeopleDS\"" eu consegui capturar os atributos do DS.
Segue o exemplo utilizando a client jmxquery.jar java -jar jmxquery.jar org.nagios.JMXQuery -U service:jmx:rmi:///jndi/rmi://localhost:1092/jmxrmi -O "Catalina:type=DataSource,class=javax.sql.DataSource,name=\"jdbc/PeopleDS\"" -A numActive Plataforma: Windows Server Tomcat 5.5 |
![]() ![]() |
Benny Andersen |
![]() |
In reply to this post by fredow
Hi
I'm trying to monitor my datasource, but stille have issues getting som result out for my call. When I do a localhost:8080/jolokia/list/Catalina, and then search for the DataSource, I get the following result. class=javax.sql.DataSource,connectionpool=connections2,context=\/dypra,host=localhost,name=\"jdbc\/dypra\",type=DataSource Then I try to do the following curl for at bash linux script. curl --data '{"type" : "read", "mbean" : "Catalina:type=DataSource,class=javax.sql.DataSource,name=\"jdbc/dypra\"", "attribute" : "numActive"}' http://localhost:8080/jolokia/read But it's not working, getting the following output. "error_type":"javax.management.InstanceNotFoundException","error":"javax.management.InstanceNotFoundException : Catalina:type=DataSource,class=javax.sql.DataSource,name=\"jdbc\/dypra\"","status":404} What am I doing wrong, have tried several combinations. |
Free forum by Nabble | Edit this page |