From 0bd2979fa762928b70d10f13cc8b97e45d358541 Mon Sep 17 00:00:00 2001 From: Alex K <8418476+fearful-symmetry@users.noreply.github.com> Date: Tue, 3 Nov 2020 06:45:05 -0800 Subject: [PATCH] Treat session ID as a string in system/users (#22359) * treat session ID as a string * add changelog * Update wording on CHANGELOG.next.asciidoc Co-authored-by: kaiyan-sheng Co-authored-by: kaiyan-sheng (cherry picked from commit 7826ef6be27cf3d3c951327fafac569426c91778) --- CHANGELOG.next.asciidoc | 3 +++ metricbeat/module/system/users/dbus.go | 9 ++------- metricbeat/module/system/users/users_test.go | 2 +- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.next.asciidoc b/CHANGELOG.next.asciidoc index 77bc9c336d8..2705a1b732e 100644 --- a/CHANGELOG.next.asciidoc +++ b/CHANGELOG.next.asciidoc @@ -432,6 +432,7 @@ field. You can revert this change by configuring tags for the module and omittin - Revert change to report `process.memory.rss` as `process.memory.wss` on Windows. {pull}22055[22055] - Add interval information to `monitor` metricset in azure. {pull}22152[22152] - Remove io.time from windows {pull}22237[22237] +- Change Session ID type from int to string {pull}22359[22359] *Packetbeat* @@ -925,3 +926,5 @@ field. You can revert this change by configuring tags for the module and omittin ==== Known Issue *Journalbeat* + + diff --git a/metricbeat/module/system/users/dbus.go b/metricbeat/module/system/users/dbus.go index 03dbc9fc3a7..3d8177f3d76 100644 --- a/metricbeat/module/system/users/dbus.go +++ b/metricbeat/module/system/users/dbus.go @@ -48,7 +48,7 @@ type sessionInfo struct { // loginSession contains basic information on a login session type loginSession struct { - ID uint64 + ID string UID uint32 User string Seat string @@ -167,16 +167,11 @@ func formatSessionList(props [][]dbus.Variant) ([]loginSession, error) { if len(session) < 5 { return nil, fmt.Errorf("wrong number of fields in session: %v", session) } - idStr, ok := session[0].Value().(string) + id, ok := session[0].Value().(string) if !ok { return nil, fmt.Errorf("failed to cast user ID to string") } - id, err := strconv.ParseUint(idStr, 10, 32) - if err != nil { - return nil, errors.Wrap(err, "error parsing ID to int") - } - uid, ok := session[1].Value().(uint32) if !ok { return nil, fmt.Errorf("failed to cast session uid to uint32") diff --git a/metricbeat/module/system/users/users_test.go b/metricbeat/module/system/users/users_test.go index 50de07a6eee..11a6a09bdee 100644 --- a/metricbeat/module/system/users/users_test.go +++ b/metricbeat/module/system/users/users_test.go @@ -61,7 +61,7 @@ func TestFormatSessionList(t *testing.T) { } goodOut := []loginSession{{ - ID: uint64(6), + ID: "6", UID: uint32(1000), User: "user", Seat: "",