diff --git a/blkiodev/blkiodev.go b/blkiodev/blkiodev.go index 84cdbd7..e9a3649 100644 --- a/blkiodev/blkiodev.go +++ b/blkiodev/blkiodev.go @@ -13,3 +13,13 @@ type WeightDevice struct { func (w *WeightDevice) String() string { return fmt.Sprintf("%s:%d", w.Path, w.Weight) } + +// ThrottleDevice is a structure that hold device:rate_per_second pair +type ThrottleDevice struct { + Path string + Rate uint64 +} + +func (t *ThrottleDevice) String() string { + return fmt.Sprintf("%s:%d", t.Path, t.Rate) +} diff --git a/sysinfo/sysinfo.go b/sysinfo/sysinfo.go index 580b6ba..c12619f 100644 --- a/sysinfo/sysinfo.go +++ b/sysinfo/sysinfo.go @@ -63,6 +63,12 @@ type cgroupBlkioInfo struct { // Whether Block IO weight_device is supported or not BlkioWeightDevice bool + + // Whether Block IO read limit in bytes per second is supported or not + BlkioReadBpsDevice bool + + // Whether Block IO write limit in bytes per second is supported or not + BlkioWriteBpsDevice bool } type cgroupCpusetInfo struct { diff --git a/sysinfo/sysinfo_linux.go b/sysinfo/sysinfo_linux.go index a93e781..e30e79a 100644 --- a/sysinfo/sysinfo_linux.go +++ b/sysinfo/sysinfo_linux.go @@ -126,9 +126,21 @@ func checkCgroupBlkioInfo(quiet bool) cgroupBlkioInfo { if !quiet && !weightDevice { logrus.Warn("Your kernel does not support cgroup blkio weight_device") } + + readBpsDevice := cgroupEnabled(mountPoint, "blkio.throttle.read_bps_device") + if !quiet && !readBpsDevice { + logrus.Warn("Your kernel does not support cgroup blkio throttle.read_bps_device") + } + + writeBpsDevice := cgroupEnabled(mountPoint, "blkio.throttle.write_bps_device") + if !quiet && !writeBpsDevice { + logrus.Warn("Your kernel does not support cgroup blkio throttle.write_bps_device") + } return cgroupBlkioInfo{ - BlkioWeight: weight, - BlkioWeightDevice: weightDevice, + BlkioWeight: weight, + BlkioWeightDevice: weightDevice, + BlkioReadBpsDevice: readBpsDevice, + BlkioWriteBpsDevice: writeBpsDevice, } }