Created
April 29, 2014 08:04
-
-
Save dawehner/11393594 to your computer and use it in GitHub Desktop.
Provide a small script to check whether a host is reachable via ssh, when the ssh connection is disabled/storage problems occured or whatever
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
import subprocess | |
import os | |
proc = subprocess.Popen(['ssh', '-v', 'user@host', 'exit'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) | |
for line in iter(proc.stderr.readline,''): | |
if line.find("Authenticated to") is not -1: | |
os.system('notify-send "Server X works again"'); | |
os.system('echo "Server X works again" | mail -s "Server update" yourmail@example.com') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment