summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2016-10-24 16:17:38 +0200
committerSimon Rettberg2016-10-24 16:17:38 +0200
commit9dc8ddb39b7cf8fbd3b857ddac06a7a653f28202 (patch)
tree680e2c1045a0376ceda02baaa8868bfa08661c05
parent[run-virt] Fix misspelled variable, extract UUID from xml again (diff)
downloadtm-scripts-9dc8ddb39b7cf8fbd3b857ddac06a7a653f28202.tar.gz
tm-scripts-9dc8ddb39b7cf8fbd3b857ddac06a7a653f28202.tar.xz
tm-scripts-9dc8ddb39b7cf8fbd3b857ddac06a7a653f28202.zip
[hardware-stats] Write more stuff to /run/hwinfo
Added virtual cpu core count, system model, system manufacturer
-rwxr-xr-xremote/modules/hardware-stats/data/opt/openslx/scripts/systemd-hardware_stats40
1 files changed, 27 insertions, 13 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 5a776054..6f4e25ec 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
@@ -49,7 +49,10 @@ fi
# 3) Uptime in seconds
UPTIME=$(grep -o -E '^[0-9]+' /proc/uptime)
-# 4) Number of real CPU cores
+# 4) Number of real and virtual CPU cores
+# Virtual, cheap way
+VCORES=$(grep '^processor\s' /proc/cpuinfo | sort -u | wc -l)
+# Real cores
CPUCORES=$(cat /sys/devices/system/cpu/cpu*/topology/thread_siblings_list | sort -u | wc -l)
# Fallback 1...
if [ -z "$CPUCORES" ] || [ "$CPUCORES" = "0" ]; then
@@ -143,24 +146,26 @@ fi
# A) Read system model and manufacturer
dmidec() {
- local LMODEL=$(dmidecode "$@" 2>/dev/null | grep -v '^#' | grep -v '^Invalid' | sed 's/\s\s*/ /g;s/^ //;s/ $//')
- case "$LMODEL" in
+ local RETVAL=$(dmidecode "$@" 2>/dev/null | grep -v '^#' | grep -v '^Invalid' | sed 's/\s\s*/ /g;s/^ //;s/ $//')
+ case "$RETVAL" in
""|*"Product Name"*|*"be filled"*|"unknown"|*"product name"*)
- LMODEL="Unknown"
+ RETVAL="Unknown"
;;
esac
- echo "$LMODEL"
+ echo "$RETVAL"
}
-MODEL=$(dmidec -q -s system-product-name)
-MANUF=$(dmidec -q -s system-manufacturer)
+
+HW_MODEL=$(dmidec -q -s system-product-name)
+HW_MANUF=$(dmidec -q -s system-manufacturer)
# Try fallback to baseboard
-if [ "$MODEL" = "Unknown" ]; then
- MODEL=$(dmidec -q -s baseboard-product-name)
- MANUF=$(dmidec -q -s baseboard-manufacturer)
+if [ "$HW_MODEL" = "Unknown" ]; then
+ HW_MODEL=$(dmidec -q -s baseboard-product-name)
+ HW_MANUF=$(dmidec -q -s baseboard-manufacturer)
fi
-if [ "$MANUF" != "Unknown" ]; then
- MODEL="$MODEL ($MANUF)"
+MODEL="$HW_MODEL"
+if [ "$HW_MANUF" != "Unknown" ]; then
+ MODEL="$MODEL ($HW_MANUF)"
fi
# n) Dump raw data to a file
@@ -169,7 +174,7 @@ cat > "$DATAFILE" <<-EOF
############################### CPU #####################################
Sockets: $(grep '^physical id' /proc/cpuinfo | sort -u | wc -l)
Real cores: $CPUCORES
-Virtual cores: $(grep '^processor' /proc/cpuinfo | sort -u | wc -l)
+Virtual cores: $VCORES
######################## Partition tables ###############################
EOF
cat "$FDISK" >> "$DATAFILE"
@@ -198,11 +203,20 @@ 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
+bashesc () {
+ sed s/\'/\'\"\'\"\'/g <<<$*
+}
+HW_MANUF=$(bashesc "$HW_MANUF")
+HW_MODEL=$(bashesc "$HW_MODEL")
cat > "/run/hwinfo" <<HORST
HW_KVM='${VT}'
HW_ID44='${ID44}'
HW_MBRAM='${RAM}'
HW_HDDCOUNT='${HDDCOUNT}'
+HW_MANUF='${HW_MANUF}'
+HW_MODEL='${HW_MODEL}'
+HW_CORES='${CPUCORES}'
+HW_THREADS='${VCORES}'
HORST
# Fire away