使用 Python 监控 Java 应用程序
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19900067/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Monitoring Java application with Python
提问by Tal
I'm a pythonprogrammer, and want to monitor a Java application, by communicating with JMX.
我是一名python程序员,想通过与JMX通信来监视 Java 应用程序。
I've been searching the web and I haven't found a proved solution.
I've looked at jmx4pythonand JPypebut I haven't maid up my mind about them.
Py4Jdoesn't look useful.
我一直在网上搜索,但没有找到经过验证的解决方案。
我已经看过jmx4python和JPype,但我还没有弄清楚它们。
Py4J看起来没什么用。
Does anyone have a suggestion of a Framework or a way to do this?
有没有人对框架或方法有建议?
btw - The application is already running and I don't want to invoke it
btw - 应用程序已经在运行,我不想调用它
采纳答案by fbacchella
Jolikia is an http-jmx that can help you : http://www.jolokia.org
Jolikia 是一个可以帮助您的 http-jmx:http: //www.jolokia.org
回答by Nathan Davis
回答by apg
Your best bet would be to utilize Jython (http://jython.org) for this task. It can call all of the fancy JMX stuff without you having to rewrite the binary protocol stuff that it uses, in the comfort of Python syntax.
最好的办法是使用 Jython ( http://jython.org) 来完成这项任务。它可以调用所有花哨的 JMX 内容,而无需您以 Python 语法的舒适度重写它使用的二进制协议内容。
Note, however, that Jython isn't 100% compatible with CPython (usually library related stuff), though in practice it's pretty darn good. The current version of Jython seems to support the language defined by CPython 2.7.
但是请注意,Jython 并非 100% 与 CPython 兼容(通常是与库相关的东西),尽管在实践中它非常好。Jython 的当前版本似乎支持 CPython 2.7 定义的语言。