-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathtransition.j2
executable file
·47 lines (40 loc) · 1.03 KB
/
transition.j2
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
#!/bin/bash
# get the latest entries from condor_history,
# N: max number to retrieve
# t: max number of seconds ago
# Update apfmon with the jobstatus (done/fault)
# JobStatus in job ClassAds
#
# 0 Unexpanded U
# 1 Idle I
# 2 Running R
# 3 Removed X
# 4 Completed C
# 5 Held H
# 6 Submission_err E
#
VERSION=20160825
factory={{ factoryid }}
t=300
N=5000
since=$(date --date="$t seconds ago" +%s)
counter=0
while read -r line ; do
if echo $line | grep --quiet 'Warning: Bad history file'; then
continue
fi
jobid=$(echo $line | cut -d'#' -f 2)
jobstate=$(echo $line | cut -d' ' -f 2)
jid=$factory:$jobid
if [ "$jobstate" -eq "3" ]; then
state="fault"
elif [ "$jobstate" -eq "4" ]; then
state="done"
else
state="$jobstate"
fi
curl --silent -d state=$state http://apfmon.lancs.ac.uk/api/jobs/$jid &>/dev/null
echo $jid $state
counter=$((counter+1))
done < <(condor_history -file $1 -match $N -const "EnteredCurrentStatus>=$since" -af GlobalJobId JobStatus)
echo Processed $counter jobs.