Sha256: ffc2e2ea0af210187246fddeb5e139f2777bedb65250d09d0e874a554438302e

Contents?: true

Size: 1.79 KB

Versions: 3

Compression:

Stored size: 1.79 KB

Contents

$: << File.join(File.absolute_path(__FILE__), '..', 'lib')

require "pulse_meter_core"

PulseMeter.redis = Redis.new

cfg = PulseMeter::Sensor::Configuration.new(
  lama_count: {
    sensor_type:'timelined/counter',
    args: {
      annotation: 'Lama Count',
      interval: 10,
      ttl: 3600
    }
  },

  lama_count_1min: {
    sensor_type:'timelined/counter',
    args: {
      annotation: 'Lama Count (1 min)',
      interval: 60,
      ttl: 3600
    }
  },

  lama_average_age: {
    sensor_type:'timelined/average',
    args: {
      annotation: 'Lama Average Age',
      interval: 20,
      ttl: 3600
    }
  },

  rhino_count: {
    sensor_type:'timelined/counter',
    args: {
      annotation: 'Rhino Count',
      interval: 10,
      ttl: 3600
    }
  },

  goose_count: {
    sensor_type:'timelined/hashed_counter',
    args: {
      annotation: 'Goose Count',
      interval: 10,
      ttl: 3600
    }
  },

  rhino_average_age: {
    sensor_type:'timelined/average',
    args: {
      annotation: 'Rhino average age',
      interval: 20,
      ttl: 3600
    }
  },

  sensor_without_annotation: {
    sensor_type:'timelined/average',
    args: {
      interval: 20,
      ttl: 3600
    }
  },

  cpu: {sensor_type: 'indicator'},
  memory: {sensor_type: 'indicator'},
  temperature: {
    sensor_type: 'hashed_indicator',
    args: {
      annotation: 'T'
    }
  }
)

while true
  sleep(Random.rand)
  STDERR.puts "tick"
  cfg.lama_count(Random.rand(10_000_000))
  cfg.lama_count_1min(10)
  cfg.rhino_count(-Random.rand(10_000))
  cfg.lama_average_age(Random.rand(50))
  cfg.rhino_average_age(Random.rand(100))

  10.times do
    goose_n = Random.rand(4)
    cfg.goose_count("g_#{goose_n}" => 1)
    cfg.temperature("g_#{goose_n}" => Random.rand(50))
  end

  cfg.cpu(Random.rand(100))
  cfg.memory(Random.rand(100))
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
pulse_meter-dygraphs_visualizer-0.4.25 examples/basic_sensor_data.rb
pulse_meter-dygraphs_visualizer-0.4.23 examples/basic_sensor_data.rb
pulse_meter-dygraphs_visualizer-0.4.22 examples/basic_sensor_data.rb