Skip to content
Snippets Groups Projects
Commit 8195e06f authored by Mark Harrison's avatar Mark Harrison
Browse files

Module to detect postgres master/slave (tid14728)

git-svn-id: https://labs.omniti.com/resmon/trunk@433 8c0face9-b7db-6ec6-c4b3-d5f7145c7d55
parent 10dbde82
No related branches found
No related tags found
No related merge requests found
package Core::PostgresMaster;
use strict;
use warnings;
use base 'Resmon::Module';
use Resmon::ExtComm qw(run_command cache_command);
=pod
=head1 NAME
Core::PostgresMaster - a sample/template resmon module
=head1 SYNOPSIS
Core::PostgresMaster {
postgres_state: pgdata => /data/postgres/pgdata
}
=head1 DESCRIPTION
This module detects whether a postgres database is master or slave by looking
for the presence or absence of a recovery.conf file in the pgdata directory.
=head1 CONFIGURATION
=over
=item check_name
The check name is descriptive only in this check. It is not used for anything.
Some checks use the check_name as part of the configuration, such as
free space checks that specify the filesystem to use.
=item pgdata
The path to the pgdata directory.
=back
=head1 METRICS
=over
=item state
The state of the database as a string - master or slave.
=back
=cut
sub handler {
my $self = shift;
unless (exists($self->{config}->{pgdata})) {
return {
"error" => ["Pgdata path is undefined", "s"]
}
};
my $state;
if (-e "$self->{config}->{pgdata}/recovery.conf") {
$state = "slave";
} else {
$state = "master";
};
return {
"state" => [$state, "s"],
};
};
1;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment