2016-01-27 06:22:25 +00:00
|
|
|
// +build linux
|
|
|
|
|
|
|
|
package fingerprint
|
|
|
|
|
|
|
|
import (
|
2016-05-09 07:54:33 +00:00
|
|
|
"fmt"
|
2016-01-27 06:22:25 +00:00
|
|
|
)
|
|
|
|
|
2018-06-01 22:23:10 +00:00
|
|
|
const (
|
|
|
|
cgroupAvailable = "available"
|
|
|
|
)
|
|
|
|
|
2018-03-11 18:27:18 +00:00
|
|
|
// Fingerprint tries to find a valid cgroup mount point
|
2018-12-01 16:10:39 +00:00
|
|
|
func (f *CGroupFingerprint) Fingerprint(req *FingerprintRequest, resp *FingerprintResponse) error {
|
2016-05-09 07:54:33 +00:00
|
|
|
mount, err := f.mountPointDetector.MountPoint()
|
|
|
|
if err != nil {
|
2018-01-26 19:31:37 +00:00
|
|
|
f.clearCGroupAttributes(resp)
|
2018-01-24 14:09:53 +00:00
|
|
|
return fmt.Errorf("Failed to discover cgroup mount point: %s", err)
|
2016-05-09 07:54:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Check if a cgroup mount point was found
|
|
|
|
if mount == "" {
|
2018-01-26 19:31:37 +00:00
|
|
|
|
|
|
|
f.clearCGroupAttributes(resp)
|
|
|
|
|
2016-05-09 07:54:33 +00:00
|
|
|
if f.lastState == cgroupAvailable {
|
2018-09-16 00:48:59 +00:00
|
|
|
f.logger.Info("cgroups are unavailable")
|
2016-05-09 07:54:33 +00:00
|
|
|
}
|
|
|
|
f.lastState = cgroupUnavailable
|
2018-01-24 14:09:53 +00:00
|
|
|
return nil
|
2016-05-09 07:54:33 +00:00
|
|
|
}
|
|
|
|
|
2018-01-26 16:21:07 +00:00
|
|
|
resp.AddAttribute("unique.cgroup.mountpoint", mount)
|
2018-01-31 22:03:55 +00:00
|
|
|
resp.Detected = true
|
2016-05-09 07:54:33 +00:00
|
|
|
|
|
|
|
if f.lastState == cgroupUnavailable {
|
2018-09-16 00:48:59 +00:00
|
|
|
f.logger.Info("cgroups are available")
|
2016-05-09 07:54:33 +00:00
|
|
|
}
|
|
|
|
f.lastState = cgroupAvailable
|
2018-01-24 14:09:53 +00:00
|
|
|
return nil
|
2016-05-09 07:54:33 +00:00
|
|
|
}
|