-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
some refactoring
- Loading branch information
Showing
8 changed files
with
75 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,34 @@ | ||
package org.vafer.jmx; | ||
|
||
import com.beust.jcommander.JCommander; | ||
import com.beust.jcommander.Parameter; | ||
|
||
public final class Main { | ||
|
||
public static void main(String[] args) throws Exception { | ||
// @Parameter(names = "-url", description = "jmx url") | ||
// private String url = "service:jmx:rmi:///jndi/rmi://localhost:7199/jmxrmi"; | ||
// | ||
// @Parameter(names = "-query", description = "query") | ||
// private String query = ""; | ||
|
||
@Parameter(names = "-config", description = "path to config file", required = true) | ||
private String configPath = ""; | ||
|
||
private void run() throws Exception { | ||
Exporter exporter = new Exporter(); | ||
Exporter.Config config = exporter.load("/Users/tcurdt/Projects/jmx2any/config.yaml"); | ||
Exporter.Config config = exporter.load(configPath); | ||
exporter.output(config); | ||
} | ||
|
||
public static void main(String[] args) throws Exception { | ||
Main m = new Main(); | ||
JCommander cli = new JCommander(m); | ||
try { | ||
cli.parse(args); | ||
} catch(Exception e) { | ||
cli.usage(); | ||
System.exit(1); | ||
} | ||
m.run(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,43 @@ | ||
package org.vafer.jmx.output; | ||
|
||
import java.util.Locale; | ||
import java.util.Map; | ||
|
||
import static org.vafer.jmx.output.GangliaOutput.UDPAddressingMode; | ||
import static org.vafer.jmx.output.GangliaOutput.ProtocolVersion; | ||
|
||
public final class OutputFactory { | ||
|
||
public static Output createOutput(Map<String, ?> config) { | ||
// System.out.println("" + config); | ||
return new ConsoleOutput(); | ||
final String type = ((String) config.get("type")).toLowerCase(Locale.US); | ||
|
||
if ("ganglia".equals(type)) { | ||
|
||
String group = (String) config.get("address"); | ||
Integer port = (Integer) config.get("port"); | ||
UDPAddressingMode mode = UDPAddressingMode.valueOf((String)config.get("mode")); | ||
ProtocolVersion version = ProtocolVersion.valueOf((String)config.get("version")); | ||
return new GangliaOutput(group, port, mode, version); | ||
|
||
} else if ("graphite".equals(type)) { | ||
|
||
String host = (String) config.get("address"); | ||
Integer port = (Integer) config.get("port"); | ||
return new GraphiteOutput(host, port); | ||
|
||
} else if ("nagios".equals(type)) { | ||
|
||
return new NagiosOutput(); | ||
|
||
} else if ("file".equals(type)) { | ||
|
||
return new FileOutput(); | ||
|
||
} else { | ||
|
||
System.err.println("jmx2any: unknown output type [" + type + "]"); | ||
return new ConsoleOutput(); | ||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...a/org/vafer/jmx/output/CompositePipe.java → ...ava/org/vafer/jmx/pipe/CompositePipe.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package org.vafer.jmx.output; | ||
package org.vafer.jmx.pipe; | ||
|
||
import org.vafer.jmx.JmxQuery; | ||
|
||
|
4 changes: 3 additions & 1 deletion
4
...a/org/vafer/jmx/output/ConverterPipe.java → ...ava/org/vafer/jmx/pipe/ConverterPipe.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...in/java/org/vafer/jmx/output/JmxPipe.java → ...main/java/org/vafer/jmx/pipe/JmxPipe.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package org.vafer.jmx.output; | ||
package org.vafer.jmx.pipe; | ||
|
||
import org.vafer.jmx.JmxQuery; | ||
|
||
|