X-Git-Url: https://git.openstreetmap.org/chef.git/blobdiff_plain/805ab61e66fe3adb45e57f50e49b168d84a6a8b1..7b9ec4b60ee39614d1d083d7220e76b07d2b275f:/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 index 000000000..a41af7d3b --- /dev/null +++ b/cookbooks/munin/files/default/plugins/postgres_replication @@ -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();