49 lines
2.0 KiB
Markdown
49 lines
2.0 KiB
Markdown
# zabbix-agent
|
|
|
|
One-shot [Zabbix agent2](https://www.zabbix.com/) installer for Ubuntu,
|
|
using **active checks** — the agent connects *out* to the server, so it
|
|
works behind NAT/firewalls and needs no inbound ports.
|
|
|
|
- Idempotent — safe to re-run
|
|
- Installs from the official Zabbix apt repo (agent2)
|
|
- Config: `ServerActive=<server>`, `Server=127.0.0.1,<server>`,
|
|
`Hostname=<name>` (defaults to the short system hostname)
|
|
|
|
## Use
|
|
|
|
```bash
|
|
# clone once, then git pull for updates:
|
|
git clone https://gitea.noctools.nz/noctools/zabbix-agent.git
|
|
sudo ./install-zabbix-agent2-ubuntu.sh --server <server-ip-or-name>
|
|
sudo ./install-zabbix-agent2-ubuntu.sh --server <server-ip-or-name> --docker # + docker monitoring
|
|
```
|
|
|
|
Or with no local copy at all:
|
|
|
|
```bash
|
|
curl -fsSL https://gitea.noctools.nz/noctools/zabbix-agent/raw/branch/main/install-zabbix-agent2-ubuntu.sh \
|
|
| sudo bash -s -- --server <server-ip-or-name>
|
|
```
|
|
|
|
## Flags
|
|
|
|
| flag | meaning | default |
|
|
|---|---|---|
|
|
| `--server HOST[:PORT]` | Zabbix server/proxy for active checks (**required**) | — |
|
|
| `--hostname NAME` | Zabbix host name — must equal the technical name on the server | short system hostname |
|
|
| `--docker` | enable the agent2 docker plugin: grants the `zabbix` user access to `/var/run/docker.sock` via the `docker` group (Docker must already be installed) | off |
|
|
| `--major X.Y` | Zabbix repo series | `7.4` |
|
|
|
|
After installing, create the host on the Zabbix server with the **exact same
|
|
technical name** and an active-agent template (e.g. "Linux by Zabbix agent
|
|
active"). The script reports whether the agent reached the server and warns
|
|
if the host doesn't exist yet — the warning clears by itself once it does.
|
|
|
|
## Docker monitoring
|
|
|
|
`--docker` has the agent talk to `/var/run/docker.sock` (adds the `zabbix`
|
|
user to the `docker` group). On the Zabbix server, link the host to a Docker
|
|
template that uses **active** checks — e.g. "Docker by Zabbix agent 2 active"
|
|
(where present) — since agents installed by this script are reached via
|
|
active checks only.
|