class Bark::Client

The Client class is the primary communicator between the program and the

Attributes

host[R]

‘:host` = The hostname of the Monit server `:port` = The port used to connect to the Monit server `:user` = The username used for basic auth with Monit server `:password` = The password used for basic auth with Monit server `:status` = The status xml api endpoint client `:server` = The server section retrieved via the status xml api `:platform` = The platform section retrieved via the status xml api `:service` = The service section retrieved via the status xml api

password[R]

‘:host` = The hostname of the Monit server `:port` = The port used to connect to the Monit server `:user` = The username used for basic auth with Monit server `:password` = The password used for basic auth with Monit server `:status` = The status xml api endpoint client `:server` = The server section retrieved via the status xml api `:platform` = The platform section retrieved via the status xml api `:service` = The service section retrieved via the status xml api

platform[R]

‘:host` = The hostname of the Monit server `:port` = The port used to connect to the Monit server `:user` = The username used for basic auth with Monit server `:password` = The password used for basic auth with Monit server `:status` = The status xml api endpoint client `:server` = The server section retrieved via the status xml api `:platform` = The platform section retrieved via the status xml api `:service` = The service section retrieved via the status xml api

port[R]

‘:host` = The hostname of the Monit server `:port` = The port used to connect to the Monit server `:user` = The username used for basic auth with Monit server `:password` = The password used for basic auth with Monit server `:status` = The status xml api endpoint client `:server` = The server section retrieved via the status xml api `:platform` = The platform section retrieved via the status xml api `:service` = The service section retrieved via the status xml api

server[R]

‘:host` = The hostname of the Monit server `:port` = The port used to connect to the Monit server `:user` = The username used for basic auth with Monit server `:password` = The password used for basic auth with Monit server `:status` = The status xml api endpoint client `:server` = The server section retrieved via the status xml api `:platform` = The platform section retrieved via the status xml api `:service` = The service section retrieved via the status xml api

service[R]

‘:host` = The hostname of the Monit server `:port` = The port used to connect to the Monit server `:user` = The username used for basic auth with Monit server `:password` = The password used for basic auth with Monit server `:status` = The status xml api endpoint client `:server` = The server section retrieved via the status xml api `:platform` = The platform section retrieved via the status xml api `:service` = The service section retrieved via the status xml api

status[R]

‘:host` = The hostname of the Monit server `:port` = The port used to connect to the Monit server `:user` = The username used for basic auth with Monit server `:password` = The password used for basic auth with Monit server `:status` = The status xml api endpoint client `:server` = The server section retrieved via the status xml api `:platform` = The platform section retrieved via the status xml api `:service` = The service section retrieved via the status xml api

user[R]

‘:host` = The hostname of the Monit server `:port` = The port used to connect to the Monit server `:user` = The username used for basic auth with Monit server `:password` = The password used for basic auth with Monit server `:status` = The status xml api endpoint client `:server` = The server section retrieved via the status xml api `:platform` = The platform section retrieved via the status xml api `:service` = The service section retrieved via the status xml api

Public Class Methods

new(opts = {}) click to toggle source
# File lib/bark/client.rb, line 14
def initialize(opts = {})
  default_if_opts_nil opts
  @client = Hurley::Client.new "http://#{@user}:#{@password}"\
                               "@#{@host}:#{@port}"
end

Private Instance Methods

decide_if_default_or_user_input(opt, default) click to toggle source

Checks if the value / option is nil. If it is, use the default value, otherwise, use the user provided input.

@return [‘String`]

# File lib/bark/client.rb, line 66
def decide_if_default_or_user_input(opt, default)
  if opt.nil?
    return default
  else
    return opt
  end
end
default_host() click to toggle source

Monit’s default hostname

@return [‘String`]

# File lib/bark/client.rb, line 77
def default_host
  @host = 'localhost'
end
default_if_opts_nil(opts) click to toggle source

Used to determine whether or not the user provided the Monit server’s hostname, port, username, and password.

@return [‘Symbol`]

# File lib/bark/client.rb, line 54
def default_if_opts_nil(opts)
  @host = decide_if_default_or_user_input opts[:host], default_host
  @port = decide_if_default_or_user_input opts[:port], default_port
  @user = decide_if_default_or_user_input opts[:user], default_user
  @password = decide_if_default_or_user_input opts[:pass], default_password
  :ok
end
default_password() click to toggle source

Monit’s default password

@return [‘String`]

# File lib/bark/client.rb, line 98
def default_password
  @password = 'monit'
end
default_port() click to toggle source

Monit’s default port number

@return [‘String`]

# File lib/bark/client.rb, line 84
def default_port
  @port = '2812'
end
default_user() click to toggle source

Monit’s default username

@return [‘String`]

# File lib/bark/client.rb, line 91
def default_user
  @user = 'admin'
end