Your first login
Zabbix has two front doors — the web
page people use, and the API programs
use — and they open with the same key:
the user Admin, whose password on a
fresh install is famously zabbix.
This chapter walks through both doors,
changes the lock's most public secret,
and leaves you with the token every
later chapter spends.
The web door
The frontend is the PHP application
from chapter 3, and a production
install serves it under Apache or
nginx at an address like
https://your-server/zabbix. The
lab's stand-in served the same pages
from PHP's built-in server on
loopback, and the first page is the
login form, titled — because the lab
named its server — "Lab Zabbix:
Zabbix". A name of your own is a
setting ($ZBX_SERVER_NAME in the
frontend's configuration file), and it
is worth setting: every page and every
alert afterwards carries it.
Log in as Admin with the password zabbix. Say the obvious out loud: those credentials are printed in every tutorial ever written, including this one, so the first real act of administration is to change them — Users → Users → Admin → change password. Until you do, anyone who can reach the page owns the installation, and chapter 1's warning about what ownership means is not abstract.
Past the form you land on the dashboard: a grid of summaries — problems by severity, hosts, the state of the system you just built. On a fresh install it is almost empty, and it should be: there is one host (the server sometimes adds itself nowhere; your watched machines are added by you), no problems, nothing to report. Chapter 7 returns here with a problem to show it.
Two other residents ship with the install and are worth meeting now: the user guest, in the Guests group, with no password and — in 7.0 — no rights to see your hosts until a group grants them (chapter 9 shows the grant working); and a ready set of roles, from User role up to Super admin role, which decide what a user may do once they may see. Hold both thoughts; chapter 9 picks them up.
The API door
The API lives at the end of the
frontend's address: api_jsonrpc.php.
It speaks JSON-RPC 2.0 — every request
is a small JSON document naming a
method and its parameters, every
answer a JSON document back. Login is
the method user.login:
$ curl -s -X POST -H 'Content-Type: application/json-rpc' \
-d '{"jsonrpc":"2.0","method":"user.login",
"params":{"username":"Admin","password":"zabbix"},
"id":1}' \
http://127.0.0.1:18082/api_jsonrpc.php
{"jsonrpc":"2.0","result":"08abbc21…","id":1}
The result — a long hex string — is
your token. Send it as an
Authorization: Bearer header on
every later call and the API treats
you as that user, with that user's
permissions: the API does not have its
own idea of who may do what. One
method needs no token at all, and it
is the right first question for any
script:
$ # apiinfo.version — what are you talking to?
{"jsonrpc":"2.0","result":"7.0.32","id":1}
Because this guide calls the API
constantly, the lab grew a pocket
helper, zabbix-lab/zapi.py, which is
shipped with the guide: it reads the
token from a file, builds the JSON,
prints the answer tidily, and takes
calls as zapi.py host.get '{...}'.
Everything the API does in this guide
is shown the long way first and the
zapi.py way after.
And the API's refusals are as instructive as its answers — they are exact, and they quote the rule. A wrong password:
{"code": -32500, "message": "Application error.",
"data": "Incorrect user name or password or account is temporarily blocked."}
Note the last clause: repeated wrong passwords block the account for a while, on the API and the web door alike. Chapter 14 keeps a small museum of these refusals; they are how Zabbix explains itself when it says no.
The check. Logged in means three
things at once: the browser shows the
dashboard under your server's name;
the Admin password is no longer the
one in this chapter; and user.login
returns a token with which
apiinfo.version and a first
host.get answer. The lab's
transcript t04 holds the first two and
the token; t05 spends it.