]> git.openstreetmap.org Git - chef.git/commitdiff
Fix munin replication plugin to work with osmium based state
authorTom Hughes <tom@compton.nu>
Wed, 12 Dec 2018 20:22:57 +0000 (20:22 +0000)
committerTom Hughes <tom@compton.nu>
Wed, 12 Dec 2018 20:22:57 +0000 (20:22 +0000)
cookbooks/munin/files/default/plugins/replication_delay
cookbooks/tile/recipes/default.rb
cookbooks/tile/templates/default/munin.erb [deleted file]

index f1761e84d34143fd947ceba93349fe3776e9ae80..f6cd317a92faeb00a72e06ab38cce6cac377e740 100755 (executable)
@@ -1,31 +1,30 @@
-#!/bin/sh 
-# 
-# Plugin to monitor the age of the imported data in the rendering db 
-# 
-# Parameters:  
-# 
-#       config   (required) 
-#       autoconf (optional - used by munin-config) 
-# 
-if [ "$1" = "config" ]; then 
-        echo 'graph_title Data import lag' 
-        echo 'graph_args --base 1000 -l 0' 
-        echo 'graph_vlabel minutes' 
-        echo 'graph_category renderd' 
-        echo 'age.label DB import age' 
-        echo 'age.type GAUGE' 
-       echo 'age.cdef age,60,/'
-       echo 'age.warning :600'
-       echo 'age.critical :3600'
-        exit 0 
-fi 
+#!/bin/sh
+#
+# Plugin to monitor the age of the imported data in the rendering db
+#
+# Parameters:
+#
+#       config   (required)
+#       autoconf (optional - used by munin-config)
+#
+
+if [ "$1" = "config" ]; then
+
+        echo 'graph_title Data import lag'
+        echo 'graph_args --base 1000 -l 0'
+        echo 'graph_vlabel minutes'
+        echo 'graph_category renderd'
+        echo 'age.label DB import age'
+        echo 'age.type GAUGE'
+        echo 'age.cdef age,60,/'
+        echo 'age.warning :600'
+        echo 'age.critical :3600'
+        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})
+tstampsec=$(date --date=${tstamp} +%s)
+nowsec=$(date +%s)
 
-state=${state:-/home/jburgess/replicate/state.txt}
-tstamp=`sed -e '/^timestamp=/!d' -e 's/.*=//' -e 's/Z//' -e 's/T/Z/' -e 's/\\\\//' -e 's/\\\\//' -e q ${state}` 
-tstampsec=`date --date=$tstamp +%s` 
-nowsec=`date +%s` 
 echo "age.value " `expr $nowsec - $tstampsec`
index f87bac614f2abce72b0dd00bf4f04265202669a5..22a6426751693aefb1427a4ae5292ae6d2319cca 100644 (file)
@@ -434,6 +434,7 @@ end
 package %w[
   osm2pgsql
   ruby
+  osmium-tool
   pyosmium
   python-pyproj
 ]
@@ -571,6 +572,4 @@ munin_plugin "renderd_queue_time"
 munin_plugin "renderd_zoom"
 munin_plugin "renderd_zoom_time"
 
-munin_plugin "replication_delay" do
-  conf "munin.erb"
-end
+munin_plugin "replication_delay"
diff --git a/cookbooks/tile/templates/default/munin.erb b/cookbooks/tile/templates/default/munin.erb
deleted file mode 100644 (file)
index b789827..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-# DO NOT EDIT - This file is being maintained by Chef
-
-[<%= @name %>]
-env.state /var/lib/replicate/state.txt