(sigChan chan int, errChan chan error)
| 122 | } |
| 123 | |
| 124 | func captureNodeStatus(sigChan chan int, errChan chan error) { |
| 125 | localLock := new(sync.Mutex) |
| 126 | var prevNodeResouce *utils.HostResourceRaw |
| 127 | var prevInstanceLinkResource map[string]map[string]*utils.LinkResourceRaw |
| 128 | var prevInstanceResource map[string]*utils.InstanceResouceRaw |
| 129 | var prevTime = time.Now() |
| 130 | withPrev := false |
| 131 | for { |
| 132 | select { |
| 133 | case sig := <-sigChan: |
| 134 | if sig == signal.STOP_SIGNAL { |
| 135 | return |
| 136 | } |
| 137 | case <-time.After(time.Duration(config.GlobalConfig.App.MonitorInterval) * time.Second): |
| 138 | // DO NOTHING, JUST FOR NO BLOCKING |
| 139 | } |
| 140 | |
| 141 | time := time.Now() |
| 142 | instanceNamespaceMap := make(map[string]string) |
| 143 | thisInstanceLinkResource := map[string]map[string]*utils.LinkResourceRaw{} |
| 144 | thisInstanceResource := map[string]*utils.InstanceResouceRaw{} |
| 145 | |
| 146 | thisNodeResouce, err := utils.GetHostResourceInfo() |
| 147 | |
| 148 | if err != nil { |
| 149 | logrus.Errorf("Get Host Performance Info of Node %d Error:%s", key.NodeIndex, err.Error()) |
| 150 | errChan <- err |
| 151 | } |
| 152 | |
| 153 | instances, err := synchronizer.GetInstanceList(key.NodeIndex) |
| 154 | |
| 155 | if err != nil { |
| 156 | logrus.Errorf("Get Instance List of Node %d Error: %s", key.NodeIndex, err.Error()) |
| 157 | errChan <- err |
| 158 | } |
| 159 | |
| 160 | instancePidPairs := []data.InstancePidPair{} |
| 161 | |
| 162 | for _, instance := range instances { |
| 163 | if pid, ok := data.TryGetInstancePid(instance.InstanceID); ok { |
| 164 | instancePidPairs = append(instancePidPairs, data.InstancePidPair{ |
| 165 | InstanceID: instance.InstanceID, |
| 166 | Pid: pid, |
| 167 | }) |
| 168 | } |
| 169 | } |
| 170 | wg := utils.ForEachWithThreadPool[data.InstancePidPair](func(instanceInfo data.InstancePidPair) { |
| 171 | if instanceInfo.Pid == 0 { |
| 172 | return |
| 173 | } |
| 174 | instanceResouce, err := utils.GetInstanceResourceInfo(instanceInfo.InstanceID, instanceInfo.Pid) |
| 175 | if err != nil { |
| 176 | logrus.Errorf("Get Instance Performance of Instance %s Error: %s", instanceInfo.InstanceID, err.Error()) |
| 177 | return |
| 178 | } |
| 179 | // linkStatus, err := utils.GetInstanceLinkResourceInfo(instanceInfo.Pid) |
| 180 | // if err != nil { |
| 181 | // logrus.Errorf("Get Link Performance of Instance %s Error: %s", instanceInfo.InstanceID, err.Error()) |
nothing calls this directly
no test coverage detected