class Splash::Processes::ProcessNotifier
Public Class Methods
new(options={})
click to toggle source
# File lib/splash/processes.rb, line 21 def initialize(options={}) @config = get_config @url = @config.prometheus_pushgateway_url @name = options[:name] @status = options[:status] @cpu_percent = options[:cpu_percent] @mem_percent = options[:mem_percent] end
Public Instance Methods
notify()
click to toggle source
send metrics to Prometheus PushGateway @return [Bool]
# File lib/splash/processes.rb, line 32 def notify unless verify_service url: @url then return { :case => :service_dependence_missing, :more => "Prometheus Notification not send."} end @@metric_mem_percent.set(@mem_percent, labels: { process: @name }) @@metric_cpu_percent.set(@cpu_percent, labels: { process: @name }) @@metric_status.set(@status, labels: { process: @name }) hostname = Socket.gethostname return Prometheus::Client::Push.new("Splash", hostname, @url).add(@@registry) end