Plugin developer guide

Netlens can learn about your network from other systems through plugins. A plugin talks to one kind of device (a router, a hypervisor, …) and hands Netlens the result in a fixed format. Several kinds exist:

Kind Reports Examples
hypervisor hosts, and the VMs/containers that run on them Proxmox VE, ESXi, Hyper-V, XCP-ng / XenServer, libvirt
dns a DNS server that Netlens writes device names and addresses to Technitium DNS (more welcome: BIND with RFC 2136, Pi-hole, AdGuard Home, dnsmasq)
topology network nodes (router, switch, access point, mesh node) and the clients connected to them ASUS AiMesh, Omada, UniFi, Fritz!Box, MikroTik
proxy a reverse proxy and the sites it publishes (domain → upstream host and port, certificate) Nginx Proxy Manager (more welcome: Traefik, Caddy, HAProxy)
storage a storage system (array, NAS, Ceph): health, pools, volumes with the hosts that use them, disks and alerts NetApp ONTAP, Ceph
backup a backup server: what is backed up (per guest), how old, whether it worked, and how full its stores are Proxmox Backup Server, Xen Orchestra
metrics a store of host readings (processor, memory, disks, network, load, uptime) that Netlens records like any monitored host Prometheus, VictoriaMetrics, Mimir

Plugin API version: 1.

How plugins work

A plugin only fetches data. It never touches Netlens’ database or the map. Netlens validates what the plugin returns, matches the entries to the devices it has scanned (by MAC address, then IP address), writes the links, and shows them on the map, the Hierarchy page and the device pages. Each plugin can be switched on or off in Settings -> Plugins, and gets its own settings page that Netlens builds from the plugin’s plugin.json, so a plugin needs no user-interface code.

Quick start

  1. In Settings -> Plugins press Download example plugin (or GET /api/plugins/example.zip).
  2. Edit plugin.json (name, id, settings fields) and plugin.py (replace the made-up data in fetch() with a call to your device).
  3. Zip plugin.json and plugin.py (at the top of the zip, or together inside a single folder).
  4. Settings -> Plugins -> Upload plugin. The plugin starts off.
  5. Open its settings page, fill in the form and press Test connection. When it works, tick Enable and Save. Netlens syncs at once and after every scan.
  6. Add a diagnose(config) (see below) before you share the plugin: it lets testers send you a report of what their device answers.

To change a plugin, upload the new zip again; Netlens asks whether to replace it and keeps its settings.

Package layout

my-router/            (the folder is optional)
  plugin.json         the manifest (required)
  plugin.py           the code (required)
  helper.py           more modules, optional (import them as usual)
  • Limits: zip at most 2 MB, 8 MB unpacked, 200 files.
  • File names: letters, digits, _, -, . and spaces. No hidden files, links or paths containing ...
  • Uploading never runs the code. plugin.py is only checked for syntax and for the two required functions.
  • Uploaded plugins are stored in the data volume (<data dir>/plugins/<id>/) and survive container updates.
  • Any plugin can be removed (this deletes its files and settings).

plugin.json reference

Field Required Meaning
id yes 2-31 characters: lowercase letters, digits, -, _; starts with a letter. Must equal the folder name once installed.
name yes Shown in the menu and plugin list (max 60).
version yes Like 1.0.0.
api_version yes Must be 1.
kind yes hypervisor, topology, dns, proxy, backup, storage or metrics.
description no A sentence or two (max 500).
author, homepage no Shown in the plugin list.
info no A collapsed box at the top of the plugin’s settings page: {"title": ..., "text": ..., "code": ...}. code is shown in a block with a Copy button, for example the docker-compose lines the plugin needs on the other side. Needs Netlens 0.3.115; older versions ignore it.
timeout no Seconds, 5-600, default 60. Netlens stops the plugin after this long.
diagnose no, but recommended true when plugin.py has diagnose(config): the plugin’s page then shows a Run diagnostic button (see below).
config no The settings form: a list of fields (below).
dashboard no Cards the plugin offers for the dashboard (below). Needs Netlens 0.3.157; older versions ignore it.

Settings fields (config)

