Show parsed #kyotocabinet status
This commit is contained in:
parent
17c8b0fa88
commit
90d48a823b
17
server.go
17
server.go
|
@ -2,9 +2,11 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -45,7 +47,20 @@ func DebugHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
Error(err, "Failed to get Kyoto Cabinet status")
|
Error(err, "Failed to get Kyoto Cabinet status")
|
||||||
}
|
}
|
||||||
info["kyoto_cabinet"] = s
|
s = s[:len(s)-1] // Removing trailing new line
|
||||||
|
|
||||||
|
ks := make(map[string]interface{})
|
||||||
|
tokens := strings.Split(s, "\n")
|
||||||
|
for _, t := range tokens {
|
||||||
|
tt := strings.Split(t, "\t")
|
||||||
|
if tt[0] == "path" {
|
||||||
|
ks[tt[0]] = tt[1]
|
||||||
|
} else {
|
||||||
|
num, _ := strconv.Atoi(tt[1])
|
||||||
|
ks[tt[0]] = num
|
||||||
|
}
|
||||||
|
}
|
||||||
|
info["kyoto_cabinet"] = ks
|
||||||
|
|
||||||
jsn, _ := json.Marshal(info)
|
jsn, _ := json.Marshal(info)
|
||||||
w.Write(jsn)
|
w.Write(jsn)
|
||||||
|
|
Loading…
Reference in New Issue