A node.js client for retrieving information from the JXM bridge provided by Roland Huss at http://www.jolokia.org/.
Currently, only a subset of commands is supported. Please Please file a case at https://github.com/jolira/jolokia-client/issues if you want a particular command to be added.
var jolokia = require("jolokia-client");
var util = require('util'); // used by the examples below
var client = new jolokia("http://my.server.com/jolokia");
mbeans
is a string that identifies one particular mbean or domain name (such
as "JMImplementation"
or "JMImplementation:type=MBeanServerDelegate"
) or an
array or such names (such as ["JMImplementation", "Catalina"]
). The parameter
may also omitted to retrieve information about all mbeans available
on the server.
The callback
method takes one parameter. It is called when data was received
from the server. The data is return as a JavaScript object.
// lists all available attributes and operations
client.list(function(response){
console.log(util.inspect(response, true, 10));
});
// lists available attributes and operations for all JMImplementation mbeans
client.list("JMImplementation", function(response){
console.log(util.inspect(response, true, 10));
});
// lists available attributes and operations for the JMImplementation:type=MBeanServerDelegate mbean
client.list("JMImplementation:type=MBeanServerDelegate", function(response){
console.log(util.inspect(response, true, 10));
});
// lists available attributes and operations for all JMImplementation and Catalina mbeans
client.list(["JMImplementation", "Catalina"], function(response){
console.log(util.inspect(response, true, 10));
});
mbean
is a string that identifies one particular (qualified) mbean (such
"JMImplementation:type=MBeanServerDelegate"
)
atrribute
is a string that identifies one particular attribute (such as
"ImplementationVersion"
). This parameter may be omitted to return all attributes
of an mbean.
The callback
method takes one parameter. It is called when data was received
from the server. The data is return as a JavaScript object.
// read all attributes of "JMImplementation:type=MBeanServerDelegate"
client.read("JMImplementation:type=MBeanServerDelegate", function(response){
console.log(util.inspect(response, true, 10));
});
// read the "ImplementationVersion" attribute of "JMImplementation:type=MBeanServerDelegate"
client.read("JMImplementation:type=MBeanServerDelegate", "ImplementationVersion", function(response){
console.log(util.inspect(response, true, 10));
});
It is also possible to read multiple metric at the same time:
// read all attributes of "JMImplementation:type=MBeanServerDelegate"
client.read(["JMImplementation:type=MBeanServerDelegate", "java.lang:type=Memory"], function(response){
console.log(util.inspect(response, true, 10));
});
// read the "ImplementationVersion" attribute of "JMImplementation:type=MBeanServerDelegate"
client.read([{mbean: "JMImplementation:type=MBeanServerDelegate", attribute="ImplementationVersion"}], function(response){
console.log(util.inspect(response, true, 10));
});
//execute the operation "operation" on mbean1 with no arguments for the call:
client.exec("mbean1", "operation", [], function(result){
console.log(...);
});
//execute the operation "operation" on all mbeans with "argument1" and "argument2" as arguments for each call:
client.exec(["mbean1","mbean2"], "operation", ["argument1", "argument2"], function(result){
console.log(...);
});
There is also a jxm2node command line utility included to access JMX information.
The utility must be invoked with a valid , such as http://my.server.com/jolokia
.
Also, a command must be provided. Valid commands are documented below.
Describe all mbeans for the given server. If no parameter is passed, all available mbeans of the server are part of the output.
Examples are:
jmx4node http://my.server.com/jolokia list
jmx4node http://my.server.com/jolokia list JMImplementation
jmx4node http://my.server.com/jolokia list JMImplementation:type=MBeanServerDelegate
Read the attributes of all mbeans for the given server. If no parameter is passed, all available attributes of the mbean are part of the output.
Examples are:
jmx4node http://my.server.com/jolokia read JMImplementation:type=MBeanServerDelegate
jmx4node http://my.server.com/jolokia read JMImplementation ImplementationVersion:
Read all the values of an , if a bean is provide, or all the values on the server otherwise
Examples are:
jmx4node http://my.server.com/jolokia dump
jmx4node http://my.server.com/jolokia dump JMImplementation
jmx4node http://my.server.com/jolokia dump JMImplementation:type=MBeanServerDelegate