Merge ~kotodama/ubuntu-mirror-charm:kotodama into ubuntu-mirror-charm:master

Proposed by Loïc Gomez
Status: Merged
Approved by: Laurent Sesquès
Approved revision: 978ed64f3f5323e300386a175862336c54c9a913
Merged at revision: 27896e15879f6170112ff6558ad2d83085f38747
Proposed branch: ~kotodama/ubuntu-mirror-charm:kotodama
Merge into: ubuntu-mirror-charm:master
Diff against target: 47 lines (+19/-0)
1 file modified
files/check-updates.sh (+19/-0)
Reviewer Review Type Date Requested Status
Laurent Sesquès Approve
Canonical IS Reviewers Pending
Review via email: mp+427205@code.launchpad.net

Commit message

Fixing CRIT alerting over the weekend:

- do not CRIT on weekends for mirrors that can stay out of date for 4 days+
- preemptively CRIT on Friday instead of WARN, if it would CRIT over the weekend

To post a comment you must log in.
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

This merge proposal is being monitored by mergebot. Change the status to Approved to merge.

Revision history for this message
Laurent Sesquès (sajoupa) :
review: Approve
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

Change successfully merged at revision 27896e15879f6170112ff6558ad2d83085f38747

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/files/check-updates.sh b/files/check-updates.sh
index 3fb11bc..144171d 100755
--- a/files/check-updates.sh
+++ b/files/check-updates.sh
@@ -26,6 +26,8 @@ if [ ! -r ${LOGFILE} ]; then
26fi26fi
2727
28now=$(date +"%s")28now=$(date +"%s")
29# Day of week, 1 = mon
30dow=$(date +"%u")
29file_mtime=$(stat --format="%Y" ${LOGFILE})31file_mtime=$(stat --format="%Y" ${LOGFILE})
3032
31file_age=$(($now - $file_mtime))33file_age=$(($now - $file_mtime))
@@ -34,6 +36,9 @@ function days {
34 echo $(( $1 * 24 * 3600 ))36 echo $(( $1 * 24 * 3600 ))
35}37}
3638
39# If mirror crit_age > weekend_threshold, do not crit on weekends
40weekend_threshold=$(days 4)
41
37case $NAME in42case $NAME in
38 extras.ubuntu.com)43 extras.ubuntu.com)
39 # This will never be updated again.44 # This will never be updated again.
@@ -53,9 +58,23 @@ esac
53warn_age=$(( crit_age / 2 ))58warn_age=$(( crit_age / 2 ))
5459
55if [ ${file_age} -gt $crit_age ]; then60if [ ${file_age} -gt $crit_age ]; then
61 # If we're on weekend and crit threshold is longer than weekend threshold, that's not critical
62 # dow = 6 = Saturday
63 if [ ${dow} -ge 6 -a ${crit_age} -ge ${weekend_threshold} ]; then
64 echo "WARNING Mirror ${NAME} [Has not updated for at least $(( $crit_age / 3600 )) hours] - Weekend shield WARN-only !"
65 exit 1
66 fi
56 echo "CRITICAL Mirror ${NAME} [Has not updated for at least $(( $crit_age / 3600 )) hours]"67 echo "CRITICAL Mirror ${NAME} [Has not updated for at least $(( $crit_age / 3600 )) hours]"
57 exit 268 exit 2
58elif [ ${file_age} -gt $warn_age ]; then69elif [ ${file_age} -gt $warn_age ]; then
70 # If we're a Friday, and that alert would CRIT over the weekend, CRIT now !
71 monday_ts=$(date +"%s" -d "next monday")
72 monday_file_age=$(($monday_ts - $file_mtime))
73 # dow = 5 = Friday
74 if [ ${dow} -eq 5 -a ${monday_file_age} -gt ${crit_age} ]; then
75 echo "CRITICAL Mirror ${NAME} [Has not updated for at least $(( $warn_age / 3600 )) hours] - Weekend shield pre-CRIT !"
76 exit 2
77 fi
59 echo "WARNING Mirror ${NAME} [Has not updated for at least $(( $warn_age / 3600 )) hours]"78 echo "WARNING Mirror ${NAME} [Has not updated for at least $(( $warn_age / 3600 )) hours]"
60 exit 179 exit 1
61fi80fi

Subscribers

People subscribed via source and target branches