-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmonitor.jl
50 lines (49 loc) · 1.54 KB
/
monitor.jl
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
45
46
47
48
49
50
# Load list and monitor Calibre transcript
cd() # Go to home dir
for dir in eachline(".monitor_list")
cd(chomp(dir))
println("### Scanning folder: $(dir) ###")
v = String[]
for f in readdir()
if ismatch(r"^run.*log", f)
# Check File already process and finished or not
if isfile(".lock.$(f)")
continue
end
is_finished = false
for l in eachline(`tail $(f)`)
if ismatch(r"TOTAL CPU TIME = ", chomp(l))
is_finished = true
break
end
end
if is_finished
push!(v, f)
end
end
end
for f in v
outf_name = ".$(f)" # Create tmp file
outf = open(outf_name, "w")
for l in eachline(f)
op_complete = ismatch(r"^Operation COMPLETED on ", l)
if ismatch(r"--- ", l) ||
ismatch(r"^// ", l) ||
ismatch(r"HGC=\d+ FGC", l) ||
ismatch(r"WARNING: ", l) ||
ismatch(r"^CPU TIME = ", l) ||
op_complete
println(outf, l)
if op_complete
println(outf)
end
end
end
close(outf)
# Send email
run(pipeline(`cat .$(f)`, `mail -s "Run Result - $(f)" [email protected]`))
println("Send mail. | Log name: $f")
run(`rm .$(f)`) # Remove tmp file
run(`touch .lock.$(f)`) # Create lock file
end
end