Class: Skutil::Server

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

Class Method Summary collapse

Class Method Details

.dfObject



133
134
135
# File 'lib/skutil.rb', line 133

def self.df
  `/bin/df -h`.chomp
end

.environmentObject



149
150
151
152
153
154
155
156
157
158
# File 'lib/skutil.rb', line 149

def self.environment
  self_methods = self.methods - Class.methods
  self_methods.delete("environment")
  self_methods.delete("execute")
  st = ""
  self_methods.each do |method|
    st << "#{method}:\n  #{self.send(method).to_s.split("\n").join("\n  ")}\n"
  end
  return st
end

.execute(command) ⇒ Object



145
146
147
# File 'lib/skutil.rb', line 145

def self.execute(command)
  `#{command}`.chomp
end

.hostnameObject



129
130
131
# File 'lib/skutil.rb', line 129

def self.hostname
  `/bin/hostname`.chomp
end

.ip_addressObject



116
117
118
119
120
121
122
123
124
125
126
127
# File 'lib/skutil.rb', line 116

def self.ip_address
  ifconfig = `/sbin/ifconfig`
  ips = []
  
  # TODO mac
  ifconfig.gsub(/inet addr:(\d+\.\d+\.\d+\.\d+)/){|ip|
    if $1 != '127.0.0.1'
      ips << $1
    end
  }
  return ips
end

.netstatObject



141
142
143
# File 'lib/skutil.rb', line 141

def self.netstat
  `/usr/sbin/netstat -an`.chomp
end

.psObject



137
138
139
# File 'lib/skutil.rb', line 137

def self.ps
  `/bin/ps -ef`.chomp
end