module Vidibus::Sysinfo::System

Returns number of CPUs on this system.

Analyzes lscpu

Public Class Methods

command() click to toggle source
# File lib/vidibus/sysinfo/system.rb, line 16
def command()
  'lscpu'
end
explain(error) click to toggle source
# File lib/vidibus/sysinfo/system.rb, line 33
def explain(error)
  if error.match('lscpu: command not found')
    return 'lscpu is not installed. On Debian you can install it with "apt-get install lscpu"'
  end
end
parse(output) click to toggle source
# File lib/vidibus/sysinfo/system.rb, line 20
def parse(output)
  sockets = output[/Socket\(s\):\s+(\d+)/i, 1]
  cores = output[/Core\(s\) per socket:\s+(\d+)/i, 1]
  cpus = output[/CPU\(s\):\s+(\d+)/i, 1]
  if sockets && cores && cpus
    Result.new({
      sockets: sockets.to_i,
      cores: cores.to_i,
      cpus: cpus.to_i
    })
  end
end