public static void main(String ... args) throws IOException, MalformedObjectNameException { String host = "localhost"; if (args.length > 0) host = args[0]; int port = 7199; if (args.length > 1) port = Integer.parseInt(args[1]); boolean munin = false; if (args.length > 2 && args[2].equals("munin")) munin = true; boolean muninConfig = false; if (args.length > 3 && args[3].equals("config")) muninConfig = true; JMXServiceURL jmxUrl = new JMXServiceURL(String.format(fmtUrl, host, port)); Map<String,Object> env = new HashMap<String,Object>(); DynamicEndpointSnitchMBean dsnitch = getDSnitchMbean(jmxUrl, env); Map<InetAddress, Double> sorted = sortMap(dsnitch.getScores()); if (munin) { if (muninConfig) printMuninConfig(sorted); else printForMunin(sorted); } else { for(Map.Entry<InetAddress, Double> score : sorted.entrySet()) { System.out.println(score.getKey().getHostName() + " : "+score.getValue()); } } } private static String getMuninHost(String hostname) {
@Override public void execute(NodeProbe probe) { // display cluster name, snitch and partitioner System.out.println("Cluster Information:"); System.out.println("\tName: " + probe.getClusterName()); String snitch = probe.getEndpointSnitchInfoProxy().getSnitchName(); boolean dynamicSnitchEnabled = false; if (snitch.equals(DynamicEndpointSnitch.class.getName())) { snitch = probe.getDynamicEndpointSnitchInfoProxy().getSubsnitchClassName(); dynamicSnitchEnabled = true; } System.out.println("\tSnitch: " + snitch); System.out.println("\tDynamicEndPointSnitch: " + (dynamicSnitchEnabled ? "enabled" : "disabled")); System.out.println("\tPartitioner: " + probe.getPartitioner()); // display schema version for each node System.out.println("\tSchema versions:"); Map<String, List<String>> schemaVersions = probe.getSpProxy().getSchemaVersions(); for (String version : schemaVersions.keySet()) { System.out.println(format("\t\t%s: %s%n", version, schemaVersions.get(version))); } } }
@Override public void execute(NodeProbe probe) { // display cluster name, snitch and partitioner System.out.println("Cluster Information:"); System.out.println("\tName: " + probe.getClusterName()); String snitch = probe.getEndpointSnitchInfoProxy().getSnitchName(); boolean dynamicSnitchEnabled = false; if (snitch.equals(DynamicEndpointSnitch.class.getName())) { snitch = probe.getDynamicEndpointSnitchInfoProxy().getSubsnitchClassName(); dynamicSnitchEnabled = true; } System.out.println("\tSnitch: " + snitch); System.out.println("\tDynamicEndPointSnitch: " + (dynamicSnitchEnabled ? "enabled" : "disabled")); System.out.println("\tPartitioner: " + probe.getPartitioner()); // display schema version for each node System.out.println("\tSchema versions:"); Map<String, List<String>> schemaVersions = probe.getSpProxy().getSchemaVersions(); for (String version : schemaVersions.keySet()) { System.out.println(format("\t\t%s: %s%n", version, schemaVersions.get(version))); } } }
@Override public void execute(NodeProbe probe) { // display cluster name, snitch and partitioner System.out.println("Cluster Information:"); System.out.println("\tName: " + probe.getClusterName()); String snitch = probe.getEndpointSnitchInfoProxy().getSnitchName(); boolean dynamicSnitchEnabled = false; if (snitch.equals(DynamicEndpointSnitch.class.getName())) { snitch = probe.getDynamicEndpointSnitchInfoProxy().getSubsnitchClassName(); dynamicSnitchEnabled = true; } System.out.println("\tSnitch: " + snitch); System.out.println("\tDynamicEndPointSnitch: " + (dynamicSnitchEnabled ? "enabled" : "disabled")); System.out.println("\tPartitioner: " + probe.getPartitioner()); // display schema version for each node System.out.println("\tSchema versions:"); Map<String, List<String>> schemaVersions = probe.getSpProxy().getSchemaVersions(); for (String version : schemaVersions.keySet()) { System.out.println(format("\t\t%s: %s%n", version, schemaVersions.get(version))); } } }