Skip to content

Instantly share code, notes, and snippets.

@joshdvir
Created May 15, 2014 10:36
Show Gist options
  • Save joshdvir/cbddb70e6d98bdd7734a to your computer and use it in GitHub Desktop.
Save joshdvir/cbddb70e6d98bdd7734a to your computer and use it in GitHub Desktop.
Automating server inventory
# Automating server inventory
Some of the most useful information you will likely want to collect if you are maintaining a profile of each of the servers you manage includes:
* the server name
* its IP address
* the number of CPUs and cores
* the processor speed
* your disk sizes
* what OS is in use
* the amount of memory on the system
* the manufacturer
* the server model
* uptime
------------------------------------------------------------------------------------------------------------
#!/bin/bash
echo -n "Name: "
uname -n
echo -n "IP: "
ifconfig | grep "inet addr" | grep -v 127.0.0.1 | awk '{print $2}' | awk -F: '{print $2}'
echo -n "CPUs: "
grep "physical id" /proc/cpuinfo | sort | uniq | wc -l
echo -n "Cores: "
grep "^processor" /proc/cpuinfo | wc -l
echo -n "Processor speed (MHz): "
grep MHz /proc/cpuinfo | sort | awk '{print $NF}' | uniq -c
echo -n "Disk(s): "
fdisk -l | grep Disk
echo -n "OS: "
uname -o -r
if [ -f /etc/redhat-release ]; then
echo -n " "
cat /etc/redhat-release
fi
echo -n "Memory: "
grep MemTotal /proc/meminfo | awk '{print $2,$3}'
echo -n "Up for: "
uptime | awk '{print $3,$4,$5}'
echo -n "Manufacturer: "
lshal | grep system\.hardware | grep "vendor" | grep -v video | awk -F\' '{print $2}'
echo -n "Model: "
lshal | grep system\.hardware | grep "product" | grep -v video | awk -F\' '{print $2}'
------------------------------------------------------------------------------------------------------------
The output from this script will look something like this. Notice that there's an extra line in the processor speed section.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment