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
1diff --git a/files/check-updates.sh b/files/check-updates.sh
2index 3fb11bc..144171d 100755
3--- a/files/check-updates.sh
4+++ b/files/check-updates.sh
5@@ -26,6 +26,8 @@ if [ ! -r ${LOGFILE} ]; then
6 fi
7
8 now=$(date +"%s")
9+# Day of week, 1 = mon
10+dow=$(date +"%u")
11 file_mtime=$(stat --format="%Y" ${LOGFILE})
12
13 file_age=$(($now - $file_mtime))
14@@ -34,6 +36,9 @@ function days {
15 echo $(( $1 * 24 * 3600 ))
16 }
17
18+# If mirror crit_age > weekend_threshold, do not crit on weekends
19+weekend_threshold=$(days 4)
20+
21 case $NAME in
22 extras.ubuntu.com)
23 # This will never be updated again.
24@@ -53,9 +58,23 @@ esac
25 warn_age=$(( crit_age / 2 ))
26
27 if [ ${file_age} -gt $crit_age ]; then
28+ # If we're on weekend and crit threshold is longer than weekend threshold, that's not critical
29+ # dow = 6 = Saturday
30+ if [ ${dow} -ge 6 -a ${crit_age} -ge ${weekend_threshold} ]; then
31+ echo "WARNING Mirror ${NAME} [Has not updated for at least $(( $crit_age / 3600 )) hours] - Weekend shield WARN-only !"
32+ exit 1
33+ fi
34 echo "CRITICAL Mirror ${NAME} [Has not updated for at least $(( $crit_age / 3600 )) hours]"
35 exit 2
36 elif [ ${file_age} -gt $warn_age ]; then
37+ # If we're a Friday, and that alert would CRIT over the weekend, CRIT now !
38+ monday_ts=$(date +"%s" -d "next monday")
39+ monday_file_age=$(($monday_ts - $file_mtime))
40+ # dow = 5 = Friday
41+ if [ ${dow} -eq 5 -a ${monday_file_age} -gt ${crit_age} ]; then
42+ echo "CRITICAL Mirror ${NAME} [Has not updated for at least $(( $warn_age / 3600 )) hours] - Weekend shield pre-CRIT !"
43+ exit 2
44+ fi
45 echo "WARNING Mirror ${NAME} [Has not updated for at least $(( $warn_age / 3600 )) hours]"
46 exit 1
47 fi

Subscribers

People subscribed via source and target branches