package main import ( "fmt" "net/http" "log" "github.com/goftp/server" filedriver "github.com/goftp/file-driver" ) var( metrics_num_passwords int ) func main() { log.Println("Starting FTP listener") go func() { factory := &filedriver.FileDriverFactory{ RootPath: "", Perm: server.NewSimplePerm("user", "group"), } opts := &server.ServerOpts{ Factory: factory, Port: 21, Hostname: "::", Auth: &FakeAuth{Name: "", Password: ""}, Logger: &server.DiscardLogger{}, } server := server.NewServer(opts) err := server.ListenAndServe() if err != nil { log.Fatal("Error starting server:", err) } }() log.Println("Starting HTTP metrics listener") http.HandleFunc("/metrics", metricsHandler) listenErr := http.ListenAndServe(":48081", nil) // set listen port if listenErr != nil { log.Fatalln(listenErr.Error()) } } // Handle HTTP /metrics requests func metricsHandler(w http.ResponseWriter, req *http.Request) { fmt.Fprintf(w, "metrics_num_passwords %d\n", metrics_num_passwords) }