package main import ( "encoding/json" "fmt" "github.com/gliderlabs/ssh" //"github.com/gorilla/mux" "io/ioutil" "log" "net/http" "strings" ) var ( metrics_num_passwords int metrics_city_num map[string]int cities map[string]location ) type geoipresult struct { Query string `json:"query"` Status string `json:"status"` Country string `json:"country"` CountryCode string `json:"countryCode"` Region string `json:"region"` RegionName string `json:"regionName"` City string `json:"city"` Zip string `json:"zip"` Lat float64 `json:"lat"` Lon float64 `json:"lon"` Timezone string `json:"timezone"` Isp string `json:"isp"` Org string `json:"org"` As string `json:"as"` } type location struct { key string `json:"key"` latitude float64 `json:"latitude"` longitude float64 `json:"longitude"` name string `json:"name"` } func main() { // create a map mapping a city to an amount of hits metrics_city_num = make(map[string]int) // create a cities map mapping a city to a location cities = make(map[string]location) // start the ssh server log.Println("Starting SSH listener") go func() { listenErr := ssh.ListenAndServe(":2222", nil, ssh.PasswordAuth(handlePass)) if listenErr != nil { log.Fatalln(listenErr.Error()) } }() // start the http server logging the metrics log.Println("Starting HTTP metrics listener") http.HandleFunc("/", indexHandler) http.HandleFunc("/metrics", metricsHandler) http.HandleFunc("/locations", locationHandlerEndpoint) // start the http server exposing the metrics and the locations listenErr := http.ListenAndServe(":8084", nil) // handle potential errors if listenErr != nil { log.Fatalln(listenErr.Error()) } }