rename files, add readme, add empty .service file

master
bryan 2020-12-28 01:58:43 +00:00
parent 97367a314b
commit 4117d3e80c
5 changed files with 57 additions and 9 deletions

BIN
.readme.md.kate-swp Normal file

Binary file not shown.

View File

@ -1,10 +1,13 @@
#! /bin/bash
if [ ! -e "$1" ]; then
exit 2
fi
TOKEN="A9jDrGFO6Ob-m88"
IP="172.16.1.82"
COUNT_TO_AWAY=900
. "$1"
countToAway=`expr $SECONDS_TO_AWAY / $INTERVAL`
startedTimeout="n"
away="n"
alertedHome="y"
@ -28,24 +31,24 @@ do
else
let "counter += 1"
echo "******** $counter"
if [ $counter -eq $COUNT_TO_AWAY ]; then
alert "Status" "Away"
if [ $counter -eq $countToAway ]; then
alert "$ALERT_TITLE" "$ALERT_MESSAGE_AWAY"
alertedHome="n"
alertedAway="y"
fi
fi
else
if [ "$startedTimeout" = "y" ]; then
if [ "$counter" -ge 100 ]; then
echo "$counter" >> count.hayleyiphone
if [ "$counter" -ge `expr 600 / $INTERVAL` && "$counter" -le `expr 1800 / $INTERVAL ]; then
echo "$counter" >> "$LOGFILE"
fi
startedTimeout="n"
counter=0
if [ "$alertedHome" = "n" ]; then
alert "Status" "Home"
alert "$ALERT_TITLE" "$ALERT_MESSAGE_HOME"
alertedHome="y"
fi
fi
fi
done < <(stdbuf -oL arping -W 1 "$IP")
done < <(stdbuf -oL arping -W "$INTERVAL" "$IP")

24
arpcheck-default.conf Normal file
View File

@ -0,0 +1,24 @@
#! /bin/bash
# ip to arp ping
IP="172.16.1.82"
# alternatively, MAC to ping
MAC="86:51:F8:EF:D1:8C"
# number of seconds for ping to timeout before device is considered to not be present
SECONDS_TO_AWAY=900
# number of seconds between pings
INTERVAL=1
# app token for gotify
TOKEN="A9jDrGFO6Ob-m88"
# logfile
LOGFILE="/var/log/arp-check/$IP"
# alert configuration:
ALERT_TITLE="Status"
ALERT_MESSAGE_HOME="Home"
ALERT_MESSAGE_AWAY="Away"

0
arpcheck@.service Normal file
View File

21
readme.md Normal file
View File

@ -0,0 +1,21 @@
# ARPCHECK #
## Uses `arping` utility to check for presence of device on network. ##
## Installation
1. Copy arpcheck to `/usr/local/bin`
2. Create `/var/log/arpcheck directory` (or directory to match log directory in conf file)
3. Copy `arpcheck-default.conf` to device specific configuration file. ex.: `arpcheck-johndoe.conf`
You may make as many individual configuartion files as you want.
4. Create `/etc/arpcheck directory`
5. Copy arpcheck config files you made to `/etc/arpcheck` directory
6. Copy `arpcheck@.service` file to `\etc\systemd\system`
7. Enable service: `systemctl enable arpcheck@<name_of_config_file>.service`
8. Start service: `systemctl start arpcheck@<name_of_config_file>.service`