Friday, April 13, 2012

JAJMX (JAnalyseJMX) 0.3.0 released

JAJMX is high level scala JMX API. The goal is to simplify to the maximum JMX operations. ( ** project page **)

Latest changes :
  • JMXOptions now contains an extra field "name" which allow user to friendly identify a remote jmx system
  • added a package object jajmx to define shortcuts to fr.janalyse.jmx.JMX class and object
  • JMX.connect renamed to JMX.once
  • scaladoc generation now works fine, follow hack described here : https://github.com/harrah/xsbt/issues/85

jvm force gc script

#!/bin/sh
exec java -jar jajmx.jar -nocompdaemon -usejavacp -savecompiled "$0" "$@"
!#

jajmx.JMX.once("127.0.0.1", 1099) { _.memory map {_ call "gc"} }
 

jmx grep script

#!/bin/sh
exec java -jar jajmx.jar -nocompdaemon -usejavacp -savecompiled "$0" "$@"
!#

import jajmx._

if (args.size < 2) {
  println("Usage   : jmxgrep host port searchMask1 ... searchMaskN")
  System.exit(1)
}
val host  = args(0)
val port  = args(1).toInt
val masks = args.toList.drop(2) map {s=>("(?i)"+s).r}

def truncate(str:String, n:Int=60) = if (str.size>n) str.take(n)+"..." else str

JMX.once(host, port) { jmx =>
  for(mbean <- jmx.mbeans ; attr <- mbean.attributes; value <- mbean.getString(attr)) {
    val found = List(mbean.name, attr.name, value) exists { 
         item => masks exists {_.findFirstIn(item).isDefined }
    }
    if (found) println("%s - %s = %s".format(mbean.name, attr.name, truncate(value)))
  }
}


No comments:

Post a Comment