class PoiseMonit::Resources::MonitCheck::Resource
A `monit_check` resource to write out a Monit
configuration file with a service check.
@provides monit_check @action create @action delete @example
monit_check 'httpd' do check 'if failed port 80 protocol http request "/_status" then restart' end
Private Instance Methods
_if_process(value)
click to toggle source
Helper for default values that only apply to process checks.
@param value [Object] Value to return for process checks. @return [Object, nil]
# File lib/poise_monit/resources/monit_check.rb, line 121 def _if_process(value) if check_type.to_s.downcase == 'process' value else nil end end
_init_command(action)
click to toggle source
Find the right command to control the init system. This checks systemctl, service, and then gives up and uses /etc/init.d.
@param action [String] Init action to run. @return [String, nil]
# File lib/poise_monit/resources/monit_check.rb, line 134 def _init_command(action) cmd = if systemctl = PoiseLanguages::Utils.which('systemctl') "#{systemctl} #{action} #{check_name}" elsif service = PoiseLanguages::Utils.which('service') "#{service} #{check_name} #{action}" else # ¯\_(ツ)_/¯ "/etc/init.d/#{check_name} #{action}" end _if_process(cmd) end
default_start_program()
click to toggle source
Default start program value.
@return [String]
# File lib/poise_monit/resources/monit_check.rb, line 106 def default_start_program _init_command('start') end
default_stop_program()
click to toggle source
Default stop program value.
@return [String]
# File lib/poise_monit/resources/monit_check.rb, line 113 def default_stop_program _init_command('stop') end
default_with()
click to toggle source
Default WITH-ish value.
@return [String]
# File lib/poise_monit/resources/monit_check.rb, line 99 def default_with _if_process("PIDFILE /var/run/#{check_name}.pid") end