Agent
This guide walks a developer through setting up a local development environment for the OCS Inventory Agent Rework repository - a complete rewrite of the OCS Inventory Agent in Dart, built for use with the 3.0 OCS Inventory server.
This guide is for development environments only. For a production install of the agent, see the OCS Inventory Agent Setup guide instead, or grab a pre-compiled Windows binary from the releases page.
Overview
This repository contains the agent only - the piece that runs on end-user machines and reports inventory data to the backend. To fully exercise it during development, you'll also need a running instance of the backend API for the agent to report to.
The agent is a standalone Dart console application, with platform-specific packaging (setup/linux, setup/windows, setup/macos) to turn it into an installable service.
Prerequisites
The Dart SDK - download the latest stable release for your platform from the official Dart installation page, then make sure the
dartbinary is available on yourPATHby following the same page's instructions for your OS.Git - to clone the repository.
Platform-specific build tools, only if you intend to compile the installable packages:
Linux/macOS: a standard shell environment is enough to run the provided
install.sh/uninstall.shscripts.Windows:
Developer Command Prompt for VS 2022(to runbuild_all.bat) and, optionally, Inno Setup if you want to build your own Windows installer package.
A running instance of the backend API, since the agent has nothing to report to without one.
Step 1 - Clone the Repository
The default branch for active development is main.
Step 2 - Install Dependencies
From the project root, fetch the Dart packages the agent depends on:
Step 3 - Run or Build the Agent
For day-to-day development, you can run the agent's entry point directly with Dart, without compiling a binary each time:
When you need a standalone executable (e.g. to test the full install flow), compile it for your platform:
Step 4 - Configure the Agent for Local Testing
Once installed (or when running the compiled binary directly), the agent reads its settings from a config.json file. Its location depends on your OS:
Linux / macOS
/etc/ocsinventory-agent
Windows
C:\ProgramData\OCSInventory-Agent\
Key properties in config.json:
url
URL of the backend server API you want the agent to report to.
username / password
Credentials used to authenticate against the backend API in remote inventory mode.
mode
Working mode: 1 remote with template, 2 remote without template, 3 local with template, 4 local without template.
data_directory
Folder where the agent stores inventory data.
log_level
0 Critical, 1 Error, 2 Warning, 3 Info, 4 Debug.
log_file / log_file_path
Whether to log to a file (instead of the terminal) and where. Note: the file itself isn't created automatically - you need to create it yourself.
certificate
Path to a certificate file (.pem), required if the backend runs over HTTPS.
bypass-certificate
Set to true to skip certificate validation - handy for a self-signed cert in a dev environment.
Example:
Uninstalling a Local Install
If you installed the agent through the platform scripts while testing:
Linux
Run uninstall.sh (with root privileges) from /usr/share/ocsinventory-agent/setup/linux/.
Windows
Run the uninstaller from C:\Program Files\OCSInventory-Agent\.
macOS
Run uninstaller.sh (with root privileges) from /Applications/OCS-NG.app/Contents/Resources/.
Troubleshooting
dart pub get fails
Confirm the Dart SDK is installed and dart is on your PATH (dart --version).
Agent can't reach the backend
Double-check url in config.json - including protocol (http/https) and port - and confirm the backend is running and reachable.
Authentication errors
Verify username and password in config.json, and that the account has the needed permissions on the backend API.
SSL/certificate errors
If the backend uses HTTPS, provide a valid certificate path, or set bypass-certificate to true for local/self-signed testing.
No logs, or logs not where expected
Check log_file and log_file_path - remember the log file itself isn't created automatically; create it first.
Nothing happens after restarting the service
Restart it explicitly: sudo systemctl restart ocsinventory-service (Linux), via Windows Services (Windows), or unload/reload the LaunchDaemon plist (macOS).
How to Contribute
Fork the repository on GitHub, then clone your fork locally (see the note in Step 1 above).
Create a branch for your change, based on main:
Make your changes, following the existing code style. The repository includes several quality and security configs (.cspell.json, .gitleaks.toml, .jscpd.json, .mega-linter.yml) — running the relevant checks locally before committing will catch most issues early and matches what CI checks on your pull request.
Commit and push your branch to your fork:
Open a pull request from your branch to the main branch of the main repository, with a clear description of what the change does and why.
One Last Thing
You just got a Dart agent talking to a backend it's never met before - that's not nothing.
This little program is the one that actually walks onto thousands of real machines, quietly counts what's installed, and phones home so someone, somewhere, doesn't have to do it by hand with a spreadsheet. It runs on Linux, Windows, and macOS, often as a background service nobody thinks about - until it stops working, at which point everybody thinks about it. Every edge case you handle here saves a sysadmin from a bad day later.
So compile that binary, point it at your local backend, and see what it reports. If something's off, that's not a dead end - that's your first pull request waiting to happen. 🚀
Last updated

