A riemann plugin for periodically collecting JMX stats from the JVM it is running in.
After cloning the repo, you can build the plugin using leiningen
lein uberjar
This will create a plugin jar named riemann-mbeans-x.y.z-SNAPSHOT-standalone.jar
which you can include into your java classpath, e.g.:
java -cp /usr/lib/riemann/riemann.jar:/usr/lib/riemann/riemann-mbeans-0.2.1-SNAPSHOT-standalone-up.jar riemann.bin start /etc/riemann/riemann.config
On Debian or Red Hat you could also add the classpath using the EXTRA_CLASSPATH
variable available in /etc/default/riemann
or /etc/sysconfig/riemann
respectively.
(load-plugins)
(mbeans/instrumentation)
This will collect the default stats every 10 seconds.
(load-plugins)
(let [beans [{:mbean "java.lang:type=Memory" :property :HeapMemoryUsage :attribute :used}
{:mbean "java.lang:type=Runtime" :property :Uptime}]]
(mbeans/instrumentation {:interval 10 :mbeans beans}))
This will collect two beans every 10 seconds.
(load-plugins)
(mbeans/instrumentation {:interval 10 :mbeans [{:mbean "java.lang:type=Runtime" :property :Uptime :service "the jvm's uptime"}]})
This will collect one bean and override its service name.
This function will add a service to the riemann core that will periodically retrieve JMX mbeans. You can run the function standalone.
(mbeans/instrumentation)
Or you can call it with options.
(mbeans/instrumentation opts)
The map opts
should contain two keys:
:interval
- collection interval in seconds (defaults to 10).:mbeans
- sequence of hash maps describing the beans to collect (See clojure/java.jmx). Every element ofmbeans
should contain the following keys::mbean
- the name of the bean.:property
- the bean's property to collect.:attribute
- the property's attribute to collect (optional if the property is scalar).:service
- the name of the riemann event's service. This defaults to a concatenation of the three previous values.
The service should behave as expected with respect to a configuration reload!
- Not sure if there are any nested types or tables. If there are, their retrieval will probably require an API change.
- If one bean fails, nothing will be reported