Connecting to JMX through Jython

Jython is great when you want a dynamically typed language based on the JVM.

Also comes really in handy when you want to write small monitoring scripts based on JMX.This is an examble on how to call a function from a MBean through Jython using JMX.

from import JMXConnector
from import JMXConnectorFactory
from import JMXServiceURL
from import MBeanServerConnection
from import MBeanInfo
from import ObjectName
from java.lang import String

from jarray import array
import sys   

if __name__=='__main__':
        if len(sys.argv)> 5:
                serverUrl = sys.argv[1]
                username = sys.argv[2]
                password = sys.argv[3] 
                beanName = sys.argv[4]
                action = sys.argv[5]
        credentials = array([username,password],String)
        environment = {JMXConnector.CREDENTIALS:credentials}

        jmxServiceUrl = JMXServiceURL('service:jmx:rmi:///jndi/rmi://'+serverUrl+':9999/jmxrmi');
        jmxConnector = JMXConnectorFactory.connect(jmxServiceUrl,environment);
        mBeanServerConnection = jmxConnector.getMBeanServerConnection()
        objectName = ObjectName(beanName);

By calling the script

jython {ip} {jmx user} {jmx password} {mbean name} {action}

You can invoke the action of the mbean specified.

Participating in the Summer AppCamp

This is the first post of this blog .And this one is about great news,really great news.

Me , Akasoglou Kostantinos and  Tsamouridis Vladimiros are going to participate in the Summer AppCamp .So what is the Summer AppCamp about ? It is a program focusing on the developement of mobile applications but you are not on your own on this one. Yes you guessed right we have mentors and we have APP CAMPUSES !!!!.

It is really great to get chosen for the AppCamp among other teams ,so we hope everything is going to be fine and making some really great applications.

Akasoglou Konstantinos blog