Field Meaning
key Required. Lowercase letters, digits, _, starts with a letter, max 32, unique. The key in the config dict your code receives.
type text (default), password, bool, number, select or servers (a list of servers, below).
label, help, placeholder Texts in the form.
section Optional heading; fields with the same section are grouped.
required The plugin cannot be switched on until every required field is filled (ignored for bool).
default Initial value.
min, max For number.
options For select: a list of strings or {"value": ..., "label": ...}. The first is the default.

password fields are secrets: they are masked in the interface and the API, and leaving the field blank when saving keeps the saved value.

A list of servers ("type": "servers")

For a plugin that talks to one or more servers, a servers field shows one line per server with its own Test button, a + button for another line, and Test all connections. Your code receives a list of objects under the field’s key, one per server, each with an id and a value for every column:

{"key": "servers", "type": "servers", "label": "Servers", "required": true,
 "columns": [
   {"key": "host", "label": "Address", "placeholder": "https://192.168.0.10", "required": true},
   {"key": "api_key", "label": "API key", "type": "password", "required": true},
   {"key": "site", "label": "Site", "optional": true}],
 "legacy": {"split": ",", "map": {"host": "url", "api_key": "api_key"}}}
  • The first column must be host. A column is text or password (masked; blank keeps the saved value of the same line); optional columns sit under More on the line; required columns must be filled on every line.
  • Test on a line calls your test(config) with a list that holds just that line, so test should simply test every server it is given. fetch receives all lines. Fail with a message that names the server, and keep exception types such as auth_failed.
  • legacy (optional) says how an older version of your plugin saved the same servers (separate settings, optionally separated by commas or spaces, pair splits a=b), so existing setups become lines by themselves.
  • Give every guest or host id a prefix when two servers can hand out the same id (two Proxmox clusters both have VM 100).
  • A plugin with a servers field needs Netlens 0.3.109 or newer (min_netlens in the plugin index).

Dashboard cards (dashboard)

Every enabled plugin gets a plain status card on the dashboard (is it working, when it last synced and, for hypervisor and proxy plugins, how many guests or sites it reported). With dashboard a plugin can offer more cards. A card is only a description: the plugin runs no code for it, and Netlens fills in the numbers.

"dashboard": [
  {"id": "guests", "title": "Proxmox guests", "about": "Running and stopped guests.", "href": "#/hierarchy",
   "rows": [
     {"label": "Running", "count": "guests", "where": {"status": "running"}},
     {"label": "Stopped", "count": "guests", "where": {"status": ["stopped"]}, "tone_if_positive": "warn"},
     {"label": "Last sync", "value": "status.ts"}]}
]
  • At most 4 cards of 1 to 8 rows. id is 1-20 lowercase letters, digits, - or _ (status is taken), title and about are texts, href (optional) is a page of Netlens such as #/devices; the default is the plugin’s settings page.
  • A row has a label and either count or value:
  • count: guests (what the plugin reported through fetch, kind hypervisor) or sites (kind proxy), optionally narrowed with where. where maps a column to a value or a list of values; the columns are kind, status, host_name for guests and type, enabled, scheme, proxy_name for sites. tone_if_positive (warn or bad) colours the row when the count is not zero.
  • value: status.ok (shown as Working or Failing), status.ts (when it last synced) or status.error.
  • Users add the cards under Customize on the dashboard; they appear while the plugin is enabled.

Example

{
  "id": "example-router",
  "name": "Example router",
  "version": "1.0.0",
  "api_version": 1,
  "kind": "topology",
  "author": "Your name",
  "description": "Template plugin: reports a made-up router with one access point and two clients. Replace fetch() with a call to your own router.",
  "timeout": 30,
  "config": [
    {
      "key": "host",
      "type": "text",
      "label": "Router address",
      "placeholder": "192.168.0.1",
      "required": true,
      "help": "Shown in the settings form Netlens builds from this file."
    },
    {
      "key": "username",
      "type": "text",
      "label": "Username"
    },
    {
      "key": "password",
      "type": "password",
      "label": "Password"
    },
    {
      "key": "verify_tls",
      "type": "bool",
      "label": "Verify TLS certificate",
      "default": false
    }
  ]
}

plugin.py: test(config) and fetch(config)

