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

- old
+ new

@@ -3,10 +3,13 @@ module Splash class LogScanner include Splash::Constants include Splash::Config + + # LogScanner Constructor + # return [LogScanner] def initialize @logs_target = get_config.logs @config = get_config @registry = Prometheus::Client.registry @metric_count = Prometheus::Client::Gauge.new(:logerrors, docstring: 'SPLASH metric log error', labels: [:log ]) @@ -15,10 +18,12 @@ @registry.register(@metric_count) @registry.register(@metric_missing) @registry.register(@metric_lines) end + + # start log analyse for log target in config def analyse @logs_target.each do |record| record[:count]=0 if record[:count].nil? record[:status] = :clean if record[:status].nil? if File.exist?(record[:log]) then @@ -29,13 +34,15 @@ record[:status] = :missing end end 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