-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheck_v4.sh
executable file
·154 lines (129 loc) · 3.47 KB
/
check_v4.sh
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
#!/bin/bash
##########################################
#
# Paths and routes
#
##########################################
# paths
source $HOME/gutta.conf
LOG_PATH=$OP_PATH/logs/out
ERR_PATH=$OP_PATH/logs/err
##########################################
#
# Load utils
#
##########################################
source ${OP_PATH}/utils.sh
##########################################
#
# Find the last run
#
##########################################
LASTRUN_LOGFILE=$(ls $LOG_PATH/runVisir*log -tr | tail -1)
LASTRUN=$(basename $LASTRUN_LOGFILE | cut -f 2 -d "_" | cut -f 1 -d ".")
echo " - Last run identified is : $LASTRUN"
##########################################
#
# Checks
#
##########################################
COMPONENTS=(campi tracce visual csv2shape copyToN08 GUTTA_n08)
# check if we already notified this job
LAST_NOTIFIED_JOB=$(cat ${LOG_PATH}/last_job_notified.log)
if [[ $LAST_NOTIFIED_JOB = $LASTRUN ]] ; then
echo " -- Job already notified"
exit
fi
# check if all the components stopped running
for COMP in ${COMPONENTS[@]}; do
# log/err file names
#echo "find ${LOG_PATH} -name ${COMP}_${LASTRUN}_\* | head -n 1"
LOG=$(find ${LOG_PATH} -name ${COMP}_${LASTRUN}_\* | head -n 1)
ERR=$(find ${ERR_PATH} -name ${COMP}_${LASTRUN}_\* | head -n 1)
if [[ ! -z "$LOG" ]] ; then
# get termination signals for the component
TermSig=$(grep "Terminated" $LOG | wc -l)
case $COMP in
"campi")
if [[ $TermSig -eq 1 ]]; then
echo "$COMP terminated"
else
echo "$COMP still to complete! Exiting..."
exit
fi
;;
"tracce")
if [[ $TermSig -eq 30 ]]; then
echo "$COMP terminated"
else
echo "$COMP still to complete! Exiting..."
exit
fi
;;
"visual")
if [[ $TermSig -eq 30 ]]; then
echo "$COMP terminated"
else
echo "$COMP still to complete! Exiting..."
exit
fi
;;
"csv2shape")
if [[ $TermSig -eq 1 ]]; then
echo "$COMP terminated"
else
echo "$COMP still to complete! Exiting..."
exit
fi
;;
"copyToN08")
if [[ $TermSig -eq 1 ]]; then
echo "$COMP terminated"
else
echo "$COMP still to complete! Exiting..."
exit
fi
;;
"GUTTA_n08")
if [[ $TermSig -eq 1 ]]; then
echo "$COMP terminated"
else
echo "$COMP still to complete! Exiting..."
exit
fi
;;
*)
echo "ELSE"
;;
esac
fi
done
# check if all the components stopped running
for COMP in ${COMPONENTS[@]}; do
echo "========"
# log/err file names
LOG=$(find ${LOG_PATH} -name ${COMP}_${LASTRUN}_\* | head -n 1)
ERR=$(find ${ERR_PATH} -name ${COMP}_${LASTRUN}_\* | head -n 1)
echo "Parsing log files:"
echo $LOG
echo $ERR
# do the analysis
echo " - Analysing component $COMP"
ERRORS=$(wc -l $ERR | cut -f 1 -d " ")
echo " - $COMP has $ERRORS errors."
if [[ ! -z $ERRORS ]]; then
if [[ $ERRORS -gt 0 ]]; then
WARNING_TO_IGNORE=$(grep "imagick.so" $ERR | wc -l)
ERRORS_UPDATE=$(echo "$ERRORS - $WARNING_TO_IGNORE" | bc -l )
#echo " -- $ERRORS_UPDATE errors about imagick.so library."
if [[ "$COMP"=="GUTTA_n08" ]] && [[ $ERRORS_UPDATE -eq 0 ]] ; then
echo " -- Errors are about imagick.so library so we can ignore!"
echo $LASTRUN > ${LOG_PATH}/last_job_notified.log
else
echo " -- Errors are real! MUST BE NOTIFIED"
echo $LASTRUN > ${LOG_PATH}/last_job_notified.log
Notify 2 "Check" "${COMP} has ${ERRORS} error lines [run: $LASTRUN]"
fi
fi
fi
done