39 lines
1.3 KiB
Go
39 lines
1.3 KiB
Go
package rigger
|
|
|
|
import (
|
|
"net/http"
|
|
"runtime"
|
|
|
|
"ciyon/web/admin"
|
|
c "ciyon/zciyon"
|
|
)
|
|
|
|
func Statssrv_init(w http.ResponseWriter, r *http.Request) bool {
|
|
post := c.NewCiyPost(w, r)
|
|
_, userid := admin.Verifyfast(r, c.CiyDB, post)
|
|
if userid == 0 {
|
|
return false
|
|
}
|
|
stats := map[string]map[string]any{}
|
|
stats["Go版本"] = map[string]any{"value": runtime.Version()}
|
|
stats["程序版本"] = map[string]any{"value": c.CiyVars.Version}
|
|
stats["操作系统"] = map[string]any{"value": runtime.GOOS}
|
|
stats["CPU数量"] = map[string]any{"value": runtime.NumCPU()}
|
|
|
|
var m runtime.MemStats
|
|
runtime.ReadMemStats(&m)
|
|
stats["Memory Allocation"] = map[string]any{"value": m.Alloc}
|
|
stats["Heap Allocation"] = map[string]any{"value": m.TotalAlloc}
|
|
stats["Heap System"] = map[string]any{"value": m.HeapSys}
|
|
stats["Heap In Use"] = map[string]any{"value": m.HeapInuse}
|
|
stats["Heap Idle"] = map[string]any{"value": m.HeapIdle}
|
|
stats["Heap Released"] = map[string]any{"value": m.HeapReleased}
|
|
stats["GC Pause"] = map[string]any{"value": m.PauseNs[(m.NumGC+255)%256]}
|
|
stats["Number of GC"] = map[string]any{"value": m.NumGC}
|
|
stats["Number of Go Routines"] = map[string]any{"value": runtime.NumGoroutine()}
|
|
|
|
ret := map[string]any{}
|
|
ret["stats"] = stats
|
|
return c.SuccJSON(w, r, ret)
|
|
}
|