Bump cgroups pkg to e950a27f3faf567abbf995bfbec90

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
Michael Crosby 2017-04-13 14:24:59 -07:00
parent d41f146eed
commit e745efdddb
3 changed files with 15 additions and 6 deletions

View File

@ -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

View File

@ -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 {

View File

@ -35,9 +35,10 @@ type OOMCollector struct {
type oom struct {
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()
@ -47,6 +48,7 @@ func (o *OOMCollector) Add(id string, cg cgroups.Cgroup) error {
o.set[fd] = &oom{
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 {