class Bark::Server
The Server
class hits the Status
Monit API endpoint and then segments it accordingly
Public Class Methods
# File lib/bark/server.rb, line 6 def initialize(client) @client = client @status = Bark::Status.new client end
Public Instance Methods
Retrieves the platform’s control file path
@return [String] ‘“/Users/jdoe/.monitrc”`
# File lib/bark/server.rb, line 70 def control_file @status.current[:monit][:server][:controlfile] end
Retrieves the platform’s hostname
@return [String] ‘“JohnDoe-Laptop.com”`
# File lib/bark/server.rb, line 63 def hostname @status.current[:monit][:server][:localhostname] end
Retrieves the platform’s httpd instance object
@return [Hash] ‘{:address=>“localhost”, :port=>“2812”, :ssl=>“0”}`
# File lib/bark/server.rb, line 77 def httpd @status.current[:monit][:server][:httpd] end
Retrieves the platform’s httpd instance address / hostname
@return [String] ‘“localhost”`
# File lib/bark/server.rb, line 84 def httpd_address @status.current[:monit][:server][:httpd][:address] end
Retrieves the platform’s httpd instance port number
@return [String] ‘“2812”`
# File lib/bark/server.rb, line 91 def httpd_port @status.current[:monit][:server][:httpd][:port] end
Retrieves the platform’s httpd instance SSL boolean (binary)
@return [String] ‘“0”`
# File lib/bark/server.rb, line 98 def httpd_ssl @status.current[:monit][:server][:httpd][:ssl] end
Retrieves the platform’s id
@return [String] ‘“4674ff31c162bba574525571642b67fd”`
# File lib/bark/server.rb, line 21 def id @status.current[:monit][:server][:id] end
Retrieves the platform’s incarnation
@return [String] ‘“1443740471”`
# File lib/bark/server.rb, line 28 def incarnation @status.current[:monit][:server][:incarnation] end
Retrieves the platform’s monit version number
@return [String] ‘“5.14”`
# File lib/bark/server.rb, line 35 def monit_version @status.current[:monit][:server][:version] end
Retrieves the platform’s polling rate
@return [String] ‘“30”`
# File lib/bark/server.rb, line 49 def poll @status.current[:monit][:server][:poll] end
Retrieves the platform’s start delay time
@return [String] ‘“0”`
# File lib/bark/server.rb, line 56 def start_delay @status.current[:monit][:server][:startdelay] end
Retrieves the server’s status
@return [Hash] ‘{:id=>“4674ff31c162bba574525571642b67fd”, :incarnation=>“1443740471”, :version=>“5.14”, :uptime=>“14536”, :poll=>“30”, :startdelay=>“0”, :localhostname=>“JohnDoe-Laptop.com”, :controlfile=>“/Users/jdoe/.monitrc”, :httpd=>{:address=>“localhost”, :port=>“2812”, :ssl=>“0”}}`
# File lib/bark/server.rb, line 14 def status @status.current[:monit][:server] end
Retrieves the platform’s uptime
@return [String] ‘“14536”`
# File lib/bark/server.rb, line 42 def uptime @status.current[:monit][:server][:uptime] end
Private Instance Methods
Validates whether we successfully retrieved the response or if we got an unknown / unexpected error.
@return [Hash]
# File lib/bark/server.rb, line 108 def validate(response) if response.status_type == :success document = Hash.from_xml(response.body) else fail StandardError, 'An unknown error occurred.' end document end