-
Notifications
You must be signed in to change notification settings - Fork 0
/
ws-heartbeat
28 lines (24 loc) · 1019 Bytes
/
ws-heartbeat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/bin/bash
# WildlifeSystems - Heartbeat
# This script is used to send a heartbeat to the WildlifeSystems server with
# the current status of the device. This is used to determine if the device is
# online or offline and its operational condition.
#
# This script is part of the WildlifeSystems project. For further information
# please refer to https://docs.wildlife.systems, or for more information on
# the project itself, please refer to https://wildlife.systems.
# If status is not set, set it to empty.
STATUS="${1:-}"
# If the token file exists, send the heartbeat to the server.
WSTOKEN_PATH=~/.ws-token
if [[ -f "$WSTOKEN_PATH" ]]; then
TOKEN=$(<~/.ws-token)
SERIAL=$(grep Serial /proc/cpuinfo | cut -d ' ' -f 2)
HNAME=$(hostname)
HB=$(sr onboard)
MACADDR=$(</sys/class/net/eth0/address)
ACTION="$(curl -s --data "token=$TOKEN&node_id=$SERIAL&status=$STATUS&hostname=$HNAME&heartbeat=$HB&mac=$MACADDR" https://devices.wildlife.systems/heartbeat/index.php)"
else
echo "No token."
exit 2
fi