Debugging Guide
This guide provides systematic debugging procedures for diagnosing issues with License Monitor and License Server Detail.
Debug Mode
Section titled “Debug Mode”Enabling Debug Output
Section titled “Enabling Debug Output”# Run License Monitor in debug mode/usr/local/bin/license_monitor \ --config /etc/license-monitor/config.toml \ --debug \ --level debugexport LICENSE_MONITOR_LOG_LEVEL=debugsystemctl restart license-monitor[daemon]log_level = "debug"console_log_level = "debug"Debug Log Levels
Section titled “Debug Log Levels”| Level | Use Case |
|---|---|
error | Production, errors only |
warn | Production, warnings and errors |
info | Normal operation visibility |
debug | Troubleshooting |
trace | Deep debugging (verbose) |
Request Tracing
Section titled “Request Tracing”Using Request IDs
Section titled “Using Request IDs”Every API request includes a correlation ID:
# Make request and capture IDcurl -v -H "X-API-Key: KEY" http://localhost:8080/api/health 2>&1 | \ grep "X-Request-ID"
# Output: < X-Request-ID: req-abc123
# Find in logsgrep "req-abc123" /var/log/license-monitor/license_monitor.logAdding Custom Request ID
Section titled “Adding Custom Request ID”# Send custom request IDcurl -H "X-API-Key: KEY" \ -H "X-Request-ID: my-trace-123" \ http://localhost:8080/api/health
# Find in logsgrep "my-trace-123" /var/log/license-monitor/license_monitor.logNetwork Debugging
Section titled “Network Debugging”Connection Testing
Section titled “Connection Testing”-
Test DNS resolution
Terminal window nslookup license-server.example.comdig license-server.example.com -
Test TCP connectivity
Terminal window nc -zv license-server.example.com 27000telnet license-server.example.com 27000 -
Test HTTP connectivity
Terminal window curl -v http://localhost:8080/api/health -
Capture network traffic
Terminal window tcpdump -i any port 8080 -w capture.pcap# Analyze with Wireshark
HTTP Debug
Section titled “HTTP Debug”# Verbose HTTP requestcurl -v -H "X-API-Key: KEY" http://localhost:8080/api/licenses
# Include timingcurl -w "@curl-format.txt" -o /dev/null -s http://localhost:8080/api/health
# curl-format.txt:# time_namelookup: %{time_namelookup}s\n# time_connect: %{time_connect}s\n# time_appconnect: %{time_appconnect}s\n# time_pretransfer: %{time_pretransfer}s\n# time_starttransfer: %{time_starttransfer}s\n# time_total: %{time_total}s\nProcess Debugging
Section titled “Process Debugging”Process Status
Section titled “Process Status”# Find processpgrep -a license_monitor
# Check process detailsps aux | grep license_monitor
# Check open fileslsof -p $(pgrep license_monitor)
# Check network connectionsss -tlnp | grep license_monitornetstat -tlnp | grep license_monitorResource Usage
Section titled “Resource Usage”# Real-time monitoringtop -p $(pgrep license_monitor)
# Memory detailscat /proc/$(pgrep license_monitor)/status | grep -E "(VmSize|VmRSS|VmPeak)"
# File descriptorsls -la /proc/$(pgrep license_monitor)/fd | wc -lcat /proc/$(pgrep license_monitor)/limits | grep "open files"strace Debugging
Section titled “strace Debugging”# Trace system callsstrace -p $(pgrep license_monitor) -f 2>&1 | tee strace.log
# Trace specific callsstrace -p $(pgrep license_monitor) -e trace=network
# Trace file operationsstrace -p $(pgrep license_monitor) -e trace=fileConfiguration Debugging
Section titled “Configuration Debugging”Validate Configuration
Section titled “Validate Configuration”# Check TOML syntax/usr/local/bin/license_monitor --config /etc/license-monitor/config.toml --validate
# Or with Pythonpython3 -c "import toml; toml.load('/etc/license-monitor/config.toml')"Print Effective Configuration
Section titled “Print Effective Configuration”# Show merged configuration/usr/local/bin/license_monitor --config /etc/license-monitor/config.toml --dump-configEnvironment Variable Debugging
Section titled “Environment Variable Debugging”# Show all relevant env varsenv | grep -E "(LICENSE_MONITOR|OTEL|LOG)"
# Check systemd environmentsystemctl show license-monitor --property=EnvironmentLicense Server Debugging
Section titled “License Server Debugging”Test License Commands
Section titled “Test License Commands”# Test FlexLMlmstat -a -c 27000@server
# Test RLMrlmstat -a -c 5053@server
# Test with timeouttimeout 30 lmstat -a -c 27000@serverParse Script Debugging
Section titled “Parse Script Debugging”# Test parse script manuallylmstat -a -c 27000@server | python3 /etc/license-monitor/servers/parse.py
# Debug parse scriptlmstat -a -c 27000@server | python3 -c "import sysimport json
data = sys.stdin.read()print('Input length:', len(data))print('First 500 chars:', data[:500])"Database Debugging
Section titled “Database Debugging”Convex Debugging
Section titled “Convex Debugging”# Check Convex connectionnpx convex dashboard
# View Convex logsnpx convex logs
# Check function executionnpx convex functionsBrowser Debugging
Section titled “Browser Debugging”Developer Tools
Section titled “Developer Tools”-
Open DevTools: Press F12
-
Check Console tab for JavaScript errors
-
Check Network tab:
- Filter by XHR/Fetch for API calls
- Filter by WS for WebSocket
- Look for red (failed) requests
-
Check Application tab:
- Cookies for session data
- Local/Session Storage for cached data
WebSocket Debugging
Section titled “WebSocket Debugging”// In browser consoleconst ws = new WebSocket('ws://localhost:8080/ws/logs?api_key=KEY');ws.onopen = () => console.log('Connected');ws.onmessage = (e) => console.log('Message:', e.data);ws.onerror = (e) => console.log('Error:', e);ws.onclose = (e) => console.log('Closed:', e.code, e.reason);Creating Debug Reports
Section titled “Creating Debug Reports”Collecting Information
Section titled “Collecting Information”#!/bin/bashREPORT_DIR="/tmp/license-monitor-debug-$(date +%Y%m%d-%H%M%S)"mkdir -p "$REPORT_DIR"
echo "Collecting system info..."uname -a > "$REPORT_DIR/system.txt"cat /etc/os-release >> "$REPORT_DIR/system.txt"
echo "Collecting service status..."systemctl status license-monitor > "$REPORT_DIR/service-status.txt" 2>&1
echo "Collecting recent logs..."journalctl -u license-monitor -n 500 > "$REPORT_DIR/journal.log" 2>&1tail -500 /var/log/license-monitor/license_monitor.log > "$REPORT_DIR/app.log" 2>&1
echo "Collecting config (sanitized)..."sed 's/api_key = .*/api_key = "[REDACTED]"/' /etc/license-monitor/config.toml > "$REPORT_DIR/config.toml"
echo "Collecting network info..."ss -tlnp > "$REPORT_DIR/network.txt"iptables -L -n > "$REPORT_DIR/firewall.txt" 2>&1
echo "Creating archive..."tar czf "$REPORT_DIR.tar.gz" -C /tmp "$(basename $REPORT_DIR)"
echo "Debug report: $REPORT_DIR.tar.gz"Next Steps
Section titled “Next Steps”- Log Analysis - Understanding log formats
- Common Issues - Frequent problems
- Performance - Performance debugging