Gather server information within a second

Gather server information within a second

If we have lot many servers and we would like to collect the asset inventory of each and every server then it is very difficult to run various  commands we have to run in order to collect / gather entire information about each server. If we manually run all the commands in each server it may require 5 minutes of time for each server where using below script which may reduce your time to 2 minutes for 100 Servers wow..!!.

Gather server information within a second

Lets see how we can achieve this task using shell script.

Note: We do not recommend to run this script in any production servers, we strictly suggest you to run this in test or home environment only. This script will come either no WARRANTY with NO support.

Create a file called

# touch

copy the below code to above created file


## Purpose: Collecting system Information Gather server information within a second
## Author Name: Ankam Ravi Kumar
## Date: 25th Apr 2016
## Website:
USERID=`id -g`
if [ $USERID == 0 ]; then
echo "Script is Running ..."
echo "Please run the script using root user"
mkdir /tmp/asset
touch /tmp/temp
touch /tmp/asset/info.txt
echo -e "\n" > $FILE
echo "Collecting System Information" >> $FILE
echo -e "\n" >> $FILE
echo "collecting information...."
echo "Date: `date`" >> $FILE
echo "HostName: `hostname`" >> $FILE
echo "Installed OS Version: `cat /etc/issue |head -1`" >> $FILE
echo "`/sbin/ifconfig -a |grep "inet addr" | awk 'BEGIN { FS = ":" } ; { print $2 }'`" > $TEMP
echo "IP Address : `egrep '^10' $TEMP |awk '{ print $1}'`" >> $FILE

## Identifying Hardware Platform ##
HF=`uname -i`
if [ $HF == i386 ]; then
echo "Hardware Platform: 32Bit" >> $FILE
else if [ $HF == x86_64 ]; then
echo "Hardware Platform: 64Bit" >> $FILE
echo "Hardware Not Matched" >> $FILE

## Colleting Hardware Details ##
echo " " >> $FILE
echo "## Hardware Information" >> $FILE
echo " " >> $FILE
echo "Serial Number     : `lshal |grep system.hardware.serial`" >> $FILE
echo "Serial Number     : `/usr/sbin/dmidecode -s system-serial-number`" >> $FILE
echo "Model Number      : `lshal |grep system.hardware.product`" >> $FILE
echo "Model Number      : `/usr/sbin/dmidecode |grep "SKU Number"`" >> $FILE
echo "Hardware Vendor   : `lshal |grep system.hardware.vendor`" >> $FILE
echo "Hardware Info     : `dmesg |grep DMI`" >> $FILE

## Redhat Version ##
echo " " >> $FILE
echo "## OS Version" >> $FILE
head -n1 /etc/issue >> $FILE
echo -en '\n' >> $FILE
uname -a >> $FILE

## CPU Info ##
echo " " >> $FILE
echo " " >> $FILE
echo "## CPU Information" >> $FILE
grep "model name" /proc/cpuinfo >> $FILE

## RAM/MEMORY Info ##
echo " " >> $FILE
echo " " >> $FILE
echo "## Memory Information" >> $FILE
grep MemTotal /proc/meminfo >> $FILE
y=`grep MemTotal /proc/meminfo |awk '{ print $2 }'`
mb="$(( $y / 1024 ))"
gb="$(( $mb / 1024 ))"
echo "RAM : $gb GB" >> $FILE

## Verify the machine is using NIS ##
echo -e '\n' >> $FILE
cat /etc/yp.conf |grep $DOMAIN > /tmp/yptemp.txt
count=`cat /tmp/yptemp.txt | wc -l`
if [ $count -gt 0 ];
echo "`hostname` is part of NIS Domain" >> $FILE
cat /etc/yp.conf |grep finnis >> $FILE
echo "`hostname` is not part of NIS" >> $FILE
echo -e '\n' >> $FILE
cat /etc/yp.conf |grep domain >> $FILE

echo -e '\n' >> $FILE
echo "Hard Disk Info" >> $FILE
fdisk -l 2>&1 | grep Disk | grep -v "identifier" | grep -v "valid partition" | awk '{print $2,$3,$4}' >> $FILE

echo -e '\n' >> $FILE
echo "Running Services" >> $FILE
service --status-all |grep running. |awk '{ print $1,$5}' >> $FILE

/bin/mail -s "Linux Asset Inventory `hostname`" $MAILIST < $FILE

run the shell script file using below command

# sh

if you would like to run the same an multiple servers we have to create password less authentication first See Guide Here

then use below to run in multiple server

Write list of server in one file  example say /tmp/hostlist.txt

now create script file and execute


Copy below code to above created file

## Date: 25th April 2016
## Purpose: Collecting Multiple Servers information yet a time Gather server information within a second
## Author: Ankam Ravi Kumar
## WebSite:

if [ "$#" = 0 ]; then
 echo "Usage: sh file"
else if [ -f "$1" ]; then
 for i in `cat $1`; do scp root@$i:/root/; done
 for i in `cat $1`; do ssh root@$i sh /root/; done
echo "$1 not found"

Now execute file using below command Gather server information within a second

# sh

That’s It you will receive an number of Emails to your mail box. Enjoy..!!

If this script is useful to you then please do comment your feedback.

Thanks for your wonderful Support and Encouragement

Stay Connected with us. Learn More and Earn More


My Name is ARK. Expert in grasping any new technology, Interested in Sharing the knowledge. Learn more & Earn More

You may also like...

9 Responses

  1. pervez says:

    where have to run this script

  2. Sumit Singh says:

    Dear Ravi, awesome info like always u post.

    Today I am trying to tag ur web site on Google +. But unable to do. Hope I could tag u on Google+ likewise LinkedIn

  3. naveen says:

    thanks ravi. it is very useful for system admins.

  4. Satya says:

    It’s useful to all Linux admins Ravi. Good keep it up!

  5. atahar says:

    very usefull script

Leave a Reply