MCPcopy
hub / github.com/prometheus/node_exporter / getSession

Method getSession

collector/logind_linux.go:235–269  ·  view source on GitHub ↗
(session logindSessionEntry)

Source from the content-addressed store, hash-verified

233}
234
235func (c *logindDbus) getSession(session logindSessionEntry) *logindSession {
236 object := c.conn.Object(dbusObject, session.SessionObjectPath)
237
238 remote, err := object.GetProperty(dbusObject + ".Session.Remote")
239 if err != nil {
240 return nil
241 }
242
243 sessionType, err := object.GetProperty(dbusObject + ".Session.Type")
244 if err != nil {
245 return nil
246 }
247
248 sessionTypeStr, ok := sessionType.Value().(string)
249 if !ok {
250 return nil
251 }
252
253 class, err := object.GetProperty(dbusObject + ".Session.Class")
254 if err != nil {
255 return nil
256 }
257
258 classStr, ok := class.Value().(string)
259 if !ok {
260 return nil
261 }
262
263 return &logindSession{
264 seat: session.SeatID,
265 remote: remote.String(),
266 sessionType: knownStringOrOther(sessionTypeStr, attrTypeValues),
267 class: knownStringOrOther(classStr, attrClassValues),
268 }
269}

Callers

nothing calls this directly

Calls 3

knownStringOrOtherFunction · 0.85
ValueMethod · 0.80
StringMethod · 0.80

Tested by

no test coverage detected