Overview
This article describes how to use the JetPatch REST API to export a full endpoint inventory — including installed agents and services — to an Excel (.xlsx) file on a schedule, without requiring manual interaction with the JetPatch console.
The script (jetpatch_inventory.py) is suitable for scheduling via cron (Linux) or Windows Task Scheduler and produces output matching the manual export format available in the UI.
Prerequisites
1. JetPatch user with API access
- In the JetPatch Console, go to Administration → Users
- Edit the relevant user and enable API access
- Copy the API key shown on the user record
- The user must have Administrator permissions
2. Network access
The machine running the script must be able to reach the JetPatch core server over HTTPS (port 443). Running the script directly on the JetPatch core server itself is a straightforward option.
3. Python 3 with required packages
pip3 install requests openpyxl
4. Clock synchronization
The JetPatch REST API uses HTTP Digest authentication, which is time-sensitive. Ensure the clock on the machine running the script is synchronized with the JetPatch server via NTP.
The Script
Place jetpatch_inventory.py in a working directory:
- Linux:
/opt/jetpatch-reports/ - Windows:
C:\JetPatchReports\
Test manually first
python3 jetpatch_inventory.py \ --url https://<jetpatch-server> \ --user <username> \ --api-key <api-key>
This produces a timestamped file such as jetpatch_inventory_20260609_140000.xlsx containing the following columns:
| Column | Description |
|---|---|
| Status | Connector status (OK, INVALID_CREDENTIALS, etc.) |
| Name | Endpoint display name |
| Hostname | Reported hostname |
| DNS Name | Fully qualified DNS name |
| Type | Machine type (physical, virtual, etc.) |
| Agents | Installed agents with version numbers |
| Services | Deployed services |
| IP | Primary IP address |
| All IPs | All known IP addresses |
| OS | Operating system name and version |
| Tags | Assigned Smart Group tags |
| Core Server ID | JetPatch core server identifier |
Command-line options
| Option | Description |
|---|---|
--url | JetPatch core server URL (e.g. https://30.30.2.63) |
--user | JetPatch username |
--api-key | API key for the user |
--output <path> | Write to a fixed filename/path instead of a timestamped file |
--auth-mode | Authentication mode (default: digest) |
--no-agents | Skip per-server agent detail calls — significantly faster for large environments |
Scheduling
Option A — Linux (cron)
Run every Monday at 06:00:
crontab -e
Add the following line:
0 6 * * 1 /usr/bin/python3 /opt/jetpatch-reports/jetpatch_inventory.py \ --url https://<jetpatch-server> \ --user <username> \ --api-key <api-key> \ --output /opt/jetpatch-reports/inventory_$(date +\%Y\%m\%d).xlsx \ >> /opt/jetpatch-reports/report.log 2>&1
Option B — Windows Task Scheduler
- Open Task Scheduler → Create Task
- General tab: Select Run whether user is logged on or not
- Triggers tab: Set your schedule (e.g. Weekly, Monday at 06:00)
- Actions tab: Add a new action:
- Program:
python.exe Arguments:
C:\JetPatchReports\jetpatch_inventory.py --url https://<jetpatch-server> --user <username> --api-key <api-key> --output C:\JetPatchReports\inventory.xlsx
- Program:
- Click OK and provide credentials when prompted
Security Guidance
Linux — use an environment variable or credentials file
export JP_API_KEY="your-api-key"
Or store credentials in a config file with restricted permissions:
chmod 600 /opt/jetpatch-reports/.jp_credentials
Windows — use a dedicated service account
Store the API key in a credentials file accessible only to the service account running the scheduled task, rather than embedding it in the task arguments.
Principle of least privilege
Create a dedicated read-only JetPatch user for the API export rather than using an administrator account, if your JetPatch version supports read-only API roles.
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
401 Unauthorized | Wrong username or API key | Verify credentials in JetPatch Console → Users |
401 Unauthorized with correct credentials | Clock skew between script machine and JetPatch server | Sync NTP on the script machine |
| SSL certificate error | Self-signed cert not trusted | Script uses verify=False by default for JetPatch — no action needed |
| Empty output / no endpoints | User lacks permissions | Ensure user has Administrator role in JetPatch |
| Script slow on large environments | Per-endpoint agent detail API calls | Add --no-agents flag to skip agent lookups |
Possible Follow-ups
The following enhancements are not included in the current script but can be implemented on request:
- Email delivery: Automatically email the generated .xlsx to a distribution list after each run via SMTP
- Network share output: Write the report directly to a UNC path or mounted network share
- Delta reporting: Compare consecutive exports and highlight only changed endpoints
API Reference
The script uses the following JetPatch REST API endpoints:
| Method | Endpoint | Description |
|---|---|---|
GET | /vmanage-server/rest/rest-api/servers | Retrieve full endpoint list |
GET | /vmanage-server/rest/rest-api/servers/{id}/deployments | Retrieve agents and services per endpoint |
Authentication: HTTP Digest using JetPatch username and API key.
Comments
0 comments
Please sign in to leave a comment.