lib/nagiosharder.rb in nagiosharder-0.2.0 vs lib/nagiosharder.rb in nagiosharder-0.2.1
- old
+ new
@@ -261,18 +261,22 @@
end
private
- def formatted_time_for(time)
+ def nagios_time_format
if @version.to_i < 3
- time.strftime("%m-%d-%Y %H:%M:%S")
- else
- time.strftime("%Y-%m-%d %H:%M:%S")
+ "%m-%d-%Y %H:%M:%S"
+ else
+ "%Y-%m-%d %H:%M:%S"
end
end
+ def formatted_time_for(time)
+ time.strftime(time_format)
+ end
+
def parse_status_html(response)
doc = Nokogiri::HTML(response)
rows = doc.css('table.status > tr')
last_host = nil
@@ -319,10 +323,11 @@
service = service_links[0].inner_html
end
status = columns[2].inner_html if columns[2]
last_check = if columns[3]
- datetime = DateTime.strptime(columns[3].inner_html, "%m-%d-%Y %H:%M:%S") rescue nil # nyoo
+ require 'ruby-debug';
+ DateTime.strptime(columns[3].inner_html, nagios_time_format).to_time rescue breakpoint # nyoo
end
duration = columns[4].inner_html.squeeze(' ').gsub(/^ /, '') if columns[4]
started_at = if duration && match_data = duration.match(/^\s*(\d+)d\s+(\d+)h\s+(\d+)m\s+(\d+)s\s*$/)
(
match_data[1].to_i.days +