API for jmx - clojure-contrib v1.2 (stable)

by Stuart Halloway

clojure-contrib is now deprecated

clojure-contrib is no longer being developed or maintained.

Rather than a single, monolithic, contributions library, Clojure now has a set of separate libraries for each unit of functionality. The libraries are in the Clojure GitHub organization at https://github.com/clojure. API documentation of the libraries can be found at https://clojure.github.io.

If you're looking for a specific function or namespace from the old clojure-contrib, see "Where Did Clojure.Contrib Go".


Full namespace name: clojure.contrib.jmx

Overview

JMX support for Clojure

Requires post-Clojure 1.0 git edge for clojure.test, clojure.backtrace.
This is prerelease.
This API will change.
Send reports to stu@thinkrelevance.com.

Usage
  (require '[clojure.contrib.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

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.contrib.jmx.Bean, and the bean
will expose read-only attributes for every key/value pair
in the ref:

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

Public Variables and Functions



*connection*

var
This library, clojure-contrib, is deprecated. See here for more information.

  
The connection to be used for JMX ops. Defaults to the local process.
Source


as-object-name

multimethod
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (as-object-name string-or-name)
Interpret an object as a JMX ObjectName.
Source


attribute-info

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (attribute-info object-name attr-name)
Get the MBeanAttributeInfo for an attribute.
Source


attribute-names

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (attribute-names n)
All attribute names available on an MBean.
Source


build-attribute-info

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (build-attribute-info attr-name attr-value)
       (build-attribute-info name type desc readable? writable? is?)
Construct an MBeanAttributeInfo. Normally called with a key/value pair from a Clojure map.
Source


guess-attribute-typename

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (guess-attribute-typename value)
Guess the attribute typename for MBeanAttributeInfo based on the attribute value.
Source


jmx->clj

multimethod
This library, clojure-contrib, is deprecated. See here for more information.
No usage documentation available
Coerce JMX data structures into Clojure data.
Handles CompositeData, TabularData, maps, and atoms.
Source


jmx-url

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (jmx-url)
       (jmx-url overrides)
Build a JMX URL from options.
Source


map->attribute-infos

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (map->attribute-infos attr-map)
Construct an MBeanAttributeInfo[] from a Clojure associative.
Source


maybe-atomize

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (maybe-atomize k)
Convert a list of length 1 into its contents, leaving other things alone.
Used to simplify keys in the tabular data API.
Source


maybe-keywordize

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (maybe-keywordize s)
Convert a string key to a keyword, leaving other types alone. Used to
simplify keys in the tabular data API.
Source


mbean

function
This library, clojure-contrib, is deprecated. See here for more information.
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
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (mbean-names n)
Finds all MBeans matching a name on the current *connection*.
Source


op-param-types

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (op-param-types n op)
The parameter types (as class name strings) for operation op on n.
Used for invoke.
Source


operation

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (operation n op)
The MBeanOperationInfo for operation op on mbean n. Used by invoke.
Source


operation-names

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (operation-names n)
All operation names available on an MBean.
Source


operations

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (operations n)
All oeprations available on an MBean.
Source


raw-read

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (raw-read n attr)
Read an mbean property. Returns low-level Java object model for
composites, tabulars, etc. Most callers should use read.
Source


read

var
This library, clojure-contrib, is deprecated. See here for more information.

  
Read an mbean property.
Source


read-supported

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (read-supported n attr)
Calls read to read an mbean property, *returning* unsupported
operation exceptions instead of throwing them. Used to keep mbean
from blowing up. Note: There is no good exception that aggregates
unsupported operations, hence the overly-general catch block.
Source


readable?

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (readable? n attr)
Is attribute readable?
Source


with-connection

macro
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (with-connection opts & body)
Execute body with JMX connection specified by opts. opts can also
include an optional :environment key which is passed as the
environment arg to JMXConnectorFactory/connect.
Source
Logo & site design by Tom Hickey.
Clojure auto-documentation system by Tom Faulhaber.