Module: Mool::Command
- Defined in:
- lib/mool/command.rb
Class Method Summary collapse
- .all_partitions ⇒ Object
-
.cpuinfo ⇒ Object
CPU COMMANDS.
- .df ⇒ Object
- .file_system ⇒ Object
- .holders(path) ⇒ Object
- .loadavg ⇒ Object
-
.logical_name(path) ⇒ Object
DISK COMMANDS.
-
.meminfo ⇒ Object
MEMORY COMMANDS.
- .mount ⇒ Object
- .mpstat ⇒ Object
- .partitions(devname) ⇒ Object
-
.ps ⇒ Object
PROCESS COMMANDS.
- .root_block_device?(devname) ⇒ Boolean
- .swap(lname = nil) ⇒ Object
- .top ⇒ Object
- .uevent(path) ⇒ Object
-
.uname ⇒ Object
SYSTEM COMMANDS.
- .uptime ⇒ Object
Class Method Details
.all_partitions ⇒ Object
47 48 49 |
# File 'lib/mool/command.rb', line 47 def self.all_partitions File.read('/proc/partitions') end |
.cpuinfo ⇒ Object
CPU COMMANDS
5 6 7 |
# File 'lib/mool/command.rb', line 5 def self.cpuinfo File.read('/proc/cpuinfo') end |
.df ⇒ Object
35 36 37 |
# File 'lib/mool/command.rb', line 35 def self.df `POSIXLY_CORRECT=512 df` end |
.file_system ⇒ Object
22 23 24 |
# File 'lib/mool/command.rb', line 22 def self.file_system Dir.glob('/sys/fs/**/*') end |
.holders(path) ⇒ Object
43 44 45 |
# File 'lib/mool/command.rb', line 43 def self.holders(path) Dir.glob("#{path}/holders/*").uniq end |
.loadavg ⇒ Object
80 81 82 |
# File 'lib/mool/command.rb', line 80 def self.loadavg File.read('/proc/loadavg').chomp end |
.logical_name(path) ⇒ Object
DISK COMMANDS
14 15 16 |
# File 'lib/mool/command.rb', line 14 def self.logical_name(path) File.read("#{path}/dm/name") rescue nil end |
.meminfo ⇒ Object
MEMORY COMMANDS
61 62 63 |
# File 'lib/mool/command.rb', line 61 def self.meminfo File.read('/proc/meminfo') end |
.mount ⇒ Object
18 19 20 |
# File 'lib/mool/command.rb', line 18 def self.mount File.read('/proc/mounts') end |
.mpstat ⇒ Object
9 10 11 |
# File 'lib/mool/command.rb', line 9 def self.mpstat File.read('|mpstat -P ALL 1 1') end |
.partitions(devname) ⇒ Object
39 40 41 |
# File 'lib/mool/command.rb', line 39 def self.partitions(devname) Dir.glob("/sys/block/#{devname}/#{devname}*") end |
.ps ⇒ Object
PROCESS COMMANDS
66 67 68 69 |
# 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) ⇒ Boolean
51 52 53 54 |
# 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) ⇒ Object
30 31 32 33 |
# File 'lib/mool/command.rb', line 30 def self.swap(lname = nil) result = File.read('/proc/swaps') lname.present? ? result[/#{lname} /] : result end |
.top ⇒ Object
71 72 73 |
# File 'lib/mool/command.rb', line 71 def self.top `top -c -b -n1` end |
.uevent(path) ⇒ Object
26 27 28 |
# File 'lib/mool/command.rb', line 26 def self.uevent(path) File.read("#{path}/uevent") end |
.uname ⇒ Object
SYSTEM COMMANDS
76 77 78 |
# File 'lib/mool/command.rb', line 76 def self.uname `uname -r`.chomp end |
.uptime ⇒ Object
84 85 86 |
# File 'lib/mool/command.rb', line 84 def self.uptime `cat /proc/uptime`.chomp end |