#!/bin/sh ######################################## # Description: This script is used to get system information on x64 systems. ######################################## ######################### # Set variables ######################### PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin ######################### # This function displays the system name. ######################### name() { value=`hostname -f` echo $value } ######################### # This function displays the operating system. ######################### os() { value=`vmware -l` echo $value } ######################### # This function displays the operating system (full details). ######################### osfull() { os_release=`vmware -l` os_version=`vmware -v | awk '{print $4}'` os_arch=`uname -m` arch=64-bit value=`echo $os_release $os_version' ('$arch' '$os_arch')'` echo $value } ######################### # This function displays the operating system (short). ######################### osshort() { value=`vmware -v | awk '{print $1}'` echo $value } ######################### # This function displays the chassis tag number. ######################### tag() { value=`smbiosDump | sed -r 's/^[[:space:]]+//' | sed -n '/^System Info.*: #/,/.*: #/p' | \ grep ^Serial: | cut -d : -f 2- | sed 's/^[ "]*//;s/[", ]*$//'` echo $value } ######################### # This function displays the hardware (full details). ######################### hardwarefull() { # CPU cpu_model=`vim-cmd hostsvc/hostsummary | sed -r 's/^[[:space:]]+//' | \ grep ^cpuModel | cut -d = -f 2- | sed 's/^[ "]*//;s/[", ]*$//'` physical_cpus=`vim-cmd hostsvc/hostsummary | sed -r 's/^[[:space:]]+//' | \ grep ^numCpuPkgs | cut -d = -f 2- | sed 's/^[ "]*//;s/[", ]*$//'` cores_per_cpu=`vim-cmd hostsvc/hostsummary | sed -r 's/^[[:space:]]+//' | \ grep ^numCpuCores | cut -d = -f 2- | sed 's/^[ "]*//;s/[", ]*$//'` threads_per_cpu=`vim-cmd hostsvc/hostsummary | sed -r 's/^[[:space:]]+//' | \ grep ^numCpuThreads | cut -d = -f 2- | sed 's/^[ "]*//;s/[", ]*$//'` logical_cpus=$(($physical_cpus * $threads_per_cpu)) if [ "$threads_per_cpu" -gt "$cores_per_cpu" ] then hyper_threading="Yes" else hyper_threading="No" fi cpu_value=`echo CPU: Model: $cpu_model, Hyper-Threading: $hyper_threading, \ Physical CPU\'s: $physical_cpus, Cores per CPU: $cores_per_cpu, Threads \ per CPU: $threads_per_cpu, Logical CPU\'s: $logical_cpus` # RAM ram_data_width=`smbiosDump | sed -r 's/^[[:space:]]+//' | \ sed -n '/^Memory Device.*: #/,/^End Address: /p' | grep '^Data Width:' | \ head -n 1 | awk '{print $3}'` ram_unit_value=`smbiosDump | sed -r 's/^[[:space:]]+//' | \ sed -n '/^Physical Memory Array.*: #/,/.*: #/p' | grep '^Max. Size: ' | \ head -n 1 | awk '{print $4}'` case $ram_unit_value in TB) ram_high_module_unit_value=TB ;; GB) ram_high_module_unit_value=GB ;; esac smbiosDump | sed -r 's/^[[:space:]]+//' | sed -n '/^Memory Device.*: #/,/^End Address: /p' | \ grep '^Speed: ' > /dev/null if [ $? -eq 0 ] then # ESXI 5.x, 6.x way of ^Speed: for ram_module_type in `smbiosDump | sed -r 's/^[[:space:]]+//' | \ sed -n '/^Memory Device.*: #/,/^End Address: /p' | \ grep '^Speed: ' | sort | uniq | awk '{print $2}'` do ram_module_type_total=0 ram_module_type_installed=0 for ram_module_values in `smbiosDump | sed -r 's/^[[:space:]]+//' | \ sed -n '/^Memory Device.*: #/,/^End Address: /p' | \ sed -n '/^Data Width: /,/^Speed: /p' | \ grep -B 1 '^Speed: '$ram_module_type'' | grep '^Size: ' | \ cut -d : -f 2- | sed 's/^[ \t]*//;s/ /_/g'` do ram_module_unit_value=`echo $ram_module_values | \ cut -d _ -f 2` if [ "$ram_module_unit_value" != "$ram_high_module_unit_value" ] then ram_module_size=`echo $ram_module_values | \ cut -d _ -f 1` ram_module_size_calculated=`awk "BEGIN {print $ram_module_size / 1024}"` else ram_module_size_calculated=`echo $ram_module_values | \ cut -d _ -f 1` fi ram_module_type_total=`awk "BEGIN {print $ram_module_type_total + $ram_module_size_calculated}"` ram_module_type_installed=$(($ram_module_type_installed + 1)) done ram_module_type_totals=`echo "Modules installed: \ $ram_module_type_installed @ Module speed: \ $ram_module_type MHz"` ram_subtotals="$ram_subtotals|$ram_module_type_totals" ram_module_total_installed=$(($ram_module_total_installed + $ram_module_type_total)) done else # ESXI 7.x way of ^Configured Speed: for ram_module_type in `smbiosDump | sed -r 's/^[[:space:]]+//' | \ sed -n '/^Memory Device.*: #/,/^End Address: /p' | \ grep '^Configured Speed: ' | sort | uniq | awk '{print $3}'` do ram_module_type_total=0 ram_module_type_installed=0 for ram_module_values in `smbiosDump | sed -r 's/^[[:space:]]+//' | \ sed -n '/^Memory Device.*: #/,/^End Address: /p' | \ sed -n '/^Data Width: /,/^Configured Speed: /p' | \ grep -B 3 '^Configured Speed: '$ram_module_type'' | grep '^Size: ' | \ cut -d : -f 2- | sed 's/^[ \t]*//;s/ /_/g'` do ram_module_unit_value=`echo $ram_module_values | \ cut -d _ -f 2` if [ "$ram_module_unit_value" != "$ram_high_module_unit_value" ] then ram_module_size=`echo $ram_module_values | \ cut -d _ -f 1` ram_module_size_calculated=`awk "BEGIN {print $ram_module_size / 1024}"` else ram_module_size_calculated=`echo $ram_module_values | \ cut -d _ -f 1` fi ram_module_type_total=`awk "BEGIN {print $ram_module_type_total + $ram_module_size_calculated}"` ram_module_type_installed=$(($ram_module_type_installed + 1)) done ram_module_type_totals=`echo "Modules installed: \ $ram_module_type_installed @ Module speed: \ $ram_module_type MHz"` ram_subtotals="$ram_subtotals|$ram_module_type_totals" ram_module_total_installed=$(($ram_module_total_installed + $ram_module_type_total)) done fi ram_subtotals_pretty=`echo $ram_subtotals | sed 's/|/, /g'` ram_value=`echo RAM: Total installed: $ram_module_total_installed \ $ram_high_module_unit_value$ram_subtotals_pretty` echo $cpu_value echo $ram_value } ######################### # This function displays the chassis. ######################### chassis() { value=`smbiosDump | sed -r 's/^[[:space:]]+//' | sed -n '/^System Info.*: #/,/.*: #/p' | \ grep ^Manufacturer: | cut -d : -f 2- | sed 's/^[ "]*//;s/[", ]*$//'` echo $value } ######################### # This function displays the model. ######################### model() { product_name=`smbiosDump | sed -r 's/^[[:space:]]+//' | sed -n '/^System Info.*: #/,/.*: #/p' | \ grep ^Product: | cut -d : -f 2- | sed 's/^[ "]*//;s/[", ]*$//'` version=`smbiosDump | sed -r 's/^[[:space:]]+//' | sed -n '/^System Info.*: #/,/.*: #/p' | \ grep ^Version: | cut -d : -f 2- | sed 's/^[ "]*//;s/[", ]*$//'` value=`echo $product_name $version` echo $value } ######################### # This is the main part of the script. ######################### if [ $# -ne 1 ] then echo usage: system_info.sh [option] echo echo " name Displays system name" echo " os Displays operating system" echo " osfull Displays operating system (full details)" echo " osshort Displays operating system (short)" echo " tag Displays chassis tag number" echo " hardwarefull Displays hardware (full details)" echo " chassis Displays chassis" echo " model Displays model" exit 0 else case $1 in name) name ;; os) os ;; osfull) osfull ;; osshort) osshort ;; tag) tag ;; hardwarefull) hardwarefull ;; chassis) chassis ;; model) model ;; *) echo Unknown option ;; esac fi exit 0