Module: OkComputer

Defined in:
lib/ok_computer/registry.rb,
lib/ok_computer/check.rb,
lib/ok_computer/engine.rb,
lib/ok_computer/version.rb,
lib/ok_computer/configuration.rb,
lib/ok_computer/check_collection.rb,
lib/ok_computer/built_in_checks/http_check.rb,
lib/ok_computer/built_in_checks/ping_check.rb,
lib/ok_computer/built_in_checks/solr_check.rb,
lib/ok_computer/built_in_checks/cache_check.rb,
lib/ok_computer/built_in_checks/neo4j_check.rb,
lib/ok_computer/built_in_checks/redis_check.rb,
lib/ok_computer/built_in_checks/sequel_check.rb,
lib/ok_computer/built_in_checks/default_check.rb,
lib/ok_computer/built_in_checks/mongoid_check.rb,
lib/ok_computer/built_in_checks/optional_check.rb,
lib/ok_computer/built_in_checks/rabbitmq_check.rb,
lib/ok_computer/built_in_checks/directory_check.rb,
lib/ok_computer/legacy_rails_controller_support.rb,
lib/ok_computer/built_in_checks/app_version_check.rb,
lib/ok_computer/built_in_checks/resque_down_check.rb,
app/controllers/ok_computer/ok_computer_controller.rb,
lib/ok_computer/built_in_checks/ruby_version_check.rb,
lib/ok_computer/built_in_checks/action_mailer_check.rb,
lib/ok_computer/built_in_checks/active_record_check.rb,
lib/ok_computer/built_in_checks/elasticsearch_check.rb,
lib/ok_computer/built_in_checks/generic_cache_check.rb,
lib/ok_computer/built_in_checks/size_threshold_check.rb,
lib/ok_computer/built_in_checks/sidekiq_latency_check.rb,
lib/ok_computer/built_in_checks/resque_backed_up_check.rb,
lib/ok_computer/built_in_checks/resque_scheduler_check.rb,
lib/ok_computer/built_in_checks/mongoid_replica_set_check.rb,
lib/ok_computer/built_in_checks/delayed_job_backed_up_check.rb,
lib/ok_computer/built_in_checks/active_record_migrations_check.rb,
lib/ok_computer/built_in_checks/resque_failure_threshold_check.rb

Overview

Private: Storage of the checks which have been registered with OkComputer.

No one is expected to interact directly with this class, but rather through the outer OkComputer interface.

Defined Under Namespace

Modules: LegacyRailsControllerSupport Classes: ActionMailerCheck, ActiveRecordCheck, ActiveRecordMigrationsCheck, AppVersionCheck, CacheCheck, Check, CheckCollection, DefaultCheck, DelayedJobBackedUpCheck, DirectoryCheck, ElasticsearchCheck, Engine, GenericCacheCheck, HttpCheck, MongoidCheck, MongoidReplicaSetCheck, Neo4jCheck, OkComputerController, OptionalCheck, PingCheck, RabbitmqCheck, RedisCheck, Registry, ResqueBackedUpCheck, ResqueDownCheck, ResqueFailureThresholdCheck, ResqueSchedulerCheck, RubyVersionCheck, SequelCheck, SidekiqLatencyCheck, SizeThresholdCheck, SolrCheck

Constant Summary collapse

VERSION =
'1.18.4'

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.analytics_ignoreObject

Public: Option to disable third-party app performance tools (.e.g NewRelic) from counting OkComputer routes towards their total.



59
60
61
# File 'lib/ok_computer/configuration.rb', line 59

def analytics_ignore
  @analytics_ignore
end

.check_in_parallelObject

Public: whether to execute checks in parallel.



56
57
58
# File 'lib/ok_computer/configuration.rb', line 56

def check_in_parallel
  @check_in_parallel
end

.loggerObject

Public: Logger to use to log check results



62
63
64
# File 'lib/ok_computer/configuration.rb', line 62

def logger
  @logger
end

.mount_atObject

Public: The route to automatically mount the OkComputer engine. Setting to false prevents OkComputer from automatically mounting itself.



53
54
55
# File 'lib/ok_computer/configuration.rb', line 53

def mount_at
  @mount_at
end

.optionsObject

Private: The options container



71
72
73
# File 'lib/ok_computer/configuration.rb', line 71

def options
  @options
end

.passwordObject

Private: The password for access to checks



68
69
70
# File 'lib/ok_computer/configuration.rb', line 68

def password
  @password
end

.usernameObject

Private: The username for access to checks



65
66
67
# File 'lib/ok_computer/configuration.rb', line 65

def username
  @username
end

Class Method Details

.authenticate(username_try, password_try) ⇒ Object

Public: Attempt to authenticate against required username and password

username - Username to authenticate with password - Password to authenticate with

Returns a Boolean



28
29
30
31
32
# File 'lib/ok_computer/configuration.rb', line 28

def self.authenticate(username_try, password_try)
  return true unless requires_authentication?

  username == username_try && password == password_try
end

.make_optional(checks) ⇒ Object

Public: Mark listed checks as optional



44
45
46
47
48
# File 'lib/ok_computer/configuration.rb', line 44

def self.make_optional(checks)
  checks.each do |check|
    OkComputer::Registry.register check, OkComputer::OptionalCheck.new(OkComputer::Registry.fetch(check))
  end
end

.require_authentication(username, password, options = {}) ⇒ Object

Public: Configure HTTP Basic authentication

username - Username required to view checks password - Password required to view checks options - Hash of additional options

- except - Array of checks to skip authentication for

Examples:

OkComputer.require_authentication("foo", "bar")
# => Require authentication with foo:bar for all checks

OkComputer.require_authentication("foo", "bar", except: %w(default nonsecret))
# => Require authentication with foo:bar for all checks except the checks named "default" and "nonsecret"


16
17
18
19
20
# File 'lib/ok_computer/configuration.rb', line 16

def self.require_authentication(username, password, options = {})
  self.username = username
  self.password = password
  self.options = options
end

.requires_authentication?(params = {}) ⇒ Boolean

Public: Whether OkComputer is configured to require authentication

Returns a Boolean

Returns:

  • (Boolean)


37
38
39
40
41
# File 'lib/ok_computer/configuration.rb', line 37

def self.requires_authentication?(params={})
  return false if params[:action] == "show" && whitelist.include?(params[:check])

  username && password
end

.whitelistObject

# Private: Configure a whitelist of checks to skip authentication



74
75
76
# File 'lib/ok_computer/configuration.rb', line 74

def whitelist
  options.fetch(:except) { [] }
end