lib/nagiosharder.rb in nagiosharder-0.1.0 vs lib/nagiosharder.rb in nagiosharder-0.1.1
- old
+ new
@@ -1,15 +1,21 @@
require 'restclient'
require 'nokogiri'
-require 'active_support/core_ext/array'
-require 'active_support/core_ext/numeric/time'
-require 'active_support/core_ext/time/calculations'
-require 'active_support/core_ext/date/calculations'
-require 'active_support/core_ext/date_time/calculations'
-require 'active_support/core_ext/date/acts_like'
-require 'active_support/core_ext/time/acts_like'
-require 'active_support/core_ext/date_time/acts_like'
+require 'active_support' # fine, we'll just do all of activesupport instead of the parts I want. thank Rails 3 for shuffling requires around.
+
+# :(
+if ActiveSupport::VERSION::MAJOR > 2
+ require 'active_support/core_ext/array'
+ require 'active_support/core_ext/numeric/time'
+ require 'active_support/core_ext/time/calculations'
+ require 'active_support/core_ext/date/calculations'
+ require 'active_support/core_ext/date_time/calculations'
+ require 'active_support/core_ext/date/acts_like'
+ require 'active_support/core_ext/time/acts_like'
+ require 'active_support/core_ext/date_time/acts_like'
+end
+
require 'httparty'
class NagiosHarder
class Site
attr_accessor :nagios_url, :user, :password, :default_options, :default_cookies, :version
@@ -153,22 +159,28 @@
when nil then nil
else
raise "Invalid options[:sort_option]"
end
+ service_group = options[:group]
+
params = {
'hoststatustype' => 15,
'servicestatustype' => service_status_type,
'host' => 'all'
}
params = if @version == 3
[ "servicegroup=all", "style=detail" ]
else
- [ "host=all" ]
+ if service_group
+ ["servicegroup=#{service_group}", "style=detail"]
+ else
+ ["host=all"]
+ end
end
params += [
service_status_type ? "servicestatustypes=#{service_status_type}" : nil,
sort_type ? "sorttype=#{sort_type}" : nil,
sort_option ? "sortoption=#{sort_option}" : nil,
@@ -239,10 +251,9 @@
else
# or save it for later
host = last_host
end
- #require 'ruby-debug'; breakpoint
if columns[1]
service_links = columns[1].css('td a')
service = service_links[0].inner_html
acknowledged = service_links.size == 3 # acknowledged servies have a link to the service, link to comments, and a link to unacknowledge
end