Alerts
Threshold actions
Reboot a box, or run your own script, when a metric holds at one of its levels.
A threshold action is what a box does on its own when one of its metrics holds at a level you chose: it reboots, or it runs a script you wrote. It hangs off the same warning and critical levels as the box's alerts, and it needs agent 0.10.0 or newer.
Off until you turn it on
A new box has no threshold actions, and the switch in its settings is off. Alert emails are the only thing on by default. Turning the switch off stops every action on that box at once; their history stays.
When an action runs
- You pick any of CPU, RAM and storage. The action runs when any of them holds at the level, not when all of them do.
- The level is the box's own: warning or worse, or critical, from its thresholds.
- It has to hold there for a number of minutes (5 by default), so one spike never reboots a server.
- It runs once per incident. It runs again only after the metric has recovered and then crossed the level again.
- Each action has a daily limit. A reboot is held to 3 a day, so a server that comes back already overloaded does not reboot all day. When an action reaches its limit you get an email saying so.
- A box runs one action at a time. Several actions on one box run one after another, never at once.
- An action that fires while the box's agent is offline is not saved for later. It is recorded as not delivered: a reboot that arrives hours after the problem is worse than none.
Reboot
The agent tells Monilogix it is about to reboot, then asks systemd to. The run shows as Rebooted once the box reports back with a new boot time. The box's offline alert is held back for ten minutes after a reboot it asked for, so a planned reboot does not page you.
Scripts
A script starting with #! runs under that interpreter; anything else runs under /bin/sh. It runs as root in its own short-lived systemd unit, so it can write where the agent itself cannot — clearing logs, pruning Docker, emptying a cache. For example:
#!/bin/shdocker volume prune -fdocker image prune -afjournalctl --vacuum-time=3d- It is stopped after its timeout (300 seconds by default, at most 1800).
- The first 16 KiB of what it prints is kept with the run for 30 days. Before it leaves the server, the agent removes Monilogix agent keys and private-key blocks (PEM and PGP) — nothing else, so don't print passwords or tokens. Only you see the output; someone the box is shared with sees that it ran, not what it ran or printed.
- Saving a script, and running any action by hand, asks for your password again.
- Anything a script starts in the background with
nohuporsystemd-runoutlives its timeout; that is what those commands are for.
Run now runs an action straight away, whatever the metrics are doing, so you can try a script before trusting it to an incident.
Refusing them on a server
A server can refuse every threshold action, reboot included, whatever the dashboard says. Add this line to /etc/monilogix/config.yaml on it:
threshold_actions_enabled: falseThen restart the agent:
$sudo systemctl restart monilogix-agentIt is on by default so that using threshold actions never needs a login to the server; nothing runs until the box's owner turns them on here. See Configure the agent for the other settings.
On a self-hosted Monilogix
Custom scripts are switched off on a Monilogix server until its operator sets THRESHOLD_SCRIPTS_ENABLED=true. Reboot actions work either way. Threshold actions are driven by the alerts pass, so with ALERTS_ENABLED=false nothing fires on its own.