Class: Nagios
- Inherits:
-
Object
- Object
- Nagios
- Defined in:
- lib/nagios.rb
Instance Attribute Summary collapse
-
#all ⇒ Object
Returns the value of attribute all.
-
#db ⇒ Object
Returns the value of attribute db.
-
#problems ⇒ Object
Returns the value of attribute problems.
Instance Method Summary collapse
- #by_host(host) ⇒ Object
- #by_status(status) ⇒ Object
- #host_list ⇒ Object
-
#initialize(config) ⇒ Nagios
constructor
A new instance of Nagios.
- #status_list ⇒ Object
Constructor Details
#initialize(config) ⇒ Nagios
Returns a new instance of Nagios.
6 7 8 9 10 11 12 |
# File 'lib/nagios.rb', line 6 def initialize (config) @db = Influx.new(config['influxdb']['host'], config['nagios']['dbname'], config['influxdb']['port'], config['influxdb']['user'], config['influxdb']['password']) @status = NagiosAnalyzer::Status.new(config['nagios']['file'], include_ok: true) @all = @status.service_items @problems = @status.service_problems return @status end |
Instance Attribute Details
#all ⇒ Object
Returns the value of attribute all.
3 4 5 |
# File 'lib/nagios.rb', line 3 def all @all end |
#db ⇒ Object
Returns the value of attribute db.
2 3 4 |
# File 'lib/nagios.rb', line 2 def db @db end |
#problems ⇒ Object
Returns the value of attribute problems.
4 5 6 |
# File 'lib/nagios.rb', line 4 def problems @problems end |
Instance Method Details
#by_host(host) ⇒ Object
30 31 32 33 |
# File 'lib/nagios.rb', line 30 def by_host(host) issues = self.all.select{ |service| service.host_name == host} return issues end |
#by_status(status) ⇒ Object
35 36 37 38 |
# File 'lib/nagios.rb', line 35 def by_status(status) issues = self.all.select{ |service| service.status == status} return issues end |
#host_list ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/nagios.rb', line 14 def host_list() host_list = [] self.all.each do |service| host_list << service.host_name end host_list.uniq!.sort! end |
#status_list ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/nagios.rb', line 22 def status_list() status_list = [] self.all.each do |service| status_list << service.status end status_list.uniq!.sort! end |