Initial commit

This commit is contained in:
waal70
2024-10-26 16:23:45 +02:00
commit b00d31c48d
22 changed files with 475 additions and 0 deletions

View File

@@ -0,0 +1,17 @@
#!/bin/bash
hostname=$(hostname);
operating_system=$(hostnamectl | grep "Operating System" | cut -d ' ' -f3-);
architecture=$(arch);
processor_model=$(cat /proc/cpuinfo | grep -E '^(model name|Model)\s*:' | sort -u | cut -d ':' -f2- | cut -d ' ' -f2-);
memory=$(free -h --si --total | grep -oP '^Total:\s+([\d,]+[.]*[\d]*)[ ]*([A-Za-z]+)' | awk '{print $2}');
system_main_ip=$(hostname -I);
# Hacky way to check for multiple possibilities
cat /proc/cpuinfo | grep -q 'Raspberry'; rc=$?
systemtype=$(if [[ $rc -eq 0 ]]; then echo "Raspberry"; else echo "Generic"; fi)
cat /proc/cpuinfo | grep -q 'Intel'; rc=$?
systemtype=$(if [[ $rc -eq 0 ]]; then echo "Intel"; else echo "$systemtype"; fi)
printf '{"systemtype":"%s","hostname":"%s","operating_system":"%s","architecture":"%s","processor_name":"%s","memory":"%s","system_main_ip":"%s"}'\
"$systemtype" "$hostname" "$operating_system" "$architecture" "$processor_model" "$memory" "$system_main_ip"