From b2758d4edd2f67e0ee8eb8531732e56a9af27432 Mon Sep 17 00:00:00 2001 From: x p k Date: Sun, 11 Apr 2021 13:03:10 +0800 Subject: [PATCH] NEW: linux-server-info.sh --- sh/linux-server-info.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 sh/linux-server-info.sh diff --git a/sh/linux-server-info.sh b/sh/linux-server-info.sh new file mode 100644 index 0000000..4db985f --- /dev/null +++ b/sh/linux-server-info.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash +CPU=$(cat /proc/cpuinfo | grep 'model name' | uniq | awk -F: '{print $2}' | sed 's/(R)//g') +NUMCPU=$(cat /proc/cpuinfo | grep 'physical id' | sort | uniq | wc -l) +MEM=$(dmidecode -t memory | awk '/Size.*MB/ {SUM+=$2}; END {print SUM/1024}') +DISK=$(for d in /dev/sd? /dev/nvme?n? /dev/vd? /dev/hd?; do blockdev --getsize64 $d 2>/dev/null | awk '{print $1}'; done | awk '{SUM+=$1}; END {print SUM/1024/1024/1024}') +SERIAL=$(dmidecode -t system | awk -F: '/Serial/ {print $2}') + +echo "{" +echo \"Hostname\": \"$(hostname -s)\", +echo \"Cpu\": \"$CPU\", +echo \"NumCpu\": \"$NUMCPU\", +echo \"Mem\": \"$MEM\", +echo \"Disk\": \"$DISK\", +echo \"Serial\": \"$SERIAL\" +echo "}" + +