bin/check_check in ruby-nagios-0.0.2 vs bin/check_check in ruby-nagios-0.1.0
- old
+ new
@@ -21,16 +21,16 @@
"3" => "UNKNOWN",
}
def initialize(path)
@path = path
- @status = Nagios::Status.new
+ @status = Nagios::Status.new @path
update
end # def initialize
def update
- @status.parsestatus(@path)
+ @status.parsestatus
end # def update
def services(service_pattern=nil, host_pattern=nil)
matches = []
self.hosts(host_pattern).each do |host, hostinfo|
@@ -157,9 +157,17 @@
total_results += 1
puts " #{service["host_name"]} => #{service["service_description"]}"
end
end # if results[state]
end # for each non-OK state
+
+ # If everything is OK, still print detailed output for confirmation
+ if total_results == 0 and results["OK"].size > 0
+ puts "OK Services:"
+ results["OK"].sort { |a,b| a["host_name"] <=> b["host_name"] }.each do |service|
+ puts " #{service["host_name"]} => #{service["service_description"]}"
+ end
+ end
exitcode = 0
if settings.down_min_percent
if results["WARNING"].length > 0 && (results["WARNING"].length / total_results) * 100 >= settings.down_min_percent