config

Personal configuration.
git clone git://code.dwrz.net/config
Log | Files | Refs

commit 6e57e2edb20177da7dce2961e1f65f0a4b00ba37
parent 8c490351098e0aea547bbf6980677cad71ea55b4
Author: dwrz <dwrz@dwrz.net>
Date:   Sun, 28 May 2023 02:39:39 +0000

Add health check script

Diffstat:
Ascripts/health-check | 26++++++++++++++++++++++++++
1 file changed, 26 insertions(+), 0 deletions(-)

diff --git a/scripts/health-check b/scripts/health-check @@ -0,0 +1,26 @@ +#!/bin/sh + +online() { + if ! ping -c 1 -W 1 8.8.8.8 > /dev/null; then + return 1 + fi + if ! ping -c 1 -W 1 1.1.1.1 > /dev/null; then + return 1 + fi +} + +main() { + if ! online; then + exit 1 + fi + + hosts="$(pass hosts)" + for host in ${hosts}; do + if ! curl --location --max-time 3 --show-error --silent "${host}" \ + > /dev/null; then + notify-send --urgency=low "${host} is not reachable" + fi + done +} + +main "$@"