【问题标题】:Munin jmx configuration穆宁 jmx 配置
【发布时间】:2014-03-15 00:02:08
【问题描述】:

我正在尝试在 Munin 上启用 JMX 监控

我已按照以下指南操作:

https://github.com/munin-monitoring/contrib/tree/master/plugins/java/jmx

它告诉我:

1) Files from "plugin" folder must be copied to /usr/share/munin/plugins (or another - where your munin plugins located)
2) Make sure that jmx_ executable : chmod a+x /usr/share/munin/plugins/jmx_
3) Copy configuration files that you want to use, from "examples" folder, into /usr/share/munin/plugins folder
4) create links from the /etc/munin/plugins folder to the /usr/share/munin/plugins/jmx_
The name of the link must follow wildcard pattern:
jmx_<configname>,
where configname is the name of the configuration (config filename without extension), for example:
ln -s /usr/share/munin/plugins/jmx_ /etc/munin/plugins/jmx_process_memory

我已经完成了这一点,但是当我运行 ./jmx_process_memory 时,我得到了:

Error: Could not find or load main class org.munin.plugin.jmx.memory

实际的配置文件名为 java_process_memory.conf,所以我也尝试将符号链接命名为 jmx_java_process_memory,但得到了同样的错误。

我通过命名符号链接 jmx_Threads 取得了成功,如下所述:

http://blog.johannes-beck.name/?p=160

我可以看到 org.munin.plugin.jmx.Threads 是 munin-jmx-plugins.jar 中的一个类的名称,其他类似乎也可以工作。但这不是 Munin 指南告诉我要做的,所以文档有问题吗?配置文件的目的是什么,它们一定是有原因的?有 Tomcat 的示例配置文件,这是我真正感兴趣的地方,所以我需要了解这一点。虽然我有点卡住了,但无法按照指南工作!

谁能帮我解决这个问题?

干杯 NFV

