Class: InfluxDB::Process::Instrumentation
- Inherits:
-
Object
- Object
- InfluxDB::Process::Instrumentation
- Defined in:
- lib/influxdb/process.rb
Instance Method Summary collapse
-
#initialize(influxdb, memory_series: nil, object_series: nil, interval: nil, process: nil) ⇒ Instrumentation
constructor
A new instance of Instrumentation.
- #instrument ⇒ Object
- #start ⇒ Object
Constructor Details
#initialize(influxdb, memory_series: nil, object_series: nil, interval: nil, process: nil) ⇒ Instrumentation
Returns a new instance of Instrumentation.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/influxdb/process.rb', line 9 def initialize(influxdb, memory_series: nil, object_series: nil, interval: nil, process: nil) @influxdb = influxdb @memory_series = memory_series || 'process_memory' @object_series = object_series || 'process_objects' @interval = interval || 10 @process = ENV['INFLUXDB_PROCESS_NAME'] || process || $PROGRAM_NAME @tags = {process: @process} @pid = ::Process.pid @system_memory_file = "/proc/#{@pid}/statm" @can_read_system_memory = File.exist?(@system_memory_file) @page_size = `getconf PAGESIZE`.to_i rescue 4096 @memory = {} @objects = {} end |
Instance Method Details
#instrument ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/influxdb/process.rb', line 27 def instrument update_memory update_objects @influxdb.write_point(@memory_series, tags: @tags, values: @memory) @influxdb.write_point(@object_series, tags: @tags, values: @objects) end |
#start ⇒ Object
35 36 37 38 39 40 41 42 |
# File 'lib/influxdb/process.rb', line 35 def start Thread.new do loop do instrument sleep(@interval) end end end |