JMX 对象和属性列表?

发布于 2024-11-18 16:23:20 字数 110 浏览 1 评论 0原文

我正在尝试实现一个 nagios 插件,这样做需要我具体知道我想要监视的对象和属性。问题是,我无法在任何地方找到标准系统 jmx 对象和属性的列表。有人能指出我正确的方向吗?我需要监视内存池、堆大小等内容。

I am trying to implement a nagios plugin, and doing so requires that I know specifically what object and attribute I want to monitor. The thing is, I haven't been able to find a listing anywhere of the standard system jmx objects and attributes. Can anyone point me in the right direction? I need to monitor things like memory pools, heap size, etc.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

慢慢从新开始 2024-11-25 16:23:20

您可以使用

Set mbeans = mBeanServer.queryNames(null, null);
for (Object mbean : mbeans)
{
    WriteAttributes(mBeanServer, (ObjectName)mbean);
}

private void WriteAttributes(final MBeanServer mBeanServer, final ObjectName http)
        throws InstanceNotFoundException, IntrospectionException, ReflectionException
{
    MBeanInfo info = mBeanServer.getMBeanInfo(http);
    MBeanAttributeInfo[] attrInfo = info.getAttributes();

    System.out.println("Attributes for object: " + http +":\n");
    for (MBeanAttributeInfo attr : attrInfo)
    {
        System.out.println("  " + attr.getName() + "\n");
    }
}

这将写入所有对象名称及其属性...

You can use

Set mbeans = mBeanServer.queryNames(null, null);
for (Object mbean : mbeans)
{
    WriteAttributes(mBeanServer, (ObjectName)mbean);
}

private void WriteAttributes(final MBeanServer mBeanServer, final ObjectName http)
        throws InstanceNotFoundException, IntrospectionException, ReflectionException
{
    MBeanInfo info = mBeanServer.getMBeanInfo(http);
    MBeanAttributeInfo[] attrInfo = info.getAttributes();

    System.out.println("Attributes for object: " + http +":\n");
    for (MBeanAttributeInfo attr : attrInfo)
    {
        System.out.println("  " + attr.getName() + "\n");
    }
}

This will write all the object names and their attributes...

断桥再见 2024-11-25 16:23:20

您始终可以使用 mBeanServer.queryNames(null, null); 用于获取在某个 MBeanServer 上注册的所有 MBean(其中mBeanServer 是您在本地或远程获取的 MBeanServerConnection)。

然而,在实现您自己的 Nagios 插件之前,为什么不使用已经存在的插件呢?例如 jmx4perlcheck_jmx4perl 附带了用于探索 JMX 的工具命名空间(例如用于列出所有 JMX MBean 及其属性和操作的 jmx4perllistj4psh基于 readline 的 JMX shell,具有上下文相关的命令行完成功能)。

You can always use mBeanServer.queryNames(null, null); for getting to all MBeans registered at a certain MBeanServer (where mBeanServer is the MBeanServerConnection which you obtained either locally or remotely).

However, before implementing your own Nagios Plugins, why not using an already exisiting one ? E.g. jmx4perl's check_jmx4perl which comes with tools for exploring the JMX namespace (like jmx4perl <url> list for listing all JMX MBeans with their attributes and operations or j4psh a readline based JMX shell with context sensitive command line completion).

我们只是彼此的过ke 2024-11-25 16:23:20

从系统管理员的角度来看,我完全理解这个问题的基础。标准 JMX 文档,或者在尝试浏览 JMX 对象树时可能遇到的对象,可能会令人不知所措且令人困惑。

我发现这篇Op5 知识库文章在提供像样的解决方案方面非常有用JBoss 感兴趣的 JMX 对象概述。

显然,需要进行调整以适应他们实际使用的监控系统,但示例中的内容足以满足正在使用的任何基于 nagios 的监控系统。

From a sysadmin point of view, I fully understand the bases for the question. The standard JMX documentation, or the objects one can encounter while trying to browse JMX object trees, can be overwhelming and confusing.

I have found this Op5 KB article quite useful in providing a decent overview of JMX objects of interest for JBoss.

Obviously, one needs to adjust to fit with the monitoring system they are actually using, but there is enough in the examples for whatever nagios-based monitoring system is being used.

故事↓在人 2024-11-25 16:23:20

您是否正在寻找 JVM 平台 MBean 文档

那里有获取 MBean 并询问它们的示例,例如

ThreadMXBean平台MBean
提供对监控线程的支持
争用和线程 CPU 时间。

Are you looking for the JVM platform MBean docs?

There are examples there on to get the MBeans and interrogate them e.g.

The ThreadMXBean platform MBean
provides support for monitoring thread
contention and thread CPU time.

想你的星星会说话 2024-11-25 16:23:20

查看 MC4JJConsole - 使用它们都很简单。

Check out MC4J or JConsole - it's trivial to get going with both of 'em.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文