forked from Yanivmd/TRACY
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathSwatchdog.py
45 lines (37 loc) · 981 Bytes
/
Swatchdog.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/python
import os
import commands
import time
import sys
import time
from sendMail import sendMail
#name of process to look for
procnamePrefix = "findClone"
waitStart = False
waitEnd = True
while True:
output = commands.getoutput("ps -A")
found = False
for process in output.split("\n"):
if "<defunct>" in process:
sendMail("Zombies!!! call rick!!!")
while True:
pass
if procnamePrefix in process:
#print "FOUND!"
found = True
if found == False:
if waitEnd:
#ok we stopped, alert via main and toggle
sendMail("Watch dog exit")
waitStart = True
waitEnd = False
print "Waiting for start"
else:
if waitStart:
# ok we have start...toggle
waitStart = False
waitEnd = True
print "Waiting for END"
# sleep 5 mins
time.sleep(60*5)