Class: Informo::System
- Inherits:
-
Object
- Object
- Informo::System
- 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
-
#arch ⇒ Object
returns the architecture of the system (i386, x86_64, etc).
-
#distro ⇒ Object
returns the linux distro.
-
#hostname ⇒ Object
returns the hostname of the system.
-
#kernel ⇒ Object
returns the running kernel version.
-
#numa? ⇒ Boolean
returns a boolean for wether or not numa is being used.
-
#version ⇒ Object
returns the version of the linux distro.
Instance Method Details
#arch ⇒ Object
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 |
#distro ⇒ Object
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 |
#hostname ⇒ Object
returns the hostname of the system
46 47 48 |
# File 'lib/informo/system.rb', line 46 def hostname return Socket.gethostname end |
#kernel ⇒ Object
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
26 27 28 29 |
# File 'lib/informo/system.rb', line 26 def numa? enabled = system("numactl","-s") ? true : false return enabled end |
#version ⇒ Object
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 |