The agent

structam-agent on Linux, macOS and Windows: files, commands, policies, what it collects per OS, redaction, the deny list, store and forward, hardening and updates.

On this page

Status. The Linux and macOS collectors have live tests on those systems, and a real agent was run against a local server on macOS. Not yet run: the Windows agent on a real Windows host. Its collectors are built and vetted for Windows and their parsers are tested against recorded output, but no live Windows run is recorded.

The agent, structam-agent, runs on each host as a system service. It connects outbound to the server's public URL over one WebSocket, proves its identity with a per-host Ed25519 key, and pins the server's identity key from its join token. It is a single static Go binary for Linux, macOS and Windows, each on amd64 and arm64. Most hosts are installed with the onboarding scripts, which run the commands below.

Files

LinuxmacOSWindows
Binary/opt/structam-agent/bin/structam-agent/Library/Application Support/Structam Agent/bin/structam-agent%ProgramFiles%\Structam\Agent\structam-agent.exe
Env file/etc/structam-agent/agent.env/Library/Application Support/Structam Agent/agent.env%ProgramData%\Structam\Agent\agent.env
Local policy/etc/structam-agent/local-policy.json/etc/structam-agent/local-policy.json%ProgramData%\Structam\Agent\local-policy.json
State directory/var/lib/structam-agent/Library/Application Support/Structam Agent%ProgramData%\Structam\Agent
Servicesystemd unit structam-agent/Library/LaunchDaemons/com.kazlabs.structam-agent.plistservice structam-agent
Logjournalctl -u structam-agent/Library/Logs/structam-agent.logagent.log in the state directory

