Sha256: 9ffa36088e8b20f3e47eef5052cd011be5148cff34ee04b2e4863ee805ce2d53

Contents?: true

Size: 890 Bytes

Versions: 3

Compression:

Stored size: 890 Bytes

Contents

module Keystone
  class Environment
    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

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

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

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

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

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

    def self.dump
      self_methods = self.methods - Class.methods
      self_methods.delete("dump")
      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
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
kanamei-kanamei-keystone-0.0.10 lib/keystone/environment.rb
kanamei-keystone-0.0.10 lib/keystone/environment.rb
kanamei-keystone-0.0.9 lib/keystone/environment.rb