]> git.openstreetmap.org Git - chef.git/blobdiff - cookbooks/munin/files/default/plugins/postgres_replication
Add a bunch more cookbooks
[chef.git] / cookbooks / munin / files / default / plugins / postgres_replication
diff --git a/cookbooks/munin/files/default/plugins/postgres_replication b/cookbooks/munin/files/default/plugins/postgres_replication
new file mode 100755 (executable)
index 0000000..a41af7d
--- /dev/null
@@ -0,0 +1,23 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use Munin::Plugin::Pgsql;
+
+my $pg = Munin::Plugin::Pgsql->new(
+    title     => 'PostgreSQL replication delay',
+    info      => 'Replication delay',
+    vlabel    => 'Seconds',
+    basequery =>
+        "SELECT
+           CASE
+             WHEN pg_last_xlog_receive_location() = pg_last_xlog_replay_location() THEN 0::int
+             ELSE (extract(epoch FROM now()) - extract(epoch FROM pg_last_xact_replay_timestamp()))::int
+           END AS delay",
+    pivotquery => 1,
+    configquery =>
+        "VALUES ('delay','Replication delay')"
+);
+
+$pg->Process();