Skip to content

Commit

Permalink
Count only the first filesystem with the same mounting point
Browse files Browse the repository at this point in the history
  • Loading branch information
monicasarbu committed Oct 20, 2016
1 parent 1fcc784 commit ff1ea04
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ https://github.com/elastic/beats/compare/v5.0.0-rc1...master[Check the HEAD diff
- Fix high value of `system.memory.actual.free` and `system.memory.actual.used`. {issue}2653[2653]
- Change several `OpenProcess` calls on Windows to request the lowest possible access provilege. {issue}1897[1897]
- Fix system.memory.actual.free high value on Windows. {issue}2653[2653]
- Calculate the fsstat values per mounting point, and not filesystem. {pull}2777[2777]

*Packetbeat*

Expand Down
2 changes: 1 addition & 1 deletion metricbeat/docs/fields.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -4522,7 +4522,7 @@ The percentage of used disk space.
[float]
== fsstat Fields

`system.fsstat` contains filesystem metrics aggregated from all mounted filesystems.
`system.fsstat` contains filesystem metrics aggregated from all mounted filesystems, similar with what `df -a` prints out.



Expand Down
2 changes: 1 addition & 1 deletion metricbeat/etc/fields.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2778,7 +2778,7 @@
type: group
description: >
`system.fsstat` contains filesystem metrics aggregated from all mounted
filesystems.
filesystems, similar with what `df -a` prints out.
fields:
- name: count
type: long
Expand Down
2 changes: 1 addition & 1 deletion metricbeat/module/system/fsstat/_meta/fields.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
type: group
description: >
`system.fsstat` contains filesystem metrics aggregated from all mounted
filesystems.
filesystems, similar with what `df -a` prints out.
fields:
- name: count
type: long
Expand Down
22 changes: 16 additions & 6 deletions metricbeat/module/system/fsstat/fsstat.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,28 @@ func (m *MetricSet) Fetch() (common.MapStr, error) {

// These values are optional and could also be calculated by Kibana
var totalFiles, totalSize, totalSizeFree, totalSizeUsed uint64
dict := map[string]bool{}

for _, fs := range fss {
fsStat, err := filesystem.GetFileSystemStat(fs)
stat, err := filesystem.GetFileSystemStat(fs)
if err != nil {
debugf("error fetching filesystem stats for '%s': %v", fs.DirName, err)
continue
}
logp.Debug("fsstat", "filesystem: %s total=%d, used=%d, free=%d", stat.Mount, stat.Total, stat.Used, stat.Free)

if _, ok := dict[stat.Mount]; ok {
// ignore filesystem with the same mounting point
continue
}

totalFiles += stat.Files
totalSize += stat.Total
totalSizeFree += stat.Free
totalSizeUsed += stat.Used

dict[stat.Mount] = true

totalFiles += fsStat.Files
totalSize += fsStat.Total
totalSizeFree += fsStat.Free
totalSizeUsed += fsStat.Used
}

return common.MapStr{
Expand All @@ -61,7 +71,7 @@ func (m *MetricSet) Fetch() (common.MapStr, error) {
"used": totalSizeUsed,
"total": totalSize,
},
"count": len(fss),
"count": len(dict),
"total_files": totalFiles,
}, nil
}

0 comments on commit ff1ea04

Please sign in to comment.