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

Commit

Permalink
Merge pull request #15 from nlamirault/refactoring-release
Browse files Browse the repository at this point in the history
Refactoring release
  • Loading branch information
nlamirault committed Aug 19, 2019
2 parents 9f8295d + 13c6eb9 commit f7b0e0d
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 30 deletions.
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.3.0 (08/19/2019)

- Use Golang modules for dependencies
- `FIX` Ping (#14)
- Update Makefile so make init works correctly (#13)
- Increase HTTP Timeout (#11)

# Version 0.2.0 (01/17/2017)

Expand Down
45 changes: 29 additions & 16 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,27 @@
# Copyright (C) 2016-2019 Nicolas Lamirault <nicolas.lamirault@gmail.com>

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

FROM golang:alpine as builder

ENV CGO_ENABLED=0
ENV GOOS=linux
ENV GOARCH=amd64
ENV GO111MODULE=on

RUN apk update && apk add --no-cache git ca-certificates tzdata && update-ca-certificates
RUN apk update \
&& apk add --no-cache git ca-certificates tzdata \
&& update-ca-certificates

RUN adduser -D -g '' appuser

Expand All @@ -14,23 +30,20 @@ WORKDIR ${GOPATH}/src/app

RUN go build -a -installsuffix cgo -ldflags="-w -s" -o /go/bin/speedtest_exporter

FROM scratch
ARG VCS_REF
ARG BUILD_DATE
# --------------------------------------------------------------------------------

LABEL org.label-schema.build-date=$BUILD_DATE \
org.label-schema.vcs-ref=$VCS_REF \
org.label-schema.vcs-url="https://github.com/nlamirault/speedtest_exporter" \
org.label-schema.docker.cmd="docker run tnwhitwell/speedtest_exporter" \
org.label-schema.schema-version="1.0" \
maintainer="tom@whi.tw"
FROM gcr.io/distroless/base

COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=builder /etc/passwd /etc/passwd
LABEL summary="Speedtest Prometheus exporter" \
description="A Prometheus exporter for speedtest" \
name="nlamirault/speedtest_exporter" \
url="https://github.com/nlamirault/speedtest_exporter" \
maintainer="Nicolas Lamirault <nicolas.lamirault@gmail.com>"

COPY --from=builder /go/bin/speedtest_exporter /go/bin/speedtest_exporter
COPY --from=builder /go/bin/speedtest_exporter /usr/bin/speedtest_exporter

COPY --from=builder /etc/passwd /etc/passwd

USER appuser
EXPOSE 9112

ENTRYPOINT [ "/go/bin/speedtest_exporter" ]
ENTRYPOINT [ "/usr/bin/speedtest_exporter" ]
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ DOCKER = docker
GO = go
GLIDE = glide

GOX = gox -os="linux darwin windows freebsd openbsd netbsd"
# GOX_OS = -os="linux darwin windows freebsd openbsd netbsd"
# GOX_ARGS = "-output={{.Dir}}-$(VERSION)_{{.OS}}_{{.Arch}}"

GOX_OS = -osarch="linux/amd64 linux/arm linux/arm64 darwin/amd64 freebsd/amd64 openbsd/amd64 netbsd/amd64 windows/amd64"
GOX_ARGS = "-output={{.Dir}}-$(VERSION)_{{.OS}}_{{.Arch}}"

BINTRAY_URI = https://api.bintray.com
Expand Down Expand Up @@ -112,7 +115,7 @@ coverage: ## Launch code coverage

gox: ## Make all binaries
@echo -e "$(OK_COLOR)[$(APP)] Create binaries $(NO_COLOR)"
$(GOX) $(GOX_ARGS) github.com/nlamirault/speedtest_exporter
@gox $(GOX_OS) $(GOX_ARGS) github.com/nlamirault/speedtest_exporter

.PHONY: binaries
binaries: ## Upload all binaries
Expand Down
33 changes: 22 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* Develop : [![Circle CI](https://circleci.com/gh/nlamirault/speedtest_exporter/tree/develop.svg?style=svg)](https://circleci.com/gh/nlamirault/speedtest_exporter/tree/develop)

This Prometheus exporter check your network connection. Metrics are :

* Latency
* Download bandwidth
* Upload bandwidth
Expand All @@ -16,42 +17,52 @@ 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.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) ]
* Architecture amd64 [ [linux](https://bintray.com/artifact/download/nlamirault/oss/speedtest_exporter-0.3.0_linux_amd64) / [darwin](https://bintray.com/artifact/download/nlamirault/oss/speedtest_exporter-0.3.0_darwin_amd64) / [freebsd](https://bintray.com/artifact/download/nlamirault/oss/speedtest_exporter-0.3.0_freebsd_amd64) / [netbsd](https://bintray.com/artifact/download/nlamirault/oss/speedtest_exporter-0.3.0_netbsd_amd64) / [openbsd](https://bintray.com/artifact/download/nlamirault/oss/speedtest_exporter-0.3.0_openbsd_amd64) / [windows](https://bintray.com/artifact/download/nlamirault/oss/speedtest_exporter-0.3.0_windows_amd64.exe) ]
* Architecture arm [ [linux](https://bintray.com/artifact/download/nlamirault/oss/speedtest_exporter-0.3.0_linux_arm) ]
* Architecture arm64 [ [linux](https://bintray.com/artifact/download/nlamirault/oss/speedtest_exporter-0.3.0_linux_arm64) ]


## Usage

Launch the Prometheus exporter :

$ speedtest_exporter -log.level=debug

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

## Development

* Initialize environment

$ make init
```bash
$ make init
```

* Build tool :

$ make build
```bash
$ make build
```

* Launch unit tests :

$ make test

```bash
$ make test
```

## Local Deployment

* Launch Prometheus using the configuration file in this repository:

$ prometheus -config.file=prometheus.yml
```bash
$ prometheus -config.file=prometheus.yml
```

* Launch exporter:

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

* Check that Prometheus find the exporter on `http://localhost:9090/targets`

Expand Down
2 changes: 1 addition & 1 deletion version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
package version

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

0 comments on commit f7b0e0d

Please sign in to comment.