The Perl Toolchain Summit 2025 Needs You: You can help 🙏 Learn more

NAME

App::MonM::Checkit - App::MonM checkit class

VIRSION

Version 1.03

SYNOPSIS

DESCRIPTION

App::MonM checkit class

new

my $checker = App::MonM::Checkit->new;

Returns checker object

check

my $ostat = $checker->check({ ... });

Performs checking of checkit-sources by checkit rules (checkit config sections)

Returns status: 0 - PASS; 1 - FAIL

cleanup

my $self = $checker->cleanup;

Flushes all working variables to defaults

code

my $code = $checker->code;
my $newcode = $checker->code(200);

Sets and returns response code (rc)

config

my $conf = $checker->config;

Returns Checkit config structure

content

my $content = $checker->content;
my $newcontent = $checker->content("Foo Bar Baz");

Sets and returns the content value

error

my $error = $checker->error;
my $newerror = $checker->error("Blah-Blah-Blah");

Sets and returns the error value

message

my $message = $checker->message;
my $newmessage = $checker->message("Foo Bar Baz");

Sets and returns the message value

note

my $note = $checker->note;
$checker->note("Blah-Blah-Blah");

Sets and returns the note value

source

my $source = $checker->source;
my $newsource = $checker->source("http://foo.example.com");

Sets and returns the source value

status

my $status = $checker->status;
my $newstatus = $checker->status(1);

Sets and returns the status value

type

my $type = $checker->type;
my $newtype = $checker->type(1);

Sets and returns the type value

CONFIGURATION DIRECTIVES

General configuration options (directives) detailed describes in "GENERAL DIRECTIVES" in App::MonM

The checkit configuration directives are specified in named sections <checkit NAME> where NAME is the name of the checkit section. The NAME is REQUIRED attribute. For example:

<Checkit "foo">
Enable yes
Target code
IsTrue 200
</Checkit>

Each the checkit section can contain the following basic directives:

Enable
Enable yes

The main switcher of the checkit section

Default: no

Interval
Interval 20s

Defines the time interval between two checks

Format for time can be in any of the following forms:

20 -- in 20 seconds
180s -- in 180 seconds
2m -- in 2 minutes
12h -- in 12 hours
1d -- in 1 day
3M -- in 3 months
2y -- in 2 years
3m -- 3 minutes ago(!)

Default: 0

IsFalse
IsFalse Error.

The definition of "What is bad?"

Default: !!perl/regexp (?i-xsm:^\s*(0|error|fail|no|false))

Examples:

IsFalse !!perl/regexp (?i-xsm:^\s*(0|error|fail|no|false))
IsFalse 0
IsFalse Error.
IsTrue
IsTrue Ok.

The definition of "What is good?"

Default: !!perl/regexp (?i-xsm:^\s*(1|ok|pass|yes|true))

Examples:

IsTrue !!perl/regexp (?i-xsm:^\s*(1|ok|pass|yes|true))
IsTrue 1
IsTrue Ok.
OrderBy
OrderBy True,False

Controls the order in which True and False are evaluated. The OrderBy directive, along with the IsTrue and IsFalse directives, controls a two-pass resolve system. The first pass processes IsTrue or IsFalse directive, as specified by the OrderBy directive. The second pass parses the rest of the directive (IsFalse or IsTrue).

Ordering is one of:

OrderBy True,False

First, IsTrue directive is evaluated. Next, IsFalse directive is evaluated. If matches IsTrue, the check's result sets to true (PASSED), otherwise result sets to false (FAILED)

OrderBy False,True

First, IsFalse directive is evaluated. Next, IsTrue directive is evaluated. If matches IsFalse, the check's result sets to false (FAILED), otherwise result sets to true (PASSED)

Default: "True,False"

Examples:

OrderBy True,False
OrderBy ASC # Is same as: "True,False"
OrderBy False,True
OrderBy DESC # Is same as: "False,True"
SendTo
SendTo Alice

Defines a List of Recipients for notifications. There can be several such directives

Email addresses for sending notifications directly (See Channel SendMail):

SendTo foo@example.com
SendTo bar@example.com

...or SMS phone numbers (See Channel SMSGW):

SendTo 11231230002
SendTo +11231230001
SendTo +1-123-123-0003

...or a notify users:

SendTo Bob, Alice
SendTo Fred

...or a notify groups:

SendTo @Foo, @Bar
SendTo @Baz
Target
Target content

Defines a target for analysis of results

status - the status of the check operation is analyzed
code - the return code is analyzed (HTTP code, error code and etc.)
content - the content is analyzed (data from HTTP response, data
from command's STDOUT or data from DB)
message - the message is analyzed (HTTP message, eg.)

Default: status

Trigger
Trigger "curl http://cam.com/[NAME]/[ID]?[MSISDN] >/tmp/photo.jpg"

Defines triggers (system commands) that runs before sending notifications There can be several such directives Each trigger can contents the variables for auto replacement, for example:

Trigger "mycommand1 "[MESSAGE]""

Replacement variables:

[ID] -- Internal ID of the message
[MESSAGE], [MSG] -- The checker message content
[MSISDN] -- Phone number, recipient
[NAME] -- Checkit section name
[NOTE] -- The checker notes
[RESULT] -- The check result: PASSED/FAILED
[SOURCE], [SRC] -- Source string (URL, Command, etc.)
[STATUS] -- The checker status: OK/ERROR
[SUBJECT], [SBJ] -- Subject of message (MIME)
[TYPE] -- Type of checkit: http/dbi/command
Type
Type https

Defines checking type. As of today, three types are supported: http(s), command and dbi(db)

Default: http

Examples:

Type http
Type dbi
Type command

The HTTP checkit directives are describes in "CONFIGURATION DIRECTIVES" in App::MonM::Checkit::HTTP, the "Command" checkit directives are describes in "CONFIGURATION DIRECTIVES" in App::MonM::Checkit::Command, the DBI checkit directives are describes in "CONFIGURATION DIRECTIVES" in App::MonM::Checkit::DBI

HISTORY

See Changes file

TO DO

See TODO file

BUGS

* none noted

SEE ALSO

App::MonM

AUTHOR

Serż Minus (Sergey Lepenkov) https://www.serzik.com <abalama@cpan.org>

COPYRIGHT

Copyright (C) 1998-2022 D&D Corporation. All Rights Reserved

LICENSE

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

See LICENSE file and https://dev.perl.org/licenses/