This commit is contained in:
Diego Fernando Carrión 2024-10-21 22:56:04 +02:00
parent 994b9215f6
commit 2752be4a23
Signed by: CRThaze
GPG Key ID: 8279B79A1A7F8194

84
main.go
View File

@ -16,15 +16,15 @@ import (
) )
const ( const (
bandwidthScale = 125000.0 bandwidthScale = 125000.0
defaultListenPort = 9090 defaultListenPort = 9090
defaultListenAddr = "0.0.0.0" defaultListenAddr = "0.0.0.0"
defaultTestPeriod = 5 defaultTestPeriod = 5
defaultSpeedtestExec = "/usr/bin/speedtest" defaultSpeedtestExec = "/usr/bin/speedtest"
listenPortEnvVar = "SPEEDTEST_METRICS_LISTEN_PORT" listenPortEnvVar = "SPEEDTEST_METRICS_LISTEN_PORT"
listenAddrEnvVar = "SPEEDTEST_METRICS_LISTEN_ADDR" listenAddrEnvVar = "SPEEDTEST_METRICS_LISTEN_ADDR"
testPeriodEnvVar = "SPEEDTEST_PERIOD_MINS" testPeriodEnvVar = "SPEEDTEST_PERIOD_MINS"
speedtestExecEnvVar = "SPEEDTEST_EXEC" speedtestExecEnvVar = "SPEEDTEST_EXEC"
) )
var ( var (
@ -61,65 +61,65 @@ var (
}, },
labels, labels,
) )
listenPort uint16 listenPort uint16
listenAddr string listenAddr string
testPeriodMins uint testPeriodMins uint
speedtestExec string speedtestExec string
) )
type SpeedTestResult struct { type SpeedTestResult struct {
Type string Type string
Timestamp time.Time Timestamp time.Time
Ping struct { Ping struct {
Jitter float64 Jitter float64
Latency float64 Latency float64
Low float64 Low float64
High float64 High float64
} }
Download struct { Download struct {
Bandwidth int Bandwidth int
Bytes int Bytes int
Elapsed int Elapsed int
Latency struct { Latency struct {
IQM float64 IQM float64
Low float64 Low float64
High float64 High float64
Jitter float64 Jitter float64
} }
} }
Upload struct { Upload struct {
Bandwidth int Bandwidth int
Bytes int Bytes int
Elapsed int Elapsed int
Latency struct { Latency struct {
IQM float64 IQM float64
Low float64 Low float64
High float64 High float64
Jitter float64 Jitter float64
} }
} }
PacketLoss float64 PacketLoss float64
ISP string ISP string
Interface struct { Interface struct {
InternalIP string InternalIP string
Name string Name string
MACAddr string MACAddr string
IsVPN bool IsVPN bool
ExternalIP string ExternalIP string
} }
Server struct { Server struct {
ID int ID int
Host string Host string
Port int16 Port int16
Name string Name string
Location string Location string
Country string Country string
IP string IP string
} }
Result struct { Result struct {
ID string ID string
URL string URL string
Persisted bool Persisted bool
} }
} }