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