apm_register_host.go 717 B

1234567891011121314151617181920212223242526272829303132
  1. package containers
  2. import (
  3. "fmt"
  4. . "github.com/coroot/coroot-node-agent/utils/modelse"
  5. "runtime"
  6. )
  7. func (r *Registry) RegisterHost() error {
  8. // 注册
  9. nodeInfo := r.nodeInfo.GetNodeInfo()
  10. if nodeInfo == nil {
  11. return fmt.Errorf("could not find node info")
  12. }
  13. req := RegisterHostReq{
  14. LicenseKey: nodeInfo.LicenseKey,
  15. HostId: nodeInfo.HostID,
  16. HostIp: nodeInfo.HostIp,
  17. HostName: "smartagent",
  18. HostNameAlias: nodeInfo.Hostname,
  19. HostType: 1,
  20. Version: "0.0.1",
  21. SysVersion: runtime.GOOS + " " + runtime.GOARCH,
  22. SystemUuid: nodeInfo.SystemUUID,
  23. Ebpf: true,
  24. }
  25. err := r.connServer.RegisterHost(req)
  26. if err != nil {
  27. return err
  28. }
  29. return nil
  30. }