module Mastercontrol::Server
Public Class Methods
disk_usage()
click to toggle source
# File lib/mastercontrol/server.rb, line 58 def self.disk_usage url = "#{Mastercontrol.base_url}/getdiskusage?api.version=1" response = RestClient.get url, {authorization: Mastercontrol.auth_header} # parse the json json_response = JSON.parse(response) return_array = [] # loop through partitions and create/add their DiskPartion objects to the return array json_response["data"]["partition"].each do |part| return_array << DiskPartition.new(part["disk"], part["filesystem"], part["mount"], part["used"], part["percentage"], part["total"], part["available"]) end # return the array of DiskPartition Objects return_array end
hostname()
click to toggle source
# File lib/mastercontrol/server.rb, line 47 def self.hostname url = "#{Mastercontrol.base_url}/gethostname?api.version=1" response = RestClient.get url, {authorization: Mastercontrol.auth_header} # parse the json json_response = JSON.parse(response) # build and return the ServerHostname Object ServerHostname.new(json_response['data']['hostname']) end
system_load_avg()
click to toggle source
# File lib/mastercontrol/server.rb, line 36 def self.system_load_avg url = "#{Mastercontrol.base_url}/systemloadavg?api.version=1" response = RestClient.get url, {authorization: Mastercontrol.auth_header} # parse the json json_response = JSON.parse(response) # build and return the ServerLoad Object ServerLoad.new(json_response["data"]["one"], json_response["data"]["five"], json_response["data"]["fifteen"]) end