Moorreee Doku

This commit is contained in:
2025-11-10 13:47:48 +00:00
parent b86924a550
commit 44ce0b9563
2 changed files with 10 additions and 2 deletions

View File

@@ -1,6 +1,5 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# Webhost Availability Monitor - Single File - Loop
# user only. keine root.
set -o errexit set -o errexit
set -o nounset set -o nounset
@@ -8,23 +7,28 @@ set -o pipefail
INTERVAL=60 INTERVAL=60
# Das dateisystem initialisieren und Prüfen
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
LOG_DIR="$ROOT_DIR/logs" LOG_DIR="$ROOT_DIR/logs"
HOSTS_FILE="$ROOT_DIR/hosts.txt" HOSTS_FILE="$ROOT_DIR/hosts.txt"
SEP=';' SEP=';'
# Zeit init
timestamp_iso() { timestamp_iso() {
date -Iseconds date -Iseconds
} }
# Erstelle Ordner
ensure_dirs() { ensure_dirs() {
mkdir -p "$LOG_DIR" mkdir -p "$LOG_DIR"
} }
# erstelle und Open log(csv) file
current_logfile() { current_logfile() {
printf "%s/%s.csv" "$LOG_DIR" "$(date +%F)" printf "%s/%s.csv" "$LOG_DIR" "$(date +%F)"
} }
# füge Header in log(CSV) hinzu
write_header_if_needed() { write_header_if_needed() {
local file="$1" local file="$1"
if [ ! -f "$file" ] || [ ! -s "$file" ]; then if [ ! -f "$file" ] || [ ! -s "$file" ]; then
@@ -32,6 +36,7 @@ write_header_if_needed() {
fi fi
} }
# Stop für Script
stop_requested=0 stop_requested=0
_on_exit() { _on_exit() {
stop_requested=1 stop_requested=1
@@ -43,10 +48,13 @@ ensure_dirs
printf "loop start. 60s. logs dir: %s\n" "$LOG_DIR" printf "loop start. 60s. logs dir: %s\n" "$LOG_DIR"
# Loop
#Überprüfen ob noch laufen soll
while [ "$stop_requested" -eq 0 ]; do while [ "$stop_requested" -eq 0 ]; do
logfile="$(current_logfile)" logfile="$(current_logfile)"
write_header_if_needed "$logfile" write_header_if_needed "$logfile"
# Statuse alle domains überprüfen und in CSV packen
while IFS= read -r line; do while IFS= read -r line; do
[ -z "$line" ] && continue [ -z "$line" ] && continue
case "$line" in \#*) continue ;; esac case "$line" in \#*) continue ;; esac