DEBOPS.MONIT(5)

NAME
debops.monit - Manage Monit using Ansible

SYNOPSIS

debops service/monit [--limit group,host,...] [--diff] [--check] [--tags tag1,tag2,...] [--skip-tags tag1,tag2,...] [<ansible-playbook options>] ...

DESCRIPTION

Monit <https://mmonit.com/monit/> is a service monitoring daemon. It can be used to monitor processes, files, system and remote hosts, and if necessary, take configured actions when specific parameters change, like restarting services and notifying the system administrator.

This role can be used to configure Monit on a host. It will automatically detect selected services and configure checks for them.

GETTING STARTED

  Default configuration

By default, Monit uses the SMTP server installed on localhost to send e-mails to the root account. Make sure that the working SMTP server or relay is available with the proper forwarding, or change the configuration of the mail server used by Monit via Ansible inventory.

The Monit HTTP server will be enabled by default, however it's not exposed to the public network and only available on localhost interface. To protect the HTTP interface against attacks by unprivileged users on the same host, the HTTP interface is secured by a randomly generated password, stored in one of the configuration files. The root account can use the monit CLI interface to interact with Monit without the need for a password.

  Example inventory

To enable Monit on a host, you need to add that host in the [debops_service_monit] Ansible inventory group:

[debops_service_monit]
hostname

  Example playbook

If you are using this role without DebOps, here's an example Ansible playbook that uses the debops.monit role:

---
- name: Manage Monit service
  collections: [ 'debops.debops', 'debops.roles01',
                 'debops.roles02', 'debops.roles03' ]
  hosts: [ 'debops_service_monit' ]
  become: True
  environment: '{{ inventory__environment | d({})
                   | combine(inventory__group_environment | d({}))
                   | combine(inventory__host_environment  | d({})) }}'
  roles:
    - role: monit
      tags: [ 'role::monit', 'skip::monit' ]

DEFAULT VARIABLE DETAILS

Some of debops.monit default variables have more extensive configuration than simple strings or lists, here you can find documentation and examples for them.

  monit__config

The monit__*_config variables contain the Monit configuration which will be generated in the /etc/monit/conf.d/ directory. The configuration stored in this directory will override configuration defined in the main Monit config file.

Each entry is a YAML dictionary that defines one configuration file with specific parameters:

name
    Required. Name of the configuration file. This parameter is used as the key in the internal configuration dictionary and can be used to override configuration entries in the inventory.

content
    A string or YAML text block with the contents of the generated configuration file. See the monit(1) <https://manpages.debian.org/monit(1)> for the Monit configuration syntax that can be used here. This parameter can use Jinja template statements for conditional configuration.

weight
    Optional. If specified, this number will be prepended to the configuration file name to aid with order of the configuration files.

state
    Optional. If not specified or present, the configuration will be generated. If absent, existing configuration will be removed. If init, the configuration will be defined, but it won't be generated - this can be used to conditionally enable Monit configuration without the need to define it entirely. If ignore, a given configuration entry will not be processed by the role.

mode
    Optional. Set the attributes of the generated configuration file (they are set to 0600 by default). If the mode 0600 is set explicitly, the configuration file generation will not be logged by Ansible and diff of the file will not be shown, this is useful for files with sensitive data like passwords.

comment
    Optional. String or YAML text block with additional comments about the configuration.

  Examples

Check some of the system parameters using Monit:

monit__config:
  - name: 'check_system'
    content: |
      check system example.org
      if loadavg (1min) > 4 for 5 cycles then alert
      if memory usage > 75% for 5 cycles then alert
    weight: 50

AUTHOR
Nick Janetakis, Maciej Delmanowski

COPYRIGHT
2014-2022, Maciej Delmanowski, Nick Janetakis, Robin Schneider and others