[Resmon-devel] [resmon commit] r433 - trunk/lib/Core
svn-commit at lists.omniti.com
svn-commit at lists.omniti.com
Tue Jan 11 14:02:31 EST 2011
Author: mark
Date: 2011-01-11 14:02:31 -0500 (Tue, 11 Jan 2011)
New Revision: 433
Added:
trunk/lib/Core/PostgresMaster.pm
Log:
Module to detect postgres master/slave (tid14728)
Added: trunk/lib/Core/PostgresMaster.pm
===================================================================
--- trunk/lib/Core/PostgresMaster.pm (rev 0)
+++ trunk/lib/Core/PostgresMaster.pm 2011-01-11 19:02:31 UTC (rev 433)
@@ -0,0 +1,73 @@
+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;
More information about the Resmon-devel
mailing list