Git Product home page Git Product logo

java.jmx's Introduction

clojure.java.jmx

Produce and consume JMX beans from Clojure.

Releases and Dependency Information

Latest stable release: 0.3.4

Leiningen dependency information:

[org.clojure/java.jmx "0.3.4"]

Maven dependency information:

<dependency>
  <groupId>org.clojure</groupId>
  <artifactId>java.jmx</artifactId>
  <version>0.3.4</version>
</dependency>

Usage

Full Documentation

(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

Give me all the attributes:

(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}

Find an invoke an operation:

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

Conneting to another 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.}

Serve your own beans. Drop a Clojure ref into create-bean to expose read-only attributes for every key/value pair in the ref:

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

Developer Information

Building

  1. Clone the repo
  2. Make sure you have maven installed
  3. Run the maven build: mvn install will produce a JAR file in the target directory, and run all tests with the most recently-released build of Clojure.

License

Copyright © Stuart Halloway

Licensed under the EPL. (See the file epl.html.)

java.jmx's People

Contributors

nickmbailey avatar stuarthalloway avatar seancorfield avatar puredanger avatar abedra avatar hiredman avatar

Watchers

 avatar

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.