| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- package containers
- import (
- "fmt"
- "github.com/coroot/coroot-node-agent/utils"
- . "github.com/coroot/coroot-node-agent/utils/modelse"
- klog "github.com/sirupsen/logrus"
- )
- func (c *Container) RegisterAppInfo(r *Registry, pid uint32) error {
- if c.WhiteSettingInfo.AppName == "" {
- return fmt.Errorf("AppName is empty")
- }
- var err error
- originAppName := c.AppInfo.AppName
- whiteAppName := c.WhiteSettingInfo.AppName
- if originAppName != whiteAppName {
- c.AppInfo.AppId, err = utils.BuildInt64ID(whiteAppName).ToInt64()
- if err != nil {
- return err
- }
- c.AppInfo.ServiceName = c.AppInfo.CodeType.ServiceTypeString()
- // 注册
- hostId, _ := utils.GetHostID()
- registerAppReq := RegisterAppReq{
- AppId: c.AppInfo.AppId,
- AppName: c.WhiteSettingInfo.AppName,
- AccountId: 110,
- AgentId: c.AppInfo.AgentId,
- Sn: c.AppInfo.Sn,
- Sport: c.AppInfo.Sport,
- ServiceType: c.AppInfo.ServiceName,
- CodeType: c.AppInfo.CodeType.Int(),
- App_type: 1,
- HostId: hostId,
- }
- klog.Infof("Register App: %s", registerAppReq.String())
- err = r.connServer.RegisterApp(registerAppReq)
- if err != nil {
- klog.WithError(err).Errorf("Failed Register App %s", registerAppReq.String())
- return err
- }
- c.AppInfo.AppName = c.WhiteSettingInfo.AppName
- }
- // ip:port + process_name + exe路径生成
- //c.instanceID.IntVal + proc.GetExe(pid)
- //c.AppInfo.AgentId =
- return nil
- }
- func (c *Container) TestRegisterAppInfo(r *Registry) error {
- var err error
- c.AppInfo.AppName = "eBPF-APP"
- c.AppInfo.AppId, err = utils.BuildInt64ID(c.AppInfo.AppName).ToInt64()
- if err != nil {
- return err
- }
- c.AppInfo.ServiceName = c.AppInfo.CodeType.ServiceTypeString()
- // 注册
- hostId, _ := utils.GetHostID()
- registerAppReq := RegisterAppReq{
- AppId: c.AppInfo.AppId,
- AppName: c.AppInfo.AppName,
- AccountId: 110,
- AgentId: c.AppInfo.AgentId,
- Sn: c.AppInfo.Sn,
- Sport: c.AppInfo.Sport,
- ServiceType: c.AppInfo.ServiceName,
- CodeType: c.AppInfo.CodeType.Int(),
- App_type: 1,
- HostId: hostId,
- }
- registerAppReq.Print()
- err = r.connServer.RegisterApp(registerAppReq)
- if err != nil {
- return err
- }
- // ip:port + process_name + exe路径生成
- //c.instanceID.IntVal + proc.GetExe(pid)
- //c.AppInfo.AgentId =
- return nil
- }
|