Skip to content

PuneethM-06/linux-sysmonitor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

92 Commits
Β 
Β 
Β 
Β 

Repository files navigation

Linux SysMonitor

A Bash-based Linux monitoring and log analysis tool designed to monitor system health, generate structured logs, and provide powerful log analysis capabilities.

Built as a hands-on DevOps learning project covering Linux administration, Bash scripting, troubleshooting, automation, and log management.


Table of Contents


Overview

Linux SysMonitor performs automated health checks on a Linux system and stores results in structured log files.

The accompanying analysis tool enables engineers to:

  • Review health check results
  • Filter logs by severity
  • Identify recurring issues
  • Generate summaries
  • Perform time-based log analysis

This project was built to strengthen practical Linux and DevOps skills through real-world scripting and troubleshooting.


Features

Health Monitoring

  • CPU Usage Monitoring
  • Memory Usage Monitoring
  • Disk Usage Monitoring
  • SSH Service Health Check
  • Cron Service Health Check
  • Network Connectivity Validation
  • Open Port Inspection
  • Recent System Log Collection
  • Load Average Monitoring
  • System Uptime Monitoring

Log Analysis

  • Summary Reports
  • Severity-Based Filtering
  • Top Recurring Issues
  • Time-Based Filtering
  • Custom Log File Support
  • Colored Terminal Output
  • Input Validation
  • Graceful Error Handling

Architecture

+-------------------+
| health-check.sh   |
+-------------------+
          |
          v
+-------------------+
| Structured Logs   |
| logs/*.log        |
+-------------------+
          |
          v
+-------------------+
| analyse.sh        |
+-------------------+
          |
   +------+------+------+
   |             |      |
   v             v      v
Summary      Filtering  Top Issues

Project Structure

linux-sysmonitor/
β”œβ”€β”€ health-check.sh
β”œβ”€β”€ analyse.sh
β”œβ”€β”€ logs/
β”‚   └── *.log
β”œβ”€β”€ sample-output/
β”‚   β”œβ”€β”€ sample-log.log
β”‚   β”œβ”€β”€ summary.txt
β”‚   β”œβ”€β”€ top-issues.txt
β”‚   β”œβ”€β”€ critical.txt
β”‚   └── since.txt
β”œβ”€β”€ README.md
└── .gitignore

Installation

Clone the Repository

git clone https://github.com/<your-username>/linux-sysmonitor.git
cd linux-sysmonitor

Make Scripts Executable

chmod +x health-check.sh
chmod +x analyse.sh

🚦 Usage

Run a Full Health Check

./health-check.sh

This generates a timestamped log file under:

logs/

Example:

logs/2026-06-23-05-06.log

Log Format

Generated logs follow the structure:

YYYY-MM-DD HH:MM:SS | LEVEL | MESSAGE

Example:

2026-06-23 05:06:37 | INFO | CPU usage is 10% β€” healthy
2026-06-23 05:06:37 | WARNING | cron is not running
2026-06-23 05:06:37 | CRITICAL | Disk usage is 96%

Log Analysis

Generate Summary Report

./analyse.sh --summary

Example Output:

=================================
Log Summary
=================================
Total Entries: 11
INFO: 9
WARNING: 1
CRITICAL: 1
=================================

Filter Logs by Severity

INFO Logs

./analyse.sh --level INFO

WARNING Logs

./analyse.sh --level WARNING

CRITICAL Logs

./analyse.sh --level CRITICAL

Find Top Recurring Issues

Display the most frequent log entries:

./analyse.sh --top 5

Example:

4 CPU usage is 10% β€” healthy
3 Memory usage is 28% β€” healthy
2 cron is not running

Time-Based Filtering

Display entries after a specific time:

./analyse.sh --since 10:30

Example:

./analyse.sh --since 14:00

Analyse a Specific Log File

./analyse.sh --file logs/sample.log --summary

Validation & Error Handling

Linux SysMonitor includes validation for:

  • Missing arguments
  • Invalid flags
  • Invalid log levels
  • Missing log files
  • Missing logs directory
  • Empty logs directory
  • Invalid user input

Invalid Level

./analyse.sh --level TEST

Output:

Error: Invalid level. Use INFO, WARNING, or CRITICAL

Missing File

./analyse.sh --file missing.log

Output:

Error: File not found: missing.log

Missing Logs Directory

Error: logs directory does not exist

Empty Logs Directory

Error: No log files found

πŸ“Έ Sample Outputs

Store generated examples under:

sample-output/

Suggested files:

sample-output/
β”œβ”€β”€ sample-log.log
β”œβ”€β”€ summary.txt
β”œβ”€β”€ top-issues.txt
β”œβ”€β”€ critical.txt
β”œβ”€β”€ since.txt
β”œβ”€β”€ health-check.png
└── analysis-summary.png

Example screenshots:

sample-output/health-check.png
sample-output/analysis-summary.png

Validation Commands

Generate a new log file:

./health-check.sh

Generate a summary:

./analyse.sh --summary

Display warning entries:

./analyse.sh --level WARNING

Display top recurring issues:

./analyse.sh --top 5

Display entries after a specific time:

./analyse.sh --since 12:00

Troubleshooting

Permission Denied

chmod +x health-check.sh
chmod +x analyse.sh

No Log Files Found

Generate a log first:

./health-check.sh

Missing Logs Directory

mkdir -p logs

Verify Script Quality

Install ShellCheck:

sudo apt update
sudo apt install shellcheck -y

Run analysis:

shellcheck health-check.sh
shellcheck analyse.sh

Technologies Used

Category Tools
Scripting Bash
Monitoring top, free, df
Networking ping, ss
Text Processing awk, grep, sort, uniq
Logging Custom Structured Logs
Version Control Git, GitHub
Quality Checks ShellCheck

What I Learned

Through this project I gained hands-on experience with:

  • Linux Fundamentals
  • Bash Scripting
  • Shell Functions
  • Conditional Logic
  • Argument Parsing
  • Log Management
  • System Monitoring
  • Process Monitoring
  • Network Troubleshooting
  • Text Processing with awk and grep
  • Error Handling
  • Defensive Scripting
  • Git Branching & Pull Requests
  • GitHub Project Management
  • ShellCheck Best Practices

Future Improvements

  • Email Alerts
  • Slack Notifications
  • HTML Report Generation
  • Systemd Service Integration
  • Cron-Based Scheduling
  • Prometheus Metrics Export
  • Grafana Dashboard Integration
  • Docker Packaging
  • Configuration File Support
  • Multi-Server Monitoring

License

This project is intended for learning, experimentation, and portfolio demonstration purposes.


Support

If you found this project useful, consider starring the repository and sharing feedback.

Happy scripting! 🐧

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages