- collect CPU, memory, disk, swap, load, and uptime telemetry - detect nginx and list /etc/nginx/sites-enabled entries - send heartbeat-v2 payload with API key auth - provide install script, config example, and systemd unit
29 lines
887 B
Bash
Executable File
29 lines
887 B
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
BIN_NAME="harborforge-monitor"
|
|
INSTALL_DIR="/usr/local/bin"
|
|
CONFIG_DIR="/etc/harborforge-monitor"
|
|
SERVICE_PATH="/etc/systemd/system/harborforge-monitor.service"
|
|
|
|
if [[ "${EUID}" -ne 0 ]]; then
|
|
echo "Please run as root (or via sudo)." >&2
|
|
exit 1
|
|
fi
|
|
|
|
mkdir -p "${CONFIG_DIR}"
|
|
|
|
pushd "${ROOT_DIR}" >/dev/null
|
|
go build -o "${BIN_NAME}" ./cmd/harborforge-monitor
|
|
install -m 0755 "${BIN_NAME}" "${INSTALL_DIR}/${BIN_NAME}"
|
|
install -m 0644 systemd/harborforge-monitor.service "${SERVICE_PATH}"
|
|
if [[ ! -f "${CONFIG_DIR}/config.json" ]]; then
|
|
install -m 0644 config.example.json "${CONFIG_DIR}/config.json"
|
|
fi
|
|
systemctl daemon-reload
|
|
systemctl enable --now harborforge-monitor
|
|
popd >/dev/null
|
|
|
|
echo "Installed ${BIN_NAME}. Edit ${CONFIG_DIR}/config.json and restart the service if needed."
|