-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbatch
More file actions
49 lines (35 loc) · 1.24 KB
/
Copy pathbatch
File metadata and controls
49 lines (35 loc) · 1.24 KB
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
#!/bin/bash
DB_HOST=""
DB_NAME=""
DB_USER=""
DB_PASS=""
job_list=("name")
desired_ds=$(date -d "yesterday" '+%Y-%m-%d')
desired_ts="00:00:00"
desired_dts="$desired_ds $desired_ts"
echo "$desired_dts"
declare -a job_output
for job_name in "${job_list[@]}"; do
sql="SELECT bje.EXIT_CODE, bje.CREATE_TIME FROM BATCH_JOB_EXECUTION bje JOIN BATCH_JOB_INSTANCE bji ON bje.JOB_INSTANCE_ID = bji.JOB_INSTANCE_ID WHERE bji.JOB_NAME='$job_name' and bje.CREATE_TIME > '$desired_dts' LIMIT 1;"
result=$(mysql -h "$DB_HOST" -u "$DB_USER" -p"$DB_PASS" -D "$DB_NAME" -se "$sql")
if [[ -z "$result" ]]; then
job_output+=("DID NOT RUN")
else
job_output+=("$result")
fi
done
count=0
for return_value in "${job_output[@]}"; do
if [[ "$return_value" == "DID NOT RUN" ]]; then
echo -e "Statistic.${job_list[$count]}: -1\n"
echo -e "Message.${job_list[$count]}: $return_value\n"
elif [[ "$return_value" == *"FAILED"* ]]; then
echo -e "Statistic.${job_list[$count]}: 1\n"
echo -e "Message.${job_list[$count]}: $return_value\n"
else
echo -e "Statistic.${job_list[$count]}: 0\n"
echo -e "Message.${job_list[$count]}: $return_value\n"
fi
((count++))
done
exit 0