Skip to content

Commit

Permalink
[Auditbeat] Disable user metricset on non-Linux systems (elastic#9368)
Browse files Browse the repository at this point in the history
Adds additional build flags to the new user metricset to prevent build failures on non-Linux systems. If it is configured, it will now throw an error and abort the launch.
  • Loading branch information
Christoph Wurm committed Dec 15, 2018
1 parent 30f3ce4 commit 1e3f4bf
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
2 changes: 2 additions & 0 deletions x-pack/auditbeat/module/system/user/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
2 changes: 2 additions & 0 deletions x-pack/auditbeat/module/system/user/user_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
21 changes: 17 additions & 4 deletions x-pack/auditbeat/module/system/user/users_other.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
1 change: 1 addition & 0 deletions x-pack/auditbeat/tests/system/test_metricsets.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 1e3f4bf

Please sign in to comment.