Metricbeat v7 on FreeBSD system module / memory not working

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) 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"
sysinfotypes "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.

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

Thanks

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 :wink:

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