2012-09-25 15:16:17 +08:00
|
|
|
package worker
|
|
|
|
|
|
|
|
import (
|
2013-08-30 12:36:57 +08:00
|
|
|
"encoding/json"
|
|
|
|
"runtime"
|
2012-09-25 15:16:17 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
type systemInfo struct {
|
2013-08-30 12:36:57 +08:00
|
|
|
GOOS, GOARCH, GOROOT, Version string
|
|
|
|
NumCPU, NumGoroutine int
|
|
|
|
NumCgoCall int64
|
2012-09-25 15:16:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func SysInfo(job *Job) ([]byte, error) {
|
2013-08-30 12:36:57 +08:00
|
|
|
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(),
|
|
|
|
})
|
2012-09-25 15:16:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
var memState runtime.MemStats
|
|
|
|
|
|
|
|
func MemInfo(job *Job) ([]byte, error) {
|
2013-08-30 12:36:57 +08:00
|
|
|
runtime.ReadMemStats(&memState)
|
|
|
|
return json.Marshal(&memState)
|
2012-09-25 15:16:17 +08:00
|
|
|
}
|