Skip to content

Instantly share code, notes, and snippets.

@alxschwarz
Created August 28, 2012 06:49
Show Gist options
  • Save alxschwarz/c6abb60fb6ffaebc4f28 to your computer and use it in GitHub Desktop.
Save alxschwarz/c6abb60fb6ffaebc4f28 to your computer and use it in GitHub Desktop.
Detect Crash Dump
#!/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