I'm developing collection of monitoring script and templates for zabbix. It's called ZTC and all script are on python.
Now I want to add support for some java monitoring. I've not found the way to do it from CPython - only from java or jython. Since all project is on python, I've decided to write a simple script on jython, which would be called from my cpython classes.
Here is how my code looks like:
#!/usr/bin/env jython
#Java Dependencies
import javax.management.remote.JMXConnector;
import javax.management.remote.JMXConnectorFactory;
import javax.management.remote.JMXServiceURL;
import java.lang.management.ManagementFactory;
#Python Dependencies
import sys, cmd, socket
def usage():
print """Usage:
jmxclient.py -h
jmxclient.py <connect_url> <jmx_attribute_path> <jmx_property>"""
class JMXClient:
remote = None
def connect(self, connect_url):
if self.remote:
return True
#Establish Connection to JMX Server
url = javax.management.remote.JMXServiceURL(connect_url);
connector = javax.management.remote.JMXConnectorFactory.connect(url);
self.remote = connector.getMBeanServerConnection();
def getAttribute(self, mbean_path, attribute):
"""Query the mbean server for a specific attribute and return the
result"""
obn = javax.management.ObjectName(mbean_path);
result = self.remote.getAttribute(obn, attribute);
return result
if len(sys.argv) <= 1:
usage()
sys.exit(2)
if sys.argv[1] in ('-h', '--help'):
usage()
sys.exit(2)
if len(sys.argv) <> 4:
usage()
sys.exit(2)
(connect_url, mbean_path, attribute) = sys.argv[1:]
j = JMXClient()
j.connect(connect_url)
print j.getAttribute(mbean_path, attribute)
Ok, now I'm trying to get some attribute from terracotta server. It uses jmxmp with url service:jmx:jmxmp://0.0.0.0:9520.
So, I'm running my script as follows:
$ ./jmxclient.py service:jmx:jmxmp://localhost:9520 java.lang.ClassLoading LoadedClassCount
Traceback (innermost last):
File "./jmxclient.py", line 87, in ?
File "./jmxclient.py", line 61, in connect
at javax.management.remote.JMXConnectorFactory.newJMXConnector(JMXConnectorFactory.java:327)
at javax.management.remote.JMXConnectorFactory.connect(JMXConnectorFactory.java:247)
at javax.management.remote.JMXConnectorFactory.connect(JMXConnectorFactory.java:207)
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)
java.net.MalformedURLException: java.net.MalformedURLException: Unsupported protocol: jmxmp
(line numbers not relevant due to some stripped comments)
How do I add support of this jmxmp protocol?
I've found that it seems it might be enabled by jmxremote_optional.jar. How do I add this jar to my jython (pref. not system-wide)?
UPDATE:
As suggested, I've added jmxremote_optional.jar and jmxremote.jar from jmxremote-1_0_1-ri-bin-b58.zip
reference implementation: jython -Djava.endorsed.dirs=. -Dpython.path=.../jmxremote_optional.jar:.../jmxremote.jar:.../jmissl.jar jmxclient.py service:jmx:jmxmp://localhost:9520 java.lang.ClassLoading LoadedClassCount
, but still getting the same error. I'm sure that jmxremote_optional.jar is in classpath, and code seems to be very similar to reference examples.
After reading api docs, I've tried following changes:
url = javax.management.remote.JMXServiceURL('jmxmp', 'localhost', 9520);
connector = javax.management.remote.jmxmp.JMXMPConnector(url)
connector.connect()
self.remote = connector.getMBeanServerConnection();
which leads me to another exception:
Traceback (innermost last):
File "../src/jmxclient.py", line 87, in ?
File "../src/jmxclient.py", line 61, in connect
at com.sun.jmx.remote.opt.security.AdminClient.connectionOpen(AdminClient.java:209)
at com.sun.jmx.remote.generic.ClientSynchroMessageConnectionImpl.connect(ClientSynchroMessageConnectionImpl.java:72)
at javax.management.remote.generic.GenericConnector.connect(GenericConnector.java:177)
at javax.management.remote.jmxmp.JMXMPConnector.connect(JMXMPConnector.java:119)
at javax.management.remote.generic.GenericConnector.connect(GenericConnector.java:124)
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)
java.io.IOException: java.io.IOException: javax.management.remote.message.HandshakeBeginMessage
Jython version is 2.2 and I don't like to use later version, because this scripts is mostly being used on RHEL5 boxes, and they only have jython 2.2.1.
PS: marking question as answered, because I've decided to give up and use jmxterm or similar tool, which all seems to work with jmxmp by just adding -Djava.endosed.dirs=/path/to/dir_with_jmxremote_optional/. But I'd still like to see jython solution.
相关推荐
3. **服务定义文件**:在`META-INF/services`目录下创建或更新`org.jppf.management.spi.JPPFDriverMBeanProvider`文件,添加你的MBean提供者类的全限定名。 4. **部署MBean**:将包含MBean类和服务定义文件的jar...
- **步骤3**:在`META-INF/services`目录下创建服务定义文件`org.jppf.management.spi.JPPFNodeMBeanProvider`,写入自定义MBean提供者的全限定名。 - **步骤4**:创建包含MBean实现和`META-INF/services`文件夹的...
《JPPF客户端3.3.3与Maven插件详解》 在IT行业中,开源项目扮演着至关重要的角色,它们推动了技术创新,提供了丰富的工具和框架供开发者使用。"jppf-client-3.3.3.zip"是这样一个开源项目,它与Maven插件紧密相关,...
3. **定义任务**:创建一个继承自`org.jppf.task.JPPFTask`的类,实现任务的业务逻辑。任务通常会重写`run()`方法,这里进行实际的计算。 4. **提交任务**:通过`JPPFClient`实例的`submit()`方法将任务提交到网格...
1. **配置文件**:JPPF提供了丰富的配置选项,可以通过编辑`jppf.properties`等配置文件来定制各种参数。 2. **启动服务**:使用命令行工具启动JPPF节点或服务器。例如,使用`jppf-server.sh start`来启动服务器实例...
【标题】"jppf-admin-4.1.1.zip" 涉及的知识点主要集中在JPPF(Java Parallel Processing Framework)平台的管理工具上。JPPF是一款开源的分布式计算框架,它允许开发者利用多核CPU和集群资源进行大规模并行计算。...
在传统的串行检索与基于JPPF的并行检索的对比实验中,以数据库查询为例,研究者们发现,在数据规模较大的情况下,基于JPPF的并行检索方式相较于传统的串行检索方式在效率上有显著提升。这表明,分布式并行计算技术...
**JPPF-3.3.2:分布式计算框架详解** JPPF(Java Parallel Processing Foundation)是一个开源的Java分布式计算框架,版本3.3.2是其在2019年发布的一个稳定版本。该框架允许开发者将计算密集型任务分散到多个计算...
### jppf 2.1 用户手册知识点概览 #### 1. 引言与预备知识 - **目标读者**:本手册适用于那些希望利用Java Parallel Processing Framework (JPPF)进行并行处理任务的开发人员和技术团队。 - **先决条件**:读者需...
Java Parallel Processing Framework(JPPF) 是一个优秀的开源的基于Java的并行处理框架。这是它的API手册,因为网站上面不提供apidoc的下载,所以我自己就做了个chm,方便大家使用!
6. **监控和管理**:JPPF提供了一个强大的管理工具——JPPF Management Console,用于监控网格状态,查看节点信息,管理任务,以及进行故障排查。 7. **性能优化**:用户手册会详细介绍如何通过配置和调优提升JPPF...
【基于JPPF的异构分布式MTH1虚拟筛选系统】是针对癌症治疗研究中的一种高效计算解决方案。文章主要探讨了如何利用JPPF(Java Parallel Processing Framework)分布式并行框架,结合Autodock Vina软件,设计一个跨...
开源网格计算解决方案这是JPPF源代码的所在地。 其他服务可以在以下位置找到:JPPF模块: :包含构建脚本,网站和相关模板,以及作为LibreOffice文本文档的文档 :桌面(基于Swing)管理控制台的代码和资源 :Web...
网格计算框架JPPF,Java Parallel Processing Framework,即java并行处理框架.一个开放源码的网格计算框架,它可以在一个分布执行环境中 同时运行多个java应用.这是他的最新版1.5版
jppf-测试 此 repo 包含涉及测试。 安装先决条件 要运行这些测试,您需要: JDK 7 或更高版本 吉特 Maven JPPF 发行版 4.2.4 或更高版本 下载项目 git 克隆 JPPFExecutorService - 运行测试 mvn 清理包 exec:java ...
**JPPF:开源网格计算解决方案** JPPF(Java Parallel Processing Framework)是一个全面的开源网格计算框架,专为在分布式环境中执行计算密集型任务而设计。它提供了一个灵活、可扩展的平台,允许开发者将应用程序...
我的应用程序是一个网格计算应用程序,它将POV-Ray(http://www.povray.org/)与JPPF(http://www.jppf.org)框架相连接。 使用我的JppfPov,您可以利用网格计算网络的潜力来执行渲染任务。
1. **JPPF.pdf**:JPPF(Java Parallel Processing Framework)是一个开源的网格计算框架,用于构建分布式应用程序。这份PDF可能包含JPPF的使用教程、原理介绍或者在面试中如何展示对分布式计算的理解。学习和了解...
2. JPPF(Java Parallel Processing Framework):专注于分布式计算,允许开发者构建可扩展的P2P应用程序,尤其适合大数据处理。 3. JMF(Java Media Framework):虽然主要针对多媒体处理,但其流媒体能力也可用于...