Skip to content
This repository has been archived by the owner on Jan 3, 2023. It is now read-only.

Commit

Permalink
Release 0.2.0
Browse files Browse the repository at this point in the history
* develop:
  update binaries version
  Update copyright
  Refactoring using official zpeters speedtest repo
  Add ignore files
  Change port listening
  Bump version
  • Loading branch information
nlamirault committed Jan 17, 2017
2 parents fc1a18c + 2b2f463 commit b3a0c6a
Show file tree
Hide file tree
Showing 9 changed files with 93 additions and 22 deletions.
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Go
speedtest_exporter

# Files
.DS_Store

# Editor swap files
*.swp
*.swo
*.swn
6 changes: 6 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
ChangeLog
==============


# Version 0.2.0 (01/17/2017)

- `FIX` Initialize correctly client.
- Update dependency to zpeters Speedtest code

# Version 0.1.0 (10/05/2016)

- Prometheus exporter for Speedtest measures
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (C) 2016 Nicolas Lamirault <[email protected]>
# Copyright (C) 2016, 2017 Nicolas Lamirault <[email protected]>

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ This Prometheus exporter check your network connection. Metrics are :

You can download the binaries :

* Architecture i386 [ [linux](https://bintray.com/artifact/download/nlamirault/oss/speedtest_exporter-0.1.0_linux_386) / [darwin](https://bintray.com/artifact/download/nlamirault/oss/speedtest_exporter-0.1.0_darwin_386) / [freebsd](https://bintray.com/artifact/download/nlamirault/oss/speedtest_exporter-0.1.0_freebsd_386) / [netbsd](https://bintray.com/artifact/download/nlamirault/oss/speedtest_exporter-0.1.0_netbsd_386) / [openbsd](https://bintray.com/artifact/download/nlamirault/oss/speedtest_exporter-0.1.0_openbsd_386) / [windows](https://bintray.com/artifact/download/nlamirault/oss/speedtest_exporter-0.1.0_windows_386.exe) ]
* Architecture amd64 [ [linux](https://bintray.com/artifact/download/nlamirault/oss/speedtest_exporter-0.1.0_linux_amd64) / [darwin](https://bintray.com/artifact/download/nlamirault/oss/speedtest_exporter-0.1.0_darwin_amd64) / [freebsd](https://bintray.com/artifact/download/nlamirault/oss/speedtest_exporter-0.1.0_freebsd_amd64) / [netbsd](https://bintray.com/artifact/download/nlamirault/oss/speedtest_exporter-0.1.0_netbsd_amd64) / [openbsd](https://bintray.com/artifact/download/nlamirault/oss/speedtest_exporter-0.1.0_openbsd_amd64) / [windows](https://bintray.com/artifact/download/nlamirault/oss/speedtest_exporter-0.1.0_windows_amd64.exe) ]
* Architecture arm [ [linux](https://bintray.com/artifact/download/nlamirault/oss/speedtest_exporter-0.1.0_linux_arm) / [freebsd](https://bintray.com/artifact/download/nlamirault/oss/speedtest_exporter-0.1.0_freebsd_arm) / [netbsd](https://bintray.com/artifact/download/nlamirault/oss/speedtest_exporter-0.1.0_netbsd_arm) ]
* Architecture i386 [ [linux](https://bintray.com/artifact/download/nlamirault/oss/speedtest_exporter-0.2.0_linux_386) / [darwin](https://bintray.com/artifact/download/nlamirault/oss/speedtest_exporter-0.2.0_darwin_386) / [freebsd](https://bintray.com/artifact/download/nlamirault/oss/speedtest_exporter-0.2.0_freebsd_386) / [netbsd](https://bintray.com/artifact/download/nlamirault/oss/speedtest_exporter-0.2.0_netbsd_386) / [openbsd](https://bintray.com/artifact/download/nlamirault/oss/speedtest_exporter-0.2.0_openbsd_386) / [windows](https://bintray.com/artifact/download/nlamirault/oss/speedtest_exporter-0.2.0_windows_386.exe) ]
* Architecture amd64 [ [linux](https://bintray.com/artifact/download/nlamirault/oss/speedtest_exporter-0.2.0_linux_amd64) / [darwin](https://bintray.com/artifact/download/nlamirault/oss/speedtest_exporter-0.2.0_darwin_amd64) / [freebsd](https://bintray.com/artifact/download/nlamirault/oss/speedtest_exporter-0.2.0_freebsd_amd64) / [netbsd](https://bintray.com/artifact/download/nlamirault/oss/speedtest_exporter-0.2.0_netbsd_amd64) / [openbsd](https://bintray.com/artifact/download/nlamirault/oss/speedtest_exporter-0.2.0_openbsd_amd64) / [windows](https://bintray.com/artifact/download/nlamirault/oss/speedtest_exporter-0.2.0_windows_amd64.exe) ]
* Architecture arm [ [linux](https://bintray.com/artifact/download/nlamirault/oss/speedtest_exporter-0.2.0_linux_arm) / [freebsd](https://bintray.com/artifact/download/nlamirault/oss/speedtest_exporter-0.2.0_freebsd_arm) / [netbsd](https://bintray.com/artifact/download/nlamirault/oss/speedtest_exporter-0.2.0_netbsd_arm) ]


## Usage

Launch the Prometheus exporter :

$ speedtest_exporter -log.level=debug
$ speedtest_exporter -log.level=debug


## Development
Expand Down
41 changes: 30 additions & 11 deletions speedtest/client.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2016 Nicolas Lamirault <[email protected]>
// Copyright (C) 2016, 2017 Nicolas Lamirault <[email protected]>

// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -18,10 +18,15 @@ import (
"time"

"github.com/prometheus/common/log"
"github.com/zpeters/speedtest/print"
"github.com/zpeters/speedtest/sthttp"
"github.com/zpeters/speedtest/tests"
)

const (
userAgent = "speedtest_exporter"
)

// Client defines the Speedtest client
type Client struct {
Server sthttp.Server
Expand All @@ -34,8 +39,8 @@ type Client struct {
func NewClient(configURL string, serversURL string) (*Client, error) {
log.Debugf("New Speedtest client %s %s", configURL, serversURL)
configTimeout, _ := time.ParseDuration("15s")
latencyTimeout, _ := time.ParseDuration("15s")
downloadTimeout, _ := time.ParseDuration("15s")
// latencyTimeout, _ := time.ParseDuration("15s")
// downloadTimeout, _ := time.ParseDuration("15s")
stClient := sthttp.NewClient(
&sthttp.SpeedtestConfig{
ConfigURL: configURL,
Expand All @@ -44,27 +49,38 @@ func NewClient(configURL string, serversURL string) (*Client, error) {
NumClosest: 3,
NumLatencyTests: 5,
Interface: "",
Blacklist: "",
Blacklist: []string{},
UserAgent: userAgent,
},
&sthttp.HTTPConfig{
ConfigTimeout: configTimeout,
LatencyTimeout: latencyTimeout,
DownloadTimeout: downloadTimeout,
// ConfigTimeout: configTimeout,
// LatencyTimeout: latencyTimeout,
// DownloadTimeout: downloadTimeout,
HTTPTimeout: configTimeout,
},
true,
"|")

log.Debug("Retrieve configuration")
config, err := stClient.GetConfig()
if err != nil {
return nil, err
}
stClient.Config = &config

print.EnvironmentReport(stClient)

log.Debugf("Retrieve all servers")
var allServers []sthttp.Server
allServers, err := stClient.GetServers()
allServers, err = stClient.GetServers()
if err != nil {
return nil, err
}

log.Debugf("Retrieve closest servers")
closestServers := stClient.GetClosestServers(allServers)
log.Debugf("Find test server")
// log.Infof("Closest Servers: %s", closestServers)
testServer := stClient.GetFastestServer(closestServers)
log.Infof("Test server: %s", testServer)

return &Client{
Server: testServer,
Expand All @@ -78,11 +94,14 @@ func (client *Client) NetworkMetrics() map[string]float64 {
result := map[string]float64{}
tester := tests.NewTester(client.SpeedtestClient, tests.DefaultDLSizes, tests.DefaultULSizes, false, false)
downloadMbps := tester.Download(client.Server)
log.Infof("Speedtest Download: %v Mbps", downloadMbps)
uploadMbps := tester.Upload(client.Server)
log.Infof("Speedtest Upload: %v Mbps", uploadMbps)
ping := client.Server.Latency
log.Infof("Speedtest Latency: %v ms", ping)
result["download"] = downloadMbps
result["upload"] = uploadMbps
result["ping"] = ping
log.Debugf("Speedtest results: %s", result)
log.Infof("Speedtest results: %s", result)
return result
}
6 changes: 3 additions & 3 deletions speedtest_exporter.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2016 Nicolas Lamirault <[email protected]>
// Copyright (C) 2016, 2017 Nicolas Lamirault <[email protected]>

// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -61,7 +61,7 @@ type Exporter struct {

// NewExporter returns an initialized Exporter.
func NewExporter(config string, server string, interval time.Duration) (*Exporter, error) {
log.Infoln("Setup Speedtest client with interval %s", interval)
log.Infof("Setup Speedtest client with interval %s", interval)
client, err := speedtest.NewClient(config, server)
if err != nil {
return nil, fmt.Errorf("Can't create the Speedtest client: %s", err)
Expand Down Expand Up @@ -105,7 +105,7 @@ func init() {
func main() {
var (
showVersion = flag.Bool("version", false, "Print version information.")
listenAddress = flag.String("web.listen-address", ":9111", "Address to listen on for web interface and telemetry.")
listenAddress = flag.String("web.listen-address", ":9112", "Address to listen on for web interface and telemetry.")
metricsPath = flag.String("web.telemetry-path", "/metrics", "Path under which to expose metrics.")
configURL = flag.String("speedtest.config-url", "http://c.speedtest.net/speedtest-config.php?x="+uniuri.New(), "Speedtest configuration URL")
serverURL = flag.String("speedtest.server-url", "http://c.speedtest.net/speedtest-servers-static.php?x="+uniuri.New(), "Speedtest server URL")
Expand Down
2 changes: 1 addition & 1 deletion speedtest_exporter_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2016 Nicolas Lamirault <[email protected]>
// Copyright (C) 2016, 2017 Nicolas Lamirault <[email protected]>

// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
36 changes: 36 additions & 0 deletions vendor/vendor.json
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,12 @@
"revision": "382f87b929b84ce13e9c8a375a4b217f224e6c65",
"revisionTime": "2016-09-26T15:04:02Z"
},
{
"checksumSHA1": "Cy6n4iTn6RtXOULn1+vufS2MWpc=",
"path": "github.com/zpeters/speedtest/coords",
"revision": "58d62245401b2a60ebc0c4acaf1d5bb5b8571aa8",
"revisionTime": "2016-12-15T03:44:06Z"
},
{
"checksumSHA1": "CvvMRMDv3/NJpVjOiLb3Kr+qOtY=",
"path": "github.com/zpeters/speedtest/internal/coords",
Expand All @@ -242,6 +248,36 @@
"revision": "f77fc9e744a209979c966d1e1c33b464cb007861",
"revisionTime": "2016-09-01T00:53:20Z"
},
{
"checksumSHA1": "vdgf5XOtpWaQpTV5nPz7QjqE3gA=",
"path": "github.com/zpeters/speedtest/misc",
"revision": "58d62245401b2a60ebc0c4acaf1d5bb5b8571aa8",
"revisionTime": "2016-12-15T03:44:06Z"
},
{
"checksumSHA1": "BKKXhxf3hfAw/EnpRMOOQVtr6co=",
"path": "github.com/zpeters/speedtest/print",
"revision": "58d62245401b2a60ebc0c4acaf1d5bb5b8571aa8",
"revisionTime": "2016-12-15T03:44:06Z"
},
{
"checksumSHA1": "qI/41r8fHJiicgcAnDicQziXDN8=",
"path": "github.com/zpeters/speedtest/sthttp",
"revision": "58d62245401b2a60ebc0c4acaf1d5bb5b8571aa8",
"revisionTime": "2016-12-15T03:44:06Z"
},
{
"checksumSHA1": "EqWlhKYeHtJhxQMXfyvT6sQOf2g=",
"path": "github.com/zpeters/speedtest/stxml",
"revision": "58d62245401b2a60ebc0c4acaf1d5bb5b8571aa8",
"revisionTime": "2016-12-15T03:44:06Z"
},
{
"checksumSHA1": "W069qAawDjVk0mrUmQVnO6xVm0Q=",
"path": "github.com/zpeters/speedtest/tests",
"revision": "58d62245401b2a60ebc0c4acaf1d5bb5b8571aa8",
"revisionTime": "2016-12-15T03:44:06Z"
},
{
"checksumSHA1": "h+pFYiRHBogczS8/F1NoN3Ata44=",
"path": "golang.org/x/crypto/curve25519",
Expand Down
4 changes: 2 additions & 2 deletions version/version.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2016 Nicolas Lamirault <[email protected]>
// Copyright (C) 2016, 2017 Nicolas Lamirault <[email protected]>

// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -15,4 +15,4 @@
package version

// Version represents the application version using SemVer
const Version string = "0.1.0"
const Version string = "0.2.0"

0 comments on commit b3a0c6a

Please sign in to comment.