From: yomguy Date: Sat, 29 Dec 2007 15:00:31 +0000 (+0000) Subject: add mail_restartd.py X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=9236feda8c7cc4bd3d83d743bf998a1d7cb16179;p=tools.git add mail_restartd.py git-svn-id: http://svn.parisson.org/svn/tools/trunk@22 457c0346-1240-4656-8a5a-9edca8063506 --- diff --git a/mail_restartd.py b/mail_restartd.py new file mode 100755 index 0000000..d75c5e0 --- /dev/null +++ b/mail_restartd.py @@ -0,0 +1,27 @@ +#!/usr/bin/python + +import os +import time + +service = 'apache2' +mails = ['yomguy@sfr.fr','pellerin@parisson.com'] +server = 'ns37892' +file = '/tmp/restartd_apache.tmp' + +def touch_and_mail(server, service, mails, file): + for mail in mails: + command = 'echo "'+service+' crashed" | mail -s"'+server+'" '+mail + os.system('touch '+file) + os.system(command) + + +if not os.path.exists(file): + touch_and_mail(server, service, mails, file) + +date = os.path.getmtime(file) +laps = time.time() - date +print laps +if laps > 120: + touch_and_mail(server, service, mails, file) + + diff --git a/zope_backup_all.py b/zope_backup_all.py index 5e23e6c..34378ea 100755 --- a/zope_backup_all.py +++ b/zope_backup_all.py @@ -18,7 +18,8 @@ def backup_all(): for version in instances: for instance in instances[version]: z = ZopeInstance(version, instance) - #z.backup(backup_dir) + print z.get_instance_dir() + z.backup(backup_dir) print version + ': ' + instance + ' backuped !' if __name__ == '__main__': diff --git a/zope_instance.py b/zope_instance.py index 684d09f..5d2afc7 100644 --- a/zope_instance.py +++ b/zope_instance.py @@ -65,6 +65,9 @@ class ZopeInstance(ZopeInstall): self.instance_var =self.instance_dir + os.sep + 'var' + os.sep self.repozo = self.zope_main_dir + os.sep + 'zope' + self.version + os.sep + 'bin' + os.sep + 'repozo.py' + def get_instance_dir(self): + return self.instance_dir + def backup(self, backup_dir): """Backup the instance""" self.backup_dir = backup_dir