【问题讨论】:

    标签: java jmx munin


    【解决方案1】:

    我遇到了同样的问题。 我做了什么让一些东西工作得更好一点,但仍然不完美。

    我在 RHEL 上:

    [root@bus|in plugins]# cat /etc/munin/plugin-conf.d/munin-node 
    [diskstats]
    user munin
    
    [iostat_ios]
    user munin
    
    [jmx_*]
    env.ip 192.168.1.101
    env.port 5054         <- being the port configured for your jmx 
    

    然后

    [root@bus|in plugins]# ls -l /etc/munin/plugins/jmx_MultigraphAll 
    lrwxrwxrwx 1 root root 29 14 mars  15:36 /etc/munin/plugins/jmx_MultigraphAll -> /usr/share/munin/plugins/jmx_
    

    我修改了 /usr/share/munin/plugins/jmx_ 如下:

    #!/bin/sh
    # -*- sh -*-
    : << =cut
    
    =head1 NAME
    
    jmx_ - Wildcard plugin to monitor Java application servers via JMX
    
    =head1 APPLICABLE SYSTEMS
    
    Tested with Tomcat 4.1/5.0/5.5/6.0 on Sun JVM 5/6 and OpenJDK.
    
    Any JVM that supports JMX should in theory do.
    
    Needs nc in path for autoconf.
    
    =head1 CONFIGURATION
    
      [jmx_*]
        env.ip 127.0.0.1
        env.port 5400
        env.category jvm
        env.username monitorRole
        env.password SomethingSecret
    
        env.JRE_HOME /usr/lib/jvm/java-6-sun/jre
        env.JAVA_OPTS -Xmx128m
    
    Needed configuration on the Tomcat side: add
    
      -Dcom.sun.management.jmxremote \
      -Dcom.sun.management.jmxremote.port=5400 \
      -Dcom.sun.management.jmxremote.ssl=false \
      -Dcom.sun.management.jmxremote.authenticate=false
    
    to CATALINA_OPTS in your startup scripts.
    
    Replace authenticate=false with 
      -Dcom.sun.management.jmxremote.password.file=/etc/tomcat/jmxremote.password \
      -Dcom.sun.management.jmxremote.access.file=/etc/tomcat/jmxremote.access
     ...if you want authentication.
    
    jmxremote.password:
     monitorRole SomethingSecret
    
    jmxremote.access:
     monitorRole readonly
    
    You may need higher access levels for some counters, notably ThreadsDeadlocked.
    
    =head1 BUGS
    
    No encryption supported in the JMX connection.
    
    The plugins available reflect the most interesting aspects of a
    JVM runtime.  This should be extended to cover things specific to
    Tomcat, JBoss, Glassfish and so on.  Patches welcome.
    
    =head1 AUTHORS
    
    =encoding UTF-8
    
    Mo Amini, Diyar Amin and Younes Hajji, Høgskolen i Oslo/Oslo
    University College.
    
    Shell script wrapper and integration by Erik Inge Bolsø, Redpill
    Linpro AS.
    
    Previous work on JMX plugin by Aleksey Studnev. Support for
    authentication added by Ingvar Hagelund, Redpill Linpro AS.
    
    =head1 LICENSE
    
    GPLv2
    
    =head1 MAGIC MARKERS
    
     #%# family=auto
     #%# capabilities=autoconf suggest
    
    =cut
    
    MUNIN_JAR="/usr/share/java/munin-jmx-plugins.jar"
    
    if [ "x$JRE_HOME" != "x" ] ; then
      JRE=$JRE_HOME/bin/java
      export JRE_HOME=$JRE_HOME
    fi
    JAVA_BIN=${JRE:-/opt/jdk/jre/bin/java}
    
    ip=${ip:-192.168.1.101}
    port=${port:-5054}
    
    if [ "x$1" = "xsuggest" ] ; then
      echo MultigraphAll
      exit 0
    fi
    
    if [ "x$1" = "xautoconf" ] ; then
        NC=`which nc 2>/dev/null`
        if [ "x$NC" = "x" ] ; then
          echo "no (nc not found)"
          exit 0
        fi
        $NC -n -z $ip $port >/dev/null 2>&1
        CONNECT=$?
    
        $JAVA_BIN -? >/dev/null 2>&1
        JAVA=$?
        if [ $JAVA -ne 0 ] ; then
          echo "no (java runtime not found at $JAVA_BIN)"
          exit 0
        fi
    
        if [ ! -e $MUNIN_JAR ] ; then
          echo "no (munin jmx classes not found at $MUNIN_JAR)"
          exit 0
        fi
    
        if [ $CONNECT -eq 0 ] ; then
          echo "yes"
          exit 0
        else
          echo "no (connection to $ip:$port failed)"
          exit 0
        fi
    fi
    
    if [ "x$1" = "xconfig" ] ; then
      param=config
    else
      param=Tomcat
    fi
    
    scriptname=${0##*/}
    jmxfunc=${scriptname##*_}
    prefix=${scriptname%_*}
    
    if [ "x$jmxfunc" = "x" ] ; then
      echo "error, plugin must be symlinked in order to run"
      exit 1
    fi
    
    ip=$ip port=$port $JAVA_BIN -cp $MUNIN_JAR $JAVA_OPTS org.munin.plugin.jmx.$jmxfunc $param $prefix
    

    您必须在您定义为 JRE 的内容上添加正确的权限和所有者:组,例如这里:

    [root@bus|in plugins]# ls -ld /opt/jdk
    drwxrwxr-x 8 nobody nobody 4096  8 oct.  15:03 /opt/jdk
    

    现在我可以运行了(我可以看到它正在使用 nobody:nobody 作为用户:组,也许可以在 conf 中使用):

    [root@bus|in plugins]# munin-run jmx_MultigraphAll -d
    # Processing plugin configuration from /etc/munin/plugin-conf.d/df
    # Processing plugin configuration from /etc/munin/plugin-conf.d/fw_
    # Processing plugin configuration from /etc/munin/plugin-conf.d/hddtemp_smartctl
    # Processing plugin configuration from /etc/munin/plugin-conf.d/munin-node
    # Processing plugin configuration from /etc/munin/plugin-conf.d/postfix
    # Processing plugin configuration from /etc/munin/plugin-conf.d/sendmail
    # Setting /rgid/ruid/ to /99/99/
    # Setting /egid/euid/ to /99 99/99/
    # Setting up environment
    # Environment ip = 192.168.1.101
    # Environment port = 5054
    # About to run '/etc/munin/plugins/jmx_MultigraphAll'
    multigraph jmx_memory
    Max.value 2162032640
    Committed.value 1584332800
    Init.value 1613168640
    Used.value 473134248
    
    multigraph jmx_MemoryAllocatedHeap
    Max.value 1037959168
    Committed.value 1037959168
    Init.value 1073741824
    Used.value 275414584
    
    multigraph jmx_MemoryAllocatedNonHeap
    Max.value 1124073472
    Committed.value 546373632
    Init.value 539426816
    Used.value 197986088
    
    [...]
    
    multigraph jmx_ProcessorsAvailable
    ProcessorsAvailable.value 1
    

    现在我正试图让它为同一主机上的不同 JVM 工作,因为这是一个单一的。 希望对你有帮助。

    编辑: 实际上我做了一些修改,以便与几个拥有自己的 jmx 端口的 java 进程一起使用。

    你必须在那里添加它们:

    [root@bus|in plugins]# cat /etc/munin/plugin-conf.d/munin-node 
    [diskstats]
    user munin
    
    [iostat_ios]
    user munin
    
    [admin_jmx_*]
    env.ip 192.168.1.101
    env.port 5054
    
    [managed_jmx_*]
    env.ip 192.168.1.101
    env.port 5055
    
    [jboss_jmx_*]
    env.ip 192.168.1.101
    env.port 1616
    

    然后创建链接:

    [root@bus|in plugins]# ls -l /etc/munin/plugins/*_jmx_*
    lrwxrwxrwx 1 root root 29 14 mars  15:36 /etc/munin/plugins/admin_jmx_MultigraphAll -> /usr/share/munin/plugins/jmx_
    lrwxrwxrwx 1 root root 29 14 mars  16:51 /etc/munin/plugins/jboss_jmx_MultigraphAll -> /usr/share/munin/plugins/jmx_
    lrwxrwxrwx 1 root root 29 14 mars  16:03 /etc/munin/plugins/managed_jmx_MultigraphAll -> /usr/share/munin/plugins/jmx_
    

    我从 /usr/share/munin/plugins/jmx_ 文件中注释掉了 ip 和 port,但我不确定它是否起作用。

    【讨论】:

    • 谢谢,我终于得到了这个工作,看起来和你的方式相似,但没有把它当作多个虚拟机!
    • 好吧,其实我认为这会更难。但实际上是同一台服务器上的不同java进程,而不是不同的vm。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-08-25
    • 1970-01-01
    相关资源
    最近更新 更多