Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cherry-pick #22359 to 7.x: Treat session ID as a string in system/users #22391

Merged
merged 1 commit into from
Nov 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -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*

Expand Down Expand Up @@ -925,3 +926,5 @@ field. You can revert this change by configuring tags for the module and omittin
==== Known Issue

*Journalbeat*

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe these are not needed


9 changes: 2 additions & 7 deletions metricbeat/module/system/users/dbus.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion metricbeat/module/system/users/users_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func TestFormatSessionList(t *testing.T) {
}

goodOut := []loginSession{{
ID: uint64(6),
ID: "6",
UID: uint32(1000),
User: "user",
Seat: "",
Expand Down