# Metricbeat v7 on FreeBSD system module / memory not working

**URL:** https://discuss.elastic.co/t/metricbeat-v7-on-freebsd-system-module-memory-not-working/266390
**Category:** Beats
**Tags:** metricbeat
**Created:** [March 5, 2021, 4:07pm UTC](https://discuss.elastic.co/t/metricbeat-v7-on-freebsd-system-module-memory-not-working/266390 "2021-03-05T16:07:59Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![michbsd](https://avatars.discourse-cdn.com/v4/letter/m/b77776/32.png) [@michbsd](https://discuss.elastic.co/u/michbsd)
#### Post date: [March 5, 2021, 4:07pm UTC](https://discuss.elastic.co/t/metricbeat-v7-on-freebsd-system-module-memory-not-working/266390/1 "2021-03-05T16:07:59Z")

</div>

metricbeat version 7.10.1 (amd64), libbeat 7.10.1 [v7.10.1 built 2021-02-02 03:16:09 +0000 UTC]

Hi,

According to the reference ([System memory metricset | Metricbeat Reference [7.11] | Elastic](https://www.elastic.co/guide/en/beats/metricbeat/current/metricbeat-metricset-system-memory.html)) the memory metricset is available for FreeBSD.

However, when enabling it - you get the following error:  
2021-03-05T16:40:58.220+0100 INFO module/wrapper.go:259 Error fetching data for metricset system.memory: VMStat: failed to read self process information: unimplemented

VMStat seems to be called from metricbeat/module/system/memory/memory.go#89 and declared in libbeat/metric/system/memory/memory.go#156

and imported from:  
sysinfo "[github.com/elastic/go-sysinfo](http://github.com/elastic/go-sysinfo)"  
sysinfotypes "[github.com/elastic/go-sysinfo/types](http://github.com/elastic/go-sysinfo/types)"

Looking at the go-sysinfo it seems this does not yet support FreeBSD: [GitHub - elastic/go-sysinfo: go-sysinfo is a library for collecting system information.](https://github.com/elastic/go-sysinfo)

Any chance we could fallback to sigar when OS is FreeBSD?

Thanks

---

<div class="post-metadata">

### Author: ![michbsd](https://avatars.discourse-cdn.com/v4/letter/m/b77776/32.png) [@michbsd](https://discuss.elastic.co/u/michbsd)
#### Post date: [March 5, 2021, 8:14pm UTC](https://discuss.elastic.co/t/metricbeat-v7-on-freebsd-system-module-memory-not-working/266390/2 "2021-03-05T20:14:50Z")

</div>

In order to disable VMStat (as this won't work on a FreeBSD system) I changed the code as such:

```auto
--- 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 😉

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [April 2, 2021, 10:15pm UTC](https://discuss.elastic.co/t/metricbeat-v7-on-freebsd-system-module-memory-not-working/266390/3 "2021-04-02T22:15:17Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
