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