Skip to content

Instantly share code, notes, and snippets.

@IanVaughan
Created March 30, 2017 11:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IanVaughan/101266416398fda8a2fc4573eb23d994 to your computer and use it in GitHub Desktop.
Save IanVaughan/101266416398fda8a2fc4573eb23d994 to your computer and use it in GitHub Desktop.
Monitor a Rancher service and display popup toast notification when that service changes state
#!/usr/local/bin/ruby -w
# Usage:
# ./rancher_status.rb service_name
SERVICE = ARGV[0]
def notify(text)
title = "Rancher"
%x(osascript -e 'display notification "#{SERVICE} is #{text}" with title "#{title}"')
end
old_status = ""
while true do
status = %x(rancher ps | grep #{SERVICE}).split[4]
next unless status != old_status
notify(status)
old_status = status
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment