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")
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")
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close