Module: Vmstat

Extended by:
Stub
Defined in:
lib/vmstat.rb,
lib/vmstat/cpu.rb,
lib/vmstat/disk.rb,
lib/vmstat/stub.rb,
lib/vmstat/task.rb,
lib/vmstat/memory.rb,
lib/vmstat/procfs.rb,
lib/vmstat/version.rb,
lib/vmstat/snapshot.rb,
lib/vmstat/linux_disk.rb,
lib/vmstat/load_average.rb,
lib/vmstat/network_interface.rb,
ext/vmstat/vmstat.c

Overview

This is a focused and fast library to get system information like:

  • Memory (free, active, …)

  • Network Interfaces (name, in bytes, out bytes, …)

  • CPU (user, system, nice, idle)

  • Load Average

  • Disk (type, disk path, free bytes, total bytes, …)

  • Boot Time

  • Current Task (used bytes and usage time MACOSX or LINUX ONLY)

Defined Under Namespace

Modules: ProcFS, Stub Classes: Cpu, Disk, LinuxDisk, LoadAverage, Memory, NetworkInterface, Snapshot, Task

Constant Summary collapse

VERSION =
"2.1.1"

Class Method Summary collapse

Class Method Details

.boot_timeTime

Fetches the boot time of the system.

Examples:

Vmstat.boot_time # => 2012-10-09 18:42:37 +0200

Returns:

  • (Time)

    the boot time as regular time object.



# File 'lib/vmstat.rb', line 25

.cpuArray<Vmstat::Cpu>

Fetches the cpu statistics (usage counter for user, nice, system and idle)

Examples:

Vmstat.cpu # => [#<struct Vmstat::Cpu ...>, #<struct Vmstat::Cpu ...>]

Returns:



# File 'lib/vmstat.rb', line 31

.disk(path) ⇒ Vmstat::Disk

Fetches the usage data and other useful disk information for the given path.

Examples:

Vmstat.disk("/") # => #<struct Vmstat::Disk type=:hfs, ...>

Parameters:

  • path (String)

    the path (mount point or device path) to the disk

Returns:



# File 'lib/vmstat.rb', line 37

.ethernet_devicesArray<NetworkInterface>

Filters all available ethernet devices.

Returns:



86
87
88
# File 'lib/vmstat.rb', line 86

def self.ethernet_devices
  network_interfaces.select(&:ethernet?)
end

.load_averageVmstat::LoadAverage

Fetches the load average for the current system.

Examples:

Vmstat.load_average # => #<struct Vmstat::LoadAverage one_minute=...>

Returns:



# File 'lib/vmstat.rb', line 44

.loopback_devicesArray<NetworkInterface>

Filters all available loopback devices.

Returns:



92
93
94
# File 'lib/vmstat.rb', line 92

def self.loopback_devices
  network_interfaces.select(&:loopback?)
end

.memoryVmstat::Memory

Fetches the memory usage information.

Examples:

Vmstat.memory # => #<struct Vmstat::Memory ...>

Returns:



# File 'lib/vmstat.rb', line 50

.network_interfacesArray<Vmstat::NetworkInterface>

Fetches the information for all available network devices.

Examples:

Vmstat.network_interfaces # => [#<struct Vmstat::NetworkInterface ...>, ...]

Returns:



# File 'lib/vmstat.rb', line 56

.pagesizeFixnum

Fetches pagesize of the current system.

Examples:

Vmstat.pagesize # => 4096

Returns:

  • (Fixnum)

    the pagesize of the current system in bytes.



# File 'lib/vmstat.rb', line 62

.snapshot(paths = ["/"]) ⇒ Vmstat::Snapshot

Creates a full snapshot of the systems hardware statistics.

Examples:

Vmstat.snapshot # => #<struct Vmstat::Snapshot ...>

Parameters:

  • paths (Array<String>) (defaults to: ["/"])

    the paths to the disks to snapshot.

Returns:



80
81
82
# File 'lib/vmstat.rb', line 80

def self.snapshot(paths = ["/"])
  Snapshot.new(paths)
end

.taskArray<Vmstat::Task>

Note:

Currently only on Mac OS X

Fetches time and memory usage for the current process.

Examples:

Vmstat.task # => #<struct Vmstat::Task ...>

Returns:



# File 'lib/vmstat.rb', line 68