Initial commit
This commit is contained in:
commit
c7be517e34
|
@ -0,0 +1,17 @@
|
||||||
|
# Build dpinger from Github
|
||||||
|
FROM alpine:latest AS build
|
||||||
|
|
||||||
|
RUN apk --no-cache add clang gcc git libc-dev make && \
|
||||||
|
cd tmp && \
|
||||||
|
git clone --depth 1 https://github.com/dennypage/dpinger.git && \
|
||||||
|
cd dpinger && \
|
||||||
|
make all
|
||||||
|
|
||||||
|
# Build final Docker image
|
||||||
|
FROM alpine:latest
|
||||||
|
|
||||||
|
RUN apk --no-cache add curl
|
||||||
|
COPY --from=build /tmp/dpinger/dpinger /usr/local/bin/
|
||||||
|
COPY ntfy.sh /usr/local/bin/
|
||||||
|
|
||||||
|
ENTRYPOINT ["/usr/local/bin/dpinger","-f", "-C", "/usr/local/bin/ntfy.sh"]
|
|
@ -0,0 +1,3 @@
|
||||||
|
# dpinger-container
|
||||||
|
|
||||||
|
Docker image for [dpinger](https://github.com/dennypage/dpinger) with [ntfy.sh](https://ntfy.sh) integration. The image is based off of `alpine:latest`.
|
|
@ -0,0 +1,18 @@
|
||||||
|
version: "3.7"
|
||||||
|
|
||||||
|
services:
|
||||||
|
dpinger-container:
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
image: local/dpinger-container:latest
|
||||||
|
command: -i <optional-identifier> -L 15 -D 80 <ip-address>
|
||||||
|
restart: unless-stopped
|
||||||
|
environment:
|
||||||
|
- NTFY_URL=https://ntfy.sh/test
|
||||||
|
|
||||||
|
# This is only needed if your Docker setup needs to go through a VPN to reach the Internet
|
||||||
|
networks:
|
||||||
|
default:
|
||||||
|
driver: bridge
|
||||||
|
driver_opts:
|
||||||
|
com.docker.network.driver.mtu: 1420
|
|
@ -0,0 +1,28 @@
|
||||||
|
#!/bin/ash
|
||||||
|
|
||||||
|
# Input data
|
||||||
|
ID="$1"
|
||||||
|
[[ "$6" ]] && shift
|
||||||
|
IP="$1"
|
||||||
|
ALERT=$2
|
||||||
|
LAT=$3
|
||||||
|
LAT=$((LAT/1000))
|
||||||
|
#DEV=$4
|
||||||
|
LOSS=$5
|
||||||
|
|
||||||
|
# Set notification content
|
||||||
|
if [[ $ALERT -eq 0 ]]; then
|
||||||
|
EMOJI="green_circle"
|
||||||
|
MESSAGE=$(printf "Link returned to nominal condition.\nPacket loss: %i%%\nLatency: %ims\n" $LOSS $LAT)
|
||||||
|
elif [[ $LOSS -lt 100 ]]; then
|
||||||
|
EMOJI="orange_circle"
|
||||||
|
MESSAGE=$(printf "Link is experiencing packet loss or high latency.\nPacket loss: %i%%\nLatency: %ims\n" $LOSS $LAT)
|
||||||
|
else
|
||||||
|
EMOJI="red_circle"
|
||||||
|
MESSAGE=$(printf "Link is down.\n")
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Send notification
|
||||||
|
if [[ "$NTFY_URL" ]]; then
|
||||||
|
curl -fsS -m 10 --retry 5 -q -H "title: $ID" -H "tags: $EMOJI" -d "$MESSAGE" -o /dev/null "$NTFY_URL"
|
||||||
|
fi
|
Loading…
Reference in New Issue