Monit

NAME

Monitor::Monit - Provide an interface to the monit monitoring daemon

SYNOPSIS


use Monitor::Monit;

# use default settings
my $mon = Monitor::Monit.new;

for $mon.service -> $service {
	say $service.name, " is ", $sevice.status-name;
}

DESCRIPTION

Monit is a lightweight, relatively simple and widely used system and application monitoring service.

This provides a mechanism to interact with its http api.

METHODS

method new

method new(Str :$host = 'localhost', Int :$port = 2812, Str :$username = 'admin', Str :$password = 'monit', Bool :$secure = False);

The constructor for the class, the parameters provide sensible defaults that should work out of the box for most installations. By default the monit daemon will only listen for connections on the loopback network device so if you intend to interact with a daemon on another host you may need to alter the configuration of the daemon.

If you are uncertain of the appropriate values for any of the parameters you should check the configuration of the monit daemon or ask a system administrator.

method status

method status() returns Monitor::Monit::Status

This requests the entire status as reported by the daemon returning a Monitor::Monit::Status object. This conprises details of each monitored service, the platform that the daemon is running on and the daemon itself. For convenience these are available as service, platform and server described below.

method service

method service() returns Array[Monitor::Monit::Status::Service]

This returns a list of Monitor::Monit::Status::Service describing each monitored service and their status.

method platform

method platform() returns Monitor::Monit::Status::Platform

This returns a Monitor::Monit::Status::Platform object that describes the physical host that the daemon is running on.

method server

method server() returns Monitor::Monit::Status::Server

This returns a Monitor::Monit::Status::Server object that describes the parameters of the monit daemon.

TYPES

Monitor::Monit::Status

attribute server

attribute platform

attribute service

Monitor::Monit::Status::Service

Provide the detail of a monitored service.

method command

method command(Action $action) returns Bool 

Request the action specified by $action on the service. Returns a Bool to indicate success or otherwise of the action.

The actions are specified by the enum :

  • Stop

  • Start

  • Restart

  • Monitor

  • Unmonitor

For convenience each action is expressed as a method, described below.

method stop

method stop() returns Bool

Stop the service if it is started. This depends on there being a stop command configured in the configuration for the service.

method start

method start() returns Bool

Start the service if it is stopped. This depends on there being a start command configured in the configuration for the service.

method restart

method restart() returns Bool

Restart the service, either by calling the configured restart command or by calling the stop command followed by the start command. It may fail if none of those are defined.

method monitor

method monitor() returns Bool

Resume monitoring the service if it had been previously un-monitored.

method unmonitor

method unmonitor() returns Bool

Turn off monitoring for the service (assuming it was being monitored. This will turn off any alerts and auto restart that may be configured.

attribute type

attribute name

attribute collected

attribute collected-usec

attribute status

attribute status-hint

attribute monitor

attribute monitormode

attribute pendingaction

attribute pid

attribute ppid

attribute uid

attribute euid

attribute gid

attribute uptime

attribute children

attribute memory

attribute cpu

attribute port

attribute unix

attribute system

method status-name

method status-name ( --> Str)

Monitor::Monit::Status::Platform

attribute name

The name of the operating system as reported. For example Linux.

attribute version

The version of the operating system kernel as reported by uname.

attribute machine

The architecture of the processor as would be reported by uname.

attribute cpu

The number of CPU cores reported by the system.

attribute memory

The amount of memory in bytes.

attribute swap

The amount of swap space in bytes.

Monitor::Monit::Status::Server

This class represents the running monit instance.

attribute id

A unique identifier string for the monit instance.

attribute incarnation

attribute version

A Version object representing the running monit server.

attribute uptime

A Duration object representing the time that the monit daemon has been running.

attribute poll

A Duration object representing the default time between the service checks.

attribute startdelay

A Duration object representing delay between the program being started and the first data being available. It defaults to 0.0

attribute localhostname

The local hostname of the host the monit daemon is running on. This is likely to be unqualified.

attribute controlfile

The path to the control file for the monit instance.

attribute httpd

An Monitor::Monit::Status::Server::Httpd object representing the http server that is used to communicate with the monit daemon. It has the following attributes:

address

The IP address to which the http server is bound to, this may for instance be '127.0.0.1' if it is only listening for local connections, '0.0.0.0' if it is listening on all the interfaces, or a specific address.

port

The integer port number the server is listening on (and to which you are connecting.)

ssl

A boolean to indicate whether it is an SSL connection.

Monitor::Monit v0.0.6

Provide an interface to the monit monitoring daemon

Authors

  • Jonathan Stowe

License

Artistic-2.0

Dependencies

HTTP::UserAgentURI::TemplateXML::Class

Test Dependencies

Provides

  • Monitor::Monit

Documentation

The Camelia image is copyright 2009 by Larry Wall. "Raku" is a trademark of the Yet Another Society. All rights reserved.

Built with Podlite — the markup and publishing tools behind this site.