Skip to main content
Automations
InfrastructureSourceAPIChangelog

Triggers

The trigger decides when an automation runs. Every automation has one.

Picking hosts​

Most triggers watch hosts. Pick one host, a fleet, or all hosts.

A fleet is usually best. Tag a new server and it is covered without editing the automation.

Metric threshold​

Runs when a number crosses a line, like memory used over 90 percent. Needs Host Metrics.

MetricWhat it measures
cpu.percentCPU use, percent.
cpu.load1, cpu.load5, cpu.load15Load average.
memory.percent, memory.usedGiBMemory used.
disk.percent, disk.availableBytesDisk used, for one mount.
temperature.highestCelsiusThe hottest sensor.
uptime.secondsHow long the host has been up.
processes.totalRunning processes.
network.rxBytes, network.txBytes, network.rxRateBps, network.txRateBpsTraffic, for one interface.

Sustained for stops false alarms. The value has to stay over the line that long before anything runs. CPU at 100 percent for two seconds is normal. For five minutes it isn't.

Cooldown is how long to wait before it can fire again for the same host. 15 minutes by default, so a value that wobbles around the line doesn't message you over and over.

Host goes up or down​

Runs when a host goes offline or comes back. When Termix first sees a host it only records its state, so a restart of Termix doesn't make every host look like it just came online.

Health check changes​

Runs when a health check from Host Metrics starts failing or recovers. Watch one check or all of them.

On a schedule​

Runs on a clock, with a cron expression like 0 3 * * * (3am every day) or an interval in seconds. Pick a Time zone so daily runs land at the right local time, through daylight saving changes too.

Schedules are checked every 15 seconds, so a run can start a few seconds late.

Container event​

Runs when a container is exited, started, unhealthy or restarting. Watch one container by name or all of them. Needs Docker.

Termix event​

Runs when something happens in Termix:

EventWhen
user_loginSomeone signs in.
host_added, host_deletedA host is made or deleted.
tunnel_disconnectedA tunnel drops. Needs Tunnels.
automation_failedAnother automation fails.

Set up one automation on automation_failed early. Then you hear when any other automation breaks.

An alert comes in​

Runs when the Alerts plugin gets an alert for you. Use it to react to what other plugins notice, like restarting a service when its Uptime monitor goes down.

FieldWhat it does
Alert categoryThe kind of alert, like uptime.down. uptime.* matches every Uptime alert and * every alert.
At leastOnly alerts at warning or critical and up. Any severity by default.
Title containsOnly alerts whose title has this text, ignoring case.
HostOnly alerts about these hosts. Alerts that are not about a host are skipped when you pick hosts.
CooldownMinutes to wait before it can run again for the same host and category.

Steps can pick The trigger's host to work on the host the alert is about. Alerts that automations send never start an automation, so one can't set off another in a loop. Needs Alerts 1.4.0.

Example: restart nginx when its monitor goes down​

  1. Trigger: An alert comes in, category uptime.down, title contains nginx, host your web server.
  2. Step: Run command systemctl restart nginx on The trigger's host, as root.
  3. Step: Send an alert saying nginx was restarted.

Incoming webhook​

Runs when something outside Termix calls a URL: CI, a monitor, a script.

When you save the trigger, Termix shows the webhook URL once. Copy it then. Only a hash is kept, so it can't be shown again. Lost it? Make a new trigger.

curl -X POST https://termix.example.com/plugin-api/automations/webhook/YOUR_TOKEN

Anyone with the URL can start the automation. Treat it like a password.

After a restart​

Hold timers and cooldowns are saved, so restarting Termix doesn't reset them.