PatchMon's monitoring agent sends package and repository information to the PatchMon server.
- Download the appropriate binary for your architecture from the releases
- Make executable and move to system path:
chmod +x patchmon-agent-linux-amd64 sudo mv patchmon-agent-linux-amd64 /usr/local/bin/patchmon-agent
-
Prerequisites:
- Go 1.25 or later
- Root access on the target system
-
Build and Install:
# Clone or copy the source code make deps # Install dependencies make build # Build the application sudo make install # Install to /usr/local/bin
-
Configure Credentials:
sudo patchmon-agent config set-api <API_ID> <API_KEY> <SERVER_URL>
Example:
sudo patchmon-agent config set-api patchmon_1a2b3c4d abcd1234567890abcdef1234567890abcdef1234567890abcdef1234567890 http://patchmon.example.com
-
Test Configuration:
sudo patchmon-agent ping
-
Send Initial Report:
sudo patchmon-agent report
- Main Config:
/etc/patchmon/config.yml(YAML format) - Credentials:
/etc/patchmon/credentials.yml(YAML format, 600 permissions) - Logs:
/var/log/patchmon-agent.log
# Configuration and setup
sudo patchmon-agent config set-api <API_ID> <API_KEY> <SERVER_URL> # Configure credentials
sudo patchmon-agent config show # Show current config
sudo patchmon-agent ping # Test credentials and connectivity
# Data collection and reporting
sudo patchmon-agent report # Report system & package status to server
# Agent management
sudo patchmon-agent check-version # Check for updates
sudo patchmon-agent update-agent # Update to latest version
sudo patchmon-agent update-crontab # Update cron schedule
sudo patchmon-agent uninstall [flags] # Uninstall the agent
# Diagnostics
sudo patchmon-agent diagnostics # Show system diagnosticsCreate /etc/patchmon/config.yml:
patchmon_server: "https://patchmon.example.com"
api_version: "v1"
credentials_file: "/etc/patchmon/credentials.yml"
log_file: "/var/log/patchmon-agent.log"
log_level: "info"The credentials file is automatically created by the configure command:
api_id: "patchmon_1a2b3c4d5e6f7890"
api_key: "abcd1234567890abcdef1234567890abcdef1234567890abcdef1234567890"The agent can automatically configure crontab based on server policies:
# Update crontab with current server policy
sudo patchmon-agent update-crontabThis creates entries like:
# Hourly reports (at minute 15)
15 * * * * /usr/local/bin/patchmon-agent report >/dev/null 2>&1
15 * * * * /usr/local/bin/patchmon-agent update-crontab >/dev/null 2>&1
# Or custom interval (every 30 minutes)
*/30 * * * * /usr/local/bin/patchmon-agent report >/dev/null 2>&1
*/30 * * * * /usr/local/bin/patchmon-agent update-crontab >/dev/null 2>&1The agent includes a built-in uninstall command for complete removal:
# Remove agent binary, crontab entries, and backup files
sudo patchmon-agent uninstall# Remove everything including configuration and logs
sudo patchmon-agent uninstall --remove-config --remove-logs
# Or use the shortcut flag
sudo patchmon-agent uninstall --remove-all # or -a
# Silent complete removal
sudo patchmon-agent uninstall -af--remove-config # Remove configuration and credentials files
--remove-logs # Remove log files
--remove-all, -a # Remove all files (shortcut for --remove-config --remove-logs)
--force, -f # Skip confirmation promptsAlways removed:
- Agent binary (current executable)
- Additional binaries found in common locations
- Crontab entries related to patchmon-agent
- Backup files created during updates
Optional (with flags):
- Configuration files (
--remove-config) - Credentials files (
--remove-config) - Log files (
--remove-logs)
The uninstall process will:
- Show what will be removed
- Prompt for confirmation (unless
--forceis used) - Remove crontab entries first
- Remove additional files and binaries
- Use a self-destruct mechanism to remove the main binary
Logs are written to /var/log/patchmon-agent.log with timestamps and structured format:
2023-09-27T10:30:00 level=info msg="Collecting package information..."
2023-09-27T10:30:01 level=info msg="Found packages" count=156
2023-09-27T10:30:02 level=info msg="Sending report to PatchMon server..."
2023-09-27T10:30:03 level=info msg="Report sent successfully"
Log levels: debug, info, warn, error
-
Permission Denied:
# Ensure running as root sudo patchmon-agent <command>
-
Credentials Not Found:
# Configure credentials first sudo patchmon-agent config set-api <API_ID> <API_KEY> <SERVER_URL>
-
Network Connectivity:
# Test server connectivity sudo patchmon-agent ping sudo patchmon-agent diagnostics # Detailed network info
-
Package Manager Issues:
# Update package lists manually sudo apt update # Ubuntu/Debian sudo dnf check-update # Fedora/RHEL
Run comprehensive diagnostics:
sudo patchmon-agent diagnosticsThis returns information about your system, the agent, the current configuration and server connectivity state, and more.
The Go implementation maintains compatibility with the existing shell script workflow:
- Same command structure: All commands work identically
- Same configuration files: Uses the same paths and formats
- Same API compatibility: Works with existing PatchMon servers
- Improved performance: Faster execution and better error handling
To migrate:
- Remove the old shell script agent, config, credentials, and crontab.
- Install the Go binary as described above
- No changes needed to crontab or server settings
# Install dependencies
make deps
# Build for current platform
make build
# Build for all supported platforms (Linux amd64, arm64, i386)
make build-all
# Run tests
make test
# Run tests with coverage
make test-coverage
# Format and lint
make fmt
make lint
# Clean build artifacts
make clean- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Run
make fmtandmake lint - Submit a pull request