Export Script CPU RAM macaddress Script
This commit is contained in:
parent
15c356fc45
commit
6eddfc1432
31
collect_vm_info.sh
Normal file
31
collect_vm_info.sh
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# collect_vm_info.sh
|
||||||
|
# Dieses Skript sammelt VM-Infos und speichert sie als CSV in /home/
|
||||||
|
|
||||||
|
# Datum & Zeit
|
||||||
|
DATE=$(date +"%Y-%m-%d.%H-%M-%S")
|
||||||
|
|
||||||
|
# Hostname
|
||||||
|
HOSTNAME=$(hostname)
|
||||||
|
|
||||||
|
# CPU & Core Infos
|
||||||
|
CPU_COUNT=$(lscpu | awk '/^Socket\(s\):/{s=$2} /^Core\(s\) per socket:/{c=$4} /^Thread\(s\) per core:/{t=$4} END{print s*c*t}')
|
||||||
|
CORE_COUNT=$(lscpu | awk '/^Core\(s\) per socket:/{print $4}')
|
||||||
|
|
||||||
|
# RAM in MB
|
||||||
|
RAM_MB=$(free -m | awk '/Mem:/{print $2}')
|
||||||
|
|
||||||
|
# MAC-Adressen (nur aktive Interfaces)
|
||||||
|
MACS=$(ip link show | awk '/link\/ether/ {print $2}' | paste -sd'|' -)
|
||||||
|
|
||||||
|
# CSV-Dateiname
|
||||||
|
CSV_FILE="/home/${HOSTNAME}.${DATE}.csv"
|
||||||
|
|
||||||
|
# Header + Werte schreiben
|
||||||
|
echo "hostname,cpu_count,core_count,ram_mb,mac_addresses" > "$CSV_FILE"
|
||||||
|
echo "${HOSTNAME},${CPU_COUNT},${CORE_COUNT},${RAM_MB},${MACS}" >> "$CSV_FILE"
|
||||||
|
|
||||||
|
# Berechtigungen anpassen (für Nicht-Root lesbar)
|
||||||
|
chmod 644 "$CSV_FILE"
|
||||||
|
|
||||||
|
echo "✅ Systeminformationen wurden gespeichert unter: $CSV_FILE"
|
||||||
Loading…
Reference in a new issue