MIRTEL

Scripts, cron and GitHub Actions

Anything that can run curl can report to Mirtel. A script doesn't need to read the instructions at the link; it only sends the report to it.

1. Add the agent

In the dashboard, add the agent with its schedule and what success looks like. Copy the link Mirtel shows you; she shows it only once. Put it in an environment variable rather than in the script itself:

export MIRTEL_LINK='https://YOUR-MIRTEL-HOST/r/mrt_agent_…'

2. Report every run, failures included

The trick is a shell trap. If the job dies halfway, the trap still fires and reports Failed, so a crash never looks like silence.

#!/bin/sh
set -e

report() {  # report STATUS ITEMS OUTPUT ERROR
  curl -sS -X POST "$MIRTEL_LINK" -H 'Content-Type: application/json' \
    -d "{\"status\":\"$1\",\"items\":${2:-0},\"output\":\"$3\",\"error\":\"$4\"}" || true
}

trap 'report failed 0 "" "exited with code $?"' EXIT
COUNT=$(./do-the-work.sh)          # your job; prints how many items it produced
trap - EXIT
report done "$COUNT" "digest ready"

Your job must print only the count, a plain number like 5, and send any other output to stderr (>&2) or a log file. Anything else in COUNT makes the JSON invalid, Mirtel answers 400, and the run shows as Missed.

Keep the output and error text simple (no double quotes), or build the JSON with a tool like jq. The || true means a hiccup reaching Mirtel never breaks your job.

If the job found nothing, report empty instead of done. If it needs a human decision, report needs_you and say what in the output.

Cron

Cron doesn't load your shell profile, so set the link on the cron line or in the script's environment:

0 8 * * 1-5  MIRTEL_LINK='https://YOUR-MIRTEL-HOST/r/mrt_agent_…' /home/me/jobs/digest.sh

Then give the agent the same schedule in Mirtel: weekdays at 08:00, with the agent's timezone set to the timezone of the machine running cron (often UTC on servers). That's how she knows when to expect it.

GitHub Actions

Store the link as a repository secret, say MIRTEL_LINK, never in the workflow file. Then add two steps at the end of the job:

      - name: Report to Mirtel
        if: success()
        run: |
          curl -sS -X POST "$MIRTEL_LINK" -H 'Content-Type: application/json' \
            -d '{"status":"done","output":"nightly build passed"}'
        env:
          MIRTEL_LINK: ${{ secrets.MIRTEL_LINK }}
      - name: Report failure to Mirtel
        if: failure()
        run: |
          curl -sS -X POST "$MIRTEL_LINK" -H 'Content-Type: application/json' \
            -d '{"status":"failed","error":"a step failed, see the Actions log"}'
        env:
          MIRTEL_LINK: ${{ secrets.MIRTEL_LINK }}

Check it worked

Run the script once by hand and look at the ledger. Then make it fail on purpose and check that the run shows as Failed, not Missed.

Anyone with the link can report as this agent. Keep it out of anything you commit. If it leaks, rotate the agent's key in the dashboard; the old link stops working at once.