Class: NewRelic::Security::Agent::Control::Health
- Inherits:
-
Object
- Object
- NewRelic::Security::Agent::Control::Health
- Defined in:
- lib/newrelic_security/agent/control/health_check.rb
Instance Attribute Summary collapse
-
#jsonName ⇒ Object
readonly
Returns the value of attribute jsonName.
-
#serviceStatus ⇒ Object
readonly
Returns the value of attribute serviceStatus.
-
#stats ⇒ Object
readonly
Returns the value of attribute stats.
Instance Method Summary collapse
- #as_json ⇒ Object
-
#initialize ⇒ Health
constructor
A new instance of Health.
- #to_json ⇒ Object
- #update_health_check ⇒ Object
Constructor Details
#initialize ⇒ Health
Returns a new instance of Health.
9 10 11 12 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 41 42 |
# File 'lib/newrelic_security/agent/control/health_check.rb', line 9 def initialize @collectorType = RUBY @language = Ruby @jsonName = :LAhealthcheck @eventType = :sec_health_check_lc = current_time_millis @version = EMPTY_STRING @groupName = NewRelic::Security::Agent.config[:mode] @policyVersion = nil @framework = NewRelic::Security::Agent.config[:framework] @protectedServer = nil @applicationUUID = NewRelic::Security::Agent.config[:uuid] @appAccountId = NewRelic::Security::Agent.config[:account_id] @appEntityGuid = NewRelic::Security::Agent.config[:entity_guid] @collectorVersion = NewRelic::Security::VERSION @buildNumber = nil @jsonVersion = NewRelic::Security::Agent.config[:json_version] @eventSentCount = 0 @eventProcessed = 0 @eventDropCount = 0 @httpRequestCount = 0 @protectedVulnerabilties = nil @protectedDB = nil @linkingMetadata = @stats = {} @serviceStatus = {} # TODO: Fill this @iastEventStats = {} @raspEventStats = {} @exitEventStats = {} @procStartTime = NewRelic::Security::Agent.config[:process_start_time] @trafficStartedTime = NewRelic::Security::Agent.config[:traffic_start_time] @scanStartTime = NewRelic::Security::Agent.config[:scan_start_time] @iastTestIdentifer = NewRelic::Security::Agent.config[:'security.iast_test_identifier'] end |
Instance Attribute Details
#jsonName ⇒ Object (readonly)
Returns the value of attribute jsonName.
7 8 9 |
# File 'lib/newrelic_security/agent/control/health_check.rb', line 7 def jsonName @jsonName end |
#serviceStatus ⇒ Object (readonly)
Returns the value of attribute serviceStatus.
7 8 9 |
# File 'lib/newrelic_security/agent/control/health_check.rb', line 7 def serviceStatus @serviceStatus end |
#stats ⇒ Object (readonly)
Returns the value of attribute stats.
7 8 9 |
# File 'lib/newrelic_security/agent/control/health_check.rb', line 7 def stats @stats end |
Instance Method Details
#as_json ⇒ Object
44 45 46 47 48 |
# File 'lib/newrelic_security/agent/control/health_check.rb', line 44 def as_json instance_variables.map! do |ivar| [ivar[1..-1].to_sym, instance_variable_get(ivar)] end.to_h end |
#to_json ⇒ Object
50 51 52 |
# File 'lib/newrelic_security/agent/control/health_check.rb', line 50 def to_json as_json.to_json end |
#update_health_check ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/newrelic_security/agent/control/health_check.rb', line 54 def update_health_check @httpRequestCount = NewRelic::Security::Agent.agent.http_request_count.fetch_and_reset_counter @eventProcessed = NewRelic::Security::Agent.agent.event_processed_count.fetch_and_reset_counter @eventSentCount = NewRelic::Security::Agent.agent.event_sent_count.fetch_and_reset_counter @eventDropCount = NewRelic::Security::Agent.agent.event_drop_count.fetch_and_reset_counter @stats[:nCores] = nil # TODO: add cpu count here @stats[:systemTotalMemoryMB] = system_total_memory_mb @stats[:systemFreeMemoryMB] = system_free_memory_mb @stats[:systemCpuLoad] = system_cpu_load @stats[:processCpuUsage] = nil @stats[:processRssMB] = nil # TODO: add process rss here @stats[:processMaxHeapMB] = nil @stats[:processHeapUsageMB] = nil @stats[:processDirDiskFreeSpaceMB] = nil @stats[:rootDiskFreeSpaceMB] = nil @serviceStatus[:websocket] = NewRelic::Security::Agent::Control::WebsocketClient.instance.is_open? ? 'OK' : 'Error' @serviceStatus[:logWriter] = NewRelic::Security::Agent.logger ? 'OK' : 'Error' @serviceStatus[:initLogWriter] = NewRelic::Security::Agent.init_logger ? 'OK' : 'Error' @serviceStatus[:agentActiveStat] = NewRelic::Security::Agent.config[:enabled] ? 'OK' : 'Error' @serviceStatus[:iastRestClient] = NewRelic::Security::Agent::Utils.is_IAST? && !NewRelic::Security::Agent.agent.iast_client ? 'Error' : 'OK' @iastEventStats = NewRelic::Security::Agent.agent.iast_event_stats.prepare_for_health_check @raspEventStats = NewRelic::Security::Agent.agent.rasp_event_stats.prepare_for_health_check @exitEventStats = NewRelic::Security::Agent.agent.exit_event_stats.prepare_for_health_check rescue Exception => exception NewRelic::Security::Agent::logger.error "Exception in finding update_health_check : #{exception.inspect} #{exception.backtrace}" end |