feat: slskd reconnect guard in downloaders_reset, mass v2 sync
- downloaders_reset: connection check block before slskd API sections; triggers PUT /api/v0/server reconnect if disconnected, polls 60s, gates Stuck Searches and Dead Transfer Records on SLSKD_CONNECTED - Sync all modified/new/deleted files from v2 refactor across Docker_Essentials, Media, Monitors, Partnership, Rsync, Tools, Transcodes, unRAID_Essentials, common.sh, master confs, and new Manual/README docs
This commit is contained in:
@@ -1,46 +1,89 @@
|
||||
#!/bin/bash
|
||||
# ==============================================================================================
|
||||
# ================================= Bandwidth Monitor ==========================================
|
||||
# ============================= Bandwidth Monitor ==============================================
|
||||
# ==============================================================================================
|
||||
# Logs rsync transfer history and generates weekly summary reports.
|
||||
# Designed for minimal flash drive impact — one bounded write per rsync run.
|
||||
#
|
||||
# ── TWO MODES ─────────────────────────────────────────────────────────────────────────────────
|
||||
# PURPOSE
|
||||
# ─────────────────────────────────────────────────────────────────────────────
|
||||
# rsync transfer history logging and weekly summary reporting. Log mode is called
|
||||
# automatically by rsync.sh after each sync — no manual scheduling needed for
|
||||
# logging. Report mode scheduled weekly (Sunday 11am).
|
||||
#
|
||||
# --log-transfer "profile" duration_seconds status
|
||||
# Called automatically by rsync.sh after each sync completes.
|
||||
# Appends one line to the log and trims entries older than BANDWIDTH_LOG_RETENTION.
|
||||
# Flags syncs exceeding BANDWIDTH_WARN_GB in the log for weekly report highlighting.
|
||||
# Log mode (--log-transfer): appends one line per sync to BANDWIDTH_LOG, trims
|
||||
# entries older than BANDWIDTH_LOG_RETENTION days. One bounded write per rsync run.
|
||||
#
|
||||
# --report (or no args)
|
||||
# Generates a summary from the accumulated log.
|
||||
# Shows per-profile breakdown, last 7 days, and overall totals.
|
||||
# This is a monitor script — SILENT_MODE=false — output is the point.
|
||||
# Report mode (default): reads the accumulated log and generates a summary —
|
||||
# per-profile breakdown, run count, total transferred, average duration, failures,
|
||||
# last 7 days activity timeline, any transfers or days exceeding BANDWIDTH_WARN_GB.
|
||||
#
|
||||
# ── LOG FORMAT ────────────────────────────────────────────────────────────────────────────────
|
||||
# One line per transfer — version-proof, never needs rsync output parsing:
|
||||
# YYYY-MM-DD|HH:MM|profile|duration_seconds|status|bytes_transferred
|
||||
# ==============================================================================================
|
||||
# DESIGN PRINCIPLES
|
||||
# ==============================================================================================
|
||||
#
|
||||
# Log file stays bounded to BANDWIDTH_LOG_RETENTION days — trimmed on every write.
|
||||
# Minimal flash drive impact: one append + one trim per rsync run.
|
||||
# Version-Proof Log Format
|
||||
# Earlier designs parsed rsync's human-readable output for bytes transferred.
|
||||
# rsync changes its output format between versions — those parsers break silently.
|
||||
# The log line (YYYY-MM-DD|HH:MM|profile|duration|status|bytes) captures bytes
|
||||
# from rsync --stats via awk using version-stable field names. Survives any rsync
|
||||
# update with no changes.
|
||||
#
|
||||
# ── SAFEGUARDS ────────────────────────────────────────────────────────────────────────────────
|
||||
# acquire_lock "wait" — prevents log corruption from concurrent rsync completions
|
||||
# validate_unraid_cmd — notify script validated before use
|
||||
# Atomic log write — temp file + mv prevents partial writes on trim
|
||||
# Log existence check — creates log directory if needed, exits cleanly if unwritable
|
||||
# Minimal Flash Drive Impact
|
||||
# unRAID boots from USB flash. One append + one trim per rsync run. The log file
|
||||
# is bounded to BANDWIDTH_LOG_RETENTION days and never grows unbounded.
|
||||
# Atomic write: tmp file + mv prevents partial writes during trim.
|
||||
#
|
||||
# ── CONFIGURATION (master.conf) ───────────────────────────────────────────────────────────────
|
||||
# BANDWIDTH_LOG — log file path
|
||||
# BANDWIDTH_LOG_RETENTION — days before old entries are purged (default 90)
|
||||
# BANDWIDTH_WARN_GB — flag syncs larger than this in report (default 50)
|
||||
# ==============================================================================================
|
||||
# OPERATIONAL SAFEGUARDS
|
||||
# ==============================================================================================
|
||||
#
|
||||
# Lock With Wait
|
||||
# acquire_lock "wait" — multiple rsync profiles may complete close together.
|
||||
# Waiting (not skipping) prevents log entries from being lost.
|
||||
#
|
||||
# Atomic Log Write
|
||||
# Trim uses tmp file + mv — partial writes on log trim cannot corrupt the log.
|
||||
#
|
||||
# Log Directory Guard
|
||||
# Creates the log directory if it doesn't exist. Exits cleanly if unwritable.
|
||||
#
|
||||
# Notification Validated
|
||||
# validate_unraid_cmd confirms the notify script is present before use.
|
||||
#
|
||||
# ==============================================================================================
|
||||
# CONFIGURATION
|
||||
# ==============================================================================================
|
||||
#
|
||||
# master.conf
|
||||
#
|
||||
# BANDWIDTH_LOG
|
||||
# Log file path. Stored on /boot/ to survive reboots.
|
||||
# (default: /boot/config/bandwidth_history.db)
|
||||
#
|
||||
# BANDWIDTH_LOG_RETENTION
|
||||
# Days before old entries are purged. File stays bounded. (default: 90)
|
||||
#
|
||||
# BANDWIDTH_WARN_GB
|
||||
# Flag transfers or daily totals exceeding this in the report. (default: 50)
|
||||
#
|
||||
# ==============================================================================================
|
||||
# RUNTIME MODES
|
||||
# ==============================================================================================
|
||||
#
|
||||
# bandwidth_monitor.sh
|
||||
# Generate transfer history report from accumulated log.
|
||||
#
|
||||
# bandwidth_monitor.sh --report
|
||||
# Generate report (explicit form).
|
||||
#
|
||||
# bandwidth_monitor.sh --log-transfer profile secs status bytes
|
||||
# Log a completed rsync transfer. Called by rsync.sh — do not call manually.
|
||||
#
|
||||
# bandwidth_monitor.sh --status
|
||||
# Show log path, retention, warn threshold, and log statistics. Then exit.
|
||||
#
|
||||
# bandwidth_monitor.sh --log
|
||||
# Verbose output during report generation.
|
||||
#
|
||||
# ── USAGE ─────────────────────────────────────────────────────────────────────────────────────
|
||||
# bandwidth_monitor.sh — generate report
|
||||
# bandwidth_monitor.sh --report — generate report (explicit)
|
||||
# bandwidth_monitor.sh --log-transfer profile secs ok — log a transfer (called by rsync.sh)
|
||||
# bandwidth_monitor.sh --status — show config and exit
|
||||
# bandwidth_monitor.sh --log — verbose output
|
||||
# ==============================================================================================
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
Reference in New Issue
Block a user