Class: Vmstat::Snapshot

Inherits:
Object
  • Object
show all
Defined in:
lib/vmstat/snapshot.rb

Overview

Snapshots help to gather information about the whole system quickly.

Examples:

Creating a snapshot

snapshop = Vmstat::Snapshop.new(["/dev/disk0", "/dev/disk1"])

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(paths = []) ⇒ Snapshot

Create a new snapshot for system informations. The passed paths array, should contain the disk paths to create a snapshot for.

Parameters:

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

    the paths to create snapshots for



22
23
24
25
26
27
28
29
30
31
# File 'lib/vmstat/snapshot.rb', line 22

def initialize(paths = [])
  @at = Time.now
  @boot_time = Vmstat.boot_time
  @cpus = Vmstat.cpu
  @disks = paths.map { |path| Vmstat.disk(path) }
  @load_average = Vmstat.load_average
  @memory = Vmstat.memory
  @network_interfaces = Vmstat.network_interfaces
  @task = Vmstat.task if Vmstat.respond_to? :task
end

Instance Attribute Details

#atTime

the timestamp, when the snapshot was created.

Returns:

  • (Time)

    the current value of at



15
16
17
# File 'lib/vmstat/snapshot.rb', line 15

def at
  @at
end

#boot_timeTime

the timestamp, when the system booted.

Returns:

  • (Time)

    the current value of boot_time



15
16
17
# File 'lib/vmstat/snapshot.rb', line 15

def boot_time
  @boot_time
end

#cpusArray<Vmstat::Cpu>

the data of each and every cpu.

Returns:



15
16
17
# File 'lib/vmstat/snapshot.rb', line 15

def cpus
  @cpus
end

#disksArray<Vmstat::Disk>

the disks that are part of the snapshot.

Returns:



15
16
17
# File 'lib/vmstat/snapshot.rb', line 15

def disks
  @disks
end

#load_averageVmstat::LoadAverage

current load average at the time when the snapshot toke place.

Returns:



15
16
17
# File 'lib/vmstat/snapshot.rb', line 15

def load_average
  @load_average
end

#memoryVmstat::Memory

the memory data snapshot.

Returns:



15
16
17
# File 'lib/vmstat/snapshot.rb', line 15

def memory
  @memory
end

#network_interfacesArray<Vmstat::NetworkInterface>

the network interface data snapshots per network interface.

Returns:



15
16
17
# File 'lib/vmstat/snapshot.rb', line 15

def network_interfaces
  @network_interfaces
end

#taskVmstat::Task

optionally the information for the current task

Returns:



15
16
17
# File 'lib/vmstat/snapshot.rb', line 15

def task
  @task
end