Collection of python scripts to do multiple network tests like download/upload speeds and network latency (ping). It also calculates statistics like averages, medians, min and max values and store results in a CSV file.
The scripts have the following features:
- Run multiple tests in one go.
- Calculate average speeds for multiple tests.
- For bandwidth measurement in both Mbps and MB/s.
- Overall statistics with metrics like minimum, maximum and average speeds, and standard deviation.
- Save the results to a file with CSV format.
- Docker image that includes all the scripts and dependencies.
- Automated periodic test runs.
- Send csv results by email.
See the other README files for examples and usage instructions.
Script for doing ping tests to a list of sites on a file and optionally save results on a csv file.
Script for doing download speed tests and optionally save results on a csv file.
Script for doing upload speed tests and optionally save results on a csv file.
git clone https://github.com/juanluisbaptiste/network-tests.git
cd network-tests
sudo python setup.py install
See each script README file for detailed instructions.
There is a docker image available to run the scripts. The tests scripts to run can be driven by the following environment variables (refer to each test program for the usage description of each variable):
To enable each of the tests (these are also the defaults):
- DOWNLOAD_TEST_ENABLE=yes
- UPLOAD_TEST_ENABLE=no
- PING_TEST_ENABLE=no
Download test configuration:
- DOWNLOAD_TEST_COUNT=1
- DOWNLOAD_TEST_LOCATION=
- DOWNLOAD_TEST_OUTFILE=
- DOWNLOAD_TEST_SILENT=no
- DOWNLOAD_TEST_URL=
Upload test configuration:
- UPLOAD_TEST_COUNT=1
- UPLOAD_TEST_FILE=
- UPLOAD_TEST_OUTFILE=
- UPLOAD_TEST_SILENT=no
- UPLOAD_TEST_HOST=
- UPLOAD_TEST_USER=
- UPLOAD_TEST_PASSWORD=
- UPLOAD_TEST_PASSIVE=no
Ping test configuration:
- PING_TEST_COUNT=1
- PING_TEST_FILE=
- PING_TEST_OUTFILE=
- PING_TEST_INTERFACE=Default
- PING_TEST_SILENT=no
Global options:
- SILENT_TEST: Disable output in all tests being run.
There's an example env file you can use with the included docker-compose file.
Test execution can be automated:
-
CRON_EXPRESSION: If a cron expression is set then automated reports will be run at the specified time. This is the default. For example, the following setting will run the tests the first day of each month past midnight:
CRON_EXPRESSION="5 0 1 \* \*"
Allo those environment variables are passed to a script called /run_test.sh, which you can also call from outside the container if you want to do a manual run instead:
sudo docker-compose tests /run_test.sh
And the tests will be run as configured on the .env file.
It also includes throttle, so different network conditions can be emulated while testing. To launch it:
sudo modprobe ifb numifbs=1
sudo docker pull juanluisbaptiste/network-tests
sudo docker run -ti --cap-add NET_ADMIN --name network-tests juanluisbaptiste/network-tests bash
These environment variables controls bandwidth throttling:
- THROTTLE_ENABLE=no
- THROTTLE_PROFILE= (see throttle documentation for possible values)
- THROTTLE_DOWN_SPEED=
- THROTTLE_UP_SPEED=
- THROTTLE_RTT=1
If you are not using the docker image, before running the tests enable throttle with the desired network speed configuration:
throttle --profile 3g
See throttle's documentation for details on how to use it. when you finish testing you can disable it:
throttle --stop
If you want the csv file to be sent to you be email then configure these environment variables:
- SEND_RESULTS_EMAIL=yes
- SMTP_FROM=[email protected]
- SMTP_TO=[email protected]