From 0edd258bbc8fc7f3403de90eff2df566f0ef3a5c Mon Sep 17 00:00:00 2001 From: Christoph Wurm Date: Mon, 3 Dec 2018 23:51:38 +0100 Subject: [PATCH 1/3] Disable user metricset on non-Linux systems. --- x-pack/auditbeat/module/system/user/user.go | 2 ++ .../module/system/user/users_other.go | 21 +++++++++++++++---- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/x-pack/auditbeat/module/system/user/user.go b/x-pack/auditbeat/module/system/user/user.go index 652e9d62ce54..82e12a11d19e 100644 --- a/x-pack/auditbeat/module/system/user/user.go +++ b/x-pack/auditbeat/module/system/user/user.go @@ -2,6 +2,8 @@ // or more contributor license agreements. Licensed under the Elastic License; // you may not use this file except in compliance with the Elastic License. +// +build linux,cgo + package user import ( diff --git a/x-pack/auditbeat/module/system/user/users_other.go b/x-pack/auditbeat/module/system/user/users_other.go index 8bc466989029..da9351dc9712 100644 --- a/x-pack/auditbeat/module/system/user/users_other.go +++ b/x-pack/auditbeat/module/system/user/users_other.go @@ -7,10 +7,23 @@ package user import ( - "github.com/pkg/errors" + "fmt" + + "github.com/elastic/beats/metricbeat/mb" +) + +const ( + moduleName = "system" + metricsetName = "user" ) -// GetUsers is not implemented on all systems. -func GetUsers() (users []*User, err error) { - return nil, errors.New("not implemented") +func init() { + mb.Registry.MustAddMetricSet(moduleName, metricsetName, New, + mb.DefaultMetricSet(), + ) +} + +// New returns an error. +func New(base mb.BaseMetricSet) (mb.MetricSet, error) { + return nil, fmt.Errorf("the %v/%v dataset is only supported on Linux", moduleName, metricsetName) } From 14b3d9618e764a6e9507429f9fa8ddf0294a3aec Mon Sep 17 00:00:00 2001 From: Christoph Wurm Date: Tue, 4 Dec 2018 00:01:41 +0100 Subject: [PATCH 2/3] Add build flags to test file. --- x-pack/auditbeat/module/system/user/user_test.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/x-pack/auditbeat/module/system/user/user_test.go b/x-pack/auditbeat/module/system/user/user_test.go index d142b833c049..ccb606f4d24d 100644 --- a/x-pack/auditbeat/module/system/user/user_test.go +++ b/x-pack/auditbeat/module/system/user/user_test.go @@ -2,6 +2,8 @@ // or more contributor license agreements. Licensed under the Elastic License; // you may not use this file except in compliance with the Elastic License. +// +build linux,cgo + package user import ( From 9271626e89adb1174e0e4ab00e3bf2a5699a9c25 Mon Sep 17 00:00:00 2001 From: Christoph Wurm Date: Tue, 4 Dec 2018 00:02:41 +0100 Subject: [PATCH 3/3] Skip system test on non-Linux systems. --- x-pack/auditbeat/tests/system/test_metricsets.py | 1 + 1 file changed, 1 insertion(+) diff --git a/x-pack/auditbeat/tests/system/test_metricsets.py b/x-pack/auditbeat/tests/system/test_metricsets.py index 2cc220105bf5..d56310745368 100644 --- a/x-pack/auditbeat/tests/system/test_metricsets.py +++ b/x-pack/auditbeat/tests/system/test_metricsets.py @@ -60,6 +60,7 @@ def test_metricset_socket(self): if "network.type" not in str(e): raise + @unittest.skipUnless(sys.platform == "linux2", "Only implemented for Linux") def test_metricset_user(self): """ user metricset collects information about users on a server.