Skip to content

Point the Monit agents at it

The agents log in as a user with the role collector: Admin › Users › New user, role Collector. A collector user can only deliver reports – it cannot log in to the pages or the API.

In each agent's monitrc:

set mmonit https://<collector user>:<password>@flyingmonit.example.com/collector

and monit reload. The host appears on the Dashboard with its first report.

A complete example

A monitrc that reports to FlyingMonit, lets it start and stop services, and gives every chart something to draw:

# Every 30 seconds: Analytics' "last seconds" needs a report less than a minute old.
set daemon 30
set log syslog

# The agent's web interface: FlyingMonit's start, stop and restart come here.
# The cleartext user and password go with each report -- without them (or with
# "register without credentials" below) FlyingMonit shows the host but cannot act.
set httpd port 2812
    use address 0.0.0.0
    allow 192.0.2.10                       # FlyingMonit's server
    allow admin:<a long random password>

# FlyingMonit: reports and events, over HTTPS (the password above travels in them).
set mmonit https://<collector user>:<password>@flyingmonit.example.com/collector
    timeout 5 seconds

# CPU, memory, swap, load: the System charts.
check system $HOST
    if loadavg (5min) > 4 then alert
    if memory usage > 85% then alert
    if cpu usage > 90% for 5 cycles then alert

# Space, inodes, reads and writes: the file system charts.
check filesystem rootfs with path /
    if space usage > 85% then alert
    if inode usage > 85% then alert

# CPU, memory, threads and disk of a process; start and stop from the Status pages.
check process sshd with pidfile /var/run/sshd.pid
    start program = "/usr/sbin/rcctl start sshd"
    stop program = "/usr/sbin/rcctl stop sshd"
    if failed port 22 protocol ssh then restart

# Response times: the port and ping charts.
check host www.example.com with address www.example.com
    if failed ping then alert
    if failed port 443 protocol https then alert

monit -t checks the file, monit reload applies it. On Linux, start program and stop program call systemctl instead of rcctl.

Reporting to more than one server

Monit (5.34 and newer) sends every message to every server its monitrc names, so an agent can report to FlyingMonit and to another server at once: add FlyingMonit's line below the other one. If FlyingMonit is down, an agent waits for its timeout (5 s by default) and goes on; the other server gets everything.

!!! warning "Every server named must answer" Up to Monit 6.0.0, when sending to one server fails half-way -- it refuses the message or closes the connection -- Monit sends the next server that message and the new one together. FlyingMonit refuses such a doubled report, and the host looks silent. Monit's source has the fix, no release yet: until one has, name only servers that are there and answer, and take a server's line out of monitrc before you take the server away (monit reload).

Service actions

Start, stop, restart, monitor and unmonitor from the Status pages go from FlyingMonit to the agent's own web interface, at the address the agent reports. An agent that reports localhost is only reachable from the same host: set the address it is reachable at under Admin › Hosts › the host.

A host's public address

/ip answers the address a request comes from, as plain text and without a login -- for a host behind NAT that does not know its public address:

ftp -o - -V https://flyingmonit.example.com/ip    # OpenBSD
curl -s https://flyingmonit.example.com/ip