Class: NagiosWebbedLog
- Inherits:
-
Sinatra::Base
- Object
- Sinatra::Base
- NagiosWebbedLog
- Defined in:
- lib/nagios_webbed_log.rb
Instance Method Summary collapse
Instance Method Details
#get_params ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/nagios_webbed_log.rb', line 58 def get_params if params[:year] && (2000..2050).map(&:to_s).include?(params[:year]) @year = params[:year] else @year = "0" end if params[:month] && (1..12).map(&:to_s).map{|s| s.rjust(2, "0") }.include?(params[:month]) @month = params[:month] else @month = "0" end if params[:day] && (1..31).map(&:to_s).map{|s| s.rjust(2, "0") }.include?(params[:day]) @day = params[:day] else @day = "0" end end |
#load_dates ⇒ Object
76 77 78 79 80 81 |
# File 'lib/nagios_webbed_log.rb', line 76 def load_dates @names_list = load_file_list(ENV["NAGIOS_LOG"]) @years = @names_list.map{|n| n.split("-") }.map{|n| n[3] }.uniq @days = @names_list.map{|n| n.split("-") }.map{|n| n[2] }.uniq @months = @names_list.map{|n| n.split("-") }.map{|n| n[1] }.uniq end |
#load_events ⇒ Object
47 48 49 50 51 52 53 54 55 56 |
# File 'lib/nagios_webbed_log.rb', line 47 def load_events lines = load_files(ENV["NAGIOS_LOG"],"nagios-#{@month.to_i == 0 ? '*' : @month}-#{@day.to_i == 0 ? '*' : @day}-#{@year.to_i == 0 ? '*' : @year}-*.log") sites = {} lines.compact.map{|l| parse_line(l) }.compact.each do |hsh| place_host(hsh, sites) end sort_sites(sites) events = make_events(sites) events end |