Add arch/cpu/hypervisor/virtualization with fallback to the report

This commit is contained in:
Sandra
2022-01-28 19:53:27 +01:00
parent 953a54998e
commit 987d649aa2

View File

@@ -1,15 +1,30 @@
#!/bin/sh #!/bin/sh
with_fallback() {
if [ -z "$2" ]; then
echo $1
else
shift
echo $@
fi
}
print_metadata() { print_metadata() {
echo "#" echo "#"
echo "# Okaeri Timings 1.0" echo "# Okaeri Timings 1.0"
echo "#" echo "#"
echo "# Hostname: $(hostname)" echo "# User: $(with_fallback "<Unknown>" $(whoami))"
# echo "# IP: $(curl -s https://checkip.amazonaws.com/)" echo "# Hostname: $(with_fallback "<Unknown>" $(hostname))"
echo "# User: $(whoami)" echo "# IP: $(with_fallback "<Unknown>" $(curl -s https://checkip.amazonaws.com/))"
echo "#" echo "#"
echo "# Kernel: $(uname -r)" echo "# Kernel: $(with_fallback "<Unknown>" $(uname -r))"
echo "# OS: $(cat /etc/os-release | grep PRETTY_NAME | awk -F '"' '{print $2}')" echo "# OS: $(with_fallback "<Unknown>" $(cat /etc/os-release | grep PRETTY_NAME | awk -F '"' '{print $2}'))"
echo "#"
echo "# Arch: $(with_fallback "<Unknown>" $(lscpu | grep '^Architecture: ' | cut -d\ -f3- | awk '{$1=$1; print}'))"
echo "# CPU: $(with_fallback "<Unknown>" $(lscpu | grep '^Model name: ' | cut -d\ -f3- | awk '{$1=$1; print}'))"
echo "#"
echo "# Hypervisor: $(with_fallback "N/A" $(lscpu | grep '^Hypervisor vendor: ' | cut -d\ -f3- | awk '{$1=$1; print}'))"
echo "# Virtualization: $(with_fallback "N/A" $(lscpu | grep '^Virtualization type: ' | cut -d\ -f3- | awk '{$1=$1; print}'))"
echo "#" echo "#"
} }
@@ -18,7 +33,7 @@ print_header() {
} }
print_data() { print_data() {
timestamp=$(date --iso-8601=seconds) timestamp=$(date +%s)
procstatout=$(cat /proc/stat | grep -m1 ^cpu | cut -d ' ' -f 3-) procstatout=$(cat /proc/stat | grep -m1 ^cpu | cut -d ' ' -f 3-)
user=$(echo "$procstatout" | awk '{print $1}') user=$(echo "$procstatout" | awk '{print $1}')
@@ -46,7 +61,7 @@ print_data() {
} }
dump_delay=60 dump_delay=60
dump_cycles="$((${1-5}))" dump_cycles="$((${1-60}))"
dump_file="okaeri-timings-$(date +%s).csv" dump_file="okaeri-timings-$(date +%s).csv"
if [ "$dump_cycles" -lt 5 ]; then if [ "$dump_cycles" -lt 5 ]; then