Operating Modes
Operating Modes
Section titled “Operating Modes”License Monitor supports four distinct operational modes, each optimized for different use cases and deployment scenarios. Understanding these modes is crucial for effective deployment and configuration.
Mode Overview
Section titled “Mode Overview”License Monitor operates in one of four modes:
- Command Mode: Executes license manager commands periodically
- Tail Mode: Monitors log files in real-time
- API Mode: Runs only the web API server
- Both Mode: Combines command and tail modes with integrated API server
Command Mode
Section titled “Command Mode”Command mode executes license manager commands periodically and processes their output using Python parsing scripts.
Features
Section titled “Features”- Periodic Execution: Configurable intervals for command execution
- Python Integration: Support for both legacy
parse.pyand advancedenhanced_parse.pyscripts - API Server: Automatically includes API server for remote command execution
- OpenTelemetry: Comprehensive metrics and logging integration
- Error Handling: Robust error handling and retry logic
Configuration
Section titled “Configuration”[command_mode]command = "lmstat -a"interval_seconds = 300 # 5 minutespython_script = "parse.py" # Optionalworking_directory = "/opt/license_manager"environment = { "LM_LICENSE_FILE" = "/opt/licenses/license.dat"}Usage Examples
Section titled “Usage Examples”# Basic command mode with API server./license_monitor --mode command --execute "lmstat -a" --interval 300
# Command mode without API server./license_monitor --mode command --execute "lmstat -a" --interval 300 --no-api
# Custom Python script./license_monitor --mode command --execute "lmutil lmstat -a" --interval 60Python Script Integration
Section titled “Python Script Integration”Command mode supports custom Python scripts for parsing command output:
# parse.py exampledef parse_command_output(output: str) -> str: """ Parse license manager command output into standardized JSON format """ try: lines = output.strip().split('\n') result = { "total_lines": len(lines), "parsed_data": [], "timestamp": datetime.now().isoformat() }
for line in lines: if "Users of" in line: result["parsed_data"].append({ "type": "usage", "data": line.strip() })
return json.dumps(result) except Exception as e: return json.dumps({"error": str(e)})Tail Mode
Section titled “Tail Mode”Tail mode monitors license manager log files in real-time using file system notifications.
Features
Section titled “Features”- Real-time Monitoring: Live log file monitoring using file system notifications
- Regex Parsing: Configurable regex patterns for log entry parsing
- Batch Processing: Configurable batch processing for log entries
- File Rotation: Automatic handling of log file rotation
- OpenTelemetry: Log data export to OpenTelemetry
Configuration
Section titled “Configuration”[tail_mode]log_file = "/var/log/lmstat.log"regex_pattern = "^(\\d{4}-\\d{2}-\\d{2}\\s\\d{2}:\\d{2}:\\d{2})\\s+(\\w+)\\s+(.*)$"batch_size = 10encoding = "utf-8"follow_rotation = trueUsage Examples
Section titled “Usage Examples”# Basic tail mode./license_monitor --mode tail --file "/var/log/lmstat.log" --regex "^(\\d{4}-\\d{2}-\\d{2}\\s\\d{2}:\\d{2}:\\d{2})\\s+(\\w+)\\s+(.*)$"
# Custom batch size./license_monitor --mode tail --file "/var/log/lmstat.log" --regex ".*" --batch-size 50Regex Pattern Examples
Section titled “Regex Pattern Examples”# FlexLM log pattern"^(\\d{4}-\\d{2}-\\d{2}\\s\\d{2}:\\d{2}:\\d{2})\\s+(\\w+)\\s+(.*)$"
# RLM log pattern"^(\\d{2}:\\d{2}:\\d{2})\\s+(\\w+)\\s+(.*)$"
# Generic timestamp pattern"^(\\d{4}-\\d{2}-\\d{2}\\s\\d{2}:\\d{2}:\\d{2})\\s+(.*)$"API Mode
Section titled “API Mode”API mode runs only the web API server for remote command execution and system monitoring.
Features
Section titled “Features”- REST API: Comprehensive REST API endpoints
- WebSocket Support: Real-time bidirectional communication
- Server-Sent Events: Unidirectional real-time streaming
- System Monitoring: Server status and performance metrics
- Command Execution: Remote command execution capabilities
Configuration
Section titled “Configuration”[api]enabled = truebind_address = "127.0.0.1"bind_port = 8080allow_public_bind = falseenable_websockets = truemax_connections = 100cors_origins = [ "http://localhost:3000", "https://your-domain.com"]rate_limit_requests = 60rate_limit_window_seconds = 60Usage Examples
Section titled “Usage Examples”# Basic API server./license_monitor --mode api
# Custom bind address and port./license_monitor --mode api --api-host 0.0.0.0 --api-port 8080
# API server with custom configuration./license_monitor --mode api --api-host 127.0.0.1 --api-port 3000API Endpoints
Section titled “API Endpoints”When running in API mode, the following endpoints are available:
GET /api/health- Health checkGET /api/server-info- Server informationPOST /api/execute- Execute commandsGET /api/metrics- Performance metricsWS /ws/logs- WebSocket log streamingGET /stream/logs- Server-Sent Events log streaming
Both Mode
Section titled “Both Mode”Both mode runs command and tail modes simultaneously with an integrated API server.
Features
Section titled “Features”- Concurrent Execution: Simultaneous command execution and log monitoring
- API Server: Integrated API server for remote access
- Coordinated Shutdown: Graceful shutdown coordination between modes
- Comprehensive Monitoring: Complete system monitoring capabilities
- Data Integration: Combined data from both command and tail modes
Configuration
Section titled “Configuration”[command_mode]command = "lmstat -a"interval_seconds = 300
[tail_mode]log_file = "/var/log/lmstat.log"regex_pattern = "^(\\d{4}-\\d{2}-\\d{2}\\s\\d{2}:\\d{2}:\\d{2})\\s+(\\w+)\\s+(.*)$"batch_size = 10
[api]enabled = truebind_address = "127.0.0.1"bind_port = 8080enable_websockets = trueUsage Examples
Section titled “Usage Examples”# Both modes with API server./license_monitor --mode both --execute "lmstat -a" --file "/var/log/lmstat.log"
# Both modes without API server./license_monitor --mode both --execute "lmstat -a" --file "/var/log/lmstat.log" --no-api
# Custom intervals and patterns./license_monitor --mode both --execute "lmutil lmstat -a" --interval 60 --file "/var/log/lmstat.log" --regex ".*"Mode Selection Guide
Section titled “Mode Selection Guide”Choose Command Mode When:
Section titled “Choose Command Mode When:”- You need periodic license status updates
- You want to execute license manager commands on a schedule
- You need Python script integration for data parsing
- You want to monitor license usage patterns over time
Choose Tail Mode When:
Section titled “Choose Tail Mode When:”- You need real-time log monitoring
- You want to capture license events as they happen
- You need to monitor log files for specific patterns
- You want to track license server activity in real-time
Choose API Mode When:
Section titled “Choose API Mode When:”- You only need the web API functionality
- You want to provide remote access to license information
- You need to integrate with external systems
- You want to build custom applications on top of License Monitor
Choose Both Mode When:
Section titled “Choose Both Mode When:”- You need comprehensive monitoring capabilities
- You want both periodic updates and real-time monitoring
- You need the full feature set of License Monitor
- You want to provide a complete monitoring solution
Command Line Options
Section titled “Command Line Options”General Options
Section titled “General Options”-m, --mode <MODE> # Operating mode (command, tail, api, both)-d, --debug # Debug mode - output to stdout-x, --daemon # Run as daemon - redirect output to log file-l, --level <LOG_LEVEL> # Log level (error, warning, info, debug)-c, --config <CONFIG> # Path to config file (default: config.toml)--no-api # Disable API server when running in command or both modesAPI Server Options
Section titled “API Server Options”--api-host <HOST> # API server bind address (default: 127.0.0.1)--api-port <PORT> # API server bind port (default: 8080)Command Mode Options
Section titled “Command Mode Options”-e, --execute <COMMAND> # Command to execute (overrides config file)-i, --interval <SECONDS> # Interval in seconds between command executionsTail Mode Options
Section titled “Tail Mode Options”-f, --file <FILE> # Log file to monitor (overrides config file)-r, --regex <PATTERN> # Regex pattern for parsing log entries-b, --batch-size <SIZE> # Batch size for processing log entriesPerformance Considerations
Section titled “Performance Considerations”Command Mode Performance
Section titled “Command Mode Performance”- Interval Impact: Shorter intervals increase CPU usage
- Command Complexity: Complex commands may take longer to execute
- Python Script Overhead: Custom parsing scripts add processing time
- Memory Usage: Command output is stored in memory
Tail Mode Performance
Section titled “Tail Mode Performance”- File Size: Large log files may impact performance
- Regex Complexity: Complex regex patterns increase CPU usage
- Batch Size: Larger batch sizes improve throughput but increase memory usage
- File Rotation: Frequent rotation may cause temporary performance impact
API Mode Performance
Section titled “API Mode Performance”- Connection Count: More connections increase memory usage
- Request Rate: High request rates may impact performance
- WebSocket Connections: WebSocket connections consume more resources
- Rate Limiting: Rate limiting helps maintain performance
Next Steps
Section titled “Next Steps”- Web API: Complete API documentation
- Configuration: Configuration options and examples
- Self-Update System: Update system documentation
- OpenTelemetry: Observability integration guide