Created
August 28, 2012 06:49
-
-
Save alxschwarz/c6abb60fb6ffaebc4f28 to your computer and use it in GitHub Desktop.
Detect Crash Dump
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 | |
import os | |
import subprocess | |
import shutil | |
import socket | |
def detect_coredump(): | |
os.chdir("/var/crash") | |
return os.path.isfile("_var_games.0.crash") | |
def copy_dump(): | |
src = "_var_games.0.crash" | |
dst = "/root/" | |
shutil.move(src, dst) | |
def send_mail(): | |
subj = "%s" % socket.gethostname() | |
email = "[email protected]" | |
os.system("echo 'there is coredump' | mutt -s %s %s" % (subj, email)) | |
def main(): | |
if detect_coredump() == True: | |
copy_dump() | |
send_mail() | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment