App::MonM::Checkit - App::MonM checkit class
Version 1.03
use App::MonM::Checkit;
App::MonM checkit class
my $checker = App::MonM::Checkit->new;
Returns checker object
my $ostat = $checker->check({ ... });
Performs checking of checkit-sources by checkit rules (checkit config sections)
Returns status: 0 - PASS; 1 - FAIL
my $self = $checker->cleanup;
Flushes all working variables to defaults
my $code = $checker->code; my $newcode = $checker->code(200);
Sets and returns response code (rc)
my $conf = $checker->config;
Returns Checkit config structure
my $content = $checker->content; my $newcontent = $checker->content("Foo Bar Baz");
Sets and returns the content value
my $error = $checker->error; my $newerror = $checker->error("Blah-Blah-Blah");
Sets and returns the error value
my $message = $checker->message; my $newmessage = $checker->message("Foo Bar Baz");
Sets and returns the message value
my $note = $checker->note; $checker->note("Blah-Blah-Blah");
Sets and returns the note value
my $source = $checker->source; my $newsource = $checker->source("http://foo.example.com");
Sets and returns the source value
my $status = $checker->status; my $newstatus = $checker->status(1);
Sets and returns the status value
my $type = $checker->type; my $newtype = $checker->type(1);
Sets and returns the type value
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 URL https://www.example.com Target code IsTrue 200 </Checkit>
Each the checkit section can contain the following basic directives:
Enable yes
The main switcher of the checkit section
Default: no
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 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 Ok.
The definition of "What is good?"
Default: !!perl/regexp (?i-xsm:^\s*(1|ok|pass|yes|true))
IsTrue !!perl/regexp (?i-xsm:^\s*(1|ok|pass|yes|true)) IsTrue 1 IsTrue Ok.
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:
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"
OrderBy True,False OrderBy ASC # Is same as: "True,False" OrderBy False,True OrderBy DESC # Is same as: "False,True"
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 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 "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 https
Defines checking type. As of today, three types are supported: http(s), command and dbi(db)
Default: http
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
See Changes file
Changes
See TODO file
TODO
* none noted
App::MonM
Serż Minus (Sergey Lepenkov) https://www.serzik.com <abalama@cpan.org>
Copyright (C) 1998-2022 D&D Corporation. All Rights Reserved
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/
LICENSE
To install App::MonM, copy and paste the appropriate command in to your terminal.
cpanm
cpanm App::MonM
CPAN shell
perl -MCPAN -e shell install App::MonM
For more information on module installation, please visit the detailed CPAN module installation guide.