Appearance
rtpengine and the agent
If rtpengine relays your media, PBXsight can show what it sees: sessions, packets and errors, calls closed by timeout, userspace vs. kernel forwarding, its own MOS from RTCP, ports in use, offer processing time, and the host's and rtpengine's CPU. It gets this through pbxsight-agent, a small read-only service you run on every rtpengine host. This page explains why the agent exists, how to install and test it, and how to add it to a PBX profile. Like Kamailio, it is optional.
First step: install the agent package on one rtpengine host (Install from the package) and test it with curl before adding the rest.
Why an agent
rtpengine has no access control. Anyone who reaches its control port (listen-ng) or CLI can also end calls (delete, terminate) — so those ports belong on localhost. The agent sits next to rtpengine, talks to it over localhost, and exposes only reading over HTTP:
PBXsight ──HTTP + token, allowed networks only──► pbxsight-agent ──localhost──► rtpengine /metrics (listen-http)
└─localhost──► rtpengine ng: ping, statistics, list, queryWhat makes it read-only:
- its ng client has a fixed list of four commands —
ping,statistics,list,query— and no way to send anything else (a unit test fails if the list grows without review); - every HTTP endpoint is GET; other methods get
405; - a client must come from an allowed network (else
403, checked before the token) and send the token (else401); - at most
max_concurrentrequests run at once (default 4; more get503), each bounded byrequest_timeout(default 5 s), so the agent can't flood rtpengine.
Nothing changes in rtpengine or Kamailio, and neither needs a restart.
Check the requirements
Linux (amd64 or arm64) with systemd.
rtpengine with
listen-ngand/orlisten-http(for its Prometheus/metrics). Find out where they really listen — options may come from the command line, not only the config file:shss -ulpn | grep rtpengine # UDP: listen-ng (control) ss -tlpn | grep rtpengine # TCP: listen-http, listen-cli grep -nE 'listen-(ng|http)' /etc/rtpengine/rtpengine.conf ps -o args= -C rtpengine # options given on the command line grep -rn rtpengine_sock /etc/kamailio/ # where Kamailio sends ng commands (= listen-ng)Use exactly that address in the agent config:
127.0.0.1:…and[::1]:…are different listeners, andlocalhostmay resolve to either.A free TCP port on the host's private IP, reachable from the PBXsight machine.
Install from the package
The Download page has pbxsight-agent_<version>_{amd64,arm64}.{deb,rpm} (uname -m: x86_64 → amd64, aarch64 → arm64). As root on the rtpengine host:
sh
apt install ./pbxsight-agent_<version>_amd64.deb # Debian / Ubuntu
dnf install ./pbxsight-agent_<version>_amd64.rpm # RHEL / Rocky / AlmaThe package installs /usr/bin/pbxsight-agent, creates the system user pbxsight-agent, puts the example config at /etc/pbxsight-agent/config.yaml (kept on upgrades), generates a random token in /etc/pbxsight-agent/token (both 0640 root:pbxsight-agent), and installs the systemd unit enabled but not started — the config's listen and allow must be set first. Then:
sh
# edit /etc/pbxsight-agent/config.yaml (see Configuration), then check it as the service user:
runuser -u pbxsight-agent -- pbxsight-agent -config /etc/pbxsight-agent/config.yaml -check
systemctl start pbxsight-agentUpgrades: install the newer package (the service restarts). apt purge also deletes the config, the token and the user.
Install from the archive
pbxsight-agent_<version>_linux_<arch>.tar.gz holds the binary, config.example.yaml, pbxsight-agent.service and a README. As root:
sh
install -m 0755 pbxsight-agent /usr/local/bin/pbxsight-agent
useradd --system --no-create-home --shell /usr/sbin/nologin pbxsight-agent
install -d -m 0750 -o root -g pbxsight-agent /etc/pbxsight-agent
openssl rand -hex 32 > /etc/pbxsight-agent/token
chown root:pbxsight-agent /etc/pbxsight-agent/token && chmod 0640 /etc/pbxsight-agent/token
install -m 0640 -o root -g pbxsight-agent config.example.yaml /etc/pbxsight-agent/config.yaml
# edit the config, then:
runuser -u pbxsight-agent -- /usr/local/bin/pbxsight-agent -config /etc/pbxsight-agent/config.yaml -check
install -m 0644 pbxsight-agent.service /etc/systemd/system/pbxsight-agent.service
systemctl daemon-reload
systemctl enable --now pbxsight-agentThe archive's unit expects the binary in /usr/local/bin; the package's unit uses /usr/bin.
Configure the agent
/etc/pbxsight-agent/config.yaml (unknown keys are rejected):
yaml
listen: "10.0.0.10:9310" # this host's PRIVATE IP and a free port
token_file: /etc/pbxsight-agent/token
allow:
- "10.8.0.0/24" # the network PBXsight connects from
rtpengine:
http: "localhost:2225" # rtpengine's listen-http, "" = off
ng: "127.0.0.1:2223" # rtpengine's listen-ng (UDP), "" = off
list_limit: 500
max_concurrent: 4
request_timeout: 5s| Key | Default | Meaning |
|---|---|---|
listen | — (required) | address the agent serves on. Don't use 0.0.0.0 on a host with a public interface |
token / token_file | — (required) | clients send Authorization: Bearer <token>; at least 32 characters (openssl rand -hex 32) |
allow | — (required) | client networks (CIDR or single IP); everyone else gets 403 |
rtpengine.http | "" | rtpengine's listen-http, for /metrics |
rtpengine.ng | "" | rtpengine's listen-ng |
rtpengine.list_limit | 500 | most calls one ng list returns (its reply must fit one UDP datagram, ~64 KB) |
rtpengine.process | rtpengine | rtpengine's process name in /proc, for its CPU |
max_concurrent | 4 | requests at once; more get 503 |
request_timeout | 5s | per request, at least 2 s. Keep the profile's rtpengine Timeout above it (default 8 s) |
The values in the example (2223, 2225) are only examples: an ng address that isn't rtpengine's real listen-ng is the most common mistake.
Run it as a service
Restart=alwayswith 5 s between tries: if the private IP isn't up yet at boot, it keeps trying.- The config is checked before every start (
ExecStartPre … -check); a bad config shows in the log. - Hardened (read-only system, no capabilities, 64 MB memory cap).
- Logs:
journalctl -u pbxsight-agent -f. Refused requests are logged with the source IP; right after start it logs once whether rtpengine is reachable.
To change the token: write a new one to /etc/pbxsight-agent/token, systemctl restart pbxsight-agent, and update it in the PBX profile.
Open the firewall
Allow the agent's port from the PBXsight machine's network only:
sh
ufw allow from 10.8.0.0/24 to any port 9310 proto tcp
nft add rule inet filter input ip saddr 10.8.0.0/24 tcp dport 9310 accept # adapt table/chain names
iptables -A INPUT -p tcp -s 10.8.0.0/24 --dport 9310 -j ACCEPTThe agent speaks plain HTTP. Keep it on a private network or VPN: someone who can sniff that network could read the token, but with it they can only read statistics and call metadata (Call-IDs, media addresses), never change anything.
Test it
From the PBXsight machine:
sh
TOKEN=<the content of /etc/pbxsight-agent/token>
curl -s -H "Authorization: Bearer $TOKEN" http://10.0.0.10:9310/v1/health
curl -s -H "Authorization: Bearer $TOKEN" http://10.0.0.10:9310/v1/rtpengine/metrics | head -c 600/v1/health shows the agent and API version and "ok": true for rtpengine_ng and rtpengine_metrics (or "configured": false for one left empty). Calling from the rtpengine host itself gives forbidden unless its own address is in allow — that's correct.
| Symptom | Cause |
|---|---|
bind: cannot assign requested address in the log | listen isn't one of the host's addresses (ip -br addr) |
permission denied reading config or token | owner/mode must be root:pbxsight-agent, 0640 (directory 0750) |
HTTP 403 | the client's IP isn't in allow (the log shows src=) |
HTTP 401 | missing or wrong Authorization: Bearer token |
rtpengine_ng not ok, "nothing listens" / "connection refused" | rtpengine.ng isn't the real listen-ng |
rtpengine_ng not ok, "no reply" / "i/o timeout" | wrong ng port, or rtpengine isn't running |
rtpengine_metrics not ok, "connection refused" | listen-http not set in rtpengine, or wrong port |
| connection times out from PBXsight | firewall, or the VPN doesn't route to that host/port |
See what the agent serves (endpoints)
All GET, all need the token. PBXsight uses them; you only need them for testing.
| Path | Returns |
|---|---|
/v1/health | agent version, API version (2 = has /v1/rtpengine/sessions, 3 = has /v1/host), uptime, whether ng and /metrics answer |
/v1/rtpengine/metrics | rtpengine's Prometheus metrics as JSON (?format=text = the original) |
/v1/rtpengine/statistics | ng statistics |
/v1/rtpengine/calls?limit=N | ng list: Call-IDs of current calls |
/v1/rtpengine/call?call_id=…&from_tag=… | ng query for one call |
/v1/rtpengine/sessions?limit=N | every current call condensed per side (protocol, codec, packets, last packet, kernel/userspace, RTCP quality) — what PBXsight polls during runs |
/v1/host | host CPU, load, rtpengine's process and busiest threads' CPU from /proc |
Add the agents to the PBX profile
In the profile's rtpengine section tick optional source, then:
- pbxsight-agent URL of each rtpengine host: one per host, e.g.
http://10.0.0.10:9310(+ Add rtpengine host for more; all are polled and summed); - Token (write-only; unchanged (set) once saved), or token file (a path on the PBXsight machine), or a token per URL as
http://TOKEN@10.0.0.10:9310when hosts have different tokens; - Poll (runs) 5 s, Poll (idle) 30 s, Timeout 8 s by default;
- per-call data during runs (on by default): polls
/v1/rtpengine/sessionsduring runs for the per-call checks (one-way audio, the stuck-call media rules, the Media path card's rtpengine part).
The Dashboard then shows one row per rtpengine and a header chip; what the numbers mean is in rtpengine metrics. These are host totals: rtpengine relays every call, not only the test's.