Created
February 7, 2019 19:07
-
-
Save acondrat/bc244ae82b8d346baca895ee08633723 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'open-uri' | |
OK = 'OK'.freeze | |
if ARGV.length != 1 | |
raise 'Please provide the service address as a single argument' | |
end | |
exit_code = 0 | |
URI.open(ARGV.first) do |f| | |
f.each_line do |line| | |
service = line.strip.split(':') | |
next if service.empty? | |
service_name = service[0].strip | |
service_status = service[1].strip | |
if service_status != OK | |
puts "The service #{service_name} is #{service_status}." | |
exit_code = 1 | |
end | |
end | |
end | |
exit exit_code |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment