Module: Vidibus::Sysinfo::System
- Extended by:
- Base
- Defined in:
- lib/vidibus/sysinfo/system.rb
Overview
Returns number of CPUs on this system.
Analyzes lscpu
Defined Under Namespace
Classes: Result
Class Method Summary collapse
Methods included from Base
Methods included from Helper
Class Method Details
.command ⇒ Object
16 17 18 |
# File 'lib/vidibus/sysinfo/system.rb', line 16 def command() 'lscpu' end |
.explain(error) ⇒ Object
33 34 35 36 37 |
# 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) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 |
# 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 |