prometheus#proxy_prefix for simplification of PrefixProxy.new. missing @verify for Postfix added.
This commit is contained in:
parent
24858883b4
commit
01677886a2
2 changed files with 20 additions and 12 deletions
|
@ -4,7 +4,7 @@ class Collector
|
||||||
class PrefixProxy
|
class PrefixProxy
|
||||||
attr_reader :prometheus, :prefix
|
attr_reader :prometheus, :prefix
|
||||||
def initialize prometheus, prefix
|
def initialize prometheus, prefix
|
||||||
@prometheus, @prefix = prometheus, prefix
|
@prometheus, @prefix = prometheus, prefix.dup.freeze
|
||||||
end
|
end
|
||||||
|
|
||||||
def counter name, **options
|
def counter name, **options
|
||||||
|
@ -22,6 +22,10 @@ class Collector
|
||||||
def summary name, **options
|
def summary name, **options
|
||||||
@prometheus.summary :"#{prefix}_#{name}", **options
|
@prometheus.summary :"#{prefix}_#{name}", **options
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def prefix_proxy prefix
|
||||||
|
PrefixProxy.new @prometheus, "#{@prefix}_#{prefix}"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.start prometheus: nil, journal: nil
|
def self.start prometheus: nil, journal: nil
|
||||||
|
@ -32,6 +36,9 @@ class Collector
|
||||||
@settings = settings
|
@settings = settings
|
||||||
@journal = journal || Systemd::Journal.new( flags: Systemd::Journal::Flags::SYSTEM_ONLY)
|
@journal = journal || Systemd::Journal.new( flags: Systemd::Journal::Flags::SYSTEM_ONLY)
|
||||||
@prometheus = prometheus || Prometheus::Client.registry
|
@prometheus = prometheus || Prometheus::Client.registry
|
||||||
|
def @prometheus.prefix_proxy prefix
|
||||||
|
PrefixProxy.new self, prefix
|
||||||
|
end
|
||||||
@store = {}
|
@store = {}
|
||||||
|
|
||||||
@errors = @prometheus.counter :postfix_exporter_errors_total, docstring: 'Count internal errors/exceptions'
|
@errors = @prometheus.counter :postfix_exporter_errors_total, docstring: 'Count internal errors/exceptions'
|
||||||
|
|
|
@ -54,8 +54,8 @@ class Collector::Postfix
|
||||||
class Postscreen
|
class Postscreen
|
||||||
def initialize store, prometheus
|
def initialize store, prometheus
|
||||||
@store = store
|
@store = store
|
||||||
@noqueue = Noqueue.new store, Collector::PrefixProxy.new( prometheus, :noqueue)
|
@noqueue = Noqueue.new store, prometheus.prefix_proxy( :noqueue)
|
||||||
@cache = Cache.new store, Collector::PrefixProxy.new( prometheus, :cache)
|
@cache = Cache.new store, prometheus.prefix_proxy( :cache)
|
||||||
@connect_from = prometheus.counter :connect_from_total, docstring: 'A counter of connections to postscreen'
|
@connect_from = prometheus.counter :connect_from_total, docstring: 'A counter of connections to postscreen'
|
||||||
@whitelisted = prometheus.counter :whitelisted_total, docstring: 'A counter of WHITELISTED connections to postscreen'
|
@whitelisted = prometheus.counter :whitelisted_total, docstring: 'A counter of WHITELISTED connections to postscreen'
|
||||||
@pass_old = prometheus.counter :pass_old_total, docstring: 'A counter of PASS OLD connections to postscreen'
|
@pass_old = prometheus.counter :pass_old_total, docstring: 'A counter of PASS OLD connections to postscreen'
|
||||||
|
@ -181,7 +181,7 @@ class Collector::Postfix
|
||||||
class Smtpd
|
class Smtpd
|
||||||
def initialize store, prometheus
|
def initialize store, prometheus
|
||||||
@store = store
|
@store = store
|
||||||
@noqueue = Noqueue.new store, Collector::PrefixProxy.new( prometheus, :noqueue)
|
@noqueue = Noqueue.new store, prometheus.prefix_proxy( :noqueue)
|
||||||
@connect_from = prometheus.counter :connect_from_total, docstring: 'A counter of connections to smtpd', labels: %i[from_unknown]
|
@connect_from = prometheus.counter :connect_from_total, docstring: 'A counter of connections to smtpd', labels: %i[from_unknown]
|
||||||
%w[0 1].each {|x| @connect_from.increment by: 0, labels: {from_unknown: x} }
|
%w[0 1].each {|x| @connect_from.increment by: 0, labels: {from_unknown: x} }
|
||||||
@tls = prometheus.counter :tls_total, docstring: 'A counter of TLS connections to smtpd with TLS-version and cipher', labels: %i[trust tls cipher]
|
@tls = prometheus.counter :tls_total, docstring: 'A counter of TLS connections to smtpd with TLS-version and cipher', labels: %i[trust tls cipher]
|
||||||
|
@ -330,7 +330,7 @@ class Collector::Postfix
|
||||||
class Verify
|
class Verify
|
||||||
def initialize store, prometheus
|
def initialize store, prometheus
|
||||||
@store = store
|
@store = store
|
||||||
@cache = Cache.new store, Collector::PrefixProxy.new( prometheus, :cache)
|
@cache = Cache.new store, prometheus.prefix_proxy( :cache)
|
||||||
end
|
end
|
||||||
|
|
||||||
def collect entry
|
def collect entry
|
||||||
|
@ -344,13 +344,14 @@ class Collector::Postfix
|
||||||
|
|
||||||
def initialize store, prometheus
|
def initialize store, prometheus
|
||||||
@store = store
|
@store = store
|
||||||
@postscreen = Postscreen.new store, Collector::PrefixProxy.new( prometheus, :postscreen)
|
@postscreen = Postscreen.new store, prometheus.prefix_proxy( :postscreen)
|
||||||
@smtp = Smtp.new store, Collector::PrefixProxy.new( prometheus, :smtp)
|
@smtp = Smtp.new store, prometheus.prefix_proxy( :smtp)
|
||||||
@smtpd = Smtpd.new store, Collector::PrefixProxy.new( prometheus, :smtpd)
|
@smtpd = Smtpd.new store, prometheus.prefix_proxy( :smtpd)
|
||||||
@submission = Smtpd.new store, Collector::PrefixProxy.new( prometheus, :submission)
|
@submission = Smtpd.new store, prometheus.prefix_proxy( :submission)
|
||||||
@tlsproxy = Tlsproxy.new store, Collector::PrefixProxy.new( prometheus, :tlsproxy)
|
@tlsproxy = Tlsproxy.new store, prometheus.prefix_proxy( :tlsproxy)
|
||||||
@scache = SCache.new store, Collector::PrefixProxy.new( prometheus, :scache)
|
@scache = SCache.new store, prometheus.prefix_proxy( :scache)
|
||||||
@bounce = Bounce.new store, Collector::PrefixProxy.new( prometheus, :bounce)
|
@bounce = Bounce.new store, prometheus.prefix_proxy( :bounce)
|
||||||
|
@verify = Verify.new store, prometheus.prefix_proxy( :verify)
|
||||||
@qmgr = prometheus.counter :qmgr_total, docstring: 'A counter of qmgr actions'
|
@qmgr = prometheus.counter :qmgr_total, docstring: 'A counter of qmgr actions'
|
||||||
@cleanup = prometheus.counter :cleanup_total, docstring: 'A counter of cleanup actions'
|
@cleanup = prometheus.counter :cleanup_total, docstring: 'A counter of cleanup actions'
|
||||||
@lmtp = prometheus.counter :lmtp_total, docstring: 'A counter of ltmp actions'
|
@lmtp = prometheus.counter :lmtp_total, docstring: 'A counter of ltmp actions'
|
||||||
|
|
Loading…
Add table
Reference in a new issue