gupta.go 773 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package gupta
  2. import (
  3. "fmt"
  4. )
  5. const version = "0.0.1"
  6. func Hello() string {
  7. return fmt.Sprintf("Welcome to gupta version %s", version)
  8. }
  9. func Run(load, cpu, memory bool, partition, networkInterface string) (cpuLoad, cpuUsage, memoryUsage float64) {
  10. cpuLoad = 0.2
  11. cpuUsage = 0.2
  12. memoryUsage = 70.0
  13. return cpuLoad, cpuUsage, memoryUsage
  14. }
  15. type GuptaReport struct {
  16. cpuLoad float64
  17. cpuUsage float64
  18. memoryUsage float64
  19. }
  20. func (g *GuptaReport) GetCPULoad() string {
  21. return fmt.Sprintf("%.2f", g.cpuLoad)
  22. }
  23. type CPULoad struct {
  24. user int
  25. nice int
  26. system int
  27. idle int
  28. iowait int
  29. irq int
  30. softirq int
  31. steal int
  32. guest int
  33. guest_nice int
  34. }
  35. func (c *CPULoad) ReadInfo(rawInfo []string) {
  36. c.user = 1
  37. }