Module Vmstat::ProcFS
In: lib/vmstat/procfs.rb

Implementation of performance metrics gathering for linux and other os with the proc file system.

Methods

Constants

CPU_DATA = /cpu(\d+)#{'\s+(\d+)' * 4}/.freeze   Grep from the man procfs about cpu data in stat file: @example Format
    (num) user nice system idle iowait irq softirq steal

@example manpage

    iowait - time waiting for I/O to complete (since 2.5.41)
    irq - time servicing interrupts (since 2.6.0-test4)
    softirq - time servicing softirqs (since 2.6.0-test4)
    Since Linux 2.6.11:
    steal - stolen time, which is the time spent in other operating
            systems when running in a virtualized environment
    Since Linux 2.6.24:
    guest - which is the time spent running a virtual CPU for guest
            operating systems under the control of the Linux kernel.
NET_DATA = /(\w+):#{'\s*(\d+)' * 16}/   Grep the network stats from the procfs. @example Format (from /proc/net/dev)
  Inter-|   Receive                                                |  Transmit
   face |bytes    packets errs drop fifo frame compressed multicast|bytes    packets errs drop fifo colls carrier compressed

@example Data

  eth0:   33660     227    0    0    0     0          0         0    36584     167    0    0    0     0       0          0

Public Instance methods

Fetches the boot time of the system. @return [Time] the boot time as regular time object. @example

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

Fetches the cpu statistics (usage counter for user, nice, system and idle) @return [Array<Vmstat::Cpu>] the array of cpu counter @example

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

Fetches the memory usage information. @return [Vmstat::Memory] the memory data like free, used und total. @example

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

Fetches the information for all available network devices. @return [Array<Vmstat::NetworkInterface>] the network device information @example

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

Opens a proc file system file handle and returns the handle in the passed block. Closes the file handle. @see File#open @param [Array<String>] names parts of the path to the procfs file @example

  procfs_file("net", "dev") { |file| }
  procfs_file("stat") { |file| }

@yieldparam [IO] file the file handle @api private

@return [String] the path to the proc file system @example

  procfs_path # => "/proc"

@api private

Fetches the current process cpu and memory data. @return [Vmstat::Task] the task data for the current process

[Validate]