From 59ec78c9ba5c2b20d06b926671e245298e784e31 Mon Sep 17 00:00:00 2001 From: K2IE Date: Mon, 11 Apr 2022 12:17:02 -0400 Subject: [PATCH 1/2] Create checkreg.sh --- scripts/checkreg.sh | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 scripts/checkreg.sh diff --git a/scripts/checkreg.sh b/scripts/checkreg.sh new file mode 100644 index 0000000..78a7611 --- /dev/null +++ b/scripts/checkreg.sh @@ -0,0 +1,41 @@ +#!/bin/bash +# checkreg.sh -- check XLX registration server for active registration and correct IP +# Author: K2IE +# +# Run as you wish from /etc/cron.daily or /etc/crontab as you wish +# Dependencies: libxml2-utils + +# Set the MY variables as appropriate for your reflector +MYXLX=XLXNNN +MYIP=1.2.3.4 +MYEMAILS="some@email.com another@email.com" +MYSENDER=root + +XML=`curl -s http://xlxapi.rlx.lu/api.php?do=GetReflectorList | \ + grep $MYXLX -B1 -A7` + +SUBJECT="$MYXLX Reg OK" + +NOW=`date +%s` +THEN=`echo $XML | xmllint --xpath 'string(/reflector/lastcontact)' -` +LAST=$((NOW-THEN)) + +if (( LAST > 1800 )); then + SUBJECT="$MYXLX Reg FAULT" + TEXT1="$MYXLX registration shows DOWN, please check." +else + TEXT1="$MYXLX registration shows UP, no action needed." +fi + +IP=`echo $XML | xmllint --xpath 'string(/reflector/lastip)' -` + +if [ "$IP" = "$MYIP" ]; then + TEXT2="$MYXLX IP Address is still $IP, no action needed." +else + SUBJECT="$MYXLX Reg FAULT" + TEXT2="$MYXLX IP address is now $IP, please check." +fi + +TEXT="$TEXT1\n$TEXT2" + +echo -e $TEXT | mail -r "$MYSENDER" -s "$SUBJECT" $MYEMAILS From fa55e78ab513c5759685c0bea16e615a08841f30 Mon Sep 17 00:00:00 2001 From: K2IE Date: Mon, 11 Apr 2022 12:18:13 -0400 Subject: [PATCH 2/2] Update checkreg.sh --- scripts/checkreg.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/checkreg.sh b/scripts/checkreg.sh index 78a7611..652f4fd 100644 --- a/scripts/checkreg.sh +++ b/scripts/checkreg.sh @@ -2,7 +2,7 @@ # checkreg.sh -- check XLX registration server for active registration and correct IP # Author: K2IE # -# Run as you wish from /etc/cron.daily or /etc/crontab as you wish +# Run as you wish from /etc/cron.daily or /etc/crontab # Dependencies: libxml2-utils # Set the MY variables as appropriate for your reflector