Log Analyzer
Advanced log analysis and reporting tool for system logs with pattern matching and summary generation.
Resource Manager and Log Analyzer Tools
Overview
This package provides two powerful system administration tools:
- Resource Manager (
resource-manager.sh
): Monitors and manages system resources - Log Analyzer (
log-analyzer.sh
): Analyzes and processes system logs
Features
Resource Manager
- Real-time resource monitoring (CPU, Memory, Disk)
- Resource usage limits and quotas
- Service-specific resource optimization
- HTML report generation
- Cross-platform support (Linux and macOS)
Log Analyzer
- Real-time log monitoring
- Pattern-based log analysis
- Service-specific log filtering
- Log summary generation
- Multiple report formats
- Cross-platform support (Linux and macOS)
Installation
- Clone the repository:
git clone https://github.com/yourusername/admin-tools.git cd admin-tools/resource-log-tools
- Make scripts executable:
chmod +x resource-manager.sh log-analyzer.sh
- Install dependencies:
# For Debian/Ubuntu sudo apt-get install sysstat net-tools # For RHEL/CentOS sudo yum install sysstat net-tools # For macOS brew install sysstat net-tools
- Download the script from the Lambda Softworks Customer Portal:
- Log in to your Lambda Softworks Customer Portal account
- Navigate to the Files section
- Download the log-analyzer.sh script
Usage
Resource Manager
# Show current resource usage ./resource-manager.sh --status # Set resource limits ./resource-manager.sh --limit-cpu 80 --limit-memory 90 # Generate daily report ./resource-manager.sh --report daily # Optimize specific services ./resource-manager.sh --optimize --target-services mysql,nginx
Log Analyzer
# Monitor logs in real-time ./log-analyzer.sh --follow /var/log/syslog # Generate log summary for last 24 hours ./log-analyzer.sh --summary --last 24h # Search for errors in specific services ./log-analyzer.sh --pattern "error|failed" --services nginx,mysql
Configuration
Both scripts use YAML configuration files located in:
- Linux:
/etc/admin-tools/
- macOS:
~/Library/Application Support/admin-tools/
Example configuration:
# resource-manager-config.yml limits: cpu: 80 memory: 90 disk: 85 services: - name: mysql limits: cpu: 60 memory: 70 - name: nginx limits: cpu: 40 memory: 50 # log-analyzer-config.yml patterns: error: "error|failed|critical" warning: "warning|warn" info: "info" services: - name: nginx log_file: "/var/log/nginx/error.log" - name: mysql log_file: "/var/log/mysql/error.log"
Logs
Log files are stored in:
- Linux:
/var/log/admin-tools/
- macOS:
~/Library/Logs/admin-tools/
Cross-Platform Compatibility
Both scripts are designed to work on:
- Linux distributions (RHEL, CentOS, Fedora, Ubuntu, Debian)
- macOS (10.15 and later)
Platform-specific features are automatically detected and appropriate commands are used.
Examples
Resource Management
- Monitor and limit resource usage:
# Set limits and monitor ./resource-manager.sh --limit-cpu 80 --limit-memory 90 --status
- Generate weekly report:
./resource-manager.sh --report weekly
- Optimize web server resources:
./resource-manager.sh --optimize --target-services nginx,php-fpm
Log Analysis
- Monitor application errors:
./log-analyzer.sh --follow /var/log/application.log --pattern "error|failed"
- Generate daily summary:
./log-analyzer.sh --summary --last 24h
- Analyze specific service logs:
./log-analyzer.sh --services mysql,redis --pattern "error|warning"
Troubleshooting
Resource Manager
Resource limits not applying
- Check if running with sufficient privileges
- Verify cgroups support on Linux
- Check service status
Incorrect resource usage
- Verify system monitoring tools are installed
- Check for conflicting monitoring tools
- Review system logs
Log Analyzer
Log file access issues
- Check file permissions
- Verify log file paths
- Ensure sufficient disk space
Pattern matching problems
- Verify regex syntax
- Check log file format
- Review pattern configuration
Common Issues
Permission Errors
- Ensure the script is run with sudo
- Check directory permissions
- Verify user has necessary privileges
Log Access Issues
- Verify log file permissions
- Check log rotation settings
- Review systemd journal settings
Report Generation Issues
- Check log directory permissions
- Verify HTML template access
- Check disk space
Debug Mode
To enable debug logging:
sudo DEBUG=1 ./log-analyzer.sh [OPTIONS]