@@ -6,28 +6,34 @@ import (
6
6
"io/ioutil"
7
7
"os"
8
8
9
+ "github.com/prometheus/common/version"
10
+
9
11
"fmt"
10
12
"net/http"
11
13
12
14
"github.com/nshttpd/mikrotik-exporter/collector"
13
15
"github.com/nshttpd/mikrotik-exporter/config"
14
16
"github.com/prometheus/client_golang/prometheus"
15
17
"github.com/prometheus/client_golang/prometheus/promhttp"
16
- "github.com/prometheus/common/version"
17
18
log "github.com/sirupsen/logrus"
18
19
)
19
20
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.
21
22
var (
22
- device = flag .String ("device" , "" , "single device to monitor" )
23
23
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) " )
27
27
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 " )
29
29
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
+
31
37
withBgp = flag .Bool ("with-bgp" , false , "retrieves BGP routing infrormation" )
32
38
withRoutes = flag .Bool ("with-routes" , false , "retrieves routing table information" )
33
39
withDHCP = flag .Bool ("with-dhcp" , false , "retrieves DHCP server metrics" )
@@ -37,10 +43,11 @@ var (
37
43
withWlanSTA = flag .Bool ("with-wlansta" , false , "retrieves connected wlan station metrics" )
38
44
withWlanIF = flag .Bool ("with-wlanif" , false , "retrieves wlan interface metrics" )
39
45
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"
44
51
)
45
52
46
53
func init () {
@@ -50,6 +57,11 @@ func init() {
50
57
func main () {
51
58
flag .Parse ()
52
59
60
+ if * ver {
61
+ fmt .Printf ("\n Version: %s\n Short SHA: %s\n \n " , appVersion , shortSha )
62
+ os .Exit (0 )
63
+ }
64
+
53
65
configureLog ()
54
66
55
67
c , err := loadConfig ()
0 commit comments