commit 78f788db6f2c47b1f9f384988f56bb6c8d86e84f Author: Michael Scalzetti Date: Tue Jul 26 22:16:09 2022 -0400 all the shit diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..3d16317 --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,23 @@ +version: '3' + +services: + downdetector: + image: debian + container_name: down_detector + + volumes: + - ./:/dd + + #entrypoint: ls -la /dd/scripts/file_uptime.sh + entrypoint: /dd/scripts/loop.sh /dd/logs /dd/conf/ips.txt + restart: always + + caddy: + image: caddy + container_name: downdetector_caddy + ports: + - "80:80" + volumes: + - "./logs:/srv/logs" + command: "caddy file-server --browse /srv/logs" + diff --git a/scripts/file_uptime.sh b/scripts/file_uptime.sh new file mode 100755 index 0000000..228711f --- /dev/null +++ b/scripts/file_uptime.sh @@ -0,0 +1,19 @@ +#! /bin/bash +FILE="dd/conf/ips.txt" +OUTDIR="dd/logs" +#FILE=$IPFILE +#OUTDIR=$LOGSDIR + + +while read LINE; +do + IP=$(echo $LINE | cut -d" " -f1) + NAME=$(echo $LINE | cut -d" " -f2) + + echo "Name=$NAME, IP=$IP" + + ping $IP -c 1 > /dev/null || echo "$(date +"%D - %H:%M:%S"): $NAME down" >> $OUTDIR/$NAME + +done < "$FILE" + + diff --git a/scripts/loop.sh b/scripts/loop.sh new file mode 100755 index 0000000..cd08b69 --- /dev/null +++ b/scripts/loop.sh @@ -0,0 +1,17 @@ +#! /bin/bash + +WAITTIME=60 + +chmod +x /dd/scripts/* +apt-get update && apt-get install -y iputils-ping +mkdir -p /dd/logs + +while true; +do + /dd/scripts/file_uptime.sh || exit 404 + + echo "" + echo "Waiting $WAITTIME seconds" + + sleep $WAITTIME +done; diff --git a/scripts/uptime.sh b/scripts/uptime.sh new file mode 100755 index 0000000..006527d --- /dev/null +++ b/scripts/uptime.sh @@ -0,0 +1,3 @@ +#! /bin/bash + +ping $1 -c 1 > /dev/null || echo "$(date +"%D - %H:%M:%S"): $2 down" >> $2