driver that reports to server

This commit is contained in:
Jonas Maier 2025-12-04 23:03:51 +01:00
parent 8066f31409
commit 547fdd8d36
Signed by: jonas
SSH Key Fingerprint: SHA256:yRTjlpb3jSdw2EnZLAWyB4AghBPI8tu42eFXiICyb1U
11 changed files with 66 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/.env*

View File

@ -1,5 +1,6 @@
#!/bin/sh
slug='cpu-load'
name='CPU Load'
recommend=1
available=1

View File

@ -2,6 +2,7 @@
THRESHOLD=90
slug='fs-usage'
name='Filesystem Usage'
recommend=1

View File

@ -2,6 +2,7 @@
THRESHOLD=90
slug='fs-inode-usage'
name='Filesystem Inode Usage'
recommend=1

View File

@ -1,5 +1,6 @@
#!/bin/sh
slug='memory-health'
name='Memory Health'
recommend=1
if command -v memtester >/dev/null 2>&1; then

View File

@ -46,6 +46,7 @@ get_mem_info() {
return 1
}
slug='memory-usage'
name='Memory Usage'
available=1
if ! get_mem_info; then

View File

@ -1,5 +1,6 @@
#!/bin/sh
slug='services'
name='Services'
recommend=0
if command -v systemctl >/dev/null 2>&1; then

View File

@ -1,5 +1,6 @@
#!/bin/sh
slug='smart-disk-health'
name='SMART Disk Health Check'
recommend=1
if command -v smartctl >/dev/null 2>&1; then

View File

@ -1,5 +1,6 @@
#!/bin/sh
slug='swap-usage'
name='Swap'
available=1
recommend=0

View File

@ -1,5 +1,6 @@
set -eu
slug='zfs-pool'
name='ZFS Pool'
recommend=0

56
webdriver.sh Executable file
View File

@ -0,0 +1,56 @@
#! /bin/sh
cd "$(dirname "$0")" || exit 1
. ./util.sh
. ./.env.sh
urlencode() {
string="$1"
i=1
len=${#string}
while [ $i -le $len ]; do
c=$(printf "%s" "$string" | cut -c $i)
printf '%%%02X' "'$c"
i=$((i + 1))
done
printf '\n'
}
report() {
curl -X POST --retry 3 "$API_URL/health-check/$API_KEY?rkid=$resource_kind_id&name=$(urlencode "$2")&status=$1" --data-raw "$3" >/dev/null 2>&1
}
ok() {
report 0 "$1" "$3"
printf '[OK] %s\n' "$3"
}
warn() {
report 1 "$1" "$3"
printf '[WARN] %s\n' "$3"
}
run_module() {
set -eu
. "$1"
printf '%s\n' "$name"
if [ "$available" -ne 1 ]; then
printf 'not available\n'
return
fi
resource_kind_id="$(curl -X POST --retry 3 "$API_URL/create-resource/$API_KEY/?slug=$(urlencode "$slug")&display_name=$(urlencode "$name")" 2>/dev/null)"
check
}
ls modules | while IFS= read -r module; do
[ -f "modules/$module" ] || continue
( run_module "modules/$module" )
if [ "$?" -ne 0 ]; then
printf 'Error running module: %s\n' "$module"
fi
printf '\n'
done