Skip to content

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.

License Monitor operates in one of four modes:

  1. Command Mode: Executes license manager commands periodically
  2. Tail Mode: Monitors log files in real-time
  3. API Mode: Runs only the web API server
  4. Both Mode: Combines command and tail modes with integrated API server

Command mode executes license manager commands periodically and processes their output using Python parsing scripts.

  • Periodic Execution: Configurable intervals for command execution
  • Python Integration: Support for both legacy parse.py and advanced enhanced_parse.py scripts
  • API Server: Automatically includes API server for remote command execution
  • OpenTelemetry: Comprehensive metrics and logging integration
  • Error Handling: Robust error handling and retry logic
[command_mode]
command = "lmstat -a"
interval_seconds = 300 # 5 minutes
python_script = "parse.py" # Optional
working_directory = "/opt/license_manager"
environment = {
"LM_LICENSE_FILE" = "/opt/licenses/license.dat"
}
Terminal window
# 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 60

Command mode supports custom Python scripts for parsing command output:

# parse.py example
def 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 monitors license manager log files in real-time using file system notifications.

  • 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
[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
encoding = "utf-8"
follow_rotation = true
Terminal window
# 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 50
Terminal window
# 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 runs only the web API server for remote command execution and system monitoring.

  • 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
[api]
enabled = true
bind_address = "127.0.0.1"
bind_port = 8080
allow_public_bind = false
enable_websockets = true
max_connections = 100
cors_origins = [
"http://localhost:3000",
"https://your-domain.com"
]
rate_limit_requests = 60
rate_limit_window_seconds = 60
Terminal window
# 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 3000

When running in API mode, the following endpoints are available:

  • GET /api/health - Health check
  • GET /api/server-info - Server information
  • POST /api/execute - Execute commands
  • GET /api/metrics - Performance metrics
  • WS /ws/logs - WebSocket log streaming
  • GET /stream/logs - Server-Sent Events log streaming

Both mode runs command and tail modes simultaneously with an integrated API server.

  • 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
[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 = true
bind_address = "127.0.0.1"
bind_port = 8080
enable_websockets = true
Terminal window
# 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 ".*"
  • 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
  • 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
  • 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
  • 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
Terminal window
-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 modes
Terminal window
--api-host <HOST> # API server bind address (default: 127.0.0.1)
--api-port <PORT> # API server bind port (default: 8080)
Terminal window
-e, --execute <COMMAND> # Command to execute (overrides config file)
-i, --interval <SECONDS> # Interval in seconds between command executions
Terminal window
-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 entries
  • 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
  • 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
  • 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