You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

32 lines
666 B

  1. package worker
  2. import (
  3. "runtime"
  4. "encoding/json"
  5. )
  6. type systemInfo struct {
  7. GOOS, GOARCH, GOROOT, Version string
  8. NumCPU, NumGoroutine int
  9. NumCgoCall int64
  10. }
  11. func SysInfo(job *Job) ([]byte, error) {
  12. return json.Marshal(&systemInfo{
  13. GOOS: runtime.GOOS,
  14. GOARCH: runtime.GOARCH,
  15. GOROOT: runtime.GOROOT(),
  16. Version: runtime.Version(),
  17. NumCPU: runtime.NumCPU(),
  18. NumGoroutine: runtime.NumGoroutine(),
  19. NumCgoCall: runtime.NumCgoCall(),
  20. })
  21. }
  22. var memState runtime.MemStats
  23. func MemInfo(job *Job) ([]byte, error) {
  24. runtime.ReadMemStats(&memState)
  25. return json.Marshal(&memState)
  26. }