How gautam-cpp/log-monitor works
Main Components
• Orchestrator: The main script (log_monitor.sh) that coordinates the entire monitoring process.
• Configuration Module: modules/config_handler.sh that loads and parses the configuration file (located in /etc/log-monitor/config.conf or its example in the config folder).
• Log Parser: modules/log_parser.sh responsible for acquiring log data, filtering through events using pattern matching, and extracting relevant entries.
• Alert Manager: modules/alert_manager.sh which handles the generation and dispatching of email alerts.
• Utilities: modules/utils.sh which comprises helper functions used across the system.
• External Dependencies/Environments: The email utilities (mailutils, sendmail) and standard Linux utilities (grep, awk, sed) that the scripts rely upon.
• Testing: The test directory contains relevant automated scripts to validate the internal modules.
Relationships and Interactions
• The orchestrator (log_monitor.sh) acts as the entry point; it triggers the configuration loading first.
• Once configuration is loaded, it passes necessary parameters to the log parser which scans the specified log sources.
• Any identified critical log events are passed to the alert manager, which formats and sends out email notifications.
• Utility functions are employed anywhere within these modules for common operations.
• The configuration file itself is a key external component that informs the behavior of these modules.
• Testing scripts interact with each module to verify functionality and error handling.
Architectural Patterns and Design Principles
• Modularity: High cohesion is maintained within each module with low coupling between them, making the system easier to maintain and extend.
• Command-Line Based: The project is designed to be run manually or via scheduled execution (cron jobs) for periodic log monitoring.
• Configuration-Driven: The use of external configuration files allows flexibility in setting log sources, patterns, and alert parameters.
• Test-Driven: A clear test directory indicates that unit testing is a part of the development process.
Relevant Technologies and Frameworks
• Bash scripting (Bash 4.0+ is required).
• Linux utilities (grep, awk, sed) for log processing.
• Mail utilities (mailutils, sendmail) for notification processing.
• Cron (for scheduled execution).