Merge pull request #522 from kateknister/apiBranch
Added an oom monitor to manager
This commit is contained in:
commit
7def27275a
@ -28,9 +28,11 @@ import (
|
||||
"github.com/golang/glog"
|
||||
"github.com/google/cadvisor/container"
|
||||
"github.com/google/cadvisor/container/docker"
|
||||
"github.com/google/cadvisor/events"
|
||||
"github.com/google/cadvisor/info"
|
||||
"github.com/google/cadvisor/storage/memory"
|
||||
"github.com/google/cadvisor/utils/cpuload"
|
||||
"github.com/google/cadvisor/utils/oomparser"
|
||||
"github.com/google/cadvisor/utils/sysfs"
|
||||
)
|
||||
|
||||
@ -623,3 +625,27 @@ func (self *manager) watchForNewContainers(quit chan error) error {
|
||||
}()
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *manager) watchForNewOoms() error {
|
||||
outStream := make(chan *oomparser.OomInstance, 10)
|
||||
oomLog, err := oomparser.New()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = oomLog.StreamOoms(outStream)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
go func() {
|
||||
for oomInstance := range outStream {
|
||||
newEvent := &events.Event{
|
||||
ContainerName: oomInstance.ContainerName,
|
||||
Timestamp: oomInstance.TimeOfDeath,
|
||||
EventType: events.TypeOom,
|
||||
EventData: oomInstance,
|
||||
}
|
||||
glog.V(1).Infof("Created an oom event: %v", newEvent)
|
||||
}
|
||||
}()
|
||||
return nil
|
||||
}
|
||||
|
@ -162,7 +162,9 @@ func (self *OomParser) StreamOoms(outStream chan *OomInstance) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
go self.analyzeLines(file, outStream)
|
||||
go func() {
|
||||
self.analyzeLines(file, outStream)
|
||||
}()
|
||||
return nil
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user