Code Monkey home page Code Monkey logo

check_java's Introduction

check_java

This is a Nagios/Shinken plugin that allows the easy monitoring of Java applications through Java's JMX interface.

Usage

check_java will connect to a Java application and check one type of property per run against user-defined limits. This is governed by command line parameters to check_java, it is called like this:

check_java [-u URL] -t TYPE -w WARN -c CRIT

The meaning of the parameters is as follows:

-u URL: The JMX service URL check_java will connect to. For details on how the
        URL is constructed see the section "URL". If no URL is given, a default
        URL is used:
           service:jmx:rmi:///jndi/rmi://:9000/jmxrmi

-t TYPE: The property type to check. See the Section "Types" for more
         information about the available types.

-w WARN: The warning threshold. If a property value is greater than this number,
         check_java will return a WARNING state to Nagios.

-c CRIT: The critical threshold. If a property value is greater than this number,
         check_java will return a CRITICAL state to Nagios.

Starting a JMX agent

You can turn any Java application into a JMX server (aka JMX agent) by supplying some additional parameters to the JVM. Call your JMX application like this:

java \
-Dcom.sun.management.jmxremote \
-Dcom.sun.management.jmxremote.authenticate=false \
-Dcom.sun.management.jmxremote.ssl=false \
-Dcom.sun.management.jmxremote.port=9000 \
-Djava.rmi.server.hostname=localhost \

This will start a JMX agent on the loopback interface that listens for incoming connections on port 9000. Authentication and SSL are turned off as they are currently unsupported by check_java. In case your application is also using RMI, you should probably drop the last parameter so no hostname and thus interface is set. Most applications will take care of this automatically, so you should not interfere. In this case, you should be extra careful not to expose the JMX port to the whole world, as anyone could just connect and use JMX to potentially even control your JVM.

URL

After you have started your JMX agent, you need to tell check_java how it can connect to that agent. This is done through the URL parameter -u. JMX agent URLs are constructed in the following manner:

service:jmx:rmi:///jndi/rmi://<TARGET_MACHINE>:<RMI_REGISTRY_PORT>/jmxrmi

<TARGET_MACHINE> is the IP address (or resolvable name) of the machine you want to connect to, normally the same as the java.rmi.server.hostname property you set when starting the agent. the <RMI_REGISTRY_PORT> is the port number set using the com.sun.management.jmxremote.port property you set when starting the agent.

If the URL parameter -u is not given on the command line, check_java uses the default URL service:jmx:rmi:///jndi/rmi://:9000/jmxrmi. Using this URL, check_java will connect to a JMX agent on localhost at port 9000.

Types

check_java is able to check several standard JMX attributes provided by the JVM itself, thus independent of the actually running program. Currently it is not possible to check arbitrary JMX attributes.

A check can be invoked by giving the check name to the check_java type parameter -t.

HeapMem

This check will return the amount of used heap memory. In the performance data fields, also the values for the initial allocation size of the heap memory, the current allocation of the heap memory, and the maximum allowed heap memory allocation are returned.

NonHeapMem

This check will return the amount of used non-heap memory. In the performance data fields, also the values for the initial allocation size of the non-heap memory, the current allocation of the heap memory, and the maximum allowed heap memory allocation are returned.

MemPoolEden

This check will return the amount of used memory in the memory pool Eden. In the performance data fiels, the values for the initial size of the memory pool, the current size of the memory pool, and the current maximum size of the memory pool are returned.

MemPoolSurvivor

This check will return the amount of used memory in the memory pool Survivor. In the performance data fiels, the values for the initial size of the memory pool, the current size of the memory pool, and the current maximum size of the memory pool are returned.

MemPoolCodeCache

This check will return the amount of used memory in the memory pool Code Cache. In the performance data fiels, the values for the initial size of the memory pool, the current size of the memory pool, and the current maximum size of the memory pool are returned.

GCMarkSweepCount

This check will return the number of runs of the Mark and Sweep Garbage Collector. This is currently an experimental feature and not yet thoroughly tested.

GCMarkSweepTime

This check will return the amount of time consumed by the Mark and Sweep Garbage Collector. This is currently an experimental feature and not yet thoroughly tested.

ClassLoading

This check will return the number of currently loaded classes. In the performance data fields, the number of total loaded classed, and the number of unloaded classes are returned as well.

ThreadCount

This check will return the number of currently existing threads. In the performance data fields, the number of total started threads, and the number of currently existing daemon threads are returned as well.

License

Copyright (c) 2015, Sebastian Schäfer [email protected] All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  • Neither the name of check_java nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SEBASTIAN SCHÄFER BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

check_java's People

Contributors

benhubert avatar sarek avatar valdm avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

check_java's Issues

Missing units in human-readable output

The human readable output line should contain units for all three values (current, warning, and critical), not just for the current value.

Bad example:
CRITICAL: Heap Memory Usage: 810245960 B/100000/1000000

Good example:
CRITICAL: Heap Memory Usage: 810245960 B/100000 B/1000000 B

Still Debug Output

There is still some debug output:

$ java -jar check_java.jar -u "service:jmx:rmi:///jndi/rmi://:9010/jmxrmi" -t HeapMem -w 100000 -c 1000000
Connecting to JMX server
CRITICAL: Heap Memory Usage: 810245960 B/100000/1000000
'used'=810245960B;100000;1000000
'init'=1073741824B
'committed'=2606759936B
'max'=5726797824B

Add integration tutorial

Describe how Nagios/Shinken needs to be configured to use check_java.

There should be a small tutorial that details how to setup a restricted user on the system, as well as a pre-fabricated pack for Shinken that just needs to be plugged in.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.