Telling someone — media and actions
A problem nobody hears about is a diary entry. This chapter connects the last links: a media type says how to send, an address on a user says who, and an action says when. The lab wired all three, fired its gauge one last time, and produced an alert that failed to leave the building — which is the most instructive alert it could have produced.
The three pieces, in the order you meet them while wondering why nobody was told:
Media types are the channels,
installed globally: email over SMTP,
webhooks into Slack and a dozen chat
and ticketing systems, a run-a-script
channel, and more rows than you will
ever want (the fresh install lists
its email, its SMS and webhook media
side by side; email is mediatypeid
1). Two facts the lab learned the
practical way: a fresh 7.0 install
ships its media types disabled,
so the first job is to enable the
channel you mean to use; and the
email channel's SMTP settings — server
localhost:25 by default — live on
the media type itself, so "email
doesn't go out" is nearly always a
line in that form, not a mystery.
The user's media is the address: on each user's record, which media type, delivered to what, during what hours, and for which severities. Admin's record in the lab gained:
{"mediatypeid": "1", "sendto": "alerts@example.com",
"active": 0, "severity": 63, "period": "1-7,00:00-24:00"}
severity: 63 is all six severities
at once; active: 0 means enabled
— yes, the flag reads backwards, and
chapter 14 keeps a copy of the
surprise it caused. (alerts@example.com
is exactly the kind of address this
guide uses for a lab: invented, and
therefore harmless whichever mistake
is made next.)
The action is the rule that connects a problem to those two: for trigger events (eventsource 0) matching a condition — this trigger, 25287 — run one operation: send the default message, through media type 1, to user Admin, starting at step 1, the action's escalation window one hour. Created through the API, it came back actionid 7, enabled, its filter and operations reading back exactly as written (chapter 10 shows the reading-back; trust nothing you have not read back).
One more inhabitant to know: the install ships a stock action, Report problems to Zabbix administrators — and in 7.0 it ships disabled. That is a deliberate design, and after this chapter you can see why: a default that mailed every administrator every problem from minute one would teach every new installer to ignore Zabbix for life.
Then, the firing. The gauge flipped; the problem opened; and inside seconds an alert existed:
alertid 1 | actionid 7 | eventid 53 | sendto alerts@example.com | status 2
error: no welcome message 220* from SMTP server
status 2 means attempted and
failed, and the error says why, in
the SMTP server's own reply: the lab
machine's outbound mail path answers
that sending is turned off. Nothing
about that is a Zabbix failure. The
trigger fired, the action matched,
the escalator built the alert, the
alerter took it to the mail server it
was configured to use, and the world
outside the lab refused it — each of
those steps is visible in the alert
record, which is the entire point:
when a real alert fails at 3 a.m.,
the alert row is where you find out
which link broke, and the chain in
this paragraph is the checklist. One
honest footnote from the lab: the
very first firing after the action
was created, seconds old, produced no
alert; the next firing, after the
server's machinery had settled into
its new configuration, produced the
alert within the half-minute —
new actions are worth one patient
test before they are trusted, which
is a production habit, not a lab
artefact.
The check. The chain is proved when an alert row exists with your action's id, your event's id, the recipient you chose, and a status that tells the truth — 1 for sent, 2 with an error you can act on. The lab's is status 2 with an error quoted in full in transcript t08, and this guide calls that a success for the machinery and a documented boundary for the lab: the last hop belongs to a mail system the sandbox does not have.