rename files, add readme, add empty .service file
parent
97367a314b
commit
4117d3e80c
Binary file not shown.
|
|
@ -1,10 +1,13 @@
|
||||||
#! /bin/bash
|
#! /bin/bash
|
||||||
|
|
||||||
|
if [ ! -e "$1" ]; then
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
|
||||||
TOKEN="A9jDrGFO6Ob-m88"
|
. "$1"
|
||||||
IP="172.16.1.82"
|
|
||||||
COUNT_TO_AWAY=900
|
|
||||||
|
|
||||||
|
|
||||||
|
countToAway=`expr $SECONDS_TO_AWAY / $INTERVAL`
|
||||||
startedTimeout="n"
|
startedTimeout="n"
|
||||||
away="n"
|
away="n"
|
||||||
alertedHome="y"
|
alertedHome="y"
|
||||||
|
|
@ -28,24 +31,24 @@ do
|
||||||
else
|
else
|
||||||
let "counter += 1"
|
let "counter += 1"
|
||||||
echo "******** $counter"
|
echo "******** $counter"
|
||||||
if [ $counter -eq $COUNT_TO_AWAY ]; then
|
if [ $counter -eq $countToAway ]; then
|
||||||
alert "Status" "Away"
|
alert "$ALERT_TITLE" "$ALERT_MESSAGE_AWAY"
|
||||||
alertedHome="n"
|
alertedHome="n"
|
||||||
alertedAway="y"
|
alertedAway="y"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
if [ "$startedTimeout" = "y" ]; then
|
if [ "$startedTimeout" = "y" ]; then
|
||||||
if [ "$counter" -ge 100 ]; then
|
if [ "$counter" -ge `expr 600 / $INTERVAL` && "$counter" -le `expr 1800 / $INTERVAL ]; then
|
||||||
echo "$counter" >> count.hayleyiphone
|
echo "$counter" >> "$LOGFILE"
|
||||||
fi
|
fi
|
||||||
startedTimeout="n"
|
startedTimeout="n"
|
||||||
counter=0
|
counter=0
|
||||||
if [ "$alertedHome" = "n" ]; then
|
if [ "$alertedHome" = "n" ]; then
|
||||||
alert "Status" "Home"
|
alert "$ALERT_TITLE" "$ALERT_MESSAGE_HOME"
|
||||||
alertedHome="y"
|
alertedHome="y"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
done < <(stdbuf -oL arping -W 1 "$IP")
|
done < <(stdbuf -oL arping -W "$INTERVAL" "$IP")
|
||||||
|
|
||||||
|
|
@ -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,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`
|
||||||
Loading…
Reference in New Issue