File: configuration.rst

package info (click to toggle)
simplemonitor 1.15.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,520 kB
  • sloc: python: 8,725; sh: 258; makefile: 74; javascript: 69
file content (244 lines) | stat: -rw-r--r-- 6,790 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
.. _Configuration:

Configuration
=============

The main configuration lives in :file:`monitor.ini`. By default, SimpleMonitor will
look for it in the working directory when launched. To specify a different
file, use the ``-f`` option.

The format is fairly standard "INI"; section names are lowercase in ``[square
brackets]``, and values inside the sections are defined as ``key=value``. You
can use blank lines to space things out, and comments start with ``#``.

Section names and option values, but not option names, support environment
variable injection. To include the value of an environment variable, use
``%env:VARIABLE%``, which will inject the value of ``$VARAIBLE`` from the
environment. You can use this to share a common configuration file across
multiple hosts, for example.

This main configuration file contains the global settings for SimpleMonitor,
plus the logging and alerting configuration. A separate file, by default
:file:`monitors.ini`, contains the monitor configuration. You can specify a
different monitors configuration file using a directive in the main
configuration.

.. warning:: I know the configuration file names are dumb, sorry.

.. _config-bytes:

Configuration value types
-------------------------

Values which take **bool** accept ``1``, ``yes``, and ``true`` as truthy, and
everything else as falsey.

Values which take **bytes** accept suffixes of ``K``, ``M``, or ``G`` for
kibibytes, mibibytes or gibibytes, otherwise are just a number of bytes.

``monitor.ini``
---------------

This file must contain a ``[monitor]`` section, which must contain at least the ``interval`` setting.

``[monitor]`` section
^^^^^^^^^^^^^^^^^^^^^

.. confval:: interval

   :type: integer
   :required: true

   defines how many seconds to wait between running all the monitors. Note that
   the time taken to run the monitors is not subtracted from the interval, so
   the next iteration will run at interval + time_to_run_monitors seconds.

.. confval:: monitors

    :type: string
    :required: false
    :default: ``monitors.ini``

    the filename to load the monitors themselves from. Relative to the cwd, not
    the path of this configuration file.

    If you want to use only ``monitors_dir``, set this to nothing (``monitors=``).



.. confval:: monitors_dir

    :type: string
    :required: false

    a directory to scan for ``*.ini`` files which are merged with the main
    monitors config file. Files are loaded in lexicographic order, and if a
    monitor name is reused, the last definition wins. Relative to the cwd, not
    the path of this configuration file.

    The main ``monitors`` file is always loaded first.

.. confval:: pidfile

    :type: string
    :required: false
    :default: none

    the path to write a pidfile to.

.. _config-remote:

.. confval:: remote

    :type: bool
    :required: false
    :default: false

    enables the listener for receiving data from remote instances. Can be
    overridden to disabled with ``-N`` command line option.

.. confval:: remote_port

    :type: integer
    :required: if ``remote`` is enabled

    the TCP port to listen on for remote data

.. confval:: key

    :type: string
    :required: if ``remote`` is enabled

    shared secret for validating data from remote instances.

.. confval:: bind_host

    :type: string
    :required: false
    :default: ``0.0.0.0`` (all interfaces)

    the local IP address to listen on, if ``remote`` is enabled.

.. confval:: hup_file

    :type: string
    :required: false
    :default: none

    a file to watch the modification time on. If the modification time increases, SimpleMonitor :ref:`reloads its configuration<Reloading>`.

    .. tip:: SimpleMonitor will reload if it receives SIGHUP; this option is useful for platforms which don't have that.

.. confval:: bind_host

    :type: string
    :required: false
    :default: all interfaces

    the local address to bind to for remote data

``[reporting]`` section
^^^^^^^^^^^^^^^^^^^^^^^

.. confval:: loggers

    :type: comma-separated list of string
    :required: false
    :default: none

    the names of the loggers you want to use. Each one must be a ``[section]`` in this configuration file.

    See Loggers for the common options and list of Alerters with their configurations.

.. confval:: alerters

    :type: comma-separated list of string
    :required: false
    :default: none

    the names of the alerters you want to use. Each one must be a ``[section]`` in this configuration file.

    See Alerters for the common options and list of Alerters with their configurations.

``monitors.ini``
----------------

This file only contains monitors. Each monitor is a ``[section]`` in the file,
with the section name giving the monitor its name. The name ``defaults`` is
reserved, and can be used to specify default values for options. Each monitor's
individual configuration overrides the defaults.

See Monitors for the common options and list of Monitors with their configurations.

Example configuration
---------------------

This is an example pair of configuration files to show what goes where. For more examples, see :ref:`Config examples`.

:file:`monitor.ini`:

.. code-block:: ini

   [monitor]
   interval=60

   [reporting]
   loggers=logfile
   alerters=email,sms

   # write a log file with the state of each monitor, each time
   [logfile]
   type=logfile
   filename=monitor.log

   # email me when monitors fail or succeed
   [email]
   type=email
   host=mailserver.example.com
   from=monitor@example.com
   to=admin@example.com

   # send me an SMS after a monitor has failed 10 times in a row
   [sms]
   type=bulksms
   username=some-username
   password=some-password
   target=+447777123456
   limit=10

:file:`monitors.ini`:

.. code-block:: ini

   # check the webserver pings
   [www-ping]
   type=ping
   host=www.example.com

   # check the webserver answers https; don't bother checking if it's not pinging
   [www-http]
   type=http
   url=https://www.example.com
   depend=www-ping

   # check the root partition has at least 1GB of free space
   [root-diskspace]
   type=diskspace
   partition=/
   limit=1G

.. _Reloading:

Reloading
---------

You can send SimpleMonitor a SIGHUP to make it reload its configuration. On
platforms which don't have that (e.g. Windows), you can specify a file to
watch. If the modification time of the file changes, SimpleMonitor will reload
its configuration.

Reloading will pick up a change to ``interval`` but no other configuration in
the ``[monitor]`` section. Monitors, Alerters and Loggers are reloaded. You can
add and remove them, and change their configurations, but not change their
types. (To change a type, first remove it from the configuration and reload,
then add it back in.)