summaryrefslogtreecommitdiffstats
path: root/remote/modules/hardware-stats/data/opt/openslx
diff options
context:
space:
mode:
authorSimon Rettberg2016-03-31 16:34:57 +0200
committerSimon Rettberg2016-03-31 16:34:57 +0200
commit5c5e649721b2cf7c0c82dadb4c84dfb72bc0f516 (patch)
tree2e392d3c96382701f70c4b03bfbd1ca0ec43084c /remote/modules/hardware-stats/data/opt/openslx
parent[vmware] Disable link/map root share if shared folders are disabled (diff)
downloadtm-scripts-5c5e649721b2cf7c0c82dadb4c84dfb72bc0f516.tar.gz
tm-scripts-5c5e649721b2cf7c0c82dadb4c84dfb72bc0f516.tar.xz
tm-scripts-5c5e649721b2cf7c0c82dadb4c84dfb72bc0f516.zip
[kdm-theme-bwlp] Patch theme with warnings about suboptimal hw config
Diffstat (limited to 'remote/modules/hardware-stats/data/opt/openslx')
-rwxr-xr-xremote/modules/hardware-stats/data/opt/openslx/scripts/systemd-hardware_stats28
1 files changed, 23 insertions, 5 deletions
diff --git a/remote/modules/hardware-stats/data/opt/openslx/scripts/systemd-hardware_stats b/remote/modules/hardware-stats/data/opt/openslx/scripts/systemd-hardware_stats
index 0331cada..eee38a7b 100755
--- a/remote/modules/hardware-stats/data/opt/openslx/scripts/systemd-hardware_stats
+++ b/remote/modules/hardware-stats/data/opt/openslx/scripts/systemd-hardware_stats
@@ -8,6 +8,20 @@
export LANG=C
export LC_ALL=C
+mktemp() {
+ /bin/mktemp && return 0
+ /opt/openslx/bin/mktemp && return 0
+ local FN DIR
+ for DIR in "tmp" "tmp" "tmp" "run/user/$UID" "run"; do
+ FN="/${DIR}/${RANDOM}-${$}-${UID}-$(date +%N)"
+ [ -e "$FN" ] && continue
+ touch "$FN" || continue
+ chmod 0600 "$FN" || continue
+ echo "$FN"
+ return 0
+ done
+}
+
if [ -z "$SLX_REMOTE_LOG" ]; then
echo "No remote log url given, will not report"
exit 1
@@ -25,8 +39,6 @@ if [ "${#BOOTIF}" -ne "20" ]; then
fi
MAC=${BOOTIF:3}
-which dmidecode || sleep 5
-
# 2) Get machine UUID, with fallback to MAC address if it fails for some reason
UUID=$(dmidecode -s system-uuid)
if [ "${#UUID}" -ne "36" ]; then
@@ -100,12 +112,14 @@ done
ID44=$(( $ID44 / 1058576 )) # we'd rather underreport
# 9) check smart values
+FDISK=$(mktemp)
+fdisk -l > "$FDISK"
BADSECTORS=0
if which smartctl; then
ALLSMART=$(mktemp)
FILE=$(mktemp)
[ -z "$FILE" ] && FILE="/tmp/smartctl.$$.$RANDOM.$RANDOM"
- for dev in $(fdisk -l | grep -o '^Disk /dev/\S*:' | cut -c 6-); do
+ for dev in $(cat "$FDISK" | grep -o '^Disk /dev/\S*:' | cut -c 6-); do
dev=${dev:0:-1}
smartctl -i -H -A -f "brief" "$dev" > "$FILE" || continue
echo "NEXTHDD=$dev" >> "$ALLSMART"
@@ -151,7 +165,6 @@ fi
# n) Dump raw data to a file
DATAFILE=$(mktemp)
-[ -z "$DATAFILE" ] && DATAFILE="/root/power-stats.$$"
cat > "$DATAFILE" <<-EOF
############################### CPU #####################################
Sockets: $(grep '^physical id' /proc/cpuinfo | sort -u | wc -l)
@@ -159,7 +172,7 @@ Real cores: $CPUCORES
Virtual cores: $(grep '^processor' /proc/cpuinfo | sort -u | wc -l)
######################## Partition tables ###############################
EOF
-fdisk -l >> "$DATAFILE"
+cat "$FDISK" >> "$DATAFILE"
cat >> "$DATAFILE" <<-EOF
############################ PCI ID #####################################
EOF
@@ -181,10 +194,15 @@ EOF
[ -n "$ALLSMART" ] && rm -f -- "$ALLSMART"
# Put some info in local file for later use
+HDDCOUNT=0
+for size in $(cat "$FDISK" | grep -E '^Disk /dev.*[0-9]{11,} bytes' | grep -o -E '[0-9]{11,}'); do
+ [ "$size" -gt 50000000000 ] && HDDCOUNT=$(( HDDCOUNT + 1 ))
+done
cat > "/run/hwinfo" <<HORST
HW_KVM='${VT}'
HW_ID44='${ID44}'
HW_MBRAM='${RAM}'
+HW_HDDCOUNT='${HDDCOUNT}'
HORST
# Fire away