@Test public void hostTest() { System.out.println("----- HostTest -----"); Ganglia g = new Ganglia(); Host host = g.getHostInfo(clusterName, hostName); if (host == null) { System.out.println("No host '" + hostName + "' found in cluster '" + clusterName); } else { System.out.println("Host '" + hostName + "'"); Assert.assertTrue(host.getLoadFive() >= 0); Assert.assertTrue(host.getLoadFifteen() >= 0); Assert.assertTrue(host.getCPUUser() >= 0); Assert.assertTrue(host.getCPUNice() >= 0); Assert.assertTrue(host.getCPUSystem() >= 0); Assert.assertTrue(host.getCPUIdle() >= 0); Assert.assertTrue(host.getCPUWio() >= 0); Assert.assertTrue(host.getDiskTotal() >= 0); Assert.assertTrue(host.getDiskFree() >= 0); Assert.assertTrue(host.getDiskUsed() >= 0); } System.out.println("----------"); }
public Host getHostInfo(String clusterName, String hostName) { String gangliaXml = null; ArrayList<Cluster> cluster_list = new ArrayList<Cluster>(); Host ret_host = null; try { ParseGanglia p = new ParseGanglia(gangliaCollectorIP, gangliaPort, gangliaPortQuery); gangliaXml = p.queryGanglia("/" + clusterName + "/" + hostName); cluster_list = (ArrayList<Cluster>) p.parseGangliaXml(gangliaXml); } catch (MonitoringException ex) { Logger.getLogger(Ganglia.class.getName()).log(Level.SEVERE, null, ex); } for (Cluster cluster : cluster_list) { if (cluster.getName().equals(clusterName)) { for (Host host : cluster.getHosts()) { if (host.getName().equals(hostName)) { ret_host = host; } } } } return ret_host; }
Ganglia { public Host getHostInfo(String clusterName, String hostName) { String gangliaXml = null; ArrayList<Cluster> cluster_list = new ArrayList<Cluster>(); Host ret_host = null; try { ParseGanglia p = new ParseGanglia(gangliaCollectorIP, gangliaPort, gangliaPortQuery); gangliaXml = p.queryGanglia("/" + clusterName + "/" + hostName); cluster_list = (ArrayList<Cluster>) p.parseGangliaXml(gangliaXml); } catch (MonitoringException ex) { Logger.getLogger(Ganglia.class.getName()).log(Level.SEVERE, null, ex); } for (Cluster cluster : cluster_list) { if (cluster.getName().equals(clusterName)) { for (Host host : cluster.getHosts()) { if (host.getName().equals(hostName)) { ret_host = host; } } } } return ret_host; } }
Ganglia { public Host getHostInfo(String clusterName, String hostName) { String gangliaXml = null; ArrayList<Cluster> cluster_list = new ArrayList<Cluster>(); Host ret_host = null; try { ParseGanglia p = new ParseGanglia(gangliaCollectorIP, gangliaPort, gangliaPortQuery); gangliaXml = p.queryGanglia("/" + clusterName + "/" + hostName); cluster_list = (ArrayList<Cluster>) p.parseGangliaXml(gangliaXml); } catch (MonitoringException ex) { Logger.getLogger(Ganglia.class.getName()).log(Level.SEVERE, null, ex); } for (Cluster cluster : cluster_list) { if (cluster.getName().equals(clusterName)) { for (Host host : cluster.getHosts()) { if (host.getName().equals(hostName)) { ret_host = host; } } } } return ret_host; } Ganglia(); }
Ganglia { public Host getHostInfo(String clusterName, String hostName) { String gangliaXml = null; ArrayList<Cluster> cluster_list = new ArrayList<Cluster>(); Host ret_host = null; try { ParseGanglia p = new ParseGanglia(gangliaCollectorIP, gangliaPort, gangliaPortQuery); gangliaXml = p.queryGanglia("/" + clusterName + "/" + hostName); cluster_list = (ArrayList<Cluster>) p.parseGangliaXml(gangliaXml); } catch (MonitoringException ex) { Logger.getLogger(Ganglia.class.getName()).log(Level.SEVERE, null, ex); } for (Cluster cluster : cluster_list) { if (cluster.getName().equals(clusterName)) { for (Host host : cluster.getHosts()) { if (host.getName().equals(hostName)) { ret_host = host; } } } } return ret_host; } Ganglia(); ArrayList<Cluster> getGridInfo(); Cluster getClusterInfo(String clusterName); Host getHostInfo(String clusterName, String hostName); ClusterSummary getClusterSummaryInfo(String clusterName); void fetchData(String clusterName, String hostName, String metric, Integer startTime); }
Ganglia { public Host getHostInfo(String clusterName, String hostName) { String gangliaXml = null; ArrayList<Cluster> cluster_list = new ArrayList<Cluster>(); Host ret_host = null; try { ParseGanglia p = new ParseGanglia(gangliaCollectorIP, gangliaPort, gangliaPortQuery); gangliaXml = p.queryGanglia("/" + clusterName + "/" + hostName); cluster_list = (ArrayList<Cluster>) p.parseGangliaXml(gangliaXml); } catch (MonitoringException ex) { Logger.getLogger(Ganglia.class.getName()).log(Level.SEVERE, null, ex); } for (Cluster cluster : cluster_list) { if (cluster.getName().equals(clusterName)) { for (Host host : cluster.getHosts()) { if (host.getName().equals(hostName)) { ret_host = host; } } } } return ret_host; } Ganglia(); ArrayList<Cluster> getGridInfo(); Cluster getClusterInfo(String clusterName); Host getHostInfo(String clusterName, String hostName); ClusterSummary getClusterSummaryInfo(String clusterName); void fetchData(String clusterName, String hostName, String metric, Integer startTime);  }