Class: NewRelic::IA::IostatReader

Inherits:
Object
  • Object
show all
Includes:
MetricNames
Defined in:
lib/new_relic/ia/iostat_reader.rb

Overview

The iostat reader simply opens a pipe on the iostat command, listening every 15 seconds and taking a sample for RPM. It runs on the thread of the caller of the #run method.

There are implementations of the command reader for different platforms. The implementations are in modules which are included into the Monitor class.

Defined Under Namespace

Modules: Linux, OSX

Constant Summary

Constants included from MetricNames

MetricNames::DISK, MetricNames::DISK_IO, MetricNames::MEMCACHED, MetricNames::SYSTEM_CPU, MetricNames::USER_CPU

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeIostatReader

Returns a new instance of IostatReader.



13
14
15
16
17
18
19
20
21
22
# File 'lib/new_relic/ia/iostat_reader.rb', line 13

def initialize
  stats_engine = NewRelic::Agent.instance.stats_engine
  @io_stats    = stats_engine.get_stats(DISK_IO, false)  # Usage in MB
  @system_cpu  = stats_engine.get_stats(SYSTEM_CPU, false)  # percentage utilization
  @user_cpu    = stats_engine.get_stats(USER_CPU, false)  # percentage utilization
  
  # Open the iostat reporting every 15 seconds cumulative
  # values for disk transfers and cpu utilization
  @pipe        = IO.popen(cmd)
end

Instance Attribute Details

#io_statsObject (readonly)

Returns the value of attribute io_stats.



12
13
14
# File 'lib/new_relic/ia/iostat_reader.rb', line 12

def io_stats
  @io_stats
end

#system_cpuObject (readonly)

Returns the value of attribute system_cpu.



12
13
14
# File 'lib/new_relic/ia/iostat_reader.rb', line 12

def system_cpu
  @system_cpu
end

#user_cpuObject (readonly)

Returns the value of attribute user_cpu.



12
13
14
# File 'lib/new_relic/ia/iostat_reader.rb', line 12

def user_cpu
  @user_cpu
end

Class Method Details

.logObject



24
25
26
# File 'lib/new_relic/ia/iostat_reader.rb', line 24

def self.log
  NewRelic::IA::CLI.log
end

Instance Method Details

#logObject



28
29
30
# File 'lib/new_relic/ia/iostat_reader.rb', line 28

def log
  self.class.log
end

#runObject



43
44
45
46
# File 'lib/new_relic/ia/iostat_reader.rb', line 43

def run
  init
  read_next while true
end