basedir = data_bag_item("accounts", username)["home"]
web_passwords = data_bag_item("web", "passwords")
-%w[bin site diffs db src].each do |dirname|
+%w[bin site diffs db src munin].each do |dirname|
directory "#{basedir}/#{dirname}" do
owner username
group username
service "overpass-area-processor" do
action [:enable]
end
+
+# Munin scripts
+
+%w[db_lag request_count].each do |name|
+ template "#{basedir}/munin/overpass_#{name}" do
+ source "munin_#{name}.erb"
+ owner username
+ group username
+ mode "755"
+ variables :basedir => basedir
+ end
+
+ munin_plugin "overpass_#{name}" do
+ target "#{basedir}/munin/overpass_#{name}"
+ conf "munin.erb"
+ conf_variables :user => username
+ end
+end
--- /dev/null
+#!/usr/bin/env bash
+
+# DO NOT EDIT - This file is being maintained by Chef
+#
+# Based on: https://github.com/drolbr/Overpass-API/blob/way_based_areas/munin/osm_replication_lag-api
+
+if [ "$1" = "config" ]; then
+
+ echo 'graph_title DB Lag'
+ echo 'graph_args --base 1000'
+ echo 'graph_vlabel minutes behind main database'
+ echo 'graph_category overpass'
+
+ echo 'lag.label replication lag'
+ echo 'lag.draw LINE'
+ echo 'lag.cdef lag,60,/'
+ echo 'lag.critical 1000'
+
+ exit 0
+fi
+
+lag=$(($(date +%s)-$(date +%s --utc -d "$(cat <%= @basedir %>/db/osm_base_version | cut -f2 -d\" | sed s/"\\\\"/""/g | sed s/[ZT]/" "/g)" )))
+echo "lag.value $lag"
--- /dev/null
+#!/usr/bin/env bash
+#
+# DO NOT EDIT - This file is being maintained by Chef
+#
+# Based on: https://github.com/drolbr/Overpass-API/blob/way_based_areas/munin/osm_db_request_count
+
+if [[ "$1" = "config" ]]; then
+{
+ echo 'graph_title API request count'
+ echo 'graph_vlabel per minute'
+ echo 'graph_category overpass'
+ echo "overpass_request_started.label started"
+ echo "overpass_request_started.type COUNTER"
+ echo "overpass_request_started.cdef overpass_request_started,60,*"
+ echo "overpass_request_started.max 10000"
+ echo "overpass_request_completed.label completed"
+ echo "overpass_request_completed.type COUNTER"
+ echo "overpass_request_completed.cdef overpass_request_completed,60,*"
+ echo "overpass_request_completed.max 10000"
+ echo "overpass_area_request_started.label started"
+ echo "overpass_area_request_started.type COUNTER"
+ echo "overpass_area_request_started.cdef overpass_request_started,60,*"
+ echo "overpass_area_request_started.max 10000"
+ echo "overpass_area_request_completed.label completed"
+ echo "overpass_area_request_completed.type COUNTER"
+ echo "overpass_area_request_completed.cdef overpass_request_completed,60,*"
+ echo "overpass_area_request_completed.max 10000"
+ exit 0
+}; fi
+
+BASE_STATUS=`<%= @basedir %>/bin/dispatcher --osm-base --status | tr '\n' '|'`
+AREA_STATUS=`<%= @basedir %>/bin/dispatcher --areas --status | tr '\n' '|'`
+
+STARTED=`echo $BASE_STATUS | sed 's,.*Counter of started requests:,,;s:|.*::'`
+echo "overpass_request_started.value $STARTED"
+
+COMPLETED=`echo $BASE_STATUS | sed 's,.*Counter of finished requests:,,;s:|.*::'`
+echo "overpass_request_completed.value $COMPLETED"
+
+STARTED=`echo $AREA_STATUS | sed 's,.*Counter of started requests:,,;s:|.*::'`
+echo "overpass_area_request_started.value $STARTED"
+
+COMPLETED=`echo $AREA_STATUS | sed 's,.*Counter of finished requests:,,;s:|.*::'`
+echo "overpass_area_request_completed.value $COMPLETED"