Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Count only the first filesystem with the same mounting point #2777

Merged
merged 1 commit into from
Oct 20, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}