1
0
Fork 0

Show parsed #kyotocabinet status

This commit is contained in:
Gregory Eremin 2014-07-29 13:57:07 +07:00
parent 17c8b0fa88
commit 90d48a823b
1 changed files with 16 additions and 1 deletions

View File

@ -2,9 +2,11 @@ package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"runtime"
"strconv"
"strings"
)
@ -45,7 +47,20 @@ func DebugHandler(w http.ResponseWriter, r *http.Request) {
if err != nil {
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)
w.Write(jsn)