API for clojure.java.jmx - java.jmx 1.1.0-SNAPSHOT (in development)

by Stuart Halloway

Full namespace name: clojure.java.jmx

Overview

JMX support for Clojure

Usage
  (require '[clojure.java.jmx :as jmx])

What beans do I have?

  (jmx/mbean-names "*:*")
  -> #<HashSet [java.lang:type=MemoryPool,name=CMS Old Gen,
                java.lang:type=Memory, ...]

What attributes does a bean have?

  (jmx/attribute-names "java.lang:type=Memory")
  -> (:Verbose :ObjectPendingFinalizationCount
      :HeapMemoryUsage :NonHeapMemoryUsage)

What is the value of an attribute?

  (jmx/read "java.lang:type=Memory" :ObjectPendingFinalizationCount)
  -> 0
  (jmx/read "java.lang:type=Memory" [:HeapMemoryUsage :NonHeapMemoryUsage])
  ->
  {:NonHeapMemoryUsage
    {:used 16674024, :max 138412032, :init 24317952, :committed 24317952},
   :HeapMemoryUsage
    {:used 18619064, :max 85393408, :init 0, :committed 83230720}}

Can't I just have *all* the attributes in a Clojure map?

  (jmx/mbean "java.lang:type=Memory")
  -> {:NonHeapMemoryUsage
       {:used 16674024, :max 138412032, :init 24317952, :committed 24317952},
      :HeapMemoryUsage
       {:used 18619064, :max 85393408, :init 0, :committed 83230720},
      :ObjectPendingFinalizationCount 0,
      :Verbose false}

Can I find and invoke an operation?

  (jmx/operation-names "java.lang:type=Memory")
  -> (:gc)
  (jmx/invoke "java.lang:type=Memory" :gc)
  -> nil

What about some other process? Just run *any* of the above code
inside a with-connection:

  (jmx/with-connection {:host "localhost", :port 3000}
    (jmx/mbean "java.lang:type=Memory"))
  -> {:ObjectPendingFinalizationCount 0,
      :HeapMemoryUsage ... etc.}

Can I serve my own beans?  Sure, just drop a Clojure ref
into an instance of clojure.java.jmx.Bean, and the bean
will expose read-only attributes for every key/value pair
in the ref:

  (jmx/register-mbean
     (create-bean
     (ref {:string-attribute "a-string"}))
     "my.namespace:name=Value")

Protocols



Destract

Protocol

    Known implementations: clojure.lang.Associative, java.lang.Boolean, javax.management.openmbean.CompositeData, javax.management.openmbean.TabularData, nil, Object
    

objects->data

function
Usage: (objects->data _)
Convert JMX object model into data. Handles CompositeData, TabularData, maps, and atoms.

      
      
      
    
Source

Types



Bean

type

    Fields: [state-ref]
Protocols:
Interfaces: javax.management.DynamicMBean

Public Variables and Functions



->Bean

function
Usage: (->Bean state-ref)
Positional factory function for class clojure.java.jmx.Bean.

    
    
    Source
  


attribute-names

function
Usage: (attribute-names n)
All attribute names available on an MBean.

    
    
    Source
  


create-bean

function
Usage: (create-bean state-ref)
Expose a reference as a JMX bean. state-ref should be a Clojure
reference (ref, atom, agent) containing a map.

Using an agent for the state-ref is not recommended when the bean may
be modified with the setAttribute(s) methods. The setAttribute(s) methods
will block on the agent to complete all submitted actions (via await).

    
    
    Source
  


invoke

function
Usage: (invoke n op & args)
Invoke an operation an an MBean. See also: invoke-signature

    
    
    Source
  


invoke-signature

function
Usage: (invoke-signature n op signature & args)
Invoke an operation an an MBean. You must also supply
the signature of the operation. This is useful in cases
where the operation is overloaded. Otherwise you should
use the 'invoke' operation which will determine the
signature for you.

The signature parameter is a sequence of strings that
describes the method parameter types in order.

    
    
    Source
  


mbean

function
Usage: (mbean n)
Like clojure.core/bean, but for JMX beans. Returns a read-only map of
a JMX bean's attributes. If an attribute it not supported, value is
set to the exception thrown.

    
    
    Source
  


mbean-names

function
Usage: (mbean-names n)
Finds all MBeans matching a name on the current *connection*.

    
    
    Source
  


operation-names

function
Usage: (operation-names n)
All operation names available on an MBean.

    
    
    Source
  


read

var

    
Read one or more mbean properties.

    
    
    Source
  


readable?

function
Usage: (readable? n attr)
Is attribute readable?

    
    
    Source
  


register-mbean

function
Usage: (register-mbean mbean mbean-name)
Register an mbean with the current *connection*.

    
    
    Source
  


unregister-mbean

function
Usage: (unregister-mbean mbean-name)
Unregister mbean named mbean-name with the current *connection*.

    
    
    Source
  


with-connection

macro
Usage: (with-connection opts & body)
Execute body with a JMX connection created based on opts. opts can include [default]:

:protocol    The protocol to use [rmi:///jndi/rmi]
:host        The host to connect to [localhost]
:port        The port to connect to [3000]
:jndi-path   The jndi-path to use [jmxuri]
:url         The full url (as a String) to use instead of generating a rmi url from
             the above options [nil]
:environment A map representing the environment used for the connection.
             See JMXConnectorFactory/connect for details [{}]

    
    
    Source
  


write!

function
Usage: (write! n attr value)
Write an attribute value.

    
    
    Source
  
Logo & site design by Tom Hickey.
Clojure auto-documentation system by Tom Faulhaber.