summaryrefslogtreecommitdiffstats
path: root/core/modules/hardware-stats
diff options
context:
space:
mode:
authorSimon Rettberg2020-06-29 16:10:56 +0200
committerSimon Rettberg2020-06-29 16:10:56 +0200
commit9c338ddf5bc9c6e1e07856c2c51208da808014da (patch)
treeeda0f6bb58852e9449eb88b13c82a3def5671749 /core/modules/hardware-stats
parent[remote-access] Use -capslock for slightly less surprising bevavior (diff)
downloadmltk-9c338ddf5bc9c6e1e07856c2c51208da808014da.tar.gz
mltk-9c338ddf5bc9c6e1e07856c2c51208da808014da.tar.xz
mltk-9c338ddf5bc9c6e1e07856c2c51208da808014da.zip
[hardware-stats] Report runmode in poweron, not runstate
It can't change anyways.
Diffstat (limited to 'core/modules/hardware-stats')
-rwxr-xr-xcore/modules/hardware-stats/data/opt/openslx/scripts/cron-system_usage_update7
-rwxr-xr-xcore/modules/hardware-stats/data/opt/openslx/system-check/hooks.d/50-hardware-report19
2 files changed, 14 insertions, 12 deletions
diff --git a/core/modules/hardware-stats/data/opt/openslx/scripts/cron-system_usage_update b/core/modules/hardware-stats/data/opt/openslx/scripts/cron-system_usage_update
index 64bd7729..4c8becc9 100755
--- a/core/modules/hardware-stats/data/opt/openslx/scripts/cron-system_usage_update
+++ b/core/modules/hardware-stats/data/opt/openslx/scripts/cron-system_usage_update
@@ -41,11 +41,6 @@ MEM_FREE=$( awk '{if ($1 == "MemAvailable:") { print $2; exit; }}' /proc/meminfo
if [ -z "$MEM_FREE" ]; then
MEM_FREE=$( awk 'BEGIN{n=0}{if ($1 == "MemFree:" || $1 == "Buffers:" || $1 == "Cached:") n += $2}END{print n}' /proc/meminfo )
fi
-if [ -n "$SLX_EXAM" ]; then
- # This isn't an actual runmode, but in case exam mode is active on a client you definitely want
- # to know about it, more than other runmodes actually
- SLX_RUNMODE_MODULE="exams"
-fi
# CPU temp and load
set --
if $full; then
@@ -78,7 +73,7 @@ curl --retry 3 --retry-connrefused -m 6 -s --data-urlencode "type=~runstate" --d
--data-urlencode "user=$Name" --data-urlencode "tmpsize=$TMP_SIZE" --data-urlencode "tmpfree=$TMP_FREE" \
--data-urlencode "swapsize=$SWAP_SIZE" --data-urlencode "swapfree=$SWAP_FREE" \
--data-urlencode "memsize=$MEM_SIZE" --data-urlencode "memfree=$MEM_FREE" \
- --data-urlencode "runmode=$SLX_RUNMODE_MODULE" "$@" \
+ "$@" \
"$SLX_REMOTE_LOG" > /dev/null 2>&1
# Warn user if tmp or swap usage is high; system might crash soon
diff --git a/core/modules/hardware-stats/data/opt/openslx/system-check/hooks.d/50-hardware-report b/core/modules/hardware-stats/data/opt/openslx/system-check/hooks.d/50-hardware-report
index 31b0b26f..6d137f40 100755
--- a/core/modules/hardware-stats/data/opt/openslx/system-check/hooks.d/50-hardware-report
+++ b/core/modules/hardware-stats/data/opt/openslx/system-check/hooks.d/50-hardware-report
@@ -12,11 +12,12 @@ disable_remote_logging() {
# sends the hardware information of this machine generated by
# systemd-hardware_stats_gather in /run/hwreport and /run/hwinfo
report_hardware_info() {
+ local uptime hwreport hwinfo uuid model subnet ret runmode
if [ -z "$SLX_REMOTE_LOG" ]; then
disable_remote_logging
return 1
fi
- local hwreport="/run/hwreport"
+ hwreport="/run/hwreport"
if [ ! -s "$hwreport" ]; then
echo "Missing hwreport file: $hwreport"
# TODO send data without?
@@ -24,7 +25,7 @@ report_hardware_info() {
fi
# Read generated data and current uptime and send it
- local hwinfo="/run/hwinfo"
+ hwinfo="/run/hwinfo"
if [ ! -s "$hwinfo" ]; then
echo "Missing hwinfo file: $hwinfo"
return 1
@@ -32,21 +33,27 @@ report_hardware_info() {
. "$hwinfo"
# got everything, get the last infos
- local uptime=$(grep -oE '^[0-9]+' /proc/uptime)
+ uptime=$(grep -oE '^[0-9]+' /proc/uptime)
uuid=$(cat /etc/system-uuid)
if [ -z "$uuid" ] || [ "${#uuid}" -ne "36" ]; then
echo "No/malformed UUID, aborting" >&2
exit 1
fi
+ runmode="$SLX_RUNMODE_MODULE"
+ if [ -n "$SLX_EXAM" ]; then
+ # This isn't an actual runmode, but in case exam mode is active on a client you definitely want
+ # to know about it, more than other runmodes actually
+ runmode="exams"
+ fi
# Combine manufacturer and model name (for displaying purposes)
- local model="$HW_MODEL"
+ model="$HW_MODEL"
if [ "$HW_MANUF" != "Unknown" ]; then
model="$model ($HW_MANUF)"
fi
# Get IP/subnet size
- local subnet="$( ip -o -f inet addr show br0 | awk '/scope global/ {print $4}' )"
+ subnet="$( ip -o -f inet addr show br0 | awk '/scope global/ {print $4}' )"
# just assume the uuid/mac dumped are valid here (its checked often enough :))
echo -n "Submitting to '$SLX_REMOTE_LOG' ... "
curl --retry 4 --retry-connrefused --max-time 5 --retry-max-time 15 \
@@ -54,7 +61,7 @@ report_hardware_info() {
--data-urlencode "uptime=$uptime" --data-urlencode "realcores=$HW_CORES" --data-urlencode "mbram=$HW_MBRAM" \
--data-urlencode "kvmstate=$HW_KVM" --data-urlencode "cpumodel=$HW_CPUMODEL" --data-urlencode "id44mb=$HW_ID44" \
--data-urlencode "badsectors=$HW_BADSECTORS" --data-urlencode "systemmodel=$model" --data-urlencode "subnet=$subnet" \
- --data-urlencode "data@$hwreport" "$SLX_REMOTE_LOG" | grep -q "RESULT=0"
+ --data-urlencode "runmode=$runmode" --data-urlencode "data@$hwreport" "$SLX_REMOTE_LOG" | grep -q "RESULT=0"
local ret=$?
if [ "$ret" -ne 0 ]; then
echo "failed."