Class: Informo::System

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

Overview

This class is used to get some generic information of the host in question; ie: distro name, version, etc

Instance Method Summary collapse

Instance Method Details

#archObject

returns the architecture of the system (i386, x86_64, etc)



40
41
42
43
# File 'lib/informo/system.rb', line 40

def arch
  arch = `uname -m`.chomp
  return arch
end

#distroObject

returns the linux distro



10
11
12
13
14
15
# File 'lib/informo/system.rb', line 10

def distro
  `lsb_release -i`.each_line do |line|
    distro = $1 if line =~ /.+:\s(.+)$/
    return distro
  end
end

#hostnameObject

returns the hostname of the system



46
47
48
# File 'lib/informo/system.rb', line 46

def hostname
  return Socket.gethostname
end

#kernelObject

returns the running kernel version



32
33
34
35
36
37
# File 'lib/informo/system.rb', line 32

def kernel
  File.open("/proc/version").each_line do |line|
    kernel = $1 if line =~ /version (.+?) /
    return kernel
  end
end

#numa?Boolean

returns a boolean for wether or not numa is being used

Returns:

  • (Boolean)


26
27
28
29
# File 'lib/informo/system.rb', line 26

def numa?
  enabled = system("numactl","-s") ? true : false  
  return enabled
end

#versionObject

returns the version of the linux distro



18
19
20
21
22
23
# File 'lib/informo/system.rb', line 18

def version
  `lsb_release -r`.each_line do |line|
    version = $1 if line =~ /.+:\s(.+)$/
    return version
  end
end