Alexandros Kosiaris has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/331623 )

Change subject: osm: Add a prometheus textfile exporter
......................................................................


osm: Add a prometheus textfile exporter

Adding a prometheus textfile export for the osm sync lag metric.

Change-Id: Ib8ad17bdf535b2eade7b4f6057d75ef757363aea
---
A modules/osm/files/osm_sync_lag.sh
A modules/osm/manifests/prometheus.pp
M modules/role/manifests/osm/master.pp
3 files changed, 37 insertions(+), 0 deletions(-)

Approvals:
  Alexandros Kosiaris: Verified; Looks good to me, approved



diff --git a/modules/osm/files/osm_sync_lag.sh 
b/modules/osm/files/osm_sync_lag.sh
new file mode 100644
index 0000000..d27e475
--- /dev/null
+++ b/modules/osm/files/osm_sync_lag.sh
@@ -0,0 +1,12 @@
+#!/bin/bash
+
+set -e
+set -u
+
+state_path=${1:-"/srv/osmosis/state.txt"}
+prometheus_path=${2:-"/var/lib/prometheus/node-exporter/osm_sync_lag.prom"}
+
+timestamp=$(awk -F= '/^timestamp=/ { print $2 }' state.txt | tr -d \\\\)
+lag=$(date "+%s" --date=${timestamp})
+echo "osm_sync_timestamp" $lag > $prometheus_path.$$
+mv $prometheus_path.$$ $prometheus_path
diff --git a/modules/osm/manifests/prometheus.pp 
b/modules/osm/manifests/prometheus.pp
new file mode 100644
index 0000000..2978465
--- /dev/null
+++ b/modules/osm/manifests/prometheus.pp
@@ -0,0 +1,21 @@
+# == Class osm::prometheus
+# This installs a prometheus Textfile exporter
+#
+class osm::prometheus(
+    $state_path,
+    $prometheus_path,
+    $ensure = 'present'
+) {
+    file { '/usr/bin/osm_sync_lag':
+        ensure => $ensure,
+        owner  => 'root',
+        group  => 'root',
+        mode   => '0555',
+        source => "puppet:///modules/${module_name}/osm_sync_lag.sh",
+    }
+
+    cron { 'osm_sync_lag':
+        ensure  => $ensure,
+        command => "/usr/bin/osm_sync_lag ${state_path}",
+    }
+}
diff --git a/modules/role/manifests/osm/master.pp 
b/modules/role/manifests/osm/master.pp
index 993344d..b85d0c3 100644
--- a/modules/role/manifests/osm/master.pp
+++ b/modules/role/manifests/osm/master.pp
@@ -36,6 +36,10 @@
     class { 'osm::ganglia':
         state_path   => '/srv/osmosis/state.txt',
     }
+    class { 'osm::prometheus':
+        state_path      => '/srv/osmosis/state.txt',
+        prometheus_path => 
'/var/lib/prometheus/node-exporter/osm_sync_lag.prom',
+    }
 
     system::role { 'role::osm::master':
         ensure      => 'present',

-- 
To view, visit https://gerrit.wikimedia.org/r/331623
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ib8ad17bdf535b2eade7b4f6057d75ef757363aea
Gerrit-PatchSet: 5
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Alexandros Kosiaris <[email protected]>
Gerrit-Reviewer: Alexandros Kosiaris <[email protected]>
Gerrit-Reviewer: Filippo Giunchedi <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to