Module: System

Extended by:
System
Included in:
System
Defined in:
lib/bettercap/monkey/system.rb

Overview

Instance Method Summary collapse

Instance Method Details

#cpu_countObject



17
18
19
20
21
22
23
24
# File 'lib/bettercap/monkey/system.rb', line 17

def cpu_count
  return Java::Java.lang.Runtime.getRuntime.availableProcessors if defined? Java::Java
  return File.read('/proc/cpuinfo').scan(/^processor\s*:/).size if File.exist? '/proc/cpuinfo'
  require 'win32ole'
  WIN32OLE.connect("winmgmts://").ExecQuery("select * from Win32_ComputerSystem").NumberOfProcessors
rescue LoadError
  Integer `sysctl -n hw.ncpu 2>/dev/null` rescue 4
end