In order to disable VMStat (as this won't work on a FreeBSD system) I changed the code as such:
--- metricbeat/module/system/memory/memory.go.orig
+++ metricbeat/module/system/memory/memory.go
@@ -28,7 +28,7 @@
mem "github.com/elastic/beats/v7/libbeat/metric/system/memory"
"github.com/elastic/beats/v7/metricbeat/mb"
"github.com/elastic/beats/v7/metricbeat/mb/parse"
- linux "github.com/elastic/beats/v7/metricbeat/module/linux/memory"
+// linux "github.com/elastic/beats/v7/metricbeat/module/linux/memory"
"github.com/elastic/beats/v7/metricbeat/module/system"
)
@@ -86,11 +86,12 @@
},
}
- vmstat, err := mem.GetVMStat()
- if err != nil {
- return errors.Wrap(err, "VMStat")
- }
+// vmstat, err := mem.GetVMStat()
+// if err != nil {
+// return errors.Wrap(err, "VMStat")
+// }
+
swap := common.MapStr{
"total": swapStat.Total,
"used": common.MapStr{
@@ -100,29 +101,29 @@
"free": swapStat.Free,
}
- if vmstat != nil {
- // Swap in and swap out numbers
- swap["in"] = common.MapStr{
- "pages": vmstat.Pswpin,
- }
- swap["out"] = common.MapStr{
- "pages": vmstat.Pswpout,
- }
- //Swap readahead
- //See https://www.kernel.org/doc/ols/2007/ols2007v2-pages-273-284.pdf
- swap["readahead"] = common.MapStr{
- "pages": vmstat.SwapRa,
- "cached": vmstat.SwapRaHit,
- }
- }
+// if vmstat != nil {
+// // Swap in and swap out numbers
+// swap["in"] = common.MapStr{
+// "pages": vmstat.Pswpin,
+// }
+// swap["out"] = common.MapStr{
+// "pages": vmstat.Pswpout,
+// }
+// //Swap readahead
+// //See https://www.kernel.org/doc/ols/2007/ols2007v2-pages-273-284.pdf
+// swap["readahead"] = common.MapStr{
+// "pages": vmstat.SwapRa,
+// "cached": vmstat.SwapRaHit,
+// }
+// }
// for backwards compatibility, only report if we're not in fleet mode
- if !m.IsAgent {
- err := linux.FetchLinuxMemStats(memory)
- if err != nil {
- return errors.Wrap(err, "error getting page stats")
- }
- }
+// if !m.IsAgent {
+// err := linux.FetchLinuxMemStats(memory)
+// if err != nil {
+// return errors.Wrap(err, "error getting page stats")
+// }
+// }
memory["swap"] = swap
memory is once again working for me 