bin/check-service-consul.rb in sensu-plugins-consul-1.6.1 vs bin/check-service-consul.rb in sensu-plugins-consul-2.0.0

- old
+ new

@@ -1,6 +1,8 @@ #! /usr/bin/env ruby +# frozen_string_literal: true + # # check-service-consul # # DESCRIPTION: # This plugin checks if consul says a service is 'passing' or @@ -97,21 +99,24 @@ data = acquire_service_data passing = [] failing = [] data.each do |d| - passing << { - 'node' => d['Node'], - 'service' => d['ServiceName'], - 'service_id' => d['ServiceID'], - 'notes' => d['Notes'] - } if d['Status'] == 'passing' - failing << { - 'node' => d['Node'], - 'service' => d['ServiceName'], - 'service_id' => d['ServiceID'], - 'notes' => d['Notes'] - } if d['Status'] == 'critical' + if d['Status'] == 'passing' + passing << { + 'node' => d['Node'], + 'service' => d['ServiceName'], + 'service_id' => d['ServiceID'], + 'notes' => d['Notes'] + } + elsif d['Status'] == 'critical' + failing << { + 'node' => d['Node'], + 'service' => d['ServiceName'], + 'service_id' => d['ServiceID'], + 'notes' => d['Notes'] + } + end end if failing.empty? && passing.empty? msg = 'Could not find checks for any services' if config[:service]