Class: Bark::Platform

Inherits:
Object
  • Object
show all
Defined in:
lib/bark/platform.rb

Overview

The Platform class hits the Status Monit API endpoint and then segments it accordingly

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Platform

Returns a new instance of Platform.



6
7
8
9
# File 'lib/bark/platform.rb', line 6

def initialize(client)
  @client = client
  @status = Bark::Status.new client
end

Instance Method Details

#cpuString

Retrieves the platform's aggregate (user / system) CPU usage

Returns:



58
59
60
# File 'lib/bark/platform.rb', line 58

def cpu
  @status.current[:monit][:platform][:cpu]
end

#full`Hash`

Retrieves the full platform object

{ :name => "Darwin", :release => "15.0.0", :version => "Darwin Kernel Version 15.0.0: Wed Aug 26 16:57:32 PDT 2015; root:xnu-3247.1.106~1/RELEASE_X86_64", :machine => "x86_64", :cpu => "4", :memory => "16777216", :swap => "0" }

Returns:



23
24
25
# File 'lib/bark/platform.rb', line 23

def full
  @status.current[:monit][:platform]
end

#machineString

Retrieves the platform's machine type

Returns:



51
52
53
# File 'lib/bark/platform.rb', line 51

def machine
  @status.current[:monit][:platform][:machine]
end

#memoryString

Retrieves the platform's total RAM (used & available)

Returns:



65
66
67
# File 'lib/bark/platform.rb', line 65

def memory
  @status.current[:monit][:platform][:memory]
end

#nameString

Retrieves the platform's name

Returns:



30
31
32
# File 'lib/bark/platform.rb', line 30

def name
  @status.current[:monit][:platform][:name]
end

#releaseString

Retrieves the platform's release number

Returns:



37
38
39
# File 'lib/bark/platform.rb', line 37

def release
  @status.current[:monit][:platform][:release]
end

#swapString

Retrieves the platform's total swap (used & available)

Returns:



72
73
74
# File 'lib/bark/platform.rb', line 72

def swap
  @status.current[:monit][:platform][:swap]
end

#versionString

Retrieves the platform's version number

Returns:

  • (String)

    "Darwin Kernel Version 15.0.0: Wed Aug 26 16:57:32 PDT 2015; root:xnu-3247.1.106~1/RELEASE_X86_64"



44
45
46
# File 'lib/bark/platform.rb', line 44

def version
  @status.current[:monit][:platform][:version]
end