Class: Nagios

Inherits:
Object
  • Object
show all
Defined in:
lib/nagios.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#allObject

Returns the value of attribute all.



3
4
5
# File 'lib/nagios.rb', line 3

def all
  @all
end

#dbObject

Returns the value of attribute db.



2
3
4
# File 'lib/nagios.rb', line 2

def db
  @db
end

#problemsObject

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_listObject



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_listObject



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