Created
March 30, 2017 11:56
-
-
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
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/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