The env file (mode 0600) holds:

  • STRUCTAM_SERVER: the server URL (https://...). There is no default.
  • STRUCTAM_JOIN: the join token, only until enrolment; the agent removes it once the server has welcomed it. STRUCTAM_JOIN_FILE names a file holding it instead.
  • STRUCTAM_SERVER_PIN: extra trusted server pins, comma-separated. Normally not needed: the join token carries the pin.
  • STRUCTAM_CA_FILE, STRUCTAM_PROXY, STRUCTAM_LOG_LEVEL, STRUCTAM_LOG_FORMAT.
  • STRUCTAM_INSECURE=on allows an http:// server, for labs only. The channel is still sealed and the server still pinned, but URLs, timing and sizes are visible on the network; the agent logs a warning on every start.
  • STRUCTAM_STATE_DIR, STRUCTAM_ENV_FILE, STRUCTAM_LOCAL_POLICY move the files above.

Precedence is the env file, then the process environment, then command-line flags. Every variable has a flag of the same meaning (-server, -ca-file, -proxy, -state-dir and so on); run structam-agent <command> -h. The full list is in the configuration reference.

The env file, a join file and the local policy must be owned by root and not writable by group or others (Windows: owned by SYSTEM or Administrators, and no access control entry lets another account write, append, delete or change permissions). Whoever can edit the env file could add a server pin and point the agent at another server, so the agent refuses to start otherwise. The error names the file and the fix, for example:

chown root /etc/structam-agent/agent.env && chmod 0600 /etc/structam-agent/agent.env

The state directory

FileWhat it is
agent.keythe agent's private key; never overwritten, and an unreadable key is an error, not a reason to make a new one
server.pinstrusted server pins, one per line
enrolment.jsonagent id, host id and the configuration-hash key; its presence means "enrolled"
policy.json, last-acked.json, commands.jsoncaches the server sends again on the next connection
queue/, next-seqinventory waiting to be acknowledged, and its sequence counter
hashcache.dbexecutable and configuration hashes, so unchanged files are not hashed again
update/, update-results.jsona self-update in progress, the rollback guard, and outcomes not yet acknowledged
pin-rotation.jsonserver key rotations waiting for a handshake with their new key
agent.lockheld by run, enrol and reset-identity, so only one process uses the directory

A corrupt cache file (last-acked.json, policy.json, commands.json, update-results.json) does not stop the agent: it is renamed to <name>.corrupt-<unix time>, a warning names it, and the agent sends a full inventory after the next welcome. A corrupt agent.key, server.pins, enrolment.json or pin-rotation.json stops the agent with an error naming the file: guessing would change the agent's identity or the servers it trusts.

Commands

All commands except status and version need root (Administrator on Windows).

CommandWhat it does
structam-agent enrol [-join-file PATH] [-timeout 60s] [-no-connect]read the join token from the file, from standard input, or from the terminal without echo; store it in the env file; connect until the server welcomes the agent. The token is never accepted as an argument. Refused while the service runs
structam-agent install [-start=false]write the service definition, enable and (re)start it; -start=false for image builds
structam-agent uninstall [-purge]stop and remove the service; -purge also deletes the state directory, the env file, the local policy and ca.pem
structam-agent statusthe service state, the agent's identity and fingerprint, the queue and any pending update
structam-agent reset-identitydelete the key, pins, queue, enrolment and caches, so the next start enrols as a new agent; run it before capturing a machine image
structam-agent guardcheck a pending self-update before a start; after three failed starts of a new build the previous one is restored
structam-agent runwhat the service manager starts
structam-agent versionthe version

Policies

What an agent collects, and how often, is decided by its policy (Policies, permission policies.manage). The effective policy of an agent is the one its join token named, else the policy of the highest-priority assignment whose match the host satisfies, else the built-in default. A match is a set of lists (sites, tenants, roles, platforms, tags, OS); every non-empty list must contain the host's value, and an empty match applies to every agent. The server pushes the effective policy at each connection and whenever it changes.

FieldDefaultMeaning
collect_interval_s300full pass: packages, accounts, facts, hardware, patches, neighbours (60 to 86 400)
process_interval_s60processes, services, ports (15 to 3 600)
config_interval_s60configuration stat scan; content is read only when a file changed (15 to 86 400)
hash.executablesonSHA-256 of executables
hash.max_file_mb256larger files are not hashed (too_large)
hash.budget_mb_per_pass2 048at most this much is hashed per pass; the rest is pending until the next
configs.includeper OS, belowconfiguration files to watch
configs.excludenoneadded to the built-in deny list, never replacing it
configs.max_file_kb1 024larger files are not collected
configs.text_only, configs.follow_symlinkson, off
configs.redactnonepatterns added to the built-in redaction set
packages, services, ports, accounts, neighbours, hardware, patchesonsections to collect
processes.cmdlineoffcollect process command lines (redacted on the host)
auto_updateontake automatic self-updates (see updates)
queue.max_mb, queue.max_days256, 7bounds of the on-disk queue

Default configuration paths: Linux /etc/**; macOS /etc/** and /Library/Preferences/*.plist; Windows the hosts file and *.conf, *.ini, *.xml and *.json under ProgramData.

Local policy

An optional file on the host narrows what the server's policy may collect there:

{"configs_include": ["/etc/nginx/**", "/etc/ssh/sshd_config"], "fetch_config": false}
  • configs_include: configuration files are collected only when both this list and the server's policy include them. An empty list collects no configuration files.
  • fetch_config: false refuses the server's on-demand file fetches.

Unknown keys are refused, and the file must be root-owned and not writable by others, or the agent refuses to start.

What it collects

Linux reports 10 sections (no patches: package versions cover them); macOS and Windows report 11. Only sections whose content changed are sent.

SectionLinuxmacOSWindows
factsos-release, kernel, CPU, memory, boot time, machine id, DMI, time zone, interfaces and addresses, default route, DNSsw_vers, sysctl, ioreg and system_profilerregistry (CurrentVersion, MachineGuid), SMBIOS
packagesdpkg, rpm, apk, pacman, snap, flatpakpkgutil receipts, /Applications bundles, Homebrewuninstall registry keys (64-bit, 32-bit and user), MSI, Appx
executablesSHA-256 of running images and package-owned bin, sbin and libexec files.app main executables, running imagesmain executables under the install location, service binaries, running images
processes/proc, with the running image and container idprocess table and argumentsToolhelp32 and the full image name
servicessystemd units (systemd as PID 1)launchd jobsService Control Manager
portslistening TCP and UDP sockets with the owning processlsofthe extended TCP and UDP tables
accounts/etc/passwd, /etc/group (never the shadow files)dscllocal users and groups
configspolicy-driven file scan (default /etc/**)/etc/**, /Library/Preferences/*.plisthosts file, configuration files under ProgramData
neighboursthe kernel neighbour table (ARP and NDP)arp, ndpGet-NetNeighbor
hardwareSMBIOS (BIOS, CPU, memory modules with slot, serial and part number), diskssystem_profiler hardware, storage and memorySMBIOS, disks and network adapters
patchesnot collectedApple install history (OS updates)installed updates (KB numbers)
  • Collectors are read-only. External programs run only from absolute paths, with no shell, LC_ALL=C, a 60 s timeout and a 64 MiB output cap, and only where the OS offers no file or API for the data.
  • On Windows, PowerShell is used only for Appx, disks and network adapters, installed updates and neighbours, once per collect interval; never on the 60-second process interval. The agent never queries Win32_Product, which triggers MSI self-repair, and never uses wmic.
  • Operating-system binaries (the macOS sealed system volume, C:\Windows) are hashed but never become applications; short-lived standalone binaries do not churn the application list.
  • Process command lines are collected only when the policy turns on processes.cmdline, and are redacted on the host.
  • On macOS the agent needs Full Disk Access to read everything; without it, it reports a limited_visibility capability. Grant it through your device management; Structam does not ship a profile for it.

Redaction and the deny list

Configuration content and process command lines are redacted on the host before they are hashed or sent: PEM private key blocks, passwords in URLs, Bearer, Basic and Digest credentials, secret command-line flags, key=value and key: value pairs whose key names a secret, well-known token shapes, and XML elements and attributes such as <password>, <secret>, <token>, <apikey>, <passphrase>, <connectionString> and password="...". The policy's configs.redact patterns add to this set. Redacted secrets never leave the host. A change to the built-in set changes the redaction revision, so the server records the next version of each file as a redaction change, not an edit.

A built-in deny list is compiled into the agent and no policy can override it: /etc/shadow*, /etc/gshadow*, SSH host keys, *.key, *privkey*, keystores (.p12, .pfx, .jks, .keystore, .keytab, .kdbx), WireGuard, NetworkManager connections, IPsec and PPP secrets, BSD password databases on macOS, and the agent's own state directory, env file, local policy and CA file. A file containing a private key block is never uploaded: it is recorded as withheld, with size, mode and owner only.

Connection and store and forward

  • After a signed handshake, every frame is sealed with AES-256-GCM under keys from an X25519 exchange, with a strict sequence number per direction (security model).
  • Heartbeat every 30 s; the server closes a connection idle for 90 s; the agent reconnects with full-jitter backoff from 1 s to 60 s, at once when a node drains.
  • Inventory is written to an on-disk queue before it is sent and deleted only after the server acknowledges it, and the server acknowledges only after commit. The queue keeps up to 256 MiB or 7 days by default. Past that the oldest messages are dropped and the server records an agent.gap change event, so loss is never silent.
  • When the server is busy (a long ingest queue, a stalled database commit) it tells agents to retry later, and they keep the data on disk.

Service hardening

  • Linux: the systemd unit runs the agent as root with its capabilities bounded to CAP_DAC_READ_SEARCH and CAP_SYS_PTRACE, NoNewPrivileges, ProtectSystem=strict (only the state directory, the binary's directory for self-update, and /etc/structam-agent to remove the join token are writable), ProtectHome=read-only, PrivateTmp, kernel, cgroup and clock protections, RestrictAddressFamilies=AF_INET AF_INET6 AF_UNIX AF_NETLINK, MemoryDenyWriteExecute and UMask=0077.
  • Linux resource caps: MemoryMax=512M, CPUQuota=50%, Nice=10 and idle I/O scheduling. These are limits set by the unit, not measurements of the agent.
  • macOS: a launchd daemon at background priority with low-priority I/O.
  • Windows: a LocalSystem service with delayed automatic start that restarts after a failure.

Updates

The server can offer an agent a new build; the agent accepts it only when the release manifest is signed by a KazLabs release key compiled into the agent, and the product, version, SHA-256 and size match. It downloads only from the server it is pinned to, keeps the previous binary, and rolls back after three failed starts. A download that fails before the swap keeps the running version and is offered again after 24 hours.

Caution. The KazLabs release key has not been generated yet, so release agents refuse every self-update today. Upgrade agents with install.sh --upgrade (or install.ps1 -Upgrade) from your server.

Questions the docs do not answer?

Ask the people who build Structam. Installation media and licences come from KazLabs.

Talk to us