Module: Mool::Command

Defined in:
lib/mool/command.rb

Class Method Summary collapse

Class Method Details

.capacity_partition_command(path) ⇒ Object



41
42
43
# File 'lib/mool/command.rb', line 41

def self.capacity_partition_command(path)
  File.read("#{path}/size")
end

.cpuinfo_commandObject



4
5
6
# File 'lib/mool/command.rb', line 4

def self.cpuinfo_command
  File.read('/proc/cpuinfo')
end

.dev_block_commandObject



49
50
51
# File 'lib/mool/command.rb', line 49

def self.dev_block_command
  Dir.glob('/sys/dev/block/*')
end

.dev_name_command(dev_entry) ⇒ Object



16
17
18
# File 'lib/mool/command.rb', line 16

def self.dev_name_command(dev_entry)
  File.read("#{dev_entry}/dev")
end

.df_commandObject



12
13
14
# File 'lib/mool/command.rb', line 12

def self.df_command
  `df`
end

.file_system_commandObject



24
25
26
# File 'lib/mool/command.rb', line 24

def self.file_system_command
  Dir.glob('/sys/fs/**/*')
end

.loadavg_commandObject



86
87
88
# File 'lib/mool/command.rb', line 86

def self.loadavg_command
  File.read('/proc/loadavg').chomp
end

.logical_name_command(path) ⇒ Object



28
29
30
# File 'lib/mool/command.rb', line 28

def self.logical_name_command(path)
  File.exist?("#{path}/dm/name") ? File.read("#{path}/dm/name").chomp : nil
end

.meminfo_commandObject



65
66
67
# File 'lib/mool/command.rb', line 65

def self.meminfo_command
  File.read('/proc/meminfo')
end

.mount_commandObject



20
21
22
# File 'lib/mool/command.rb', line 20

def self.mount_command
  File.read('/proc/mounts')
end

.mpstat_commandObject



8
9
10
# File 'lib/mool/command.rb', line 8

def self.mpstat_command
  File.read('|mpstat -P ALL 1 1')
end

.partitions_command(path, devname) ⇒ Object



45
46
47
# File 'lib/mool/command.rb', line 45

def self.partitions_command(path, devname)
  Dir.glob("#{path}/#{devname}*")
end

.ps_commandObject



69
70
71
72
# File 'lib/mool/command.rb', line 69

def self.ps_command
  # `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

.real_path_block_command(entry) ⇒ Object



53
54
55
# File 'lib/mool/command.rb', line 53

def self.real_path_block_command(entry)
  `readlink -f #{entry}`.chomp
end

.real_path_command_exist?(real_path) ⇒ Boolean

Returns:

  • (Boolean)


57
58
59
# File 'lib/mool/command.rb', line 57

def self.real_path_command_exist?(real_path)
  File.exist?("#{real_path}/partition")
end

.slaves_command(real_path) ⇒ Object



61
62
63
# File 'lib/mool/command.rb', line 61

def self.slaves_command(real_path)
  Dir.glob("#{real_path}/slaves/*")
end

.swap_command(lname = nil) ⇒ Object



36
37
38
39
# File 'lib/mool/command.rb', line 36

def self.swap_command(lname = nil)
  result = File.read('/proc/swaps')
  lname.present? ? result[/#{lname} /] : result
end

.top_commandObject



74
75
76
# File 'lib/mool/command.rb', line 74

def self.top_command
  `top -c -b -n1`
end

.uevent_command(path) ⇒ Object



32
33
34
# File 'lib/mool/command.rb', line 32

def self.uevent_command(path)
  File.read("#{path}/uevent")
end

.uname_commandObject



78
79
80
# File 'lib/mool/command.rb', line 78

def self.uname_command
  `uname -r`.chomp
end

.uptime_commandObject



82
83
84
# File 'lib/mool/command.rb', line 82

def self.uptime_command
  `cat /proc/uptime`.chomp
end