Skip to content

Ramtinboreili/monitoring-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

56 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A lightweight and extensible Bash script to analyze basic server performance statistics. Ideal for debugging, monitoring, or tracking system health over time. Second version of this project sets up a simple monitoring stack using Prometheus, Node Exporter, and Grafana using Docker Compose — with custom ports to avoid conflict with existing services like Outline.


📊 What It Does

The script server-stats.sh provides the following information:

  • ✅ Total CPU usage
  • ✅ Memory usage (used, free, percentage)
  • ✅ Disk usage (used, free, percentage)
  • ✅ Top 5 processes by CPU
  • ✅ Top 5 processes by Memory
  • ✅ System info (uptime, OS version, load average, logged-in users)
  • ✅ Failed SSH login attempts
  • ✅ Daily logs saved with timestamp
  • ✅ Automatic Git commit and push of logs

🛠️ Setup

  1. Clone the repository:
git clone https://github.com/Ramtinboreili/monitoring-server.git
cd monitoring-server
  1. Make the script executable:
chmod +x server-stats.sh
  1. Create logs/ directory (optional, auto-created on run):
mkdir -p logs

🧪 Run the script manually

./server-stats.sh

This will:

  • 🎨 Print all stats with colors to terminal
  • 📝 Save a daily log to logs/YYYY-MM-DD.log
  • 🔄 Automatically commit and push the log file to GitHub (branch: main)

🕙 Schedule with Cron (Run daily at 10 PM)

To automate daily reporting:

  1. Open your crontab:
crontab -e
  1. Add this line at the bottom:
0 22 * * * /bin/bash /full/path/to/monitoring-server/server-stats.sh

✅ Replace /full/path/to/... with the absolute path to your script.


📦 Sample Output

Log files are saved in the logs/ folder like this:

logs/
├── 2025-03-28.log
├── 2025-03-29.log
└── ...

Each log contains stats like:

===== CPU Usage =====
CPU Usage: 15.2%

===== Memory Usage =====
Used: 1048MB | Free: 512MB | Usage: 67.18%

...

📊 Simple Monitoring Stack with Docker Compose

🧰 Components

  • Prometheus (metrics collection) - exposed on 19090
  • Node Exporter (host metrics)
  • Grafana (visualization) - exposed on 13000

🚀 How to Run

git clone https://github.com/your-username/monitoring-project.git
cd monitoring-project
docker compose up -d

🔐 Notes

  • Requires Bash and standard Linux tools: top, ps, df, free, lsb_release, uptime, etc.
  • Make sure your Git repo is initialized and connected to a remote (origin).
  • You should have SSH keys or GitHub token-based authentication set up for push to work without password prompts.

🙌 Author

Ramtin Boreili
GitHub: @Ramtinboreili


🔥 If you'd like to improve this further (e.g. generate HTML/JSON reports, email daily summaries, or build a dashboard), just open an issue or fork the repo!

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages