#! /bin/bash # # BASH script to extract and (formatted) display of useful system # information. Tested on Red Hat Enterprise Linux edition but is # expected to run on other distributions with little or no modification. # # Questions, comments and/or concerns should be sent to # mail@sgowtham.net # # First written: Gowtham, Thu, 05 Apr 2007 14:25:02 -0400 # Last modified: Gowtham, Fri, 06 Apr 2007 11:09:25 -0400 # export OFFSET=25 # Current User, etc export TODAY=`date` export USER=`whoami` export DISK_USAGE=`du -sh $HOME/ | awk '{print $1}'` echo printf "%"$OFFSET"s %s\n" "TODAY :" "$TODAY" printf "%"$OFFSET"s %s\n" "USER :" "$USER" printf "%"$OFFSET"s %s\n" "USER ID :" "$UID" printf "%"$OFFSET"s %s\n" "SHELL :" "$SHELL" printf "%"$OFFSET"s %s\n" "HOME FOLDER :" "$HOME" printf "%"$OFFSET"s %s\n" "DISK USAGE :" "$DISK_USAGE" # Hardware, Kernel, OS, etc export UNAME="/bin/uname" export NAME=`$UNAME -n` export HARDWARE=`$UNAME -m` export PROCESSOR=`$UNAME -p` export PLATFORM=`$UNAME -i` export OPERATING_SYSTEM=`$UNAME -o` export KERNEL_RELEASE=`$UNAME -r` export KERNEL_VERSION=`$UNAME -v` echo printf "%"$OFFSET"s %s\n" "HOST NAME :" $NAME printf "%"$OFFSET"s %s\n" "HARDWARE :" $HARDWARE printf "%"$OFFSET"s %s\n" "PROCESSOR :" $PROCESSOR printf "%"$OFFSET"s %s\n" "PLATFORM :" $PLATFORM printf "%"$OFFSET"s %s\n" "OPERATING SYSTEM :" $OPERATING_SYSTEM printf "%"$OFFSET"s %s\n" "KERNEL RELEASE :" $KERNEL_RELEASE printf "%"$OFFSET"s %s\n" "KERNEL VERSION :" "$KERNEL_VERSION" # CPU, etc export CPU_NUMBER=`cat /proc/cpuinfo | grep "model name" | \ sed 's/model name\t: //' | wc -l` export CPU_MODEL=`cat /proc/cpuinfo | grep "model name" | \ sed 's/model name\t: //' | head -1` export CPU_CACHE=`cat /proc/cpuinfo | grep "cache size" | \ sed 's/cache size\t: //' | head -1` export TOTAL_MEMORY=`cat /proc/meminfo | head -1 | sed 's/MemTotal://' | \ sed 's/^[ \t]*//;s/[ \t]*$//'` export SWAP_MEMORY=`cat /proc/meminfo | grep "SwapTotal" |\ sed 's/SwapTotal://' | sed 's/^[ \t]*//;s/[ \t]*$//'` export LOAD_AVERAGE=`cat /proc/loadavg | awk '{print $1 " " $2 " " $3 }' | \ sed 's/^[ \t]*//;s/[ \t]*$//'` export UPTIME=`cat /proc/uptime | awk '{ x = $1 / 86400; printf "%d\n", x}'` echo printf "%"$OFFSET"s %s\n" "CPU # :" "$CPU_NUMBER" printf "%"$OFFSET"s %s\n" "CPU MODEL :" "$CPU_MODEL" printf "%"$OFFSET"s %s\n" "CPU CACHE :" "$CPU_CACHE" printf "%"$OFFSET"s %s\n" "MEMORY (RAM) :" "$TOTAL_MEMORY" printf "%"$OFFSET"s %s\n" "SWAP :" "$SWAP_MEMORY" printf "%"$OFFSET"s %s\n" "LOAD AVERAGE :" "$LOAD_AVERAGE" printf "%"$OFFSET"s %s\n" "UPTIME :" "$UPTIME+ day(s)" # Network, etc export IP_ADDRESS0=`/sbin/ifconfig | grep -A 5 eth0 | grep "Bcast" | \ awk '{print $2}' | awk -F ':' '{print $2}'` export MAC_ADDRESS0=`/sbin/ifconfig | grep -A 5 eth0 | grep "HWaddr" | \ awk '{print $NF}'` export IP_ADDRESS1=`/sbin/ifconfig | grep -A 5 eth1 | grep "Bcast" | \ awk '{print $2}' | awk -F ':' '{print $2}'` export MAC_ADDRESS1=`/sbin/ifconfig | grep -A 5 eth1 | grep "HWaddr" | \ awk '{print $NF}'` echo printf "%"$OFFSET"s %s\n" "MAC ADDRESS (eth0) :" "$MAC_ADDRESS0" printf "%"$OFFSET"s %s\n" "IP ADDRESS (eth0) :" "$IP_ADDRESS0" if [ "$MAC_ADDRESS1" != "" ]; then printf "%"$OFFSET"s %s\n" "MAC ADDRESS (eth1) :" "$MAC_ADDRESS1" fi if [ "$IP_ADDRESS1" != "" ]; then printf "%"$OFFSET"s %s\n" "IP ADDRESS (eth1) :" "$IP_ADDRESS1" fi echo