It all depends what you want and why you're asking, a little more context might be applicable: Do you want to monitor from a Clojure process, or do you want to monitor a Clojure process ? Which of these two processes do you have author control over ?
JMX client
clojure.java.jmx
is a client library to call Java JMX functions from Clojure, either locally or over the wire (JMX over RMI). It's basically the programming alternative to GUI's like JVisualVM / JMC.
JMX server
Over RMI
While you can always use JMX calls from within a Java process itself, to be able to monitor a Java / Clojure process remotely, you'd still need to include the -Dcom.sun.management.jmxremote
parameters. This makes the process act as a server for JMX requests over an RMI connection.
Over HTTP
An alternative to RMI is serving JMX through a REST interface via jolokia. RMI is notoriously hard to manage over network infrastructure borders like firewalls, and to secure through authentication and authorization.
JMX over REST is much easier to manage (reverse proxy exclusions for JMX URLs). Authentication and authorization can also be done in your current web stack.
There's no Clojure client for these REST calls though, but it should be easy to mirror the clojure.java.jmx API and have it generate HTTP requests.
Exposing JMX beans
If you have a Clojure app that needs to expose application specific metrics that can be read through JMX, you need turn it into an JMX MBean. You can wrap any clojure map ref in a bean, and any updates to that ref can be seen through a JMX request.
clojure.java.jmx
can help here as well.
(def my-statistics
(ref {:current-sessions 0}))
(jmx/register-mbean
(jmx/create-bean my-statistics)
"my.namespace:name=Sessions")
(defn login
[user]
;(do-login user)
(dosync (alter my-statistics update :current-sessions inc)))
(login "foo")
;just as an example to show you can read the bean through JMX
(jmx/attribute-names "my.namespace:name=Sessions")
=> (:current-sessions)
(jmx/read "my.namespace:name=Sessions" :current-sessions)
=> 1
Make sure the ref map has string/symbol keys and Java 'primitive' values, or you might get a read exception on the client side.
The data from this bean can then be requested through JMX, provided you have set up a way to connect to the process.