]> git.openstreetmap.org Git - chef.git/commitdiff
Make replication delay monitoring more reliable
authorTom Hughes <tom@compton.nu>
Tue, 1 Jan 2019 08:54:39 +0000 (08:54 +0000)
committerTom Hughes <tom@compton.nu>
Tue, 1 Jan 2019 09:06:09 +0000 (09:06 +0000)
cookbooks/munin/files/default/plugins/replication_delay
cookbooks/tile/templates/default/replicate.erb

index f6cd317a92faeb00a72e06ab38cce6cac377e740..27dd1080944e7f06103f90c3db770f69b480fa7b 100755 (executable)
@@ -22,8 +22,7 @@ if [ "$1" = "config" ]; then
         exit 0
 fi
 
         exit 0
 fi
 
-latest_changes=$(ls /var/lib/replicate/changes-*.osc.gz | sort --version-sort | tail -1)
-tstamp=$(osmium fileinfo --extended --get=data.timestamp.last ${latest_changes})
+tstamp=$(osmium fileinfo --extended --get=data.timestamp.last /var/lib/replicate/changes-latest.osc.gz)
 tstampsec=$(date --date=${tstamp} +%s)
 nowsec=$(date +%s)
 
 tstampsec=$(date --date=${tstamp} +%s)
 nowsec=$(date +%s)
 
index 8ebfd94a55ecfce888b4fdc8daf619831dcacdf7..81fc66419e153fa5e4e7970bae7b816ff02c3553 100644 (file)
@@ -60,8 +60,17 @@ do
         # No need to rollback now
         rm sequence-prev.txt
 
         # No need to rollback now
         rm sequence-prev.txt
 
+        # Get buffer count
+        buffers=$(osmium fileinfo --extended --get=data.buffers.count ${file})
+
+        # If this diff has content mark it as the latest diff
+        if [ $buffers -gt 0 ]
+        then
+            ln -f ${file} changes-latest.osc.gz
+        fi
+
         # Queue these changes for expiry processing
         # Queue these changes for expiry processing
-        ln ${file} expire-queue/$file
+        ln ${file} expire-queue/${file}
 
         # Delete old downloads
         find . -name 'changes-*.gz' -mmin +300 -exec rm -f {} \;
 
         # Delete old downloads
         find . -name 'changes-*.gz' -mmin +300 -exec rm -f {} \;