# Controller settings, one example per vendor

Every example goes in the `controller` block of `collector.json`. The rest of the file (server,
polling, `accessPoints`) is the same for all of them; see `collector.example.json`.

Rules that hold for every vendor:

- Secrets are never written in the JSON. Use the environment variable named below, or the same
  setting with `File` on the end (`"passwordFile": "/etc/occupi/controller-password"`, owner-only
  permissions). The collector refuses a secret that sits in the JSON.
- REST controllers are reached over HTTPS only, and `url` is the controller's address with no path.
- Pin the controller's certificate with `tlsFingerprint256` (the value `--discover` prints) or
  trust your campus CA with `"caFile": "campus-ca.pem"`. A pin is checked before any credential is sent.
- The key in each `accessPoints` entry is what the controller calls the AP. `npm run discover`
  lists them.
- Use a read-only account everywhere.

## MikroTik RouterOS

```json
{ "type": "mikrotik", "host": "192.168.88.1", "port": 8729, "tls": true,
  "tlsFingerprint256": "…", "username": "occupi", "ssids": ["eduroam"] }
```
Password: `OCCUPI_CONTROLLER_PASSWORD`. Keys are interface names (`cap-lib2-1`).

## Ruckus SmartZone

```json
{ "type": "smartzone", "url": "https://sz.campus.example:8443", "tlsFingerprint256": "…",
  "username": "occupi", "zoneId": "…", "apKey": "mac", "ssids": ["eduroam"] }
```
Password: `OCCUPI_CONTROLLER_PASSWORD`. `apiVersion` (like `v11_1`) is optional; without it the newest
one the controller lists is used. Without `ssids`, each AP's own client total is read.

## UniFi Network

```json
{ "type": "unifi", "url": "https://unifi.campus.example", "tlsFingerprint256": "…",
  "site": "default", "apKey": "mac" }
```
API key: `OCCUPI_CONTROLLER_API_KEY` (created in the UniFi console). `ssids` is refused: the API does
not say which network a client is on. `site` is needed only if the key sees more than one.

## Cisco Meraki

```json
{ "type": "meraki", "organizationId": "123456", "networkIds": ["N_1234567890"], "ssids": ["eduroam"] }
```
API key: `OCCUPI_CONTROLLER_API_KEY`, from a read-only dashboard admin. The cloud address is the
default; set `url` for `api.meraki.ca`, `.cn`, `.in` or `api.gov-meraki.com`. `networkIds` is
required with `ssids`. Keys are AP serial numbers.

## Juniper Mist

```json
{ "type": "mist", "siteId": "11111111-2222-3333-4444-555555555555", "url": "https://api.eu.mist.com",
  "apKey": "mac", "ssids": ["eduroam"] }
```
Token: `OCCUPI_CONTROLLER_API_KEY` (an organisation token with the `read` role). `url` defaults to
`https://api.mist.com`; use the cloud the campus's Mist portal is on (`manage.gc3.mist.com` means
`https://api.gc3.mist.com`). With `ssids`, clients are counted over the last `countWindowMinutes`
(default 5). First day at a campus: [mist-first-day.md](mist-first-day.md).

Phones only, so a laptop left on a desk or a lab's own PCs are not counted as people:

```json
{ "type": "mist", "siteId": "11111111-2222-3333-4444-555555555555", "url": "https://api.eu.mist.com",
  "apKey": "mac", "ssids": ["eduroam"], "count": "phones" }
```
Run `--discover` first: it prints the operating systems Mist names at the site and the share it
can't name. `phoneOs` (default `["iOS", "iPhone", "Android"]`) lists the names that mean a phone,
matched from the start of Mist's name; `maxUnnamedPercent` (default 25) is the share of unnamed
clients above which the poll fails. Then set "What the Wi-Fi counts" to phones on Staff → Head
counts, on the same day. Not available with `"countBy": "zone"`.

Per room, from zones drawn on the floor maps (see [per-room-counts.md](per-room-counts.md)):

```json
{ "type": "mist", "siteId": "11111111-2222-3333-4444-555555555555", "countBy": "zone",
  "zoneKey": "name", "mapIds": ["123449d4-d12f-4feb-b40f-5be0e2ae1234"] }
```
Each zone is reported like an access point, keyed by its name (or its id with `"zoneKey": "id"`), so
list the zone names under `accessPoints` in the mapping. `mapIds` is optional; `ssids` is refused.
`--discover` lists the zones.

## Cisco Catalyst 9800

```json
{ "type": "cisco9800", "url": "https://wlc.campus.example", "tlsFingerprint256": "…",
  "username": "occupi", "wlanIds": [1, 2] }
```
Password: `OCCUPI_CONTROLLER_PASSWORD`. RESTCONF must be switched on (`ip http secure-server` and
`restconf`). The counters are per WLAN id, so `ssids` is refused; take ids from `show wlan summary`.
Keys are the APs' MAC addresses.

## Aruba OS 8

```json
{ "type": "aruba-os8", "url": "https://conductor.campus.example:4343", "tlsFingerprint256": "…",
  "username": "occupi", "nameField": "Name", "clientsField": "Clients" }
```
Password: `OCCUPI_CONTROLLER_PASSWORD`. `nameField` and `clientsField` are optional: if the driver cannot
find the AP-name and client-count columns it stops and lists the columns it saw, and you set these.
Point it at each managed device rather than the Conductor.

## HPE Aruba Central

```json
{ "type": "aruba-central", "url": "https://us1.api.central.arubanetworks.com",
  "clientId": "…", "tokenFile": "/var/lib/occupi/central-refresh-token", "customerId": "…",
  "site": "Main campus", "ssids": ["eduroam"] }
```
Client secret: `OCCUPI_CONTROLLER_CLIENT_SECRET`. `tokenFile` holds the current refresh token. Create it once
(owner-only permissions) from the token Central gives you; the collector replaces it on every
refresh, so the directory must be writable by the collector's user. `pollSeconds` must be at least
120 (300 with `ssids`), because Central allows 5,000 calls a day. Keys are AP serial numbers.

## Not sure what the controller calls its APs?

```bash
npm run discover
```
lists every AP key the controller reports, without sending anything to Occupi. For an on-premises controller with no `tlsFingerprint256` or `caFile` yet, it prints the certificate fingerprint to pin (nothing is logged in) and exits with code 3.

## Fortinet / Meru FortiWLC

```json
{ "type": "fortiwlc", "host": "10.20.0.5", "communityFile": "/etc/occupi/snmp-community" }
```
SNMP, not HTTPS: there is no certificate to pin. Community: `OCCUPI_CONTROLLER_COMMUNITY`, or
`communityFile`. For SNMPv3 use `"snmp": "v3", "username": "occupi"` with `authKeyFile` and `privKeyFile`
(`OCCUPI_CONTROLLER_AUTH_KEY`, `OCCUPI_CONTROLLER_PRIV_KEY`); `authProtocol` is `sha` or `md5` and privacy is DES,
the options FortiWLC has. Keys are AP names as `show station` prints them. What to enable on the controller,
the sources and what is unverified: [controller-apis.md](controller-apis.md#fortinet--meru-fortiwlc-snmp-driver-and-file-import).
