]> git.openstreetmap.org Git - chef.git/commitdiff
overpass: add munin scripts
authorSarah Hoffmann <lonvia@denofr.de>
Sat, 30 Oct 2021 12:34:29 +0000 (14:34 +0200)
committerSarah Hoffmann <lonvia@denofr.de>
Sat, 30 Oct 2021 12:36:08 +0000 (14:36 +0200)
cookbooks/overpass/recipes/default.rb
cookbooks/overpass/templates/default/munin.erb [new file with mode: 0644]
cookbooks/overpass/templates/default/munin_db_lag.erb [new file with mode: 0644]
cookbooks/overpass/templates/default/munin_request_count.erb [new file with mode: 0644]

index 4ec94b895c299c89b695098fb5a8cb4c27274b60..8804202268c5500af71f368e47e5f13cb36e0bc2 100644 (file)
@@ -25,7 +25,7 @@ username = "overpass"
 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
@@ -210,3 +210,21 @@ end
 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
diff --git a/cookbooks/overpass/templates/default/munin.erb b/cookbooks/overpass/templates/default/munin.erb
new file mode 100644 (file)
index 0000000..a2f47fa
--- /dev/null
@@ -0,0 +1,4 @@
+# DO NOT EDIT - This file is being maintained by Chef
+
+[<%= @name %>]
+user <%= @user %>
diff --git a/cookbooks/overpass/templates/default/munin_db_lag.erb b/cookbooks/overpass/templates/default/munin_db_lag.erb
new file mode 100644 (file)
index 0000000..ce8bdfa
--- /dev/null
@@ -0,0 +1,23 @@
+#!/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"
diff --git a/cookbooks/overpass/templates/default/munin_request_count.erb b/cookbooks/overpass/templates/default/munin_request_count.erb
new file mode 100644 (file)
index 0000000..c131522
--- /dev/null
@@ -0,0 +1,44 @@
+#!/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"