Posts

Showing posts with the label jmx

Running Java in a Script

Recently I wanted to invoke a JMX operation in a WSO2 server from a script. I was first thinking of writing a simple Java class with a main method and run it as an executable jar file. Then I found that we can run a script with the command " jrunscript ". I also found an example of interacting with a JMX MBean from Javascript . However this example didn't work with Java 8. The reason is that from Java 8, the JavaScript Engine for the JVM is Oracle Nashorn . In Java 7, the JavaScript Engine is based on Mozilla Rhino. Let's see the difference: Following script works with Java 7, but not with Java 8 packages = new JavaImporter(java.lang, java.lang.reflect); with (packages) { // create Java String array of 5 elements var a = Array.newInstance(String, 5); // Accessing elements and length access is by usual Java syntax a[0] = "scripting is great!"; print(a.length); print('\n'); print(a[0]); print('\n'); } ...

Monitoring WSO2 products with logstash JMX input plugin

These days, I got the chance to play with ELK  ( Elasticsearch , Logstash & Kibana ). These tools are a great way to analyze & visualize all logs. You can easily analyze all wso2carbon.log files from ELK. However we also needed to use ELK for monitoring WSO2 products and this post explains the essential steps to use logstash JMX input plugin to monitor WSO2 servers. Installing Logstash JMX input plugin Logstash has many inputs and the JMX input plugin is available under "contrib" We can use "plugin install contrib" command to install extra plugins. cd /opt/logstash/bin sudo ./plugin install contrib Note: If you use logstash 1.4.0 and encounter issues in loading the jmx4r, please refer Troubleshooting below. Logstash JMX input configuration When using the JMX input plugin, we can use a similar configuration as follows. We are keeping the logstash configs in "/etc/logstash/conf.d/logstash.conf" input { jmx{ path ...