Netlens calls two top-level, normal (not async) functions. config is a dict holding every key of plugin.json (passwords as plain text).

  • test(config) runs when the user presses Test connection. Return {"message": "text to show"} (the message is optional) or raise an exception. It must not change anything on your device and Netlens saves nothing.
  • fetch(config) runs after every scan and when the user presses Sync now. Return a dict in the format of your plugin’s kind (see below).

Your code runs in a separate Python process (python -I) with only the plugin folder importable, a stripped environment (no NETLENS_* variables) and no database path. Use only the Python standard library (urllib, json, ssl, socket, re, …); packages cannot be installed. Anything printed is ignored.

"""Example Netlens plugin (kind "topology").

Netlens runs this file in its own process and calls two functions, each with the settings the user typed
into the form (the keys come from "config" in plugin.json):

    test(config)   -> {"message": "text shown after Test connection"}
    fetch(config)  -> the data described in PLUGINS.md for your plugin's kind

Raise an exception with a clear message when something goes wrong; Netlens shows it to the user. If the
login was refused, set `auth_failed = True` on the exception so Netlens stops retrying until the user acts
(this protects the account from being locked). Use only the Python standard library.
"""


class LoginRefused(Exception):
    auth_failed = True


def _connect(config):
    if not config.get("host"):
        raise ValueError("enter the router address")
    # Replace this with a real request to your device, for example with urllib.request.
    # if the password is wrong:  raise LoginRefused("login refused (check the username and password)")
    return {"host": config["host"]}


def test(config):
    _connect(config)
    return {"message": "Connected to the example router: 1 access point, 2 clients"}


def fetch(config):
    _connect(config)
    return {
        "nodes": [
            {"mac": "aa:bb:cc:00:00:01", "ip": "192.168.0.1", "name": "Router", "role": "gateway"},
            {"mac": "aa:bb:cc:00:00:02", "ip": "192.168.0.2", "name": "Access point", "role": "ap",
             "parent_mac": "aa:bb:cc:00:00:01"},
        ],
        "clients": [
            {"mac": "11:22:33:44:55:01", "ip": "192.168.0.50", "name": "Laptop", "node_mac": "aa:bb:cc:00:00:02",
             "medium": "wifi", "band": "5 GHz"},
            {"mac": "11:22:33:44:55:02", "ip": "192.168.0.51", "name": "Printer", "node_mac": "aa:bb:cc:00:00:01",
             "medium": "wired"},
        ],
    }

diagnose(config): please include it

Nobody can test a plugin on every device, firmware or version. A diagnose(config) lets a tester press Run diagnostic on your plugin’s settings page in Netlens and send you a report of what their device answered, without running any script. Every plugin should have one: it is what turns “it does not work” into a fix. Add "diagnose": true to plugin.json and a function that returns a dictionary:

def diagnose(config):
    controller = connect(config)             # a refused login raises the same exceptions as test(): it must not retry either
    report = {"steps": {}}
    try:
        report["controller_version"] = controller.version
        for name, call in (("devices", controller.devices), ("clients", controller.clients)):
            try:
                rows = call()
                report["steps"][name] = {"ok": True, "count": len(rows), "first": [describe(r) for r in rows[:3]]}
            except Exception as exc:               # record the step that failed and go on with the others
                report["steps"][name] = {"ok": False, "error": str(exc)[:300]}
        result = fetch(config)                    # what the plugin makes of it, as counts
        report["result"] = {"nodes": len(result["nodes"]), "clients": len(result["clients"])}
    finally:
        controller.logout()
    return report

Netlens runs diagnose(config) in the same isolated process as test() and fetch(), with the values in the form, and shows the report in a box to copy or download. Rules for what goes in it:

  • Describe the shape of what the device returned: field names, types, counts, and a few harmless enumerations (type, status…). Never content: no names, addresses, MAC addresses, serial numbers or free text. Copy this helper (it replaces numbers, MAC and IP addresses and text by placeholders):
import re


