Example control file¶
Every release carries this file; the installer puts it at
/usr/local/share/flyingmonit-agent/flyingmonit-agentrc.example and writes the first
/etc/flyingmonit-agentrc from it. It has the sections of Monit's monitrc in Monit's
order, each statement with an example and how it stands against Monit. The
agent's tests check it with every release: every statement the agent reads has its
example, and what it calls Monit's, Monit takes.
###############################################################################
## FlyingMonit Agent control file
###############################################################################
##
## This is the FlyingMonit Agent's example control file. The agent reads
## Monit's control file syntax: a control file written for Monit is one for the
## agent, as far as the agent supports its statements. This file shows every
## statement of Monit in the place Monit's own monitrc has it, explains
## it, and says how the agent stands to it.
##
## How to use it
## -------------
##
## Copy it, remove the '#' and the space after it from the examples you want,
## and adapt them. The installer writes the first /etc/flyingmonit-agentrc from
## this file, with the poll interval, the collector, the id and pid files and
## the system service in force; the release puts the file itself at
## /usr/local/share/flyingmonit-agent/flyingmonit-agentrc.example, renewed with
## every update. An update never changes /etc/flyingmonit-agentrc -- but once:
## a host the agent updated every minute before set agent update was there gets
## "set agent update every 1 minute" at its end, so that it keeps updating.
##
## A control file of this file's form keeps it with "flyingmonit-agent format":
## this file as the installed release has it, the control file's statements in
## force in their blocks -- printed, or with --write in its place (a copy kept).
##
## Where the agent looks for its control file (the first that exists):
## -c <file> on the command line, else ~/.flyingmonit-agentrc,
## /etc/flyingmonit-agentrc, /usr/local/etc/flyingmonit-agentrc,
## ./flyingmonit-agentrc
##
## The control file must be readable and writable by its owner only (mode 0600
## or stricter), as Monit's: it holds passwords. The agent refuses one others may
## read. The service on Debian reads /etc/flyingmonit-agentrc as the user
## flyingmonit-agent, who owns it.
##
## Check a control file: flyingmonit-agent -t -c <file>
## Have the running agent read it: systemctl reload flyingmonit-agent
## (or: flyingmonit-agent reload)
##
## Syntax
## ------
##
## - A '#' starts a comment, to the end of the line.
## - Statements are free in form: spaces, tabs and line breaks separate words,
## a statement may go on over several lines (indented by custom).
## - Keywords are case-insensitive: "set daemon" and "SET DAEMON" are the same.
## - A value with spaces is quoted, with "..." or '...'.
## - Some words are only for reading: "and", "with", "use" may stand or not
## ("check filesystem data with path ..." = "check filesystem data path ...").
## - $HOST is the host's name, as the system has it (/proc/sys/kernel/hostname).
## - The statements may come in any order; the services are reported in the
## order they stand, and an include reads its files where it stands.
##
## What the agent does not support yet, it never ignores: a control file with
## such a statement is refused with an error naming the file, the line and the
## word -- the agent does not start, a reload keeps the agent as it was. So a
## control file the agent accepts is one it carries out.
##
## Each statement below says how it stands to Monit:
## "Monit: same" -- it means what it means for Monit
## "Monit: differs -- ..." -- the agent takes it; the difference named
## "FlyingMonit Agent: not supported yet" -- the agent refuses it; Monit takes it
## "FlyingMonit Agent: its own" -- the agent takes it; Monit refuses it
## The agent's tests check this with every release: every example the agent
## takes passes its -t, every example of Monit's statements passes Monit's, and
## Monit refuses every one of the agent's own.
##
## "Monit" in this file is the reference Monit, Monit 6.1.0: the version
## the agent and this file are checked against, raised in a change of its own
## when Monit releases a new one.
##
###############################################################################
## Global section
###############################################################################
##
## The poll interval
## -----------------
##
## Syntax: set daemon <seconds>
##
## Runs the agent as a daemon that checks its services every <seconds> (1 to
## 86400). It sends a status report to its collectors after every check, and
## between checks at least every 17 seconds, so FlyingMonit sees the host
## alive even with a long interval.
##
## Without it the agent checks its services once and exits, sending nothing
## (unless the command line names an interval). The command line's -d <seconds>
## wins over it; with -I (run in the foreground, as systemd runs the service)
## one of the two is needed.
##
## Default: none -- without it the agent checks once and exits, sending
## nothing. The installer writes 60 seconds.
##
## Monit: differs -- "with start delay <seconds>" is not supported yet.
##
# set daemon 60
#
##
## The log
## -------
##
## Syntax: set log <file>
##
## Writes the agent's log to the file, appended to it: its start and stop, the
## failures to report, what it could not read, the services' events -- each
## line "[<date and time>] <level> : <message>". The user the agent runs as (root,
## as the installer sets it up) must be able to create or write the file, in a
## folder that exists.
##
## Without it, the agent in the foreground (-I) logs to its standard output --
## on Debian the service's journal: journalctl -u flyingmonit-agent -- and the
## agent in the background logs nothing. The command line's -l <file> wins
## over it. -v adds debugging lines (each report sent).
##
## Default: none -- the standard output in the foreground (the journal for the
## service), nothing in the background.
##
## Monit: differs -- "set log syslog" is not supported yet.
##
## A file in /tmp, for a try; the service's user may write in its home,
## /var/lib/flyingmonit-agent, too:
# set log /tmp/flyingmonit-agent.log
#
##
## The pid file
## ------------
##
## Syntax: set pidfile <file>
##
## The file the running agent writes its process id to. The agent's command
## line finds the running agent through it: "flyingmonit-agent" without a
## command wakes it to check at once, "reload", "quit", "status", "summary"
## and "report" reach it -- so the command line must read the same control
## file, or name the file with -p. A second start while it runs only wakes it.
##
## Default: ~/.flyingmonit-agent.pid in the home of the user running it. The
## installer writes the service's own, so that root's command line reaches the
## service. The command line's -p <file> wins over it.
##
## Monit: differs -- the default is ~/.flyingmonit-agent.pid, not
## ~/.monit.pid, so the agent and Monit can run on one host.
##
## The service's, as the installer writes it:
# set pidfile /var/lib/flyingmonit-agent/.flyingmonit-agent.pid
#
##
## The id file
## -----------
##
## Syntax: set idfile <file>
##
## The file holding the agent's unique id: 32 hexadecimal digits, made at the
## agent's first start when the file does not exist. Every report carries it;
## FlyingMonit knows the host by it. "flyingmonit-agent --id" prints it,
## "--resetid" makes a new one -- FlyingMonit then sees a new host.
##
## Default: ~/.flyingmonit-agent.id in the home of the user running it.
##
## Replacing Monit on a host: copy Monit's id into this file before the agent's
## first start, and FlyingMonit goes on with the host it knows (its history,
## its settings).
##
## Monit: differs -- the default is ~/.flyingmonit-agent.id, not
## ~/.monit.id.
##
## The service's, as the installer writes it:
# set idfile /var/lib/flyingmonit-agent/.flyingmonit-agent.id
#
##
## The state file
## --------------
##
## Monit keeps its services' monitoring states in it across restarts (which
## services are monitored, which not).
##
## FlyingMonit Agent: not supported yet.
##
# set statefile /var/lib/monit/state
#
##
## Limits
## ------
##
## Monit's limits for its tests: how much of a program's output or a file's
## content it reads, how long it waits on the network.
##
## FlyingMonit Agent: not supported yet.
##
# set limits { programoutput: 1 kB, sendexpectbuffer: 512 B, filecontentbuffer: 512 B, httpcontentbuffer: 1 MB, networktimeout: 5 s }
#
##
## SSL/TLS options
## ---------------
##
## Monit's global options for its TLS connections: whether certificates are
## verified, self-signed ones accepted, which versions and ciphers.
##
## FlyingMonit Agent: not supported yet. (The agent's https connections to its
## collectors are verified against the system's certificates.)
##
# set ssl { verify: enable, selfsigned: reject }
#
##
## Mail servers
## ------------
##
## The mail servers Monit sends its alert mails through, tried in turn.
##
## FlyingMonit Agent: not supported yet. (The agent reports its events to
## FlyingMonit, which alerts by mail.)
##
# set mailserver smtp.example.org
#
##
## The event queue
## ---------------
##
## A folder where Monit keeps the alerts no mail server took, to send them
## later.
##
## FlyingMonit Agent: not supported yet. (A report no collector took is not
## kept: the next status report says how the host is.)
##
# set eventqueue basedir /var/lib/monit/events slots 100
#
##
## Reporting to FlyingMonit
## ------------------------
##
## Syntax: set mmonit <url> [timeout <seconds> second[s]]
##
## Reports the host to a collector: FlyingMonit's collector, or another that
## takes Monit's reports. <url> is the collector's http or https URL with the
## collector login of FlyingMonit (Administration, collector logins) as
## user:password -- written <credentials> below. A user or password with
## characters a URL does not allow (@ : / ? # %) is percent-encoded (@ is %40).
##
## The agent sends a status report after every check and at least every 17
## seconds, and an event when it starts, stops or is reloaded and when a
## service's test fails or recovers. A report a collector does not take (no
## answer, an error) is logged -- the URL without the password -- and the next
## report is sent as usual; nothing is queued. The password is never logged.
##
## timeout: how long to wait for the collector's answer, 1 to 300 seconds
## (default 5); a report not answered by then is given up.
##
## An https URL is verified against the system's certificates; a collector with
## a certificate that does not verify gets no report (the agent logs why).
##
## Each "set mmonit" adds a collector; every report goes to each, at once.
##
## Default: none -- without a "set mmonit" the agent reports to no one. The
## timeout: 5 seconds. The installer writes the collector --collector names.
##
## Monit: differs -- "register without credentials" and the "ssl { ... }"
## options are not supported yet.
##
## A collector over http (only within a trusted network: the password is sent
## in clear):
# set mmonit http://<credentials>@collector.example/collector
#
## Over https, waiting at most 5 seconds for the answer:
# set mmonit https://<credentials>@collector.example/collector timeout 5 seconds
#
## Over https, waiting at most a second:
# set mmonit https://<credentials>@collector.example/collector timeout 1 second
#
##
## The alert mails' format
## -----------------------
##
## The sender, subject and text of Monit's alert mails.
##
## FlyingMonit Agent: not supported yet.
##
# set mail-format { from: monit@example.org }
#
##
## Alert recipients
## ----------------
##
## Who gets Monit's alert mails, of which events.
##
## FlyingMonit Agent: not supported yet. (FlyingMonit's alerts go to its users.)
##
# set alert admin@example.org
#
##
## The HTTP interface
## ------------------
##
## Syntax: set httpd [port <n>] [[and] [use] address <host or address>]
## [[with] ssl { <option>: <value> ... }]
## allow <host | address | address/bits | address/mask | user:password> ...
##
## Opens the agent's HTTP interface, which its command line asks for "status",
## "summary" and "report" -- as Monit's command line asks Monit. Without it
## those commands say "the HTTP interface is not enabled".
##
## port: the TCP port, 1 to 65535 (default 2812).
## address: the address to listen on, a name or an address (default: every
## address of the host). The command line asks this address -- localhost
## when none is given.
## allow: who may ask, as often as needed --
## - a host's name (resolved when the file is read), an IPv4 or IPv6
## address, or a net as address/bits or address/mask: a connection from
## elsewhere is closed unanswered;
## - user:password: the request must carry one of them (HTTP Basic
## authentication); the command line sends the first. A password with
## spaces is quoted: admin:"pass word".
## Hosts and users together: both must hold. Without any "allow" no port is
## opened at all.
##
## Every request must also carry the same security token in its cookie and
## its body (the command line does), against requests a browser could be
## tricked into. A reload opens the interface anew as the file says; a port in
## use is logged, and the agent runs on without it.
##
## ssl: the interface speaks HTTPS only -- a plain HTTP request, or one in a TLS
## version not allowed, is closed unanswered -- and the command line asks over
## HTTPS. Its options, a comma between them or not:
## - pemfile: <file>: the key and the certificate (with its chain) in one
## PEM file; or pemchain: <file> (the certificate and its chain) and
## pemkey: <file> (the key). A file holding the key must exist and allow
## no more than mode 0750 -- the control file is refused otherwise. They
## are read at the start and at a reload.
## - selfsigned: allow|reject: the command line takes a self-signed
## certificate -- the configured one -- or refuses it (default reject:
## "self signed certificate is not allowed").
## - verify: enable|disable: the command line checks the certificate against
## the system's authorities and the host it asks (default enable), or takes
## the configured certificate whatever name it carries.
## - version: auto, tlsv12, tlsv13, each excluded with "-" (default auto:
## TLS 1.2 and 1.3).
##
## Security: without ssl the interface speaks plain HTTP -- passwords and
## answers cross the network unencrypted: keep it on localhost then. With ssl,
## use a certificate of an authority the hosts trust, or selfsigned: allow on
## the hosts that ask.
##
## Default: none -- without "set httpd" no interface, and "status", "summary"
## and "report" say it is not enabled. The port: 2812. The address: every
## address of the host. Allow: none -- no port opened. ssl: none -- plain HTTP.
## The installer writes no "set httpd".
##
## Monit: differs -- it answers "status", "summary" and "report" only:
## no web pages, no actions (start, stop, monitor, ...). A port outside 1 to
## 65535 is refused when the file is read (Monit fails only at its start).
## Of ssl's options "ciphers" (Go chooses its own), "clientpemfile",
## "cacertificatefile" and "cacertificatepath", and the TLS versions before
## 1.2 are not supported yet; nor "unixsocket", "read-only", "signature",
## "allow @<group>" and htpasswd files ("allow md5|crypt|cleartext <file>").
##
## The usual: on this host only, with a password of its own:
# set httpd port 2812 and use address localhost
# allow localhost
# allow admin:"pass word"
#
## On one address, for the hosts that resolve as localhost, no password:
# set httpd port 2812 address 127.0.0.1
# allow localhost
#
## On every address, for a user only (any host may try the password):
# set httpd port 2812
# allow admin:monit
#
## On every address, for nets and an address, each with the password:
# set httpd port 2812
# allow 10.0.0.0/8
# allow 192.168.0.0/255.255.0.0
# allow ::1
# allow admin:monit
#
## The default port, 2812:
# set httpd
# allow admin:monit
#
## Over TLS, the key and the certificate in one file:
# set httpd port 2812
# with ssl { pemfile: /etc/ssl/private/flyingmonit-agent.pem }
# allow admin:monit
#
## Over TLS on this host, a self-signed certificate and its key apart:
# set httpd port 2812 and use address localhost
# ssl { pemchain: /etc/ssl/certs/flyingmonit-agent.pem, pemkey: /etc/ssl/private/flyingmonit-agent.key, selfsigned: allow }
# allow admin:monit
#
## Over TLS 1.3 only, the command line taking the configured certificate:
# set httpd port 2812
# with ssl { pemfile: /etc/ssl/private/flyingmonit-agent.pem, verify: disable, version: tlsv13 }
# allow admin:monit
#
##
## After a reboot
## --------------
##
## Whether Monit starts its services' monitoring after the host's reboot.
##
## FlyingMonit Agent: not supported yet.
##
# set onreboot start
#
###############################################################################
## FlyingMonit Agent section
###############################################################################
##
## Statements only the FlyingMonit Agent has -- Monit does not take them --
## stand here, so that the sections before and after stay Monit's. Each begins
## with "set agent". A control file with one of them is no longer one for
## Monit: remove them before you give it to Monit.
##
##
## Updates
## -------
##
## Syntax: set agent update every <n> minute[s]|hour[s]|day[s]
## set agent update disable
##
## The agent installs a newer release by itself, checking every <n> minutes,
## hours or days -- from 1 minute to 7 days -- plus a random delay of up to a
## tenth of that (at most 5 minutes), so that hosts do not all ask at once.
## It installs only a release whose signature verifies with the key installed
## with the agent, that takes this control file, and that still runs 30
## seconds after its start; else it puts the previous one back and never tries
## that version again. "disable" switches the updates off.
##
## Default: off -- without the statement the agent never updates itself.
##
## FlyingMonit Agent: its own -- Monit refuses it.
##
## Once a day:
# set agent update every 1 day
#
## Off:
# set agent update disable
#
###############################################################################
## Services
###############################################################################
##
## Each service has a name of its own (a second service of a name is refused).
## The services are reported in the order they stand here.
##
## The system
## ----------
##
## Syntax: check system <name>
##
## The host itself, reported to FlyingMonit as the system service: its load
## averages, CPU usage (user, system, nice, iowait, interrupts, steal, guest),
## memory and swap in use, pages swapped in and out per second, uptime and boot
## time, file descriptors in use. One "check system" at most.
##
## Default: the system service is reported also without it, named as the host.
## The installer writes "check system $HOST".
##
## Monit: differs -- its tests ("if loadavg ... then", "if cpu ...",
## "if memory ...", ...) are not supported yet.
##
## Named as the host:
# check system $HOST
#
##
## A file
## ------
##
## Monit checks a file: whether it exists, its checksum, permissions, owner,
## size, timestamps, its content.
##
## FlyingMonit Agent: not supported yet.
##
# check file app path /etc/app.conf
#
##
## A process
## ---------
##
## Monit checks a process, by its pid file or a pattern: whether it runs, its
## CPU and memory, its children; it starts, stops and restarts it.
##
## FlyingMonit Agent: not supported yet.
##
# check process app with pidfile /run/app.pid
#
##
## A filesystem
## ------------
##
## Syntax: check filesystem <name> [with] path <mount point or device>
## [if space usage > <percent>% then alert]
##
## A mounted filesystem, by its mount point or the device mounted (as
## /proc/self/mounts names them; the last mount there when several). Reported
## to FlyingMonit: its type and mount flags, its mount point's permission and
## owner, its block size, space total, free and used (the root's reserve counts
## as free, unlike df), inodes total and free.
##
## A path where nothing is mounted is a failed service, "Does not exist", with
## one event; the agent goes on checking it.
##
## The space usage test: when the space used gets over <percent> (0 to 100, a
## fraction allowed), the agent sends an event and the service fails
## ("Resource limit matched"); when it is back to or under the limit, an event
## that it recovered. One test per filesystem.
##
## Default: none -- no filesystem is checked without its "check filesystem";
## without a test its figures are reported, with no event but "Does not exist".
##
## Monit: differs -- of its tests only "if space usage > <percent>% then
## alert" is supported yet ("space free", "inode usage", "read rate", "if
## changed fsflags", "for <n> cycles", other actions, ... are not).
##
## The root filesystem, its figures only:
# check filesystem rootfs path /
#
## By its device:
# check filesystem data with path /dev/sda1
#
## An event when more than 80 percent of /var is used, and when it is back:
# check filesystem var path /var
# if space usage > 80% then alert
#
## A limit with a fraction:
# check filesystem home path /home
# if space usage > 90.5 % then alert
#
##
## A directory
## -----------
##
## Monit checks a directory: whether it exists, its permissions, owner,
## timestamps.
##
## FlyingMonit Agent: not supported yet.
##
# check directory app path /var/lib/app
#
##
## A fifo
## ------
##
## Monit checks a named pipe: whether it exists, its permissions, owner.
##
## FlyingMonit Agent: not supported yet.
##
# check fifo app path /run/app.fifo
#
##
## A remote host
## -------------
##
## Monit checks another host: ping, its ports, protocols spoken on them.
##
## FlyingMonit Agent: not supported yet.
##
# check host web with address 192.0.2.10
# if failed ping then alert
#
##
## A network interface
## -------------------
##
## Monit checks a network interface: its link, speed, duplex, traffic.
##
## FlyingMonit Agent: not supported yet.
##
# check network eth0 with interface eth0
#
##
## A program
## ---------
##
## Monit runs a program at every check: its exit status, its output.
##
## FlyingMonit Agent: not supported yet.
##
# check program app path /bin/true
# if status != 0 then alert
#
###############################################################################
## Includes
###############################################################################
##
## Including files
## ---------------
##
## Syntax: include <file or pattern>
##
## Reads more control files where the include stands, as if their text stood
## there: a file, or a pattern (* ? [...]) matching several, read in the order
## of their names; folders it matches are skipped. A relative path is taken
## from the agent's working directory -- the service's is / on Debian. A path
## with spaces is quoted. Included files may include more.
##
## A pattern that matches nothing, and a file that would include itself, are
## warned about and skipped. A file that cannot be read stops the agent with an
## error naming it; an error in an included file names that file and its line.
##
## Default: none -- only the control file is read. The installer writes no
## include.
##
## Monit: same.
##
## Every file ending in .cfg in /etc/monit.d -- files shared with Monit's
## configuration work as they are, as far as the agent supports their
## statements:
# include /etc/monit.d/*.cfg
#
## A folder with a space in its name:
# include "/etc/monit conf.d/*"
#