lib/splash/logs.rb in prometheus-splash-0.1.0 vs lib/splash/logs.rb in prometheus-splash-0.1.1

- old
+ new

@@ -1,7 +1,6 @@ -require 'socket' - +# coding: utf-8 module Splash class LogScanner include Splash::Constants include Splash::Config @@ -32,23 +31,22 @@ record[:lines] = `wc -l "#{record[:log]}"`.strip.split(/\s+/)[0].to_i unless record[:status] == :missing else record[:status] = :missing end end + return {:case => :quiet_exit } end # pseudo-accessor on @logs_target def output return @logs_target end # start notification on prometheus for metric logerrors, logmissing; loglines def notify unless verify_service host: @config.prometheus_pushgateway_host ,port: @config.prometheus_pushgateway_port then - $stderr.puts "Prometheus PushGateway Service IS NOT running" - $stderr.puts "Exit without notification." - exit 30 + return { :case => :service_dependence_missing, :more => "Prometheus Notification not send." } end puts "Sending metrics to Prometheus Pushgateway" @logs_target.each do |item| missing = (item[:status] == :missing)? 1 : 0 puts " * Sending metrics for #{item[:log]}" @@ -59,9 +57,10 @@ end hostname = Socket.gethostname url = "http://#{@config.prometheus_pushgateway_host}:#{@config.prometheus_pushgateway_port}" Prometheus::Client::Push.new('Splash',hostname, url).add(@registry) puts "Sending done." + return {:case => :quiet_exit } end end end