Sha256: 1f2b0b3df0e28ab8bb62728e0602dad698b13bd332d2a3fa002c15c11c561c0a

Contents?: true

Size: 693 Bytes

Versions: 1

Compression:

Stored size: 693 Bytes

Contents

module Splash
  class CommandWrapper
    def initialize(name)
      @name = name
    end

    def ack
      puts "Sending ack for command : '#{@name}'"
      notify(0)
      exit 0
    end

    def notify(value)
      registry = Prometheus::Client.registry
      metric = Prometheus::Client::Gauge.new(:errorcode, docstring: 'SPLASH metric batch errorcode')
      registry.register(metric)
      metric.set(value)
      Prometheus::Client::Push.new(@name).add(registry)
    end


    def call_and_notify
      puts "Executing command : '#{@name}' and notify Prometheus PushGateway"
      system("#{@name} > /dev/null")
      exit_code = $?.exitstatus
      notify(exit_code)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
prometheus-splash-0.0.1 lib/splash/command.rb