Class: Bipbip::Plugin::Monit
- Inherits:
-
Bipbip::Plugin
- Object
- Bipbip::Plugin
- Bipbip::Plugin::Monit
- Defined in:
- lib/bipbip/plugin/monit.rb
Constant Summary collapse
- MONITOR_NOT =
0x0
- MONITOR_YES =
0x1
- MONITOR_INIT =
0x2
- MONITOR_WAITING =
0x4
Instance Attribute Summary
Attributes inherited from Bipbip::Plugin
#config, #frequency, #metric_group, #name, #tags
Instance Method Summary collapse
Methods inherited from Bipbip::Plugin
factory, factory_from_plugin, #initialize, #metrics_names, #run, #source_identifier
Methods included from InterruptibleSleep
#interrupt_sleep, #interruptible_sleep
Constructor Details
This class inherits a constructor from Bipbip::Plugin
Instance Method Details
#metrics_schema ⇒ Object
11 12 13 14 15 16 |
# 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 ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# 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 |