Collects volume inode stats using the same find command that cadvisor uses these are included in the summary

This commit is contained in:
David Ashpole
2016-11-01 10:51:11 -07:00
parent 2244bfed81
commit d494ef66f0
6 changed files with 91 additions and 15 deletions

View File

@@ -50,6 +50,11 @@ func (md *metricsDu) GetMetrics() (*Metrics, error) {
return metrics, err
}
err = md.runFind(metrics)
if err != nil {
return metrics, err
}
err = md.getFsInfo(metrics)
if err != nil {
return metrics, err
@@ -68,14 +73,26 @@ func (md *metricsDu) runDu(metrics *Metrics) error {
return nil
}
// runFind executes the "find" command and writes the results to metrics.InodesUsed
func (md *metricsDu) runFind(metrics *Metrics) error {
inodesUsed, err := util.Find(md.path)
if err != nil {
return err
}
metrics.InodesUsed = resource.NewQuantity(inodesUsed, resource.BinarySI)
return nil
}
// getFsInfo writes metrics.Capacity and metrics.Available from the filesystem
// info
func (md *metricsDu) getFsInfo(metrics *Metrics) error {
available, capacity, _, err := util.FsInfo(md.path)
available, capacity, _, inodes, inodesFree, _, err := util.FsInfo(md.path)
if err != nil {
return NewFsInfoFailedError(err)
}
metrics.Available = resource.NewQuantity(available, resource.BinarySI)
metrics.Capacity = resource.NewQuantity(capacity, resource.BinarySI)
metrics.Inodes = resource.NewQuantity(inodes, resource.BinarySI)
metrics.InodesFree = resource.NewQuantity(inodesFree, resource.BinarySI)
return nil
}