gearman-go/worker/func.go
mikespook 05590bfb8c Info funcs added
--HG--
branch : dev
2012-09-25 15:16:17 +08:00

32 lines
666 B
Go

package worker
import (
"runtime"
"encoding/json"
)
type systemInfo struct {
GOOS, GOARCH, GOROOT, Version string
NumCPU, NumGoroutine int
NumCgoCall int64
}
func SysInfo(job *Job) ([]byte, error) {
return json.Marshal(&systemInfo{
GOOS: runtime.GOOS,
GOARCH: runtime.GOARCH,
GOROOT: runtime.GOROOT(),
Version: runtime.Version(),
NumCPU: runtime.NumCPU(),
NumGoroutine: runtime.NumGoroutine(),
NumCgoCall: runtime.NumCgoCall(),
})
}
var memState runtime.MemStats
func MemInfo(job *Job) ([]byte, error) {
runtime.ReadMemStats(&memState)
return json.Marshal(&memState)
}