speedtest-cli


Objetivo

Instalar speedtest cli en pfsense y programar una tarea automática para que se ejecute.

Para esto vamos a instalar desde el Package Manager de pfsense el paquete Cron.

Speedtest cli no está disponible al momento para pfsense pero sí para FreeBSD y es este el que vamos a usar.


Si bien pfsense está basado en FreeBSD, los pasos son diferentes.

1 - Bajar speedtest-cli

https://www.speedtest.net/apps/cli


Ir a FreeBSD. Nos mostrará lo siguiente:


1 - $ sudo pkg update && sudo pkg install -g libidn2 ca_root_nss

2 - # Example how to remove conflicting or old versions using pkg

$ sudo pkg remove speedtest

3 - # freeBSD 12 install

$ sudo pkg add "https://install.speedtest.net/app/cli/ookla-speedtest-1.1.1-freebsd12-x86_64.pkg"

4 - # freeBSD 13 install

$ sudo pkg add "https://install.speedtest.net/app/cli/ookla-speedtest-1.1.1-freebsd13-x86_64.pkg"


1 - Este comando en FreeBSD actualiza la lista de paquetes e instala las dependencias.

2 - Remueve la versión anterior de speedtest, si está instalada.

3 - Instalación para FreeBSD 12

4 - Instalación para FreeBSD 13

2 - Verificar dependencias

Desde la consola de pfsense ejecutar:


# pkg info libidn2


libidn2-2.3.1

Name : libidn2

Version : 2.3.1

Installed on : Fri Jul 2 16:42:01 2021 -03

Origin : dns/libidn2

Architecture : FreeBSD:12:amd64

Prefix : /usr/local

Categories : dns

Licenses : GPLv3

Maintainer : sunpoet@FreeBSD.org

WWW : https://www.gnu.org/software/libidn/#libidn2

Comment : Implementation of IDNA2008 internationalized domain names

Shared Libs required:

libunistring.so.2

Shared Libs provided:

libidn2.so.0

Annotations :

FreeBSD_version: 1202504

repo_type : binary

repository : pfSense

Flat size : 561KiB

Description :

Libidn2 is an implementation of IDNA2008 internationalized domain names.


WWW: https://www.gnu.org/software/libidn/#libidn2

WWW: https://gitlab.com/libidn/libidn2


# pkg info ca_root_nss


ca_root_nss-3.63

Name : ca_root_nss

Version : 3.63

Installed on : Fri Jul 2 16:41:56 2021 -03

Origin : security/ca_root_nss

Architecture : FreeBSD:12:*

Prefix : /usr/local

Categories : security

Licenses : MPL20

Maintainer : ports-secteam@FreeBSD.org

WWW : UNKNOWN

Comment : Root certificate bundle from the Mozilla Project

Options :

ETCSYMLINK : on

Annotations :

repo_type : binary

repository : pfSense

Flat size : 759KiB

Description :

Root certificates from certificate authorities included in the Mozilla

NSS library and thus in Firefox and Thunderbird.


This port directly tracks the version of NSS in the security/nss port.


Como vemos, en pfsense las dependencias están instaladas.

3 - Verificar versión de FreeBSD

Debemos ver que versión de FreeBSD corre nuestro pfsense, ejecutando el siguiente comando:


# uname -sr


FreeBSD 12.2-STABLE

4 - Instalar speedtest cli

En la consola de pfsense ejecutar el siguiente comando (FreeBSD 12):


# pkg add "https://install.speedtest.net/app/cli/ookla-speedtest-1.1.1-freebsd12-x86_64.pkg"


Installing speedtest-1.1.1.28-1.c732eb82cf...

Extracting speedtest-1.1.1.28-1.c732eb82cf: 100%


Speedtest quedará instalado en: /usr/local/bin/speedtest

5 - Verificar

Para ver la ayuda ejecutar:


# /usr/local/bin/speedtest --help


Speedtest by Ookla is the official command line client for testing the speed and performance of your internet connection.


Version: speedtest 1.1.1.28


Usage: speedtest [<options>]

-h, --help Print usage information

-V, --version Print version number

-L, --servers List nearest servers

-s, --server-id=# Specify a server from the server list using its id

-I, --interface=ARG Attempt to bind to the specified interface when connecting to servers

-i, --ip=ARG Attempt to bind to the specified IP address when connecting to servers

-o, --host=ARG Specify a server, from the server list, using its host's fully qualified domain name

-p, --progress=yes|no Enable or disable progress bar (Note: only available for 'human-readable'

or 'json' and defaults to yes when interactive)

-P, --precision=# Number of decimals to use (0-8, default=2)

-f, --format=ARG Output format (see below for valid formats)

--progress-update-interval=# Progress update interval (100-1000 milliseconds)

-u, --unit[=ARG] Output unit for displaying speeds (Note: this is only applicable

for ‘human-readable’ output format and the default unit is Mbps)

-a Shortcut for [-u auto-decimal-bits]

-A Shortcut for [-u auto-decimal-bytes]

-b Shortcut for [-u auto-binary-bits]

-B Shortcut for [-u auto-binary-bytes]

--selection-details Show server selection details

--ca-certificate=ARG CA Certificate bundle path

-v Logging verbosity. Specify multiple times for higher verbosity

--output-header Show output header for CSV and TSV formats


Valid output formats: human-readable (default), csv, tsv, json, jsonl, json-pretty


Machine readable formats (csv, tsv, json, jsonl, json-pretty) use bytes as the unit of measure with max precision


Valid units for [-u] flag:

Decimal prefix, bits per second: bps, kbps, Mbps, Gbps

Decimal prefix, bytes per second: B/s, kB/s, MB/s, GB/s

Binary prefix, bits per second: kibps, Mibps, Gibps

Binary prefix, bytes per second: kiB/s, MiB/s, GiB/s

Auto-scaled prefix: auto-binary-bits, auto-binary-bytes, auto-decimal-bits, auto-decimal-bytes

6 - Crear archivo de log


# touch /var/log/speedtest.log

7 - Probar funcionamiento


# /usr/local/bin/speedtest -p no -f csv --output-header | tee -a /var/log/speedtest.log

8 - Programar tarea (Cron)

Ir a Services --> Cron y agregar una nueva tarea.

Ejemplo: Ejecutar el script de 06:00 a 18:00 cada 10 minutos, todos los días.


Minute: */10

Hour: 6-18

Day of the Month: *

Month of the Year: *

Day of the Week: *

User: root

Command: /usr/local/bin/speedtest -p no -f json | tee -a /var/log/speedtest.log

NOTA

Estos procedimientos se realizaron sobre la siguiente versión de pfsense:

Version 2.5.2-RELEASE (amd64)

built on Fri Jul 02 15:33:00 EDT 2021

FreeBSD 12.2-STABLE