javamonitoringrrdtoolrrdganglia

How to get Ganglia metrics from Java code


Statement

I have a cluster with an installed Ganglia monitoring service. Now I want to create a simple frontend visualisation tool which can take metrics data from Ganglia backend and graph this data. This visualisation tool is written in Java and just need to get monitoring data to draw graphs by itself.

Question

What is the easiest way to get metrics data from Ganglia for a time period with the help of Java application? Any Ganglia's API or RRD-oriented Java libraries which can read Ganglia's RRD files?


Solution

  • There is a python-project called Ganglia-api, which requests metrics via tcp and provides them in json-format via URL. In Java the url may be queried, parsed and etc.

    Or you may get values from ganglia-web directly by requesting the following urls:

     "http://yourhost/ganglia/graph.php?h="+hostName+"&m="+metricName+"&r=hour&c="+clusterName+"&json=1"   //values for period (hour/2hr/day ... etc)
     "http://yourhost/ganglia/api/metrics.php?host=" + hostName + "&metric_name="+metricName  //actual value
     "http://yourhost/ganglia/api/rundeck.php"  //hosts list