Class: Cuboid::System::Platforms::Windows
- Defined in:
- lib/cuboid/system/platforms/windows.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#disk_space_free ⇒ Integer
Amount of free disk in bytes.
-
#memory_for_process_group(pgid) ⇒ Integer
Amount of RAM in bytes used by the given GPID.
-
#memory_free ⇒ Integer
Amount of free RAM in bytes.
Methods inherited from Base
#_exec, #cpu_count, #disk_directory, #disk_space_for_process, inherited
Class Method Details
Instance Method Details
#disk_space_free ⇒ Integer
Returns Amount of free disk in bytes.
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/cuboid/system/platforms/windows.rb', line 54 def disk_space_free device_id = disk_directory.split( '/' ).first drives = wmi.ExecQuery( "select FreeSpace from win32_LogicalDisk where DeviceID='#{device_id}'" ) space = nil drives.each do |drive| space = drive.freeSpace.to_i drive.ole_free end drives.ole_free space end |
#memory_for_process_group(pgid) ⇒ Integer
Returns Amount of RAM in bytes used by the given GPID.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/cuboid/system/platforms/windows.rb', line 36 def memory_for_process_group( pgid ) processes = wmi.ExecQuery( "select PrivatePageCount from win32_process where ProcessID='#{pgid}' or ParentProcessID='#{pgid}'" ) memory = 0 processes.each do |process| # Not actually pages but bytes, no idea why. memory += process.privatePageCount.to_i process.ole_free end processes.ole_free memory end |
#memory_free ⇒ Integer
Returns Amount of free RAM in bytes.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/cuboid/system/platforms/windows.rb', line 16 def memory_free result = wmi.ExecQuery( 'select AvailableBytes from Win32_PerfFormattedData_PerfOS_Memory' ) memory = nil result.each do |e| memory = e.availableBytes.to_i e.ole_free end result.ole_free memory end |