class Bipbip::Plugin::Monit
Constants
- MONITOR_INIT
- MONITOR_NOT
- MONITOR_WAITING
- MONITOR_YES
Public Instance Methods
metrics_schema()
click to toggle source
# File lib/bipbip/plugin/monit.rb, line 11 def metrics_schema [ { name: 'Running', type: 'gauge', unit: 'Boolean' }, { name: 'All_Services_ok', type: 'gauge', unit: 'Boolean' } ] end
monitor()
click to toggle source
# File lib/bipbip/plugin/monit.rb, line 18 def monitor status = ::Monit::Status.new({ host: 'localhost', port: 2812, ssl: false, auth: false, username: nil, password: nil }.merge(config)) data = Hash.new(0) begin data['Running'] = status.get ? 1 : 0 data['All_Services_ok'] = status.services.any? do |service| error_flags_bitmap = service.status.to_i monitor_status = service.monitor.to_i (monitor_status == MONITOR_NOT) || error_flags_bitmap.nonzero? end ? 0 : 1 rescue data['Running'] = 0 data['All_Services_ok'] = 0 end data end