GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing clojure.github.io — clojure.java.jmx - java.jmx 1.1.0-SNAPSHOT API documentation API for clojure.java.jmx - java.jmx 1.1.0-SNAPSHOT (in development)by Stuart HallowayFull namespace name: clojure.java.jmx OverviewProject home page is https://github.com/clojure/java.jmx/
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")
ProtocolsDestractProtocolKnown implementations: clojure.lang.Associative, java.lang.Boolean, javax.management.openmbean.CompositeData, javax.management.openmbean.TabularData, nil, Object objects->datafunctionUsage: (objects->data _) Convert JMX object model into data. Handles CompositeData, TabularData, maps, and atoms. TypesBeantypeFields: [state-ref] Protocols: Interfaces: javax.management.DynamicMBean Public Variables and Functions->BeanfunctionUsage: (->Bean state-ref) Positional factory function for class clojure.java.jmx.Bean.Source attribute-namesfunctionUsage: (attribute-names n) All attribute names available on an MBean.Source create-beanfunctionUsage: (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 invokefunctionUsage: (invoke n op & args) Invoke an operation an an MBean. See also: invoke-signatureSource invoke-signaturefunctionUsage: (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 mbeanfunctionUsage: (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-namesfunctionUsage: (mbean-names n) Finds all MBeans matching a name on the current *connection*.Source operation-namesfunctionUsage: (operation-names n) All operation names available on an MBean.Source register-mbeanfunctionUsage: (register-mbean mbean mbean-name) Register an mbean with the current *connection*.Source unregister-mbeanfunctionUsage: (unregister-mbean mbean-name) Unregister mbean named mbean-name with the current *connection*.Source with-connectionmacroUsage: (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
Copyright 2007-2023 by Rich Hickey and the various contributors
Logo & site design by Tom Hickey.
Clojure auto-documentation system by Tom Faulhaber. |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |