diff --git a/vendor.conf b/vendor.conf index 1758e1b4e..f3e4eb576 100644 --- a/vendor.conf +++ b/vendor.conf @@ -1,6 +1,6 @@ github.com/crosbymichael/go-runc 65847bfc51952703ca24b564d10de50d3f2db6e7 github.com/crosbymichael/console f13f890e20a94bdec6c328cdf9410b7158f0cfa4 -github.com/crosbymichael/cgroups a692a19766b072b86d89620c97a7916b2e2de3e7 +github.com/crosbymichael/cgroups e950a27f3faf567abbf995bfbec90eaddc766d25 github.com/docker/go-metrics 8fd5772bf1584597834c6f7961a530f06cbfbb87 github.com/prometheus/client_golang v0.8.0 github.com/prometheus/client_model fa8ad6fec33561be4280a8f0514318c79d7f6cb6 diff --git a/vendor/github.com/crosbymichael/cgroups/prometheus/metrics.go b/vendor/github.com/crosbymichael/cgroups/prometheus/metrics.go index 4a0ba3c81..13a4a191e 100644 --- a/vendor/github.com/crosbymichael/cgroups/prometheus/metrics.go +++ b/vendor/github.com/crosbymichael/cgroups/prometheus/metrics.go @@ -16,6 +16,10 @@ var ( ErrCgroupNotExists = errors.New("cgroup does not exist in the collector") ) +// Trigger will be called when an event happens and provides the cgroup +// where the event originated from +type Trigger func(string, cgroups.Cgroup) + // New registers the Collector with the provided namespace and returns it so // that cgroups can be added for collection func New(ns *metrics.Namespace) *Collector { diff --git a/vendor/github.com/crosbymichael/cgroups/prometheus/oom.go b/vendor/github.com/crosbymichael/cgroups/prometheus/oom.go index 0cfd6a49c..a1a90880e 100644 --- a/vendor/github.com/crosbymichael/cgroups/prometheus/oom.go +++ b/vendor/github.com/crosbymichael/cgroups/prometheus/oom.go @@ -33,11 +33,12 @@ type OOMCollector struct { } type oom struct { - id string - c cgroups.Cgroup + id string + c cgroups.Cgroup + triggers []Trigger } -func (o *OOMCollector) Add(id string, cg cgroups.Cgroup) error { +func (o *OOMCollector) Add(id string, cg cgroups.Cgroup, triggers ...Trigger) error { o.mu.Lock() defer o.mu.Unlock() fd, err := cg.OOMEventFD() @@ -45,8 +46,9 @@ func (o *OOMCollector) Add(id string, cg cgroups.Cgroup) error { return err } o.set[fd] = &oom{ - id: id, - c: cg, + id: id, + c: cg, + triggers: triggers, } // set the gauge's default value o.memoryOOM.WithValues(id).Set(0) @@ -102,6 +104,9 @@ func (o *OOMCollector) process(fd uintptr, event uint32) { return } o.memoryOOM.WithValues(info.id).Inc(1) + for _, t := range info.triggers { + t(info.id, info.c) + } } func flush(fd uintptr) error {