Class: TCellAgent::SensorEvents::ServerAgentDetailsSensorEvent

Inherits:
TCellSensorEvent
  • Object
show all
Includes:
ModuleLoggerAccess
Defined in:
lib/tcell_agent/sensor_events/server_agent.rb

Instance Attribute Summary

Attributes inherited from TCellSensorEvent

#ensure, #flush, #send

Instance Method Summary collapse

Methods included from ModuleLoggerAccess

#module_logger

Methods inherited from TCellSensorEvent

#bucket_key, #calculate_offset

Constructor Details

#initializeServerAgentDetailsSensorEvent

Returns a new instance of ServerAgentDetailsSensorEvent.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/tcell_agent/sensor_events/server_agent.rb', line 13

def initialize
  super('server_agent_details')
  @flush = true
  @ensure = true

  self['user'] = 'unknown'
  self['group'] = 'unknown'

  begin
     = Etc.getlogin
    if 
      self['user'] = 
      begin
        info = Etc.getpwnam()
        self['group'] = info.gid.to_s
      rescue StandardError => te
        module_logger.debug("Could not get group id: #{te.message}")
        module_logger.exception(te)
      end
    end
  rescue StandardError => to
    module_logger.debug("Could not get user & group: #{to.message}")
    module_logger.exception(te)
  end

  module_logger.debug("User #{self['user']}")
  module_logger.debug("Group #{self['group']}")
end