Add a bunch more cookbooks
[chef.git] / cookbooks / munin / files / default / plugins / postgres_replication
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5
6 use Munin::Plugin::Pgsql;
7
8 my $pg = Munin::Plugin::Pgsql->new(
9     title     => 'PostgreSQL replication delay',
10     info      => 'Replication delay',
11     vlabel    => 'Seconds',
12     basequery =>
13         "SELECT
14            CASE
15              WHEN pg_last_xlog_receive_location() = pg_last_xlog_replay_location() THEN 0::int
16              ELSE (extract(epoch FROM now()) - extract(epoch FROM pg_last_xact_replay_timestamp()))::int
17            END AS delay",
18     pivotquery => 1,
19     configquery =>
20         "VALUES ('delay','Replication delay')"
21 );
22
23 $pg->Process();