]> git.parisson.com Git - tools.git/commitdiff
add mail_restartd.py
authoryomguy <yomguy@457c0346-1240-4656-8a5a-9edca8063506>
Sat, 29 Dec 2007 15:00:31 +0000 (15:00 +0000)
committeryomguy <yomguy@457c0346-1240-4656-8a5a-9edca8063506>
Sat, 29 Dec 2007 15:00:31 +0000 (15:00 +0000)
git-svn-id: http://svn.parisson.org/svn/tools/trunk@22 457c0346-1240-4656-8a5a-9edca8063506

mail_restartd.py [new file with mode: 0755]
zope_backup_all.py
zope_instance.py

diff --git a/mail_restartd.py b/mail_restartd.py
new file mode 100755 (executable)
index 0000000..d75c5e0
--- /dev/null
@@ -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)
+
+
index 5e23e6ce15d9513a4ea3f79835a9e445da392e09..34378eab8edc1400abec3f7d21a2ea5bc71a4555 100755 (executable)
@@ -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__':
index 684d09f07e8cc958d3d4560e12aeecad77d212cc..5d2afc7e1c5ce4ef289b52503420a8002a7da319 100644 (file)
@@ -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