Skip to content

samthegent/bash-projects

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Bash Automation & Log Management Toolkit

This repository contains a collection of production-ready Bash scripts designed to automate log management, system monitoring, and diagnostic analysis. These projects represent my transition into DevOps engineering, focusing on shell scripting best practices, error handling, and system observability.

Key Technical Features

Across these projects, I have implemented several industry-standard scripting techniques:

Defensive Programming: Used set -euo pipefail to ensure scripts exit immediately on errors or undefined variables.

Robust File Handling: Utilized shopt -s nullglob to prevent globbing errors in empty directories.

Modular Design: Implemented reusable functions and conditional logic for system health checks.

Exit Codes: Standardized exit codes (0, 1, 2) to allow for integration with CI/CD pipelines or cron jobs.

Project Overview

1. Automated Log Backup Utility (log_backup.sh)

An automated solution for log rotation and archiving. It scans a source directory for .log files and moves them to a timestamped backup location.

Features: Verification of directory existence, timestamped file versioning, and internal logging of backup activities.

Use Case: Preventing disk space issues by archiving old application logs.

2. Smart Log Analyzer (smart_log_analyzer.sh)

A multi-file scanning tool that provides a high-level overview of log health across entire directories.

Features: Iterates through all .log files and provides a summary count of ERROR and WARNING patterns per file.

Use Case: Quick morning checks across multiple microservice logs.

3. Deep Log Summarizer (log_summary.sh)

Focused on deep-dive analysis of a specific application log.

Features: Calculates total line counts, identifies unique error messages using sort | uniq, and separates total vs. unique occurrences.

Use Case: Troubleshooting recurring bugs and identifying specific error spikes.

4. DevOps System Monitor (devops_monitor.sh)

A monitoring script that evaluates log health and returns a system status based on threshold logic.

Features: Implements a "Health Check" logic.

Healthy: Minimal warnings/errors.

Warning: Exceeds 3 warnings.

Critical: Any CRITICAL pattern found or >2 errors.

Use Case: Can be used as a custom health check for a monitoring agent.

5. Ultimate Log & IP Analyzer (ultimate_analyzer.sh)

My most advanced script in the collection, combining pattern analysis with network forensics.

Features: Uses awk to extract IP addresses from error logs and identify the top offending source.

Use Case: Identifying potential security threats (brute force) or faulty client-side integrations.

Usage

Clone the repository:

git clone https://github.com/samthegent/bash-projects.git
cd bash-projects
Grant execution permissions:

Bash
chmod +x *.sh
Run a script:

Bash
./ultimate_analyzer.sh /var/log/nginx/access.log 

📈 Learning Outcomes

Through these projects, I strengthened my expertise in:

Stream Editors: Using grep, awk, and sed for data extraction.

Positional Parameters: Handling CLI arguments and default values ${1:-}.

Automation: Writing scripts that can be easily scheduled via crontab.

Looking to connect? Feel free to check out my other repositories or reach out on linkedin.com/in/oladimejiolalekan

About

A repository of Bash automation scripts designed to solve real-world infrastructure challenges. Includes tools for smart log analysis, automated backups, and system status monitoring, demonstrating my transition into Linux automation and DevOps engineering.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages