store and report git info

This commit is contained in:
Stephen McQuay 2018-03-08 16:16:14 -08:00
parent 56bd8445a4
commit bcbbe000f3
Signed by: sm
GPG Key ID: 4E4B72F479BA3CE5
3 changed files with 5 additions and 0 deletions

View File

@ -27,6 +27,7 @@ func main() {
r := hw.V{ r := hw.V{
Hostname: hn, Hostname: hn,
V: hw.Version, V: hw.Version,
G: hw.Git,
} }
if err := json.NewEncoder(w).Encode(r); err != nil { if err := json.NewEncoder(w).Encode(r); err != nil {
log.Printf("json: %+v", err) log.Printf("json: %+v", err)

View File

@ -20,6 +20,7 @@ var success *prometheus.CounterVec
type state struct { type state struct {
Hostname string `json:"hostname"` Hostname string `json:"hostname"`
V string `json:"version"` V string `json:"version"`
G string `json:"git"`
sync.RWMutex sync.RWMutex
Counts map[string]int `json:"counts"` Counts map[string]int `json:"counts"`
@ -84,6 +85,7 @@ func main() {
fetcher := state{ fetcher := state{
Hostname: hn, Hostname: hn,
V: hw.Version, V: hw.Version,
G: hw.Git,
Counts: map[string]int{}, Counts: map[string]int{},
} }
go fetcher.update(target) go fetcher.update(target)

2
hw.go
View File

@ -3,6 +3,7 @@ package hw
import "net/http" import "net/http"
var Version = "unset" var Version = "unset"
var Git = "unset"
// OK simply return 200 // OK simply return 200
func OK(w http.ResponseWriter, req *http.Request) {} func OK(w http.ResponseWriter, req *http.Request) {}
@ -11,4 +12,5 @@ func OK(w http.ResponseWriter, req *http.Request) {}
type V struct { type V struct {
Hostname string `json:"hostname"` Hostname string `json:"hostname"`
V string `json:"version"` V string `json:"version"`
G string `json:"git"`
} }