bin/check-kannel.rb in sensu-plugins-kannel-0.0.3 vs bin/check-kannel.rb in sensu-plugins-kannel-0.1.0

- old
+ new

@@ -50,10 +50,15 @@ option :password, short: '-p PASSWORD', long: '--password PASSWORD', description: 'Your Kannel password' + option :pattern, + short: '-i PATTERN', + long: '--id PATTERN', + description: 'Match a SMSC id against this pattern' + def run path = "/status.xml?password=#{config[:password]}" begin response = Net::HTTP.get(config[:host], path, config[:port]) @@ -67,9 +72,11 @@ critical 'Denied' if 'Denied' == document.root.text.strip smscs_status = Hash[REXML::XPath.each(document, '//smsc').map do |smsc| [smsc.text('id'), smsc.text('status')] end] + + smscs_status.reject! { |id, _| /#{config[:pattern]}/ !~ id } if config[:pattern] offline_smscs = smscs_status.reject { |_, status| status.start_with? 'online' }.keys if offline_smscs.any? critical "Offline: #{offline_smscs.join(', ')}"