diff --git a/plugins/java/jmx/examples/java/java_cpu.conf b/plugins/java/jmx/examples/java/java_cpu.conf new file mode 100644 index 00000000..1e56cd34 --- /dev/null +++ b/plugins/java/jmx/examples/java/java_cpu.conf @@ -0,0 +1,22 @@ +graph_args --upper-limit 100 -l 0 +graph_scale no +graph_title CPU Usage +graph_vlabel 1000* CPU time % +graph_category Java +graph_order java_cpu_time java_cpu_user_time + +java_cpu_time.label cpu +java_cpu_time.jmxObjectName java.lang:type=Threading +java_cpu_time.jmxAttributeName CurrentThreadCpuTime +java_cpu_time.type DERIVE +java_cpu_time.min 0 +java_cpu_time.graph yes +java_cpu_time.cdef java_cpu_time,3000000,/ + +java_cpu_user_time.label user +java_cpu_user_time.jmxObjectName java.lang:type=Threading +java_cpu_user_time.jmxAttributeName CurrentThreadUserTime +java_cpu_user_time.type DERIVE +java_cpu_user_time.min 0 +java_cpu_user_time.graph yes +java_cpu_user_time.cdef java_cpu_user_time,3000000,/ \ No newline at end of file diff --git a/plugins/java/jmx/examples/java/java_process_memory.conf b/plugins/java/jmx/examples/java/java_process_memory.conf new file mode 100644 index 00000000..ddbdc4d0 --- /dev/null +++ b/plugins/java/jmx/examples/java/java_process_memory.conf @@ -0,0 +1,46 @@ +graph_title Process Memory +graph_vlabel Bytes +graph_category Java +graph_order java_memory_nonheap_committed java_memory_nonheap_max java_memory_nonheap_used java_memory_heap_committed java_memory_heap_max java_memory_heap_used os_memory_physical os_memory_vm + +java_memory_nonheap_committed.label non-heap committed +java_memory_nonheap_committed.jmxObjectName java.lang:type=Memory +java_memory_nonheap_committed.jmxAttributeName NonHeapMemoryUsage +java_memory_nonheap_committed.jmxAttributeKey committed + +java_memory_nonheap_max.label non-heap max +java_memory_nonheap_max.jmxObjectName java.lang:type=Memory +java_memory_nonheap_max.jmxAttributeName NonHeapMemoryUsage +java_memory_nonheap_max.jmxAttributeKey max + +java_memory_nonheap_used.label non-heap used +java_memory_nonheap_used.jmxObjectName java.lang:type=Memory +java_memory_nonheap_used.jmxAttributeName NonHeapMemoryUsage +java_memory_nonheap_used.jmxAttributeKey used + +java_memory_heap_committed.label heap committed +java_memory_heap_committed.jmxObjectName java.lang:type=Memory +java_memory_heap_committed.jmxAttributeName HeapMemoryUsage +java_memory_heap_committed.jmxAttributeKey committed + +java_memory_heap_max.label heap max +java_memory_heap_max.jmxObjectName java.lang:type=Memory +java_memory_heap_max.jmxAttributeName HeapMemoryUsage +java_memory_heap_max.jmxAttributeKey max + +java_memory_heap_used.label heap used +java_memory_heap_used.jmxObjectName java.lang:type=Memory +java_memory_heap_used.jmxAttributeName HeapMemoryUsage +java_memory_heap_used.jmxAttributeKey used + +os_memory_physical.label os free mem +os_memory_physical.jmxObjectName java.lang:type=OperatingSystem +os_memory_physical.jmxAttributeName FreePhysicalMemorySize +os_memory_physical.graph no + +os_memory_vm.label os vmem committed +os_memory_vm.jmxObjectName java.lang:type=OperatingSystem +os_memory_vm.jmxAttributeName CommittedVirtualMemorySize +os_memory_vm.graph no + + diff --git a/plugins/java/jmx/examples/java/java_threads.conf b/plugins/java/jmx/examples/java/java_threads.conf new file mode 100644 index 00000000..f8b64cd4 --- /dev/null +++ b/plugins/java/jmx/examples/java/java_threads.conf @@ -0,0 +1,14 @@ +graph_title Thread Count +graph_vlabel Thread Count +graph_category Java +graph_order java_thread_count java_thread_count_peak + +java_thread_count.label count +java_thread_count.jmxObjectName java.lang:type=Threading +java_thread_count.jmxAttributeName ThreadCount + +java_thread_count_peak.label peak +java_thread_count_peak.jmxObjectName java.lang:type=Threading +java_thread_count_peak.jmxAttributeName PeakThreadCount + + diff --git a/plugins/java/jmx/examples/tomcat/catalina_requests.conf b/plugins/java/jmx/examples/tomcat/catalina_requests.conf new file mode 100644 index 00000000..acb48175 --- /dev/null +++ b/plugins/java/jmx/examples/tomcat/catalina_requests.conf @@ -0,0 +1,16 @@ +graph_title Requests Per Second +graph_vlabel requests per second +graph_category Tomcat +graph_order catalina_request_count catalina_error_count + +catalina_request_count.label requests +catalina_request_count.jmxObjectName Catalina:name=http-8080,type=GlobalRequestProcessor +catalina_request_count.jmxAttributeName requestCount +catalina_request_count.type DERIVE +catalina_request_count.min 0 + +catalina_error_count.label errors +catalina_error_count.jmxObjectName Catalina:name=http-8080,type=GlobalRequestProcessor +catalina_error_count.jmxAttributeName errorCount +catalina_error_count.type DERIVE +catalina_error_count.min 0 diff --git a/plugins/java/jmx/examples/tomcat/catalina_threads.conf b/plugins/java/jmx/examples/tomcat/catalina_threads.conf new file mode 100644 index 00000000..32ab44c2 --- /dev/null +++ b/plugins/java/jmx/examples/tomcat/catalina_threads.conf @@ -0,0 +1,12 @@ +graph_title Thread Count +graph_vlabel Thread Count +graph_category Tomcat +graph_order catalina_threads_count catalina_threads_busy + +catalina_threads_busy.label busy +catalina_threads_busy.jmxObjectName Catalina:name=http-8080,type=ThreadPool +catalina_threads_busy.jmxAttributeName currentThreadsBusy + +catalina_threads_count.label current +catalina_threads_count.jmxObjectName Catalina:name=http-8080,type=ThreadPool +catalina_threads_count.jmxAttributeName currentThreadCount diff --git a/plugins/java/jmx/examples/tomcat/catalina_times.conf b/plugins/java/jmx/examples/tomcat/catalina_times.conf new file mode 100644 index 00000000..e3790259 --- /dev/null +++ b/plugins/java/jmx/examples/tomcat/catalina_times.conf @@ -0,0 +1,32 @@ +graph_title Response Time +graph_vlabel Time, ms +graph_category Rules Engine +graph_args --upper-limit 100 -l 0 +graph_scale no +graph_category Tomcat +graph_order catalina_request_count catalina_max_time catalina_proc_time catalina_proc_tpr + +catalina_request_count.label requests +catalina_request_count.jmxObjectName Catalina:name=http-8080,type=GlobalRequestProcessor +catalina_request_count.jmxAttributeName requestCount +catalina_request_count.graph no +catalina_request_count.type DERIVE +catalina_request_count.min 0 + +catalina_proc_time.label time +catalina_proc_time.jmxObjectName Catalina:name=http-8080,type=GlobalRequestProcessor +catalina_proc_time.jmxAttributeName processingTime +catalina_proc_time.type DERIVE +catalina_proc_time.min 0 +catalina_proc_time.graph no + +catalina_proc_tpr.label avg +catalina_proc_tpr.jmxObjectName Catalina:name=http-8080,type=GlobalRequestProcessor +catalina_proc_tpr.jmxAttributeName processingTime +catalina_proc_tpr.cdef catalina_request_count,0,EQ,0,catalina_proc_time,catalina_request_count,/,IF + +catalina_max_time.label peak +catalina_max_time.jmxObjectName Catalina:name=http-8080,type=GlobalRequestProcessor +catalina_max_time.jmxAttributeName maxTime + + diff --git a/plugins/java/jmx/examples/tomcat/catalina_traffic.conf b/plugins/java/jmx/examples/tomcat/catalina_traffic.conf new file mode 100644 index 00000000..f6d9498d --- /dev/null +++ b/plugins/java/jmx/examples/tomcat/catalina_traffic.conf @@ -0,0 +1,18 @@ +graph_title Traffic +graph_vlabel Bytes rec(-)/sent(+) per second +graph_category Tomcat +graph_order catalina_bytes_received catalina_bytes_sent + +catalina_bytes_sent.label bps +catalina_bytes_sent.jmxObjectName Catalina:name=http-8080,type=GlobalRequestProcessor +catalina_bytes_sent.jmxAttributeName bytesSent +catalina_bytes_sent.type DERIVE +catalina_bytes_sent.min 0 +catalina_bytes_sent.negative catalina_bytes_received + +catalina_bytes_received.label received +catalina_bytes_received.jmxObjectName Catalina:name=http-8080,type=GlobalRequestProcessor +catalina_bytes_received.jmxAttributeName bytesReceived +catalina_bytes_received.type DERIVE +catalina_bytes_received.min 0 +catalina_bytes_received.graph no \ No newline at end of file diff --git a/plugins/java/jmx/plugin/jmx_ b/plugins/java/jmx/plugin/jmx_ new file mode 100755 index 00000000..9fe33f2f --- /dev/null +++ b/plugins/java/jmx/plugin/jmx_ @@ -0,0 +1,54 @@ +#!/bin/sh +# +# Wildcard-plugin to monitor Java JMX (http://java.sun.com/jmx)attributes. +# To monitor a # specific set of JMX attributes, +# link to this file. E.g. +# +# ln -s /usr/share/plugins/jmx_ /etc/munin/plugins/jmx_java_threads +# + +# ...will monitor Java thread count, assuming java_threads.conf file is located in +# /etc/munin/plugins folder. +# +# For Java process to be monitored, it must expose JMX remote interface. +# With Java 1.5 it can be done by adding parameters as: +# +# -Dcom.sun.management.jmxremote.port= -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false +# +# For Tomcat to be monitored, add the following line in catalina.bat script: +# set JAVA_OPTS=%JAVA_OPTS% -Dcom.sun.management.jmxremote.port= -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false +# +# By default, the plugin monitors localhost on = 1616 using URL +# service:jmx:rmi:///jndi/rmi://localhost:1616/jmxrmi +# It can be changed by specifying parameters in /etc/munin/plugin-conf.d/munin-node +# +# [jmx_*] +# env.jmxurl service:jmx:rmi:///jndi/rmi://localhost:1616/jmxrmi +# +# Read more on JMX configuring at http://java.sun.com/j2se/1.5.0/docs/guide/management/agent.html +# $Log$ +# +LINK=`readlink $0` +CONFIGNAME=`basename $0 | sed 's/^jmx_//g'`.conf +RDIR=`dirname $LINK` + +if [ "$jmxurl" = "" ]; then +SERVICE=service:jmx:rmi:///jndi/rmi://localhost:1616/jmxrmi +else +SERVICE="$jmxurl" +fi + +if [ "$jmxuser" != "" ]; then +CREDS="--user=$jmxuser --pass=$jmxpass" +fi + +# checks +test -z $CONFIGNAME || test -z "$RDIR" && exit 1 + +JMXQUERY="java -cp $RDIR/jmxquery.jar org.munin.JMXQuery --url=$SERVICE $CREDS --conf=$RDIR/$CONFIGNAME" + + +case $1 in + (config) $JMXQUERY config;; + (*) $JMXQUERY ;; +esac diff --git a/plugins/java/jmx/plugin/jmxquery.jar b/plugins/java/jmx/plugin/jmxquery.jar new file mode 100644 index 00000000..5c37d4bd Binary files /dev/null and b/plugins/java/jmx/plugin/jmxquery.jar differ diff --git a/plugins/java/jmx/readme.txt b/plugins/java/jmx/readme.txt new file mode 100644 index 00000000..cae58a28 --- /dev/null +++ b/plugins/java/jmx/readme.txt @@ -0,0 +1,66 @@ +-------- JMX plugin for Munin --------- + +Java JMX Munin plugin enables you to monitor JMX attributes in Munin. +As soon as JMX embedded in Java 5, any Java process may expose parameters to be monitored using JMX interface, +look http://java.sun.com/j2se/1.5.0/docs/guide/management/agent.html and http://java.sun.com/jmx for details +In Java version < 5 it is still possible to expose JMX interface using third party libraries + +To see what can be monitored by JMX, run /bin/jconsole.exe and connect to +the host/port you setup in your Java process. + +Some examples are: +* standard Java JMX implementation exposes memory, threads, OS, garbage collector parameters +* Tomcat exposes multiple parameters - requests, processing time, threads, etc.. +* spring framework allows to expose Java beans parameters to JMX +* your application may expose any attributes for JMX by declaration or explicitly. +* can monitor localhost or remote processes + +-------- Installation --------- + +Pre-requsisites are: +- installed munin-node +- Java version 5 JRE + +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_, +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 +5) optionally specify the environment variable for JMX URL. The default URL corresponds to localhost:1616. +If you have different port listening by JMX or different hostname to monitor, specify jmxurl parameter +in /etc/munin/plugin-conf.d/munin-node: + +[jmx_*] +env.jmxurl service:jmx:rmi:///jndi/rmi://localhost:1616/jmxrmi + +-------- Check Installation --------- + +To check that all installed properly, try invoke plugins from command line, using links like: + +root@re:/etc/munin/plugins# ./jmx_java_process_memory config +graph_category Java +... +root@re:/etc/munin/plugins# ./jmx_java_process_memory +java_memory_nonheap_committed.value 35291136 +... + +If you have configured environment for jmxurl, do not forget to export it before! + +-------- Configuration Files --------- + +Folder "examples" contains configuration files for Java and Tomcat monitoring examples. +The format of configuration file is a superset of Munin plugin "config" command output +(http://munin.projects.linpro.no/wiki/protocol-config) +It has the following additions: + +.jmxObjectName JMX object name, e.g. java.lang:type=Memory +.jmxAttributeName JMX attribute name, e.g. NonHeapMemoryUsage +.jmxAttributeKey If attribute is a composed data (structure), the name of the field in structure, e.g. max + +% separates comments in file + + +