def describe(value, key=""):
    """The shape of a value: types and sizes, never the content (except a few harmless enumerations)."""
    if isinstance(value, dict):
        return {k: describe(v, k) for k, v in value.items()}
    if isinstance(value, list):
        return [describe(v, key) for v in value[:2]] + ([f"... {len(value)} items"] if len(value) > 2 else [])
    if isinstance(value, bool) or value is None:
        return value
    if key in ("type", "status", "state"):  # words that are the same on every device and help to understand the data
        return value
    if isinstance(value, (int, float)):
        return f"<number {'negative' if value < 0 else 'positive' if value > 0 else 'zero'}, {len(str(abs(value)))} digits>"
    if isinstance(value, str):
        if re.fullmatch(r"([0-9A-Fa-f]{2}[:-]){5}[0-9A-Fa-f]{2}", value):
            return "<mac " + ("dashes" if "-" in value else "colons") + ">"
        if re.fullmatch(r"\d{1,3}(\.\d{1,3}){3}", value):
            return "<ipv4>"
        return f"<text {len(value)} chars>"
    return f"<{type(value).__name__}>"
  • Record which step failed and why (without addresses) and carry on with the other steps, so one report shows everything that is wrong. Raise your usual exceptions for a refused login.
  • Log in once, like fetch(), and log out again.
  • Keep the report small (a few hundred KB at most).
  • Netlens removes the values of the plugin’s own settings (addresses, user names, keys, passwords) and every MAC address from the report before showing it. That is a second line of defence, not a licence to send content.

python plugin-index/tools/check_plugin.py <plugin> --config cfg.json runs your diagnose() too, and prints a note when a plugin has none.

Errors and refused logins

  • Raise any exception. Its text (cut at 500 characters) is shown to the user.
  • If the login was refused, set auth_failed = True on the exception (a class attribute is fine). Netlens then stops calling the plugin automatically until the user saves its settings or presses Sync now, so a wrong password cannot get an account locked. Never retry a failed login in a loop.
  • A crash, a timeout, output that is not JSON and output that breaks the format are all reported in the plugin’s status. The last good data and links stay on the map.

Output for kind hypervisor

Return {"hosts": [...], "guests": [...]}.

Host field Required Meaning
id yes Text or number, unique.
name no Default: the id.
ip no IPv4 address.
mac no MAC address.
online no true (default) or false.
Guest field Required Meaning
id yes Text or number, unique.
name no Default: the id.
kind no Text such as vm, lxc, qemu. Default vm.
host_id no Must be the id of an entry in hosts.
status no Text such as running. Default unknown.
macs no List of MAC addresses of the guest’s network cards.
ips no List of IPv4 addresses.
{
  "hosts": [
    {"id": "pve1", "name": "pve1", "ip": "192.168.0.180", "online": true}
  ],
  "guests": [
    {"id": "100", "name": "web", "kind": "lxc", "host_id": "pve1", "status": "running",
     "macs": ["bc:24:11:aa:bb:cc"], "ips": ["192.168.0.50"]}
  ]
}

Output for kind proxy

Return {"proxies": [...], "sites": [...], "certificates": [...]} (needs Netlens 0.3.116). Netlens ties every site to the device or Docker container its upstream address leads to, shows the sites on both devices, warns before a certificate expires, can keep one HTTPS check per site and can give the domains a DNS name. The plugin only reads.

Proxy field Required Meaning
id yes Text or number, unique.
name no Default: the id.
ip no IPv4 address of the machine the proxy runs on: it finds the proxy’s device, and site checks are sent to it.
version no Text.
warnings no Up to 10 short sentences shown in the plugin’s settings (for example “this account can change things”).
Site field Required Meaning
id yes Text or number, unique.
proxy_id yes The id of an entry in proxies.
type no proxy (default), redirect, stream or dead (a 404 page). Only proxy and stream lead to an upstream.
domains no List of domain names (a * wildcard is fine).
enabled no true (default) or false. Disabled sites get no check and no DNS name.
scheme no http (default) or https: how the proxy talks to the upstream.
forward_host, forward_port no The upstream: an IPv4 address, a host name, or the name of a container on the proxy’s Docker network.
forward_ips no The IPv4 addresses the plugin found for a host name. Netlens does no lookups itself.
incoming_port, protocols no For a stream: the port the proxy listens on, and tcp / udp.
ssl, ssl_forced, websockets no Booleans.
certificate_id, cert_name, cert_provider, cert_expires no The certificate the site uses; cert_expires is UTC like 2026-12-31T23:59:59Z.
access_list, redirect_to, name no Text shown with the site.
Certificate field Required Meaning
id yes Text or number; proxy_id (optional) says which proxy it belongs to.
name, provider, domains no Shown in the certificate events.
expires no UTC like 2026-12-31T23:59:59Z. A certificate that no enabled site uses is never reported.

