Skip to content

Commit 9bb5a0c

Browse files
authored
various issues fixing (#49)
* arm64 Dockerfile and Makefile update * #46 version flag
1 parent f1f09b4 commit 9bb5a0c

File tree

4 files changed

+40
-14
lines changed

4 files changed

+40
-14
lines changed

Dockerfile.arm64

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
FROM arm64v8/busybox:1.31.0
2+
3+
EXPOSE 9090
4+
5+
COPY scripts/start.sh /app/
6+
COPY dist/mikrotik-exporter_linux_arm64 /app/mikrotik-exporter
7+
8+
ENTRYPOINT ["/app/start.sh"]

Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
VERSION=`cat VERSION`
44
SHORTSHA=`git rev-parse --short HEAD`
55

6-
LDFLAGS=-X github.com/nshttpd/mikrotik-exporter/cmd.version=$(VERSION)
7-
LDFLAGS+=-X github.com/nshttpd/mikrotik-exporter/cmd.shortSha=$(SHORTSHA)
6+
LDFLAGS=-X main.appVersion=$(VERSION)
7+
LDFLAGS+=-X main.shortSha=$(SHORTSHA)
88

99
build:
1010
go build -ldflags "$(LDFLAGS)" .
@@ -21,3 +21,5 @@ dockerhub: deploy
2121
@docker login -u $(DOCKER_USER) -p $(DOCKER_PASS)
2222
docker build -t $(CIRCLE_PROJECT_USERNAME)/$(CIRCLE_PROJECT_REPONAME):$(VERSION) .
2323
docker push $(CIRCLE_PROJECT_USERNAME)/$(CIRCLE_PROJECT_REPONAME):$(VERSION)
24+
docker build -f Dockerfile.arm64 -t $(CIRCLE_PROJECT_USERNAME)/$(CIRCLE_PROJECT_REPONAME)-linux-arm64:$(VERSION) .
25+
docker push $(CIRCLE_PROJECT_USERNAME)/$(CIRCLE_PROJECT_REPONAME)-linux-arm64:$(VERSION)

main.go

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,34 @@ import (
66
"io/ioutil"
77
"os"
88

9+
"github.com/prometheus/common/version"
10+
911
"fmt"
1012
"net/http"
1113

1214
"github.com/nshttpd/mikrotik-exporter/collector"
1315
"github.com/nshttpd/mikrotik-exporter/config"
1416
"github.com/prometheus/client_golang/prometheus"
1517
"github.com/prometheus/client_golang/prometheus/promhttp"
16-
"github.com/prometheus/common/version"
1718
log "github.com/sirupsen/logrus"
1819
)
1920

20-
// single device can be defined via CLI flags, mutliple via config file.
21+
// single device can be defined via CLI flags, multiple via config file.
2122
var (
22-
device = flag.String("device", "", "single device to monitor")
2323
address = flag.String("address", "", "address of the device to monitor")
24-
user = flag.String("user", "", "user for authentication with single device")
25-
password = flag.String("password", "", "password for authentication for single device")
26-
logLevel = flag.String("log-level", "info", "log level")
24+
configFile = flag.String("config-file", "", "config file to load")
25+
device = flag.String("device", "", "single device to monitor")
26+
insecure = flag.Bool("insecure", false, "skips verification of server certificate when using TLS (not recommended)")
2727
logFormat = flag.String("log-format", "json", "logformat text or json (default json)")
28-
port = flag.String("port", ":9436", "port number to listen on")
28+
logLevel = flag.String("log-level", "info", "log level")
2929
metricsPath = flag.String("path", "/metrics", "path to answer requests on")
30-
configFile = flag.String("config-file", "", "config file to load")
30+
password = flag.String("password", "", "password for authentication for single device")
31+
port = flag.String("port", ":9436", "port number to listen on")
32+
timeout = flag.Duration("timeout", collector.DefaultTimeout, "timeout when connecting to devices")
33+
tls = flag.Bool("tls", false, "use tls to connect to routers")
34+
user = flag.String("user", "", "user for authentication with single device")
35+
ver = flag.Bool("version", false, "find the version of binary")
36+
3137
withBgp = flag.Bool("with-bgp", false, "retrieves BGP routing infrormation")
3238
withRoutes = flag.Bool("with-routes", false, "retrieves routing table information")
3339
withDHCP = flag.Bool("with-dhcp", false, "retrieves DHCP server metrics")
@@ -37,10 +43,11 @@ var (
3743
withWlanSTA = flag.Bool("with-wlansta", false, "retrieves connected wlan station metrics")
3844
withWlanIF = flag.Bool("with-wlanif", false, "retrieves wlan interface metrics")
3945
withMonitor = flag.Bool("with-monitor", false, "retrieves ethernet interface monitor info")
40-
timeout = flag.Duration("timeout", collector.DefaultTimeout, "timeout when connecting to devices")
41-
tls = flag.Bool("tls", false, "use tls to connect to routers")
42-
insecure = flag.Bool("insecure", false, "skips verification of server certificate when using TLS (not recommended)")
43-
cfg *config.Config
46+
47+
cfg *config.Config
48+
49+
appVersion = "DEVELOPMENT"
50+
shortSha = "0xDEADBEEF"
4451
)
4552

4653
func init() {
@@ -50,6 +57,11 @@ func init() {
5057
func main() {
5158
flag.Parse()
5259

60+
if *ver {
61+
fmt.Printf("\nVersion: %s\nShort SHA: %s\n\n", appVersion, shortSha)
62+
os.Exit(0)
63+
}
64+
5365
configureLog()
5466

5567
c, err := loadConfig()

scripts/start.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
#!/bin/sh
22

3+
if [ ! -x /app/mikrotik-exporter ]; then
4+
chmod 755 /app/mikrotik-expoter
5+
fi
6+
37
if [ -z "$CONFIG_FILE" ]
48
then
59
/app/mikrotik-exporter -device $DEVICE -address $ADDRESS -user $USER -password $PASSWORD

0 commit comments

Comments
 (0)