Thursday, October 27, 2011

Linux command to get hardware and system information

Copy and paste the script given below , save on your linux box and then give execute permission . You have to run this script AS ROOT USER

#!/bin/bash

#########################################################################
# #
# Get System Information #
# By Suvabrata Mukherjee #
#Linux command to get hardware info
#########################################################################

echo "System Report" > report.txt
echo "##########################################################################" >> report.txt
echo "HostName" >> report.txt
hostname >> report.txt
echo "----------------------------------------------------------" >> report.txt
echo "OS Version" >> report.txt
cat /etc/issue.net >> report.txt
echo "----------------------------------------------------------" >> report.txt
echo "Total Memory in GB" >> report.txt
echo `free -g | head -n 2 | tail -n 1 | awk '{print $2}'` >> report.txt
echo "----------------------------------------------------------" >> report.txt
echo "Total number of processors" >> report.txt
echo `cat /proc/cpuinfo | grep processor | wc -l` >> report.txt
echo "----------------------------------------------------------" >> report.txt
echo "Processor Make " >> report.txt
echo `cat /proc/cpuinfo | grep 'model name' | head -1` >> report.txt
#Linux command to get hardware info
echo "----------------------------------------------------------" >> report.txt
echo "HardDisk Details :" >> report.txt
echo "Number of Harddisk" >> report.txt
echo `/sbin/fdisk -l | grep Disk | wc -l` >> report.txt
echo `/sbin/fdisk -l | grep Disk` >> report.txt
echo "----------------------------------------------------------" >> report.txt
echo "Ip Addresses:" >> report.txt
echo `/sbin/ifconfig | grep 'inet addr' | awk '{print $2}'| cut -c6-25` >> report.txt
echo "----------------------------------------------------------" >> report.txt
echo "Number of Ethernet Cards" >> report.txt
echo `/sbin/lspci | grep -i ethernet | wc -l` >> report.txt
echo "----------------------------------------------------------" >> report.txt
echo "Server Model and Serial" >> report.txt
echo `/usr/sbin/dmidecode -t system | grep Manufacturer` >> report.txt
echo `/usr/sbin/dmidecode -t system | grep 'Product Name'` >> report.txt
echo ` /usr/sbin/dmidecode -t system | grep 'Serial Number'` >> report.txt
echo "----------------------------------------------------------" >> report.txt
#Linux command to get hardware information
echo "Total DIMM Module available" >> report.txt
echo ` /usr/sbin/dmidecode -t 17 | grep 'Size' | wc -l` >> report.txt
echo "Total DIMM Module free" >> report.txt
echo ` /usr/sbin/dmidecode -t 17 | grep 'Size: No Module Installed' | wc -l` >> report.txt
echo "----------------------------------------------------------" >> report.txt

cat report.txt

# End of Linux command to get hardware information