From: Tom Hughes Date: Wed, 12 Dec 2018 20:22:57 +0000 (+0000) Subject: Fix munin replication plugin to work with osmium based state X-Git-Url: https://git.openstreetmap.org/chef.git/commitdiff_plain/7d07126f5470b9f0acc18d67ebbf015b7241d35b Fix munin replication plugin to work with osmium based state --- diff --git a/cookbooks/munin/files/default/plugins/replication_delay b/cookbooks/munin/files/default/plugins/replication_delay index f1761e84d..f6cd317a9 100755 --- a/cookbooks/munin/files/default/plugins/replication_delay +++ b/cookbooks/munin/files/default/plugins/replication_delay @@ -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` diff --git a/cookbooks/tile/recipes/default.rb b/cookbooks/tile/recipes/default.rb index f87bac614..22a642675 100644 --- a/cookbooks/tile/recipes/default.rb +++ b/cookbooks/tile/recipes/default.rb @@ -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 index b789827b2..000000000 --- a/cookbooks/tile/templates/default/munin.erb +++ /dev/null @@ -1,4 +0,0 @@ -# DO NOT EDIT - This file is being maintained by Chef - -[<%= @name %>] -env.state /var/lib/replicate/state.txt