(mon monitor.CompositeMonitor)
| 229 | } |
| 230 | |
| 231 | func (s *Sensor) processMonitoringResults(mon monitor.CompositeMonitor) error { |
| 232 | // A bit of code duplication to avoid starting a goroutine |
| 233 | // for error event handling - keeping the control flow |
| 234 | // "single-threaded" keeps reasoning about the logic. |
| 235 | for _, err := range mon.DrainErrors() { |
| 236 | log.WithError(err).Warn("sensor: non-critical monitor error condition (drained)") |
| 237 | s.exe.PubEvent(event.Error, monitor.NonCriticalError(err).Error()) |
| 238 | } |
| 239 | |
| 240 | log.Info("sensor: composite monitor is done, checking status...") |
| 241 | |
| 242 | report, err := mon.Status() |
| 243 | if err != nil { |
| 244 | log.WithError(err).Error("sensor: composite monitor failed") |
| 245 | return fmt.Errorf("composite monitor failed: %w", err) |
| 246 | } |
| 247 | |
| 248 | if err := s.artifactor.Process( |
| 249 | mon.StartCommand(), |
| 250 | s.mountPoint, |
| 251 | report.PeReport, |
| 252 | report.FanReport, |
| 253 | report.PtReport, |
| 254 | ); err != nil { |
| 255 | log.WithError(err).Error("sensor: artifact.Process() failed") |
| 256 | return fmt.Errorf("saving reports failed: %w", err) |
| 257 | } |
| 258 | return nil // Clean exit |
| 259 | } |
no test coverage detected