blob: 574d12cb0ca107cd5bb8de128dd17e82ab67d0ae [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2015 Christian Pontesegger and others. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*
* Contributors: Christian Pontesegger - initial API and implementation
******************************************************************************/
loadModule('/Charting');
loadModule('/System/Platform');
var servers = ["localhost", "www.eclipse.org", "www.google.com", "www.adelaidecitycouncil.com"];
figure("Ping Statistics");
clear();
setXLabel("Ping attempt")
setYLabel("Time [ms]")
for (var count = 1; count < 20; count++) {
for each (address in servers) {
series(address);
// run 'ping' command
// process = runProcess("ping", [ "-c 1", address ]); // linux command style
process = runProcess("ping", [ "-n", "1", address ]); // windows command style
while (!process.isFinished())
;
// parse output
output = process.getOutput();
start = output.indexOf("time=");
if (start != -1) {
end = output.indexOf("ms", start);
if (end != -1) {
time = parseFloat(output.substring(start + 5, end).trim());
plotPoint(count, time);
}
}
}
}