2026-03-27 22:16:11 +01:00

92 lines
2.1 KiB
Markdown

# Process Monitor
Simple Windows C++ application that checks running processes every 30 seconds
and sends one HTTP heartbeat with all matching processes.
## What it does
- Enumerates running Windows processes via ToolHelp API
- Finds processes by partial name match
- Sends one JSON payload with all currently matched processes
- Builds with CMake without external runtime dependencies
## Expected payload
The application sends HTTP `POST` with `Content-Type: application/json`.
```json
{
"machine_name": "PC-01",
"status": "running",
"detected_at": "2026-03-27T12:34:56Z",
"processes": ["notepad.exe", "notepad++.exe"]
}
```
If `api_token` is set, request header `Authorization: Bearer <token>` is added.
If no process matches in a cycle, the application still sends a heartbeat, but without the `processes` field:
```json
{
"machine_name": "PC-01",
"status": "running",
"detected_at": "2026-03-27T12:34:56Z"
}
```
## Configuration
Edit `process-monitor.conf`.
```ini
api_url=http://10.0.0.147/hb/api
api_token=
machine_name=
interval_seconds=30
request_timeout_seconds=2
process_names=fortnite,chrome,discord,steam
```
Notes:
- `machine_name` is optional; if empty, Windows computer name is used
- `process_names` is a comma-separated list of substrings to search in executable names
- `interval_seconds` can be changed from the default `30`
- `request_timeout_seconds` sets WinHTTP connect/send/receive timeout in seconds
## Build
Developer Command Prompt for Visual Studio:
```powershell
cmake -S . -B build
cmake --build build --config Release
```
Or with Ninja if you have a compiler environment ready:
```powershell
cmake -S . -B build -G Ninja
cmake --build build
```
## Run
```powershell
.\build\Release\process-monitor.exe
```
Or specify custom config path:
```powershell
.\build\Release\process-monitor.exe .\my-config.conf
```
## Next useful improvements
- Run as Windows service
- Add retry/backoff for failed API calls
- Add richer payload items if your API needs both matched pattern and actual process name
- Load config from JSON/YAML if richer metadata is needed