Class: ISPMonitor::Checks::HealthcheckCheck

Inherits:
BaseCheck
  • Object
show all
Defined in:
lib/isp_monitor/checks/healthcheck_check.rb

Constant Summary collapse

DEFAULT_URL =
"https://hc-ping.com/5d4cb729-4c3a-405c-8e6c-c4d8c3d266c5"

Instance Attribute Summary collapse

Attributes inherited from BaseCheck

#config, #interval, #name

Instance Method Summary collapse

Methods inherited from BaseCheck

#run

Constructor Details

#initialize(config) ⇒ HealthcheckCheck

Returns a new instance of HealthcheckCheck.



7
8
9
10
11
# File 'lib/isp_monitor/checks/healthcheck_check.rb', line 7

def initialize(config)
  super(config)
  @url = config.fetch(:url, DEFAULT_URL)
  @uri = URI(@url)
end

Instance Attribute Details

#uriObject (readonly)

Returns the value of attribute uri.



5
6
7
# File 'lib/isp_monitor/checks/healthcheck_check.rb', line 5

def uri
  @uri
end

#urlObject (readonly)

Returns the value of attribute url.



4
5
6
# File 'lib/isp_monitor/checks/healthcheck_check.rb', line 4

def url
  @url
end

Instance Method Details

#checkObject



13
14
15
16
17
18
19
# File 'lib/isp_monitor/checks/healthcheck_check.rb', line 13

def check
  res = Net::HTTP.get_response(uri)

  log_event 'healthcheck', {
    response_code: res.code
  }
end