MCPcopy
hub / github.com/slimtoolkit/slim / Run

Function Run

pkg/app/sensor/monitor/pevent/monitor.go:18–54  ·  view source on GitHub ↗

Process Event Monitor goal: Watch the processes to separate the activity we care about from unrelated stuff running in the background. Run starts the PEVENT monitor

(stopChan <-chan struct{})

Source from the content-addressed store, hash-verified

16
17// Run starts the PEVENT monitor
18func Run(stopChan <-chan struct{}) <-chan *report.PeMonitorReport {
19 log.Info("pemon: starting...")
20
21 //"connection refused" with boot2docker...
22 watcher, err := pdiscover.NewAllWatcher(pdiscover.PROC_EVENT_ALL)
23 errutil.FailOn(err)
24
25 reportChan := make(chan *report.PeMonitorReport, 1)
26
27 go func() {
28 peReport := &report.PeMonitorReport{
29 Children: map[int][]int{},
30 Parents: map[int]int{},
31 }
32
33 done:
34 for {
35 select {
36 case <-stopChan:
37 log.Info("pemon: stopping...")
38 break done
39 case ev := <-watcher.Fork:
40 peReport.Children[ev.ParentPid] = append(peReport.Children[ev.ParentPid], ev.ChildPid)
41 peReport.Parents[ev.ChildPid] = ev.ParentPid
42 case <-watcher.Exec:
43 case <-watcher.Exit:
44 case err := <-watcher.Error:
45 errutil.FailOn(err)
46 }
47 }
48
49 reportChan <- peReport
50 watcher.Close()
51 }()
52
53 return reportChan
54}

Callers

nothing calls this directly

Calls 4

NewAllWatcherFunction · 0.92
FailOnFunction · 0.92
CloseMethod · 0.65
InfoMethod · 0.45

Tested by

no test coverage detected