Created
October 18, 2012 13:03
-
-
Save kwharrigan/3911663 to your computer and use it in GitHub Desktop.
Server monitoring script
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/python | |
from twisted.internet import task | |
from twisted.internet import reactor | |
from subprocess import Popen, PIPE, STDOUT | |
logfile = open('status.txt', 'a') | |
def runEverySecond(): | |
output = Popen(["ssh", "user@host", "date"], stdout=PIPE, stderr=STDOUT).communicate()[0] | |
logfile.write(output) | |
output = Popen(["ssh", "user@host", "date"], stdout=PIPE, stderr=STDOUT).communicate()[0] | |
logfile.write(output) | |
logfile.flush() | |
l = task.LoopingCall(runEverySecond) | |
l.start(60.0) # call every second | |
# l.stop() will stop the looping calls | |
reactor.run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment