@@ -315,12 +315,17 @@ func (c *Container) Collect(ch chan<- prometheus.Metric) {
315315
316316 if disks , err := node .GetDisks (); err == nil {
317317 ioStat := c .cgroup .IOStat ()
318+ seenVolumes := map [string ]struct {}{}
318319 for majorMinor , mounts := range c .getMounts () {
319320 var device string
320321 if dev := disks .GetParentBlockDevice (majorMinor ); dev != nil {
321322 device = dev .Name
322323 }
323324 for mountPoint , fsStat := range mounts {
325+ if _ , ok := seenVolumes [mountPoint + ":" + device ]; ok {
326+ continue
327+ }
328+ seenVolumes [mountPoint + ":" + device ] = struct {}{}
324329 dls := []string {mountPoint , device , c .metadata .volumes [mountPoint ]}
325330 ch <- gauge (metrics .DiskSize , float64 (fsStat .CapacityBytes ), dls ... )
326331 ch <- gauge (metrics .DiskUsed , float64 (fsStat .UsedBytes ), dls ... )
@@ -1049,6 +1054,21 @@ func (c *Container) getMounts() map[string]map[string]*proc.FSStat {
10491054 if len (c .mounts ) == 0 {
10501055 return nil
10511056 }
1057+ var current map [string ]proc.MountInfo
1058+ for pid := range c .processes {
1059+ if current = proc .GetMountInfo (pid ); current != nil {
1060+ break
1061+ }
1062+ }
1063+ if len (current ) > 0 {
1064+ for mntId := range c .mounts {
1065+ if mi , ok := current [mntId ]; ok {
1066+ c .mounts [mntId ] = mi
1067+ } else {
1068+ delete (c .mounts , mntId )
1069+ }
1070+ }
1071+ }
10521072 res := map [string ]map [string ]* proc.FSStat {}
10531073 for _ , mi := range c .mounts {
10541074 var stat * proc.FSStat
0 commit comments