Netlens finds the upstream in this order: a container that publishes the forwarded port on the host with that address; a guest (virtual machine, macvlan container) that has that address; the device with that address; a container (or compose service) with that name on the proxy’s own Docker host; localhost and host.docker.internal mean the proxy’s own machine; a name through the addresses you list in forward_ips or a device with that host name. A site Netlens cannot place is listed as not found, never guessed. The plugin settings create_checks, check_interval and cert_warn_days are read by Netlens (all optional): create_checks (default true) keeps one check per enabled proxy site, check_interval is its interval in seconds (default 300) and cert_warn_days (default 14) is the first warning step before a certificate expires (the later steps are 7, 3 and 1 days and expired).

{
  "proxies": [{"id": "npm", "name": "npm", "ip": "192.168.0.184", "version": "2.15.1", "warnings": []}],
  "sites": [{"id": "proxy-1", "proxy_id": "npm", "domains": ["media.example.com"], "forward_host": "192.168.0.189", "forward_port": 8096,
             "ssl": true, "certificate_id": "1", "cert_expires": "2027-01-31T10:20:30Z"}],
  "certificates": [{"id": "1", "proxy_id": "npm", "name": "wildcard", "provider": "letsencrypt", "domains": ["*.example.com"], "expires": "2027-01-31T10:20:30Z"}]
}

Output for kind backup

Return {"servers": [...], "stores": [...], "targets": [...], "problems": [...]}. Times are UTC text like 2026-10-16T03:01:05Z; sizes are bytes.

  • servers: id, name, ip (to find the device), version, online, warnings (short texts).
  • stores (a datastore, repository or bucket): id, server_id, name, total, used, avail, full (when it is expected to be full), and per job kind gc, prune, verify, sync a <job>_state (ok, warning, failed, none) and a <job>_at.
  • targets (one per guest or host that is backed up): id, server_id, store_id, type (vm, ct, host, other), backup_id (for a VM or container the id of the guest on the hypervisor, as text), name, count (copies kept), last_backup, last_state (ok, warning, failed, unknown), last_size, verify_state, interval (the usual seconds between two backups; Netlens warns when a backup is older than 2.5 times that), protected (copies that cannot be pruned).
  • problems: recent failed or warning jobs: id, server_id, kind (backup, prune, gc, verify, sync, other), state (warning, failed), at, text, target_id.

Netlens matches a vm or ct target to the guest of a hypervisor plugin with the same id (type-aware: a container 100 is not the VM 100), shows the state on that guest’s device page and raises events when a backup starts failing, when it is late, and when a store is on course to fill up. Guests of the hypervisor plugins that no target matches are listed as without a backup (only once a backup plugin has reported).

Output for kind storage

Return {"systems": [...], "controllers": [...], "pools": [...], "volumes": [...], "disks": [...], "alerts": [...]}. Sizes are bytes, times UTC text like 2026-10-16T03:01:05Z. Every list is optional; health is ok, warning, critical or unknown.

  • systems: id, name, ip (to find the device), vendor, model, version, serial, online, health, warnings (short texts).
  • controllers (nodes, storage processors, heads): id, system_id, name, ip, mac (matched to the devices Netlens found), online, health.
  • pools (aggregate, storage pool, RAID group): id, system_id, name, total, used, avail, health, raid.
  • volumes (volume, LUN, share, file system, bucket): id, system_id, pool_id, name, kind (volume, lun, share, filesystem, bucket, other), protocol (nfs, smb, iscsi, fc, s3 …), size, used, health, clients (IPv4 addresses of the hosts that use it: NFS clients, iSCSI initiators).
  • disks: id, system_id, name, slot, model, size, state (ok, degraded, failed, spare, unknown).
  • alerts: open alarms: id, system_id, severity (warning, critical), text, at.

