module Mool::Command

Public Class Methods

all_partitions() click to toggle source
# File lib/mool/command.rb, line 47
def self.all_partitions
  File.read('/proc/partitions')
end
cpuinfo() click to toggle source

CPU COMMANDS

# File lib/mool/command.rb, line 5
def self.cpuinfo
  File.read('/proc/cpuinfo')
end
df() click to toggle source
# File lib/mool/command.rb, line 35
def self.df
  `POSIXLY_CORRECT=512 df`
end
file_system() click to toggle source
# File lib/mool/command.rb, line 22
def self.file_system
  Dir.glob('/sys/fs/**/*')
end
holders(path) click to toggle source
# File lib/mool/command.rb, line 43
def self.holders(path)
  Dir.glob("#{path}/holders/*").uniq
end
loadavg() click to toggle source
# File lib/mool/command.rb, line 80
def self.loadavg
  File.read('/proc/loadavg').chomp
end
logical_name(path) click to toggle source

DISK COMMANDS

# File lib/mool/command.rb, line 14
def self.logical_name(path)
  File.read("#{path}/dm/name") rescue nil
end
meminfo() click to toggle source

MEMORY COMMANDS

# File lib/mool/command.rb, line 61
def self.meminfo
  File.read('/proc/meminfo')
end
mount() click to toggle source
# File lib/mool/command.rb, line 18
def self.mount
  File.read('/proc/mounts')
end
mpstat() click to toggle source
# File lib/mool/command.rb, line 9
def self.mpstat
  File.read('|mpstat -P ALL 1 1')
end
partitions(devname) click to toggle source
# File lib/mool/command.rb, line 39
def self.partitions(devname)
  Dir.glob("/sys/block/#{devname}/#{devname}*")
end
ps() click to toggle source

PROCESS COMMANDS

# File lib/mool/command.rb, line 66
def self.ps
  # `ps --no-headers -o pid,user,pcpu,pmem,rss,priority,time,stat,nice,args -A`
  `ps --no-headers -o ruser,user,rgroup,group,pid,ppid,pgid,pcpu,vsz,nice,etime,time,tty,comm,args=HEADER -A`
end
root_block_device?(devname) click to toggle source
# File lib/mool/command.rb, line 51
def self.root_block_device?(devname)
  File.exist?("/sys/block/#{devname}") &&
    !Dir.glob("/sys/block/#{devname}/slaves/*").present?
end
swap(lname = nil) click to toggle source
# File lib/mool/command.rb, line 30
def self.swap(lname = nil)
  result = File.read('/proc/swaps')
  lname.present? ? result[/#{lname} /] : result
end
top() click to toggle source
# File lib/mool/command.rb, line 71
def self.top
  `top -c -b -n1`
end
uevent(path) click to toggle source
# File lib/mool/command.rb, line 26
def self.uevent(path)
  File.read("#{path}/uevent")
end
uname() click to toggle source

SYSTEM COMMANDS

# File lib/mool/command.rb, line 76
def self.uname
  `uname -r`.chomp
end
uptime() click to toggle source
# File lib/mool/command.rb, line 84
def self.uptime
  `cat /proc/uptime`.chomp
end