sosreport.go 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. package installationinfo
  2. import (
  3. "fmt"
  4. "time"
  5. config "github.com/OliveTin/OliveTin/internal/config"
  6. "gopkg.in/yaml.v3"
  7. )
  8. var (
  9. Config *config.Config
  10. )
  11. type sosReportConfig struct {
  12. CountOfActions int
  13. CountOfDashboards int
  14. LogLevel string
  15. ListenAddressSingleHTTPFrontend string
  16. ListenAddressWebUI string
  17. ListenAddressRestActions string
  18. Timezone string
  19. TimeNow string
  20. ConfigDirectory string
  21. WebuiDirectory string
  22. }
  23. func configToSosreport(cfg *config.Config) *sosReportConfig {
  24. return &sosReportConfig{
  25. CountOfActions: len(cfg.Actions),
  26. CountOfDashboards: len(cfg.Dashboards),
  27. LogLevel: cfg.LogLevel,
  28. ListenAddressSingleHTTPFrontend: cfg.ListenAddressSingleHTTPFrontend,
  29. ListenAddressWebUI: cfg.ListenAddressWebUI,
  30. ListenAddressRestActions: cfg.ListenAddressRestActions,
  31. Timezone: time.Now().Location().String(),
  32. TimeNow: time.Now().String(),
  33. ConfigDirectory: cfg.GetDir(),
  34. WebuiDirectory: cfg.WebUIDir,
  35. }
  36. }
  37. func GetSosReport() string {
  38. ret := ""
  39. ret += "### SOSREPORT START (copy all text to SOSREPORT END)\n"
  40. out, _ := yaml.Marshal(Build)
  41. ret += fmt.Sprintf("# Build: \n%+v\n", string(out))
  42. out, _ = yaml.Marshal(Runtime)
  43. ret += fmt.Sprintf("# Runtime:\n%+v\n", string(out))
  44. out, _ = yaml.Marshal(configToSosreport(Config))
  45. ret += fmt.Sprintf("# Config:\n%+v\n", string(out))
  46. ret += "### SOSREPORT END (copy all text from SOSREPORT START)\n"
  47. return ret
  48. }