Netlens matches a system or controller to the device with that address, links the clients of a volume to their devices (the device page then says which volumes it uses) and raises events when a system, pool or disk becomes unhealthy or recovers, when a pool passes 85 and 95 percent, and when a new critical alert appears. The first sync after switching a plugin on is not news.

Storage from other kinds (Netlens 0.4.180): a plugin of any other kind, typically a hypervisor plugin for a NAS or a hyperconverged system (Synology, TrueNAS, Unraid, Nutanix …), may add a storage object to its output with the same lists (systems, controllers, pools, volumes, disks, alerts). Netlens shows them on the Storage page next to the guests; leave the key out (or null) when there is nothing to report. A mistake in the storage part fails the whole answer like any other part of the contract.

Output for kind metrics

For a plugin that reads host readings from a store the customer already runs (Prometheus, VictoriaMetrics, Mimir …). Return {"hosts": [...]}. Netlens matches each host to a device (IP address, then MAC, then name) and records the readings like those of any monitored host: graphs, limits and alerts, the dashboard, reports, Ask, the assistant and MCP. A device that is monitored another way (SNMP, SSH, WinRM, a host agent, another plugin) is left alone. Needs Netlens 0.4.304.

Host field Required Meaning
id yes Unique in the answer (up to 120 characters).
name no Host name (default: the id); used to match when there is no IP or MAC match.
ip no IPv4 address (the strongest way to match).
macs no MAC addresses.
readings no Up to 400 readings, below.

A reading: metric (required: cpu_pct, load1, mem_pct, swap_pct, disk_pct, disk_free_b, net_rx_bps, net_tx_bps, uptime_s or temp_c), label (up to 40 characters: the mount point or interface name, empty for a whole-host figure), value (the newest figure) and optionally samples: up to 240 [unix time, value] pairs from the store’s own history since the last sync. With samples the graphs are as dense as the store’s, not as sparse as the sync interval; a sample that is already stored is overwritten, so a window that repeats does no harm. A reading with neither value nor samples is left out. Percentages are 0 to 100, rates are per second in bits (net_*_bps), disk_free_b is bytes.

{"hosts": [
  {"id": "web01:9100", "name": "web01", "ip": "10.0.0.5",
   "readings": [
     {"metric": "cpu_pct", "value": 12.5, "samples": [[1790000000, 11.0], [1790000060, 12.5]]},
     {"metric": "disk_pct", "label": "/", "value": 61.0},
     {"metric": "net_rx_bps", "label": "eth0", "value": 85000}]}]}

Output for kind topology

Return {"nodes": [...], "clients": [...]}. A node is a router, switch, access point or mesh node; a client is a device connected to one.

Node field Required Meaning
mac yes, or give an ip Unique. A node without a MAC (a firewall known only from its management server) gets a placeholder made from its ip, and is matched to a device by IP.
macs no Extra MAC addresses of the same device (for example other radios).
ip no IPv4 address.
name no Default: the MAC.
model no Free text.
role no gateway, switch, ap or node (default). At most one node may be the gateway (the main router).
parent_mac no The mac (or one of the macs) of the node this one is connected to. Without it, the node hangs below the gateway.
ports no For a switch: its ports (up to 128), see below. Needs Netlens 0.4.139.
firewall no For a firewall: version, serial, model, ha (mode, state, peer_state, in_sync), tunnels (name, remote, up) and licences (name, expires as YYYY-MM-DD). Shown in a Firewall card; Netlens raises firewall_ha, vpn_down, vpn_up and firewall_licence events when it changes between two syncs. Needs Netlens 0.4.152.

A port (in a node’s ports): port (1-1024, required, unique), up (a link, true/false, default false), enabled (not switched off by the administrator, default true), speed_mbps, duplex (full or half), name (up to 40 characters), and the counters tx_packets, rx_packets, tx_errors, rx_errors (whole numbers that only grow; a counter that goes back is taken as a restart). Netlens keeps the latest state and one counter sample per sync for 14 days, shows them in a Switch ports card on the switch’s device page (packets per second, errors in the last 24 hours, link changes) and logs a link_down / link_up event when a port changes state between two syncs. The switch must be a device Netlens has scanned (matched by MAC, then IP).

