lib/nagiosharder.rb in nagiosharder-0.2.3 vs lib/nagiosharder.rb in nagiosharder-0.2.4

- old
+ new

@@ -123,23 +123,22 @@ response = post(cmd_url, :body => request) response.code == 200 && response.body =~ /successful/ end - # FIXME need to confirm this functionality exists in nagios - #def cancel_downtime(downtime_id, downtime_type = :host_downtime) - # downtime_types = { - # :host_downtime => 78, - # :service_downtime => 79 - # } - # response = post(cmd_url, :body => { - # :cmd_typ => downtime_types[downtime_type], - # :cmd_mod => 2, - # :down_id => downtime_id - # }) - # response.code == 200 && response.body =~ /successful/ - #end + def cancel_downtime(downtime_id, downtime_type = :host_downtime) + downtime_types = { + :host_downtime => 78, + :service_downtime => 79 + } + response = post(cmd_url, :body => { + :cmd_typ => downtime_types[downtime_type], + :cmd_mod => 2, + :down_id => downtime_id + }) + response.code == 200 && response.body =~ /successful/ + end def schedule_host_check(host) response = post(cmd_url, :body => { :start_time => formatted_time_for(Time.now), :host => host, @@ -322,10 +321,12 @@ service = service_links[0].inner_html end status = columns[2].inner_html if columns[2] - last_check = if columns[3] + last_check = if columns[3] && columns[3].inner_html != 'N/A' + last_check_str = columns[3].inner_html + DateTime.strptime(columns[3].inner_html, nagios_time_format).to_time 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*$/) (