Puppet Class: monit

Inherits:
monit::params
Defined in:
manifests/init.pp

Overview

monit

This class is the responsible of installing and configuring the Monit service. Almost all configuration options for ‘monitrc` are exposed as class parameters.

In addition to Monit configuration options, this class accepts other parameters:

* `init_system`, to set globally the default init system for `service` checks.
* `checks`, to provide checks from Hiera.

Lastly, this class also configures a ‘system` check with sane defaults. It can be disabled or tweaked to fit your needs. See the set of parameters starting with `system_`.

Parameters:

  • service_enable (Boolean) (defaults to: true)

    Whether to enable the monit service.

  • service_ensure (Enum[ 'running', 'stopped' ]) (defaults to: 'running')

    Ensure status of the monit service.

  • conf_file (Stdlib::Absolutepath) (defaults to: $monit::params::conf_file)

    Path to the Monit main configuration file.

  • conf_dir (Stdlib::Absolutepath) (defaults to: $monit::params::conf_dir)

    Path to the Monit configuration directory (where checks are placed).

  • conf_purge (Boolean) (defaults to: true)

    Whether to purge checks not managed by Puppet.

  • check_interval (Integer) (defaults to: $monit::params::check_interval)

    Check services at given interval.

  • check_start_delay (Integer) (defaults to: $monit::params::check_start_delay)

    Delay the first check after Monit starts by this interval.

  • logfile (Variant[ Stdlib::Absolutepath, Pattern['^syslog( facility [_a-zA-Z0-9]+)?$'] ]) (defaults to: $monit::params::logfile)

    Path to a logfile or syslog logging facility.

  • idfile (Optional[Stdlib::Absolutepath]) (defaults to: $monit::params::idfile)

    Path to the Monit instance unique id file.

  • statefile (Optional[Stdlib::Absolutepath]) (defaults to: $monit::params::statefile)

    Path to the persistent state file.

  • eventqueue (Boolean) (defaults to: $monit::params::eventqueue)

    Whether to enable the event queue.

  • eventqueue_basedir (Stdlib::Absolutepath) (defaults to: '/var/monit')

    Path to the event queue directory.

  • eventqueue_slots (Integer) (defaults to: 100)

    Size of the event queue.

  • mmonit_url (Optional[Stdlib::Httpurl]) (defaults to: undef)

    M/Monit url.

  • mailserver (Optional[String]) (defaults to: undef)

    List of mail servers for alert delivery.

  • mailformat_from (String) (defaults to: "monit@${facts['networking']['fqdn']}")

    Override FROM field of the alert mail format.

  • mailformat_replyto (Optional[String]) (defaults to: undef)

    Override REPLYTO field of the alert mail format. NOTE: reply-to available since Monit 5.

  • mailformat_subject (Optional[String]) (defaults to: undef)

    Override SUBJECT field of the alert mail format.

  • mailformat_message (Optional[String]) (defaults to: undef)

    Override MESSAGE field of the alert mail format.

  • alerts (Array[String]) (defaults to: [])

    Alert recipients. Alerts may be restricted on events by using a filter.

  • httpserver (Boolean) (defaults to: true)

    Whether to enable the embedded webserver.

  • httpserver_port (Integer[1024, 65535]) (defaults to: 2812)

    Webserver port.

  • httpserver_bind_address (Optional[String]) (defaults to: undef)

    Webserver bind address.

  • httpserver_ssl (Boolean) (defaults to: false)

    Whether to enable SSL for the webserver.

  • httpserver_pemfile (Optional[ Stdlib::Absolutepath ]) (defaults to: undef)

    Webserver SSL certificate file.

  • httpserver_allow (Array[String]) (defaults to: ['localhost'])

    Webserver grants.

  • init_system (Enum[ 'sysv', 'systemd', 'upstart' ]) (defaults to: $monit::params::init_system)

    Default init system. Used to build service checks.

  • service_program (Stdlib::Absolutepath) (defaults to: $monit::params::service_program)

    Path to the default init system program.

  • system_check_ensure (Monit::Check::Ensure) (defaults to: 'present')

    Whether to create the system check.

  • system_loadavg_1min (Numeric) (defaults to: (3 * $::facts['processors']['count'])

    1 minute load average threshold.

  • system_loadavg_5min (Numeric) (defaults to: (1.5 * $::facts['processors']['count'])

    5 minute load average threshold.

  • system_loadavg_15min (Numeric) (defaults to: (1.5 * $::facts['processors']['count'])

    15 minute load average threshold.

  • system_cpu_user (String) (defaults to: '75%')

    CPU user usage threshold.

  • system_cpu_system (String) (defaults to: '30%')

    CPU system usage threshold.

  • system_cpu_wait (String) (defaults to: '30%')

    CPU wait usage threshold.

  • system_memory (String) (defaults to: '75%')

    Memory usage threshold.

  • system_swap (Optional[String]) (defaults to: undef)

    Swap usage threshold. NOTE: swap available since monit 5.2.

  • system_fs (Variant[ Array[Stdlib::Absolutepath], Array[Pattern['^/']] ]) (defaults to: [])

    Path to filesystems to check. If empty, will check all mounted filesystems, but the ones with a type in $monit::fs_banned_types.

  • system_fs_space_usage (String) (defaults to: '80%')

    Filesystem space usage threshold.

  • system_fs_inode_usage (String) (defaults to: '80%')

    Filesystem inode usage threshold.

  • system_cycles (Optional[Integer]) (defaults to: undef)

    Number of cycles before alerting.

  • fs_banned_types (Array[String]) (defaults to: ['devpts', 'devtmpfs', 'hugetlbfs', 'mqueue', 'nsfs', 'overlay', 'rpc_pipefs', 'tmpfs'])

    List of filesystem types to ignore in generation of $monit::system_fs.

  • system_ifaces (Optional[Array[String]]) (defaults to: undef)

    Network interfaces to check. If empty, will check $facts[‘primary’] network interface.

  • checks (Hash[String, Hash]) (defaults to: {})

    Hash of additional checks to create.

  • hiera_merge_strategy (Optional[Enum[ 'hiera_hash', ]]) (defaults to: undef)

    Merge strategy when obtaining checks from Hiera. Deprecated use instead hiera 5 [‘lookup_options`](puppet.com/docs/puppet/latest/hiera_merging.html).



108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
# File 'manifests/init.pp', line 108

class monit (
  Boolean $service_enable                   = true,
  Enum[
    'running',
    'stopped'
  ] $service_ensure                         = 'running',
  Stdlib::Absolutepath $conf_file           = $monit::params::conf_file,
  Stdlib::Absolutepath $conf_dir            = $monit::params::conf_dir,
  Boolean $conf_purge                       = true,
  Integer $check_interval                   = $monit::params::check_interval,
  Integer $check_start_delay                = $monit::params::check_start_delay,
  # $logfile can be an absolute path or
  # a string of the form "syslog facility log_daemon"
  Variant[
    Stdlib::Absolutepath,
    Pattern['^syslog( facility [_a-zA-Z0-9]+)?$']
  ] $logfile                                = $monit::params::logfile,
  Optional[Stdlib::Absolutepath] $idfile    = $monit::params::idfile,
  Optional[Stdlib::Absolutepath] $statefile = $monit::params::statefile,
  Boolean $eventqueue                       = $monit::params::eventqueue,
  Stdlib::Absolutepath $eventqueue_basedir  = '/var/monit',
  Integer $eventqueue_slots                 = 100,
  Optional[Stdlib::Httpurl] $mmonit_url     = undef,
  Optional[String] $mailserver              = undef,
  String $mailformat_from                   = "monit@${facts['networking']['fqdn']}",
  # NOTE: reply-to available since monit 5.2
  Optional[String] $mailformat_replyto      = undef,
  Optional[String] $mailformat_subject      = undef,
  Optional[String] $mailformat_message      = undef,
  Array[String] $alerts                     = [],
  Boolean $httpserver                       = true,
  Integer[1024, 65535] $httpserver_port     = 2812,
  Optional[String] $httpserver_bind_address = undef,
  Boolean $httpserver_ssl                   = false,
  Optional[
    Stdlib::Absolutepath
  ] $httpserver_pemfile                     = undef,
  Array[String] $httpserver_allow           = ['localhost'],
  # Init system defaults.
  Enum[
    'sysv',
    'systemd',
    'upstart'
  ] $init_system                           = $monit::params::init_system,
  Stdlib::Absolutepath $service_program    = $monit::params::service_program,
  # System resources check.
  Monit::Check::Ensure $system_check_ensure = 'present',
  Numeric $system_loadavg_1min              = (3 * $::facts['processors']['count']),
  Numeric $system_loadavg_5min              = (1.5 * $::facts['processors']['count']),
  Numeric $system_loadavg_15min             = (1.5 * $::facts['processors']['count']),
  String $system_cpu_user                   = '75%',
  String $system_cpu_system                 = '30%',
  String $system_cpu_wait                   = '30%',
  String $system_memory                     = '75%',
  # NOTE: swap available since monit 5.2.
  Optional[String] $system_swap             = undef,
  Variant[
    Array[Stdlib::Absolutepath],
    Array[Pattern['^/']]
  ] $system_fs                              = [],
  String $system_fs_space_usage             = '80%',
  String $system_fs_inode_usage             = '80%',
  Optional[Integer] $system_cycles          = undef,
  Array[String] $fs_banned_types            = ['devpts', 'devtmpfs', 'hugetlbfs', 'mqueue', 'nsfs', 'overlay', 'rpc_pipefs', 'tmpfs'],
  Optional[Array[String]] $system_ifaces    = undef,
  # Additional checks.
  Hash[String, Hash] $checks                = {},
  Optional[Enum[
      'hiera_hash',
  ]] $hiera_merge_strategy                  = undef,
) inherits monit::params {
  if !empty($hiera_merge_strategy) {
    warning('\$hiera_merge_strategy parameter is deprecated and will be removed in future versions! Please use Hiera 5 `lookup_options` instead. See https://puppet.com/docs/puppet/latest/hiera_merging.html')
  }
  class { 'monit::install': }
  -> class { 'monit::config': }
  ~> class { 'monit::service': }
  -> Class['monit']
}