Igor,
Writing your own JMX client is not that difficult.
The natural language to write JMX clients is Java, but if you prefer to
use your favourite language like Python or Ruby, there is a 'natural'
way too.
For python, you could use 'jython' http://jython.org
You can then look at sample Java clients and adapts them to jython.
For Cassandra, here is a sample JMX client I wrote to give you an idea
(sample output follows)
Writing a pure python JMX client seems on the other hand really difficult ;)
Alex
======================
# This is a jython JMX dumper
# to install jython on debian:
# apt-get install jython
# see
http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/tools/NodeProbe.java?view=markup&pathrev=822791
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import javax.management.MBeanServerConnection;
import javax.management.ObjectName;
import javax.management.openmbean.CompositeDataSupport;
import javax.management.openmbean.CompositeType;
import javax.management.remote.JMXConnector;
import javax.management.remote.JMXConnectorFactory;
import javax.management.remote.JMXServiceURL;
from array import array
import getopt
import sys
def get_connection(url,username,password):
ad=array(java.lang.String,[username,password])
n = java.util.HashMap()
n.put (javax.management.remote.JMXConnector.CREDENTIALS, ad);
jmxurl = javax.management.remote.JMXServiceURL(url)
testme = javax.management.remote.JMXConnectorFactory.connect(jmxurl,n)
connection = testme.getMBeanServerConnection();
# could also return the testme to allow closing the connection (but
jython will close it at exit time)
# testme.close()
return connection
def dump_object(connection,objectName):
"""Dumps an object based on its name (string)"""
mymbeaninfo=connection.getMBeanInfo(javax.management.ObjectName(objectName))
out=[]
for attribute in mymbeaninfo.attributes:
atvalue=connection.getAttribute(javax.management.ObjectName(objectName),attribute.name)
out.append("%s: %s" % (attribute.name,atvalue))
return "\n".join(out)
def query_objects(connection,queryString):
"""Dumps lists of objects based on a query (string)"""
out=[]
out.append("doing queryString=%s " % queryString)
query=javax.management.ObjectName(queryString)
result = connection.queryNames(query,None)
# print result
for objectName in result:
out.append("***** %s *****" % objectName)
out.append(dump_object(connection,"%s" % objectName))
return "\n".join(out)
if __name__ == "__main__":
# defaults:
url="service:jmx:rmi:///jndi/rmi://localhost:8080/jmxrmi"
username="controlRole"
password="change_asap"
objectname="org.apache.cassandra.db:type=ColumnFamilyStores,name=Keyspace1,columnfamily=Super1"
# defaults can be changed using command line options:
optlist, list = getopt.getopt(sys.argv[1:], 'c:u:p:o:')
# print "optlist =", optlist
# print "list =", list
for option in optlist:
# print option
if option[0] == '-c':
url=option[1]
print "connection= "+url
if option[0] == '-u':
username=option[1]
print "username= "+username
if option[0] == '-p':
password=option[1]
print "password= "+password
if option[0] == '-o':
objectname=option[1]
print "objectname= "+objectname
# connect
connection=get_connection(url,username,password)
# dump the default object
print dump_object(connection,objectname)
# now test queries:
queryString="org.apache.cassandra.db:type=ColumnFamilyStores,*"
print query_objects(connection,queryString)
====== sample output =====
jython cassandra_jmx.py
PendingTasks: 0
ColumnFamilyName: Super1
MemtableColumnsCount: 0
MemtableDataSize: 0
MemtableSwitchCount: 0
ReadCount: 0
ReadLatency: NaN
WriteCount: 0
WriteLatency: NaN
doing queryString=org.apache.cassandra.db:type=ColumnFamilyStores,*
*****
org.apache.cassandra.db:type=ColumnFamilyStores,name=system,columnfamily=LocationInfo
*****
PendingTasks: 0
ColumnFamilyName: LocationInfo
MemtableColumnsCount: 2
MemtableDataSize: 56
MemtableSwitchCount: 0
ReadCount: 0
ReadLatency: NaN
WriteCount: 0
WriteLatency: NaN
*****
org.apache.cassandra.db:type=ColumnFamilyStores,name=Keyspace1,columnfamily=Standard1
*****
PendingTasks: 0
ColumnFamilyName: Standard1
MemtableColumnsCount: 0
MemtableDataSize: 0
MemtableSwitchCount: 0
ReadCount: 0
ReadLatency: NaN
WriteCount: 0
WriteLatency: NaN
*****
org.apache.cassandra.db:type=ColumnFamilyStores,name=Keyspace1,columnfamily=Super1
*****
PendingTasks: 0
ColumnFamilyName: Super1
MemtableColumnsCount: 0
MemtableDataSize: 0
MemtableSwitchCount: 0
ReadCount: 0
ReadLatency: NaN
WriteCount: 0
WriteLatency: NaN
*****
org.apache.cassandra.db:type=ColumnFamilyStores,name=Keyspace1,columnfamily=StandardByUUID1
*****
PendingTasks: 0
ColumnFamilyName: StandardByUUID1
MemtableColumnsCount: 0
MemtableDataSize: 0
MemtableSwitchCount: 0
ReadCount: 0
ReadLatency: NaN
WriteCount: 0
WriteLatency: NaN
*****
org.apache.cassandra.db:type=ColumnFamilyStores,name=system,columnfamily=HintsColumnFamily
*****
PendingTasks: 0
ColumnFamilyName: HintsColumnFamily
MemtableColumnsCount: 0
MemtableDataSize: 0
MemtableSwitchCount: 0
ReadCount: 0
ReadLatency: NaN
WriteCount: 0
WriteLatency: NaN
*****
org.apache.cassandra.db:type=ColumnFamilyStores,name=Keyspace1,columnfamily=Standard2
*****
PendingTasks: 0
ColumnFamilyName: Standard2
MemtableColumnsCount: 0
MemtableDataSize: 0
MemtableSwitchCount: 0
ReadCount: 0
ReadLatency: NaN
WriteCount: 0
WriteLatency: NaN
Igor Katkov wrote:
I suppose it will Cassandra tailored solution, have you ever stumbled
upon something decent but general purpose JMX text JMX client?
On Wed, Nov 18, 2009 at 12:52 PM, Jonathan Ellis <[email protected]
<mailto:[email protected]>> wrote:
Michael Greene is working on something web-based:
https://issues.apache.org/jira/browse/CASSANDRA-451
On Wed, Nov 18, 2009 at 11:46 AM, Igor Katkov <[email protected]
<mailto:[email protected]>> wrote:
> As a side question, Is there a console-based (TTY) JConsole
alternative?
> Perhaps a web GUI proxy?
>
> On Wed, Nov 18, 2009 at 12:40 PM, Jonathan Ellis
<[email protected] <mailto:[email protected]>> wrote:
>>
>> Cassandra takes advantage of the JMX standard to expose its
internals.
>> You can access these via JConsole and lots of other tools.
>>
>> We've also wrapped some of the most common in bin/nodeprobe.
>>
>> For thrift queries there is bin/cassandra-cli and a web tool in
>> contrib/cassandra_browser.
>>
>> On Wed, Nov 18, 2009 at 11:37 AM, Matthias Wessendorf
<[email protected] <mailto:[email protected]>>
>> wrote:
>> > Hi,
>> >
>> > I wonder if there is some tool, like futon (which is the
(web) admin
>> > console for couchdb) ?
>> >
>> > Thx,
>> > Matthias
>> >
>> > --
>> > Matthias Wessendorf
>> >
>> > blog: http://matthiaswessendorf.wordpress.com/
>> > sessions: http://www.slideshare.net/mwessendorf
>> > twitter: http://twitter.com/mwessendorf
>> >
>
>