NAME

OmniPITR::Program::Monitor::Check - base for omnipitr-monitor checks

SYNOPSIS

package OmniPITR::Program::Monitor::Check::Whatever;
use base qw( OmniPITR::Program::Monitor::Check );
sub setup { ... }
sub get_args { ... }
sub run_check { ... }

DESCRIPTION

This is base class that we expect all check classes inherit from.

While not technically requirement, it might make writing check classes simpler.

CONTROL FLOW

When omnipitr-monitor creates check object, it doesn't pass any arguments (yet).

Afterwards, it calls ->setup() function, passing (as hash):

  • state-dir - directory where check can store it's own data, in subdirectory named like last element of check package name

  • log - log object

  • psql - coderef which will run given query via psql, and return whole output as scalar

Afterwards, omnipitr-monitor will run "get_args" method (if it's defined), to get all necessary options from command line - options specifically for this check.

Finally run_check() method will be called, with one argument - being full copy of omnipitr-monitor internal state.

METHODS

new()

Object constructor. No logic in here. Just makes simple hashref based object.

setup()

Sets check for work - receives state-dir and log object from omnipitr-monitor.

get_args()

This method should be overriden in check class if the check has some options get from command line.

log()

Shortcut to make code a bit nicer.

Returns logger object.

psql()

Runs given query via psql.