Client field Required Meaning
mac yes The client’s MAC address.
ip no IPv4 address.
name no Free text.
node_mac no The mac (or one of the macs) of the node it is connected to. Without it, the client hangs below the gateway.
medium no wired, wifi or unknown (default).
band no Text such as 5 GHz.
rssi no Wi-Fi signal in dBm (a whole number from -127 to 0). Netlens stores one sample per sync and shows signal history and roaming.
tx_mbps, rx_mbps no Current Wi-Fi link rate in Mbit/s (numbers, 0 or more).
vendor no The manufacturer as the router knows it. If it is really a DHCP vendor class (MSFT 5.0, android-dhcp-13), Netlens recognises that and uses it as the operating system.
os no The operating system, if the router has fingerprinted it (Windows 11, Android 13).
model no A model or product name (iPhone14,2, Chromecast).
port no The switch port a wired client is plugged into (Gi1/0/5, up to 60 characters). Netlens shows it on the device page next to the node’s name.
device_type no One of router, switch, ap, server, pc, phone, tablet, tv, speaker, console, appliance, printer, iot, camera, nas, vm. Any other value is ignored.

The last four are evidence, not facts: Netlens weighs them against what its own scans found, and the device page shows why it chose a type. Only send what the router actually knows; leave a field out rather than guessing.

{
  "nodes": [
    {"mac": "aa:bb:cc:00:00:01", "ip": "192.168.0.1", "name": "Router", "role": "gateway"},
    {"mac": "aa:bb:cc:00:00:02", "ip": "192.168.0.2", "name": "Access point", "role": "ap",
     "parent_mac": "aa:bb:cc:00:00:01"}
  ],
  "clients": [
    {"mac": "11:22:33:44:55:01", "ip": "192.168.0.50", "name": "Laptop",
     "node_mac": "aa:bb:cc:00:00:02", "medium": "wifi", "band": "5 GHz"}
  ]
}

General rules for both kinds: MAC addresses are aa:bb:cc:dd:ee:ff or aa-bb-cc-dd-ee-ff in any case (Netlens stores them in lower case); IP addresses are dotted IPv4; each list may hold at most 5000 entries; the result must be JSON (dict, list, str, int, float, bool, None).

How Netlens uses the output

  • Matching. Hosts and nodes are matched to scanned devices by IP then MAC (nodes: MAC first, then IP). Hypervisor guests: by MAC first, then IP. A host is never taken for a guest and a device is claimed only once. Entries Netlens has not scanned are simply not shown (they appear once a scan finds them).
  • Links. A hypervisor plugin creates host-of links (guest below host). A topology plugin creates uplink links (client below node, node below its parent). These are the strongest automatic sources for the network hierarchy: hypervisor links first, then uplinks, then traceroute and default-gateway guesses. A parent you set by hand always wins, and a link you delete on the map stays deleted.
  • Device pages. Hypervisor plugins add a Virtualization box (the guest’s host, or a host’s guests). A topology plugin that reports rssi for Wi-Fi clients adds a Wi-Fi card (signal history, node, roaming).
  • Names. A client’s name becomes an alias of the matching device (source router); a device that has no hostname of its own shows it.
  • Turning a plugin off removes its links and guests from the map and keeps its settings. Turning it on syncs immediately.

Publishing your plugin

Plugins can be listed in the plugin index so that other people can find and install them under Settings → Plugin store. Include a diagnose(config) (see above) so that people who try your plugin can report problems with one click. Release your plugin as a zip on GitHub, check it with plugin-index/tools/check_plugin.py (a copy of the Netlens repository is enough; it runs the same checks Netlens runs), and submit an entry by pull request. Reviewers read the code and set the review level (Verified, Reviewed or Community). The whole process, the entry format and a plugin template are in plugin-index/README.md in the Netlens repository.

Limits and security

