tuwiendsg / MELA

Monitoring and analyzing elasticity of cloud services
http://tuwiendsg.github.io/MELA/
2 stars 4 forks source link

Replace telnet command in GangliaDataSource with java.net.Socket implementation #10

Closed olmoser closed 10 years ago

olmoser commented 10 years ago

In class GangliaDataSource, the polling is realized via the system command telnet:

String cmd = "telnet " + hostname + " " + port;
String content = "";

try {
    Process p = Runtime.getRuntime().exec(cmd);
    BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream()));
    String line = null;

    while ((line = reader.readLine()) != null) {
        ...
    }
    ...

this approach might not be very portable as it is not guaranteed that there is a telnet command available. We should replace this with a java.net.Socket based implementation that opens a client socket towards the Ganglia port