From: Tim Pierce Date: Fri, 11 Apr 2014 11:02:42 +0000 (-0400) Subject: Write status output in JSON. (refs #2561) X-Git-Tag: 1.1.0~2690^2~10^2~13 X-Git-Url: https://git.arvados.org/arvados.git/commitdiff_plain/c4b51836d29d37cb75c6432ce056d844cf27c3ac Write status output in JSON. (refs #2561) --- diff --git a/services/keep/keep.go b/services/keep/keep.go index 4ee9fb3832..71c2a8b913 100644 --- a/services/keep/keep.go +++ b/services/keep/keep.go @@ -4,6 +4,7 @@ import ( "bufio" "bytes" "crypto/md5" + "encoding/json" "errors" "fmt" "github.com/gorilla/mux" @@ -209,6 +210,14 @@ func StatusHandler(w http.ResponseWriter, req *http.Request) { for _, vol := range KeepVolumes { st.Volumes[vol] = GetVolumeStatus(vol) } + + if jstat, err := json.Marshal(st); err == nil { + w.Write(jstat) + } else { + log.Printf("json.Marshal: %s\n", err) + log.Printf("NodeStatus = %v\n", st) + http.Error(w, err.Error(), 500) + } } // GetVolumeStatus