File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change 5
5
"flag"
6
6
"fmt"
7
7
"log"
8
+ "net"
8
9
"net/http"
9
10
"os"
10
11
"os/signal"
@@ -21,6 +22,25 @@ var appConfig *config.Config
21
22
22
23
var Version = "develop" // This will be set during compile time using go build ldflags
23
24
25
+ // getLocalIP retrieves the local IP address of the machine.
26
+ // It returns the first non-loopback IPv4 address found.
27
+ // If no valid address is found, it returns "<ip-address>" as a placeholder.
28
+ // This function is used to display the local IP address in the log message.
29
+ func getLocalIP () string {
30
+ addrs , err := net .InterfaceAddrs ()
31
+ if err != nil {
32
+ return "<ip-address>"
33
+ }
34
+ for _ , addr := range addrs {
35
+ if ipnet , ok := addr .(* net.IPNet ); ok && ! ipnet .IP .IsLoopback () {
36
+ if ipnet .IP .To4 () != nil {
37
+ return ipnet .IP .String ()
38
+ }
39
+ }
40
+ }
41
+ return "<ip-address>"
42
+ }
43
+
24
44
func main () {
25
45
showVersion := flag .Bool ("version" , false , "Display the version of the capture" )
26
46
flag .Parse ()
@@ -52,6 +72,8 @@ func main() {
52
72
apiV1 .GET ("/metrics/host" , handler .MetricsHost )
53
73
apiV1 .GET ("/metrics/smart" , handler .SmartMetrics )
54
74
75
+ log .Println ("warning: Remember to add http://" + getLocalIP () + ":" + appConfig .Port + "/api/v1/metrics to your Checkmate dashboard" )
76
+
55
77
server := & http.Server {
56
78
Addr : ":" + appConfig .Port ,
57
79
Handler : r .Handler (),
You can’t perform that action at this time.
0 commit comments