Java Munin jmx配置

Java Munin jmx配置,java,jmx,munin,Java,Jmx,Munin,我正在尝试在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 tha

我正在尝试在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
实际的配置文件名为java_process_memory.conf,因此我也尝试了命名符号链接jmx_java_process_memory,但得到了相同的错误

我成功地命名了symlink jmx_线程,如下所述:

http://blog.johannes-beck.name/?p=160
我可以看到org.munin.plugin.jmx.Threads是munin-jmx-plugins.jar中一个类的名称,其他类似乎也可以工作。但这不是Munin指南告诉我要做的,所以文档是错误的吗?配置文件的用途是什么,它们必须存在是有原因的?这里有一些Tomcat的示例配置文件,这是我真正感兴趣的地方,所以我需要理解这一点。虽然我有点卡住了,但却无法按照指南来操作它

有人能告诉我这件事吗

干杯
NFV

我不知何故也遇到了同样的问题。 我所做的是让某些东西工作得更好一点,但仍然不完美

我在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 
我用以下内容修改了/usr/share/munin/plugins/jmx_u:

#!/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
现在我可以运行了(我可以看到它使用nobody:nobody作为user:group,可能是在conf中使用的东西):

现在,我试图让它在同一台主机上的不同JVM上工作,因为这是针对单个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_uu文件中注释掉了ip和端口,但我不确定它是否发挥了作用。

谢谢,我终于实现了这一点,与您的方式类似,但没有将其扩展到多个虚拟机!好吧,事实上我觉得那会更难。但实际上是同一台服务器上的不同java进程,而不是不同的vm。
[root@bus|in plugins]# ls -ld /opt/jdk
drwxrwxr-x 8 nobody nobody 4096  8 oct.  15:03 /opt/jdk
[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
[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_