An uploaded plugin is Python code that runs inside the Netlens container with the rights of the application. Netlens isolates it as well as it reasonably can: its own process, a stripped environment, no database path, a time limit, and validation of everything it returns. This is not a sandbox: the plugin runs as the same operating-system user and could read the data volume, which holds the database with saved credentials. So:

  • Only install plugins from sources you trust, and read the code first.
  • Uploading needs the Netlens login. A freshly uploaded plugin stays off until you switch it on, and the upload shows the file’s SHA-256 so you can compare it with the author’s.
  • Give a plugin the least privileged account your device offers (read-only where possible).

Troubleshooting

Message What to do
plugin.json: ... / ... Fix the manifest as the message says; choose another id.
plugin.py must define a top-level function test(config) Define both test(config) and fetch(config), not async.
the plugin did not answer within N seconds Make the plugin faster, or raise timeout (max 600).
the plugin crashed (...) Run the code outside Netlens and look at the traceback; remember only the standard library is available.
the plugin returned data that does not follow the contract: guests[0].host_id: ... The path at the start names the offending field; fix it as described in the tables above.
the plugin returned data that is not JSON Return plain dicts, lists, strings and numbers (no sets, bytes or custom objects).
not configured yet: ... Fill in the required fields on the plugin’s settings page.
Status says automatic syncing is paused The login was refused (auth_failed). Fix the credentials, then Save or Sync now.

DNS plugins (kind dns)

A DNS plugin lets Netlens register devices in a DNS server. Netlens does the thinking (which names and addresses should exist, what is already there, what is safe to change, the preview and the approval); the plugin only talks to the server. Unlike the other kinds it also writes, so its page says so, and nothing is written before the administrator approves it (or switches on automatic mode).

Entry points (all def f(config), except apply):

  • test(config) returns {"message": ...}, as always.
  • fetch(config) returns a snapshot of the server: {"zones": [{"name": "home.example.com", "kind": "forward", "writable": true}, ...], "records": [{"zone": ..., "name": "nas.home.example.com", "type": "A", "value": "192.168.0.7", "ttl": 3600, "managed": true, "comment": "..."}], "server": "dns1"}. Types are A, AAAA, PTR (value = the target name) and CNAME. writable says whether this account can write the zone (a secondary zone is not writable). Include the reverse zones (...in-addr.arpa) you find. Names are compared in lower case without a final dot. managed is true when the record carries Netlens’ marker.
  • apply(config, changes) gets a list of changes and returns [{"id": ..., "ok": true|false, "error": "..."}], one per change. A change is {"id", "action": "add"|"update"|"delete", "zone", "name", "type", "value", "old_value", "comment"}: value is the new value, old_value the current one of an update, comment the marker to put on the record. Write A and PTR records exactly as given (the reverse record is a separate change). Do not send a TTL unless the server needs one: the zone default is wanted.

Netlens adds two settings next to the user’s: zones (the forward zones to read) and marker (the comment that marks Netlens’ own records).

Rules for authors (they protect other people’s DNS): put the marker on every record you write and report it back as managed; select the exact record to update or delete by its current value so a record that changed meanwhile is not overwritten; before an add, check that the name still has no record; never fall back to writing on a read-only (secondary) server; and report a refused login with auth_failed.

The manifest may list "capabilities": ["marker", "delete"] (the server can mark records, and can remove them). technitium in plugins/ is a complete example, and tests/fake_technitium.py shows how to test one against a simulated server.

Guest details (hypervisor plugins)

A guest may carry details, an object Netlens stores and shows on the device page, in Statistics and (some of it) in events:

key meaning
image, image_created a container’s image and when it was built (ISO time; images older than a year are flagged)
project, service the compose project / service of a container
health, restarts, restarting, exit_code, started health check result, restart count, state details, start time
network, network_driver the networks a container is on and the driver (bridge, host, macvlan, ipvlan)
ports published ports: a list of {container_port, host_port, proto, bind}; the host’s Open ports table names the guest behind a port
exposed published on all interfaces
cpus, memory_mb, disk_gb, os, tags, autostart resources and labels of a VM or container
version, update_available the version of an app and whether a newer one exists (raises an event)

Unknown keys are dropped and every value is length-limited. The Proxmox, TrueNAS and Docker plugins all fill what they know. Netlens raises events from guest changes between two syncs: containers get container_unhealthy, container_restarting and container_stopped; every other guest gets guest_stopped, guest_started and guest_update_available.