Browse Source

add /debug/pprof/trace

pull/279/head
tnextday 10 years ago
parent
commit
c2f9bf6818
  1. 21
      weed/util/duration.go
  2. 1
      weed/weedserver/master_server.go
  3. 2
      weed/weedserver/master_server_handlers_ui.go
  4. 1
      weed/weedserver/volume_server.go
  5. 2
      weed/weedserver/volume_server_handlers_ui.go

21
weed/util/duration.go

@ -0,0 +1,21 @@
package util
import (
"fmt"
"time"
)
func FormatDuration(d time.Duration) string {
if days := d / (time.Hour * 24); days > 0 {
hours := d % (time.Hour * 24) / time.Hour
return fmt.Sprintf("%d days %d hours", int(days), int(hours))
} else if hours := d / time.Hour; hours > 0 {
minutes := d % time.Hour / time.Minute
return fmt.Sprintf("%d hours %d minutes", int(hours), int(minutes))
} else {
minutes := d / time.Minute
seconds := d % time.Minute / time.Second
return fmt.Sprintf("%d minutes %d seconds", int(minutes), int(seconds))
}
return d.String()
}

1
weed/weedserver/master_server.go

@ -83,6 +83,7 @@ func NewMasterServer(r *mux.Router, port int, metaFolder string,
r.HandleFunc("/stats/counter", ms.guard.WhiteList(statsCounterHandler)) r.HandleFunc("/stats/counter", ms.guard.WhiteList(statsCounterHandler))
r.HandleFunc("/stats/memory", ms.guard.WhiteList(statsMemoryHandler)) r.HandleFunc("/stats/memory", ms.guard.WhiteList(statsMemoryHandler))
r.HandleFunc("/debug/pprof/", ms.guard.WhiteList(pprof.Index)) r.HandleFunc("/debug/pprof/", ms.guard.WhiteList(pprof.Index))
r.HandleFunc("/debug/pprof/trace", ms.guard.WhiteList(pprof.Trace))
r.HandleFunc("/debug/pprof/{name}", ms.guard.WhiteList(pprof.Index)) r.HandleFunc("/debug/pprof/{name}", ms.guard.WhiteList(pprof.Index))
ms.Topo.StartRefreshWritableVolumes() ms.Topo.StartRefreshWritableVolumes()

2
weed/weedserver/master_server_handlers_ui.go

@ -13,7 +13,7 @@ import (
func (ms *MasterServer) uiStatusHandler(w http.ResponseWriter, r *http.Request) { func (ms *MasterServer) uiStatusHandler(w http.ResponseWriter, r *http.Request) {
infos := make(map[string]interface{}) infos := make(map[string]interface{})
infos["Version"] = util.VERSION infos["Version"] = util.VERSION
infos["Up Time"] = time.Now().Sub(startTime).String()
infos["Up Time"] = util.FormatDuration(time.Now().Sub(startTime))
args := struct { args := struct {
Version string Version string
Topology interface{} Topology interface{}

1
weed/weedserver/volume_server.go

@ -67,6 +67,7 @@ func NewVolumeServer(adminMux, publicMux *http.ServeMux, ip string,
adminMux.HandleFunc("/stats/memory", vs.guard.WhiteList(statsMemoryHandler)) adminMux.HandleFunc("/stats/memory", vs.guard.WhiteList(statsMemoryHandler))
adminMux.HandleFunc("/stats/disk", vs.guard.WhiteList(vs.statsDiskHandler)) adminMux.HandleFunc("/stats/disk", vs.guard.WhiteList(vs.statsDiskHandler))
adminMux.HandleFunc("/debug/pprof/", vs.guard.WhiteList(pprof.Index)) adminMux.HandleFunc("/debug/pprof/", vs.guard.WhiteList(pprof.Index))
adminMux.HandleFunc("/debug/pprof/trace", vs.guard.WhiteList(pprof.Trace))
adminMux.HandleFunc("/debug/pprof/{name}", vs.guard.WhiteList(pprof.Index)) adminMux.HandleFunc("/debug/pprof/{name}", vs.guard.WhiteList(pprof.Index))
adminMux.HandleFunc("/delete", vs.guard.WhiteList(vs.batchDeleteHandler)) adminMux.HandleFunc("/delete", vs.guard.WhiteList(vs.batchDeleteHandler))
adminMux.HandleFunc("/", vs.privateStoreHandler) adminMux.HandleFunc("/", vs.privateStoreHandler)

2
weed/weedserver/volume_server_handlers_ui.go

@ -13,7 +13,7 @@ import (
func (vs *VolumeServer) uiStatusHandler(w http.ResponseWriter, r *http.Request) { func (vs *VolumeServer) uiStatusHandler(w http.ResponseWriter, r *http.Request) {
infos := make(map[string]interface{}) infos := make(map[string]interface{})
infos["Version"] = util.VERSION infos["Version"] = util.VERSION
infos["Up Time"] = time.Now().Sub(startTime).String()
infos["Up Time"] = util.FormatDuration(time.Now().Sub(startTime))
var ds []*stats.DiskStatus var ds []*stats.DiskStatus
for _, loc := range vs.store.Locations { for _, loc := range vs.store.Locations {
if dir, e := filepath.Abs(loc.Directory); e == nil { if dir, e := filepath.Abs(loc.Directory); e == nil {

Loading…
Cancel
Save