Skip to content

Commit

Permalink
code quality cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
fearful-symmetry committed Mar 3, 2020
1 parent 133500b commit 8d9d42e
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 13 deletions.
2 changes: 1 addition & 1 deletion metricbeat/module/system/users/_meta/docs.asciidoc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
The system/users metricset reports logged in users and associated sessions via dbus and logind, which is a system component. By default, the metricset will look in `/var/run/dbus/` for a system socket, although a new path can be selected with `DBUS_SYSTEM_BUS_ADDRESS`.
The system/users metricset reports logged in users and associated sessions via dbus and logind, which is a systemd component. By default, the metricset will look in `/var/run/dbus/` for a system socket, although a new path can be selected with `DBUS_SYSTEM_BUS_ADDRESS`.

This metricset is available on:

Expand Down
6 changes: 3 additions & 3 deletions metricbeat/module/system/users/dbus.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// specific language governing permissions and limitations
// under the License.

//+build !netbsd
//+build linux

package users

Expand Down Expand Up @@ -88,10 +88,10 @@ func getSessionProps(conn *dbus.Conn, path dbus.ObjectPath) (sessionInfo, error)
return sessionInfo{}, errors.Wrap(err, "error calling DBus")
}

return formatSessonProps(props)
return formatSessionProps(props)
}

func formatSessonProps(props map[string]dbus.Variant) (sessionInfo, error) {
func formatSessionProps(props map[string]dbus.Variant) (sessionInfo, error) {
if len(props) < 8 {
return sessionInfo{}, fmt.Errorf("wrong number of fields in info: %v", props)
}
Expand Down
8 changes: 1 addition & 7 deletions metricbeat/module/system/users/users.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// specific language governing permissions and limitations
// under the License.

//+build !netbsd
//+build linux

package users

Expand Down Expand Up @@ -53,11 +53,6 @@ type MetricSet struct {
func New(base mb.BaseMetricSet) (mb.MetricSet, error) {
cfgwarn.Beta("The system users metricset is beta.")

config := struct{}{}
if err := base.Module().UnpackConfig(&config); err != nil {
return nil, err
}

conn, err := initDbusConnection()
if err != nil {
return nil, errors.Wrap(err, "error connecting to dbus")
Expand All @@ -74,7 +69,6 @@ func New(base mb.BaseMetricSet) (mb.MetricSet, error) {
// format. It publishes the event which is then forwarded to the output. In case
// of an error set the Error field of mb.Event or simply call report.Error().
func (m *MetricSet) Fetch(report mb.ReporterV2) error {

sessions, err := listSessions(m.conn)
if err != nil {
return errors.Wrap(err, "error listing sessions")
Expand Down
4 changes: 2 additions & 2 deletions metricbeat/module/system/users/users_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// specific language governing permissions and limitations
// under the License.

//+build !netbsd
//+build linux

package users

Expand Down Expand Up @@ -50,7 +50,7 @@ func TestFormatSession(t *testing.T) {
Leader: 17459,
}

output, err := formatSessonProps(testIn)
output, err := formatSessionProps(testIn)
assert.NoError(t, err)
assert.Equal(t, goodOut, output)
}
Expand Down

0 comments on commit 8d9d42e

Please sign in to comment.