Bash-инструментарий для мониторинга Linux-серверов, бэкапов и начальной настройки. Без зависимостей — только bash и стандартные утилиты.
A collection of Bash scripts for Linux server monitoring, automated backups, and initial server hardening. Zero dependencies beyond standard Linux utilities.
| Script | Description |
|---|---|
sysmon.sh |
Real-time CPU/RAM/disk monitoring with Telegram alerts |
backup.sh |
Automated backups for directories and databases (PostgreSQL, MySQL) |
disk-alert.sh |
Disk usage alerts per partition with configurable threshold and Telegram notifications |
logrotate.sh |
Log rotation by size with gzip compression and age-based cleanup |
netmon.sh |
Network latency and packet loss monitor with Telegram alerts |
healthcheck.sh |
HTTP endpoint health checker with response times and Telegram alerts |
ssl-check.sh |
SSL certificate expiry checker with configurable warning threshold |
server-setup.sh |
Ubuntu server initial setup: UFW, fail2ban, deploy user, SSH hardening, Docker |
git clone https://github.com/qorexdevs/bash-sysmon
cd bash-sysmon
chmod +x *.sh# Show current system status
./sysmon.sh status
# Continuous monitoring (60s interval)
./sysmon.sh watch
# Single check — outputs only if thresholds exceeded
./sysmon.sh check
# Top 10 processes by CPU/RAM
./sysmon.sh top
# Check service status
./sysmon.sh services
# Show listening ports
./sysmon.sh netTelegram alerts:
export TELEGRAM_BOT_TOKEN="your_bot_token"
export TELEGRAM_CHAT_ID="your_chat_id"
./sysmon.sh watchCron (every 5 minutes):
echo '*/5 * * * * CPU_THRESHOLD=80 /path/to/sysmon.sh check' | crontab -Custom thresholds:
CPU_THRESHOLD=70 RAM_THRESHOLD=85 DISK_THRESHOLD=80 ./sysmon.sh watch# Backup a directory
./backup.sh dir /var/www/html mysite
# Backup PostgreSQL database
PGPASSWORD=secret ./backup.sh postgres mydb
# Backup MySQL database
MYSQL_PASSWORD=secret ./backup.sh mysql mydb
# Clean up backups older than 7 days
RETENTION_DAYS=7 ./backup.sh cleanupDaily cron:
0 3 * * * BACKUP_DIR=/backups PGPASSWORD=pass /path/to/backup.sh postgres mydb
0 4 * * * BACKUP_DIR=/backups /path/to/backup.sh cleanup# Check all partitions (default threshold: 80%)
./disk-alert.sh
# Custom threshold
./disk-alert.sh --threshold 90
# Only check root partition
./disk-alert.sh --mount /
# Preview mode — shows what would alert without sending notifications
./disk-alert.sh --dry-run
# Combine options
./disk-alert.sh --threshold 75 --mount /home --dry-runHourly cron with Telegram:
0 * * * * TELEGRAM_BOT_TOKEN=xxx TELEGRAM_CHAT_ID=yyy /path/to/disk-alert.sh --threshold 85# Check current log sizes
./logrotate.sh status
# Rotate logs bigger than 10M (default)
./logrotate.sh rotate
# Remove rotated logs older than 30 days
./logrotate.sh clean
# Both rotate + clean in one go
./logrotate.sh all
# Preview what would happen without changing anything
DRY_RUN=true ./logrotate.sh all
# Custom size threshold and retention
MAX_SIZE=5M MAX_FILES=3 ./logrotate.sh rotate
# Use with any log directory
LOG_DIR=/var/log/myapp ./logrotate.sh rotateDaily cron:
0 2 * * * /path/to/logrotate.sh all# Check latency and packet loss for default targets (8.8.8.8, 1.1.1.1, google.com)
./netmon.sh
# 10 pings per target
./netmon.sh -c 10
# Custom targets and loss threshold
./netmon.sh --targets "8.8.8.8 cloudflare.com" --loss 10
# Set latency alert threshold (ms)
./netmon.sh --latency 100Telegram alerts:
export TELEGRAM_BOT_TOKEN="your_bot_token"
export TELEGRAM_CHAT_ID="your_chat_id"
./netmon.shCron (every 10 minutes):
*/10 * * * * TELEGRAM_BOT_TOKEN=xxx TELEGRAM_CHAT_ID=yyy /path/to/netmon.shChecks HTTP endpoints from a config file and reports status + response time. Exits with code 1 if any service is down.
# Check endpoints from config file
./healthcheck.sh healthcheck.conf
# Custom timeout (default: 5s)
TIMEOUT=10 ./healthcheck.sh healthcheck.conf
# With Telegram alerts
TELEGRAM_BOT_TOKEN=xxx TELEGRAM_CHAT_ID=yyy ./healthcheck.sh healthcheck.confConfig file format (healthcheck.conf):
# name url [timeout]
google https://www.google.com
my-api https://api.example.com 10
Cron (every 2 minutes):
*/2 * * * * TELEGRAM_BOT_TOKEN=xxx TELEGRAM_CHAT_ID=yyy /path/to/healthcheck.sh /path/to/healthcheck.conf# Check one or more domains
./ssl-check.sh example.com google.com
# Read domains from a file
./ssl-check.sh --file domains.txt
# Custom warning threshold (default: 30 days)
./ssl-check.sh --warn-days 14 example.com
# Preview without Telegram alerts
./ssl-check.sh --dry-run example.comDaily cron:
0 8 * * * TELEGRAM_BOT_TOKEN=xxx TELEGRAM_CHAT_ID=yyy /path/to/ssl-check.sh --file /path/to/domains.txt# Full setup (run on a fresh Ubuntu 22.04/24.04 server)
sudo DEPLOY_USER=app TIMEZONE=Europe/Moscow ./server-setup.sh all
# Individual steps
sudo ./server-setup.sh update # Update packages
sudo ./server-setup.sh ufw # Configure firewall
sudo ./server-setup.sh docker # Install Docker
sudo ./server-setup.sh swap 4096 # Create 4GB swapScripts read environment variables or an optional config file at ~/.config/sysmon/config:
# ~/.config/sysmon/config
CPU_THRESHOLD=80
RAM_THRESHOLD=85
DISK_THRESHOLD=85
TELEGRAM_BOT_TOKEN=xxxxx
TELEGRAM_CHAT_ID=yyyyy
CHECK_INTERVAL=300- Linux (tested on Ubuntu 20.04/22.04/24.04, Debian 11/12, CentOS 7/8)
- bash 4.0+
- Standard utilities:
awk,sed,df,ps,ss,ping curl— for Telegram alerts (optional)pg_dump— for PostgreSQL backups (optional)mysqldump— for MySQL backups (optional)systemctl— for service checks and server-setup.sh