Skip to content

Commit

Permalink
Merge branch 'master' of github.com:ndt-project/ndt
Browse files Browse the repository at this point in the history
Conflicts:
	src/network.c
  • Loading branch information
pboothe committed Jun 23, 2015
2 parents a22df7c + 645364c commit af7475b
Show file tree
Hide file tree
Showing 10 changed files with 154 additions and 263 deletions.
98 changes: 55 additions & 43 deletions HTML5-frontend/script.js
Expand Up @@ -23,6 +23,8 @@ var PHASE_RESULTS = 5;

// STATUS VARIABLES

var use_websocket_client = false;

var websocket_client = null;

var currentPhase = PHASE_LOADING;
Expand All @@ -32,8 +34,7 @@ var transitionSpeed = 400;
// Gauges used for showing download/upload speed
var downloadGauge, uploadGauge;
var gaugeUpdateInterval;
var gaugeMaxValue = 100; // Mb/s

var gaugeMaxValue = 1000;

// PRIMARY METHODS

Expand All @@ -58,6 +59,7 @@ function initializeTest() {
function startTest(evt) {
evt.stopPropagation();
evt.preventDefault();
createBackend();
if (!isPluginLoaded()) {
$('#warning-plugin').show();
return;
Expand Down Expand Up @@ -322,10 +324,19 @@ function resetGauges() {
}

function updateGaugeValue() {
var downloadSpeedVal = downloadSpeed();
var uploadSpeedVal = uploadSpeed(false);

if (currentPhase == PHASE_UPLOAD) {
uploadGauge.setValue(uploadSpeed(true));
uploadGauge.updateConfig({
units: getSpeedUnit(uploadSpeedVal)
});
uploadGauge.setValue(getJustfiedSpeed(uploadSpeedVal));
} else if (currentPhase == PHASE_DOWNLOAD) {
downloadGauge.setValue(downloadSpeed());
downloadGauge.updateConfig({
units: getSpeedUnit(downloadSpeedVal)
});
downloadGauge.setValue(getJustfiedSpeed(downloadSpeedVal));
} else {
clearInterval(gaugeUpdateInterval);
}
Expand All @@ -338,7 +349,7 @@ function testNDT() {
return websocket_client;
}

return ndt = document.getElementById('NDT');
return document.getElementById('NDT');
}

function testStatus() {
Expand Down Expand Up @@ -445,28 +456,27 @@ function printJitter(boldValue) {
return retStr;
}

function getSpeedUnit(speedInKB) {
var unit = ['kb/s', 'Mb/s', 'Gb/s', 'Tb/s', 'Pb/s', 'Eb/s'];
var e = Math.floor(Math.log(speedInKB*1000) / Math.log(1000));
return unit[e];
}

function getJustfiedSpeed(speedInKB) {
var e = Math.floor(Math.log(speedInKB) / Math.log(1000));
return (speedInKB / Math.pow(1000, e)).toFixed(2);
}

function printDownloadSpeed() {
var downloadSpeedVal = downloadSpeed();
if (downloadSpeedVal >= 1000) {
downloadSpeedVal = parseFloat(downloadSpeedVal/1000);
document.getElementById('download-speed').innerHTML = downloadSpeedVal.toFixed(2);
document.getElementById('download-speed-units').innerHTML = 'gb/s';
} else {
document.getElementById('download-speed').innerHTML = downloadSpeedVal.toFixed(2);
document.getElementById('download-speed-units').innerHTML = 'mb/s';
}
document.getElementById('download-speed').innerHTML = getJustfiedSpeed(downloadSpeedVal);
document.getElementById('download-speed-units').innerHTML = getSpeedUnit(downloadSpeedVal);
}

function printUploadSpeed() {
var uploadSpeedVal = uploadSpeed(false);
if (uploadSpeedVal >= 1000) {
uploadSpeedVal = parseFloat(uploadSpeedVal/1000);
document.getElementById('upload-speed').innerHTML = uploadSpeedVal.toFixed(2);
document.getElementById('upload-speed-units').innerHTML = 'gb/s';
} else {
document.getElementById('upload-speed').innerHTML = uploadSpeedVal.toFixed(2);
document.getElementById('upload-speed-units').innerHTML = 'mb/s';
}
document.getElementById('upload-speed').innerHTML = getJustfiedSpeed(uploadSpeedVal);
document.getElementById('upload-speed-units').innerHTML = getSpeedUnit(uploadSpeedVal);
}

function readNDTvar(variable) {
Expand Down Expand Up @@ -549,25 +559,14 @@ function testDetails() {

// BACKEND METHODS
function useJavaAsBackend() {
websocket_client = null;

$('#warning-websocket').hide();
$("#rtt").show();
$("#rttValue").show();
var backendContainer = document.getElementById('backendContainer');
while (backendContainer.firstChild) {
backendContainer.removeChild(backendContainer.firstChild);
}
document.getElementById('warning-environment').innerHTML = "";

var app = document.createElement('applet');
app.id = 'NDT';
app.name = 'NDT';
app.archive = 'Tcpbw100.jar';
app.code = 'edu.internet2.ndt.Tcpbw100.class';
app.width = '600';
app.height = '10';
document.getElementById('backendContainer').appendChild(app);

$('.warning-environment').innerHTML = "";

use_websocket_client = false;

$('#websocketButton').removeClass("active");
$('#javaButton').addClass("active");
}
Expand All @@ -577,17 +576,30 @@ function useWebsocketAsBackend() {
$("#rttValue").hide();
$('#warning-websocket').show();

var backendContainer = document.getElementById('backendContainer');
while (backendContainer.firstChild) {
backendContainer.removeChild(backendContainer.firstChild);
}

websocket_client = new NDTWrapper();
use_websocket_client = true;

$('#javaButton').removeClass("active");
$('#websocketButton').addClass("active");
}

function createBackend() {
$('#backendContainer').empty();

if (use_websocket_client) {
websocket_client = new NDTWrapper();
}
else {
var app = document.createElement('applet');
app.id = 'NDT';
app.name = 'NDT';
app.archive = 'Tcpbw100.jar';
app.code = 'edu.internet2.ndt.Tcpbw100.class';
app.width = '600';
app.height = '10';
$('#backendContainer').append(app);
}
}

// UTILITIES

function debug(message) {
Expand Down
22 changes: 17 additions & 5 deletions conf/ndt-init
Expand Up @@ -60,7 +60,7 @@ then
touch /var/log/ndt/fakewww_error.log
chown nobody:nobody /var/log/ndt/fakewww*log

sudo -u nobody $path/fakewww $FAKEWWW_OPTIONS 2>/dev/null &
runuser --session-command="$path/fakewww $FAKEWWW_OPTIONS" -s /bin/sh nobody &
RETVAL=$?
if [ $RETVAL = 0 ]
then
Expand Down Expand Up @@ -133,8 +133,20 @@ restart() {
}

condrestart() {
rhstatus
if [ $? == 0 ]; then
RUNNING=0
status web100srv
if [ $? -eq 0 ]; then
RUNNING=1
fi
if [ ! $USE_FAKEWWW = 0 ]
then
status fakewww
if [ $? -eq 0 ]; then
RUNNING=1
fi
fi

if [ $RUNNING -eq 1 ]; then
restart
fi
}
Expand All @@ -149,14 +161,14 @@ stop)
status)
rhstatus
;;
cond-restart)
condrestart)
condrestart
;;
restart|reload)
restart
;;
*)
echo $"Usage: $0 {start|stop|status|restart}"
echo $"Usage: $0 {start|stop|status|restart|condrestart}"
exit 1
esac

Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Expand Up @@ -29,7 +29,7 @@
# Process this file with autoconf to produce a configure script.
#
# AC_PREREQ(2.57)
AC_INIT([NDT],[3.7.0],[ndt-user@internet2.edu])
AC_INIT([NDT],[3.7.0.1],[ndt-user@internet2.edu])
AC_CONFIG_AUX_DIR(config)
# AM_INIT_AUTOMAKE(NDT, v1.0, [no-define])
AM_INIT_AUTOMAKE
Expand Down
21 changes: 17 additions & 4 deletions ndt.spec
@@ -1,6 +1,6 @@
Name: ndt
Version: 3.7.0
Release: 8%{?dist}
Version: 3.7.0.1
Release: 2%{?dist}
Summary: Network Diagnostic Tool

Group: Applications/Networking
Expand Down Expand Up @@ -92,7 +92,7 @@ if [ "$1" = "1" ]; then
# If this is a first time install, add the users and enable it by default
/sbin/chkconfig --add ndt
else
/sbin/service ndt cond-restart
/sbin/service ndt condrestart
fi

%preun server
Expand All @@ -103,9 +103,22 @@ fi

%post server-apache
%{_prefix}/%{name}/manage_fakewww_usage disable
# Need to restart NDT first so that it lets go of 7123
service ndt condrestart
service httpd condrestart

%preun server-apache
%{_prefix}/%{name}/manage_fakewww_usage enable
if [ $1 -eq 0 ]; then
# This will retry to start NDT, but since apache still has the port,
# it'll fail. The %postun condrestart will get NDT going again.
%{_prefix}/%{name}/manage_fakewww_usage enable || :
fi

%postun server-apache
# Need to restart HTTPD first so that it lets go of 7123. This gets done in the
# '%postun' so that the apache ndt.conf is gone.
service httpd condrestart
service ndt condrestart

%files

Expand Down
15 changes: 7 additions & 8 deletions src/Makefile.am
Expand Up @@ -47,6 +47,7 @@ endif
endif
endif


if HAVE_SSL
if HAVE_JANSSON
bin_PROGRAMS += web100clt
Expand Down Expand Up @@ -78,7 +79,7 @@ endif

noinst_PROGRAMS += $(TESTS)

web100clt_SOURCES = web100clt.c network.c network_clt.c usage.c logging.c utils.c protocol.c runningtest.c ndtptestconstants.c \
web100clt_SOURCES = web100clt.c network.c usage.c logging.c utils.c protocol.c runningtest.c ndtptestconstants.c \
test_sfw_clt.c test_mid_clt.c test_c2s_clt.c test_s2c_clt.c test_meta_clt.c strlutils.c \
test_results_clt.c jsonutils.c websocket.c
web100clt_LDADD = $(I2UTILLIBDEPS) -lpthread $(ZLIB) $(JSONLIB) $(OPENSSL_LDFLAGS) $(OPENSSL_LIBS)
Expand All @@ -98,7 +99,7 @@ analyze_LDADD = $(NDTLIBS) $(I2UTILLIBDEPS) $(ZLIB)
analyze_CPPFLAGS ='-DBASEDIR="$(ndtdir)"' -DFORCE_WEB100

if BUILD_FAKEWWW
fakewww_SOURCES = fakewww.c troute.c troute6.c tr-tree.c tr-tree6.c network.c network_clt.c usage.c logging.c \
fakewww_SOURCES = fakewww.c troute.c troute6.c tr-tree.c tr-tree6.c network.c usage.c logging.c \
runningtest.c ndtptestconstants.c strlutils.c jsonutils.c websocket.c
fakewww_LDADD = $(I2UTILLIBDEPS) $(ZLIB) $(JSONLIB) $(OPENSSL_LDFLAGS) $(OPENSSL_LIBS)
fakewww_CPPFLAGS ='-DBASEDIR="$(ndtdir)"' $(OPENSSL_INCLUDES)
Expand Down Expand Up @@ -189,9 +190,7 @@ install: install-am install-ln
$(I2UTILLIBDEPS):
$(I2UTILLIBMAKE)

EXTRA_DIST = clt_tests.h connection.h heuristics.h jsonutils.h logging.h \
mrange.h ndt_odbc.h ndtptestconstants.h network.h network_clt.h \
node_tests/ndt_client.js protocol.h runningtest.h strlutils.h test_meta.h \
test_results_clt.h test_sfw.h testoptions.h tests_srv.h third_party/safe_iop.h \
tr-tree.h troute.h unit_testing.h usage.h utils.h varinfo.h web100-admin.h \
web100srv.h websocket.h
EXTRA_DIST = clt_tests.h logging.h mrange.h network.h protocol.h testoptions.h test_sfw.h test_meta.h \
troute.h tr-tree.h usage.h utils.h varinfo.h web100-admin.h web100srv.h ndt_odbc.h runningtest.h ndtptestconstants.h \
heuristics.h strlutils.h test_results_clt.h tests_srv.h jsonutils.h unit_testing.h websocket.h third_party/safe_iop.h

11 changes: 0 additions & 11 deletions src/connection.h

This file was deleted.

0 comments on commit af7475b

Please sign in to comment.