A co-worker wrote the below script a long time ago and there are many things it can do, but obviously stumbles when it comes to detecting the hard drives because /dev/sd[a-z] is not as common as it once was.
I'm curious if anyone wanted to improve upon this switch to work in more situations. I find it handy for what it reports.
======== Start ========
#! /bin/sh
hostname=`hostname`
drives=`ls /dev/sda[1-10] | wc -l`
echo
echo
echo =================================================
echo " $hostname"
echo =================================================
# echo ========
proctype=`cat /proc/cpuinfo | grep 'model name' | head -n 1`
numcpu=`cat /proc/cpuinfo | grep '^processor' | wc -l`
procspeedghz=`cat /proc/cpuinfo | grep 'cpu MHz' | head -n 1 | awk '{printf "%7.2f\n", $4}'`
procspeedbogo=`cat /proc/cpuinfo | grep 'bogomips' | head -n 1 | awk '{printf "%4.0f\n", $3}'`
echo $proctype | cut -d: -f2
echo $numcpu cores
echo $procspeedghz MHz \($procspeedbogo bogomips\)
# echo ========
memory=`cat /proc/meminfo | grep MemTotal | awk '{printf "%4.1f\n", $2 / 1024 / 1024}'`
echo $memory GB RAM
echo -------------------------------------------------
echo $drives hard drives
if [ -f /proc/mdstat ]
then
raid=True
else
raid=False
fi
if [ $raid = 'True' ]
then
df=`df -h | grep md | grep -v boot | grep -v var | awk '{print $2;}'`
freedisk=`df -h | grep md | grep -v boot | grep -v var | awk '{print $4;}'`
echo $df of RAID storage \($freedisk free\)
else
df=`df -k | grep '/dev/sd[a-z]' | awk '{sum += $2} ; END {printf "%4.0fG\n", sum / 1024 / 1024}'`
freedisk=`df -k | grep '/dev/sd[a-z]' | awk '{sum += $4} ; END {printf "%4.0fG\n", sum / 1024 / 1024}'`
echo $df of non-RAID storage \($freedisk free\)
fi
echo -------------------------------------------------
# echo ========
debver=`cat /etc/debian_version`
debverc=`lsb_release -c`
kerver=`uname -r`
echo debian version $debver
echo debian $debverc
echo kernel version $kerver
echo
df -h
========= End ==========
I'm curious if anyone wanted to improve upon this switch to work in more situations. I find it handy for what it reports.
======== Start ========
#! /bin/sh
hostname=`hostname`
drives=`ls /dev/sda[1-10] | wc -l`
echo
echo
echo =================================================
echo " $hostname"
echo =================================================
# echo ========
proctype=`cat /proc/cpuinfo | grep 'model name' | head -n 1`
numcpu=`cat /proc/cpuinfo | grep '^processor' | wc -l`
procspeedghz=`cat /proc/cpuinfo | grep 'cpu MHz' | head -n 1 | awk '{printf "%7.2f\n", $4}'`
procspeedbogo=`cat /proc/cpuinfo | grep 'bogomips' | head -n 1 | awk '{printf "%4.0f\n", $3}'`
echo $proctype | cut -d: -f2
echo $numcpu cores
echo $procspeedghz MHz \($procspeedbogo bogomips\)
# echo ========
memory=`cat /proc/meminfo | grep MemTotal | awk '{printf "%4.1f\n", $2 / 1024 / 1024}'`
echo $memory GB RAM
echo -------------------------------------------------
echo $drives hard drives
if [ -f /proc/mdstat ]
then
raid=True
else
raid=False
fi
if [ $raid = 'True' ]
then
df=`df -h | grep md | grep -v boot | grep -v var | awk '{print $2;}'`
freedisk=`df -h | grep md | grep -v boot | grep -v var | awk '{print $4;}'`
echo $df of RAID storage \($freedisk free\)
else
df=`df -k | grep '/dev/sd[a-z]' | awk '{sum += $2} ; END {printf "%4.0fG\n", sum / 1024 / 1024}'`
freedisk=`df -k | grep '/dev/sd[a-z]' | awk '{sum += $4} ; END {printf "%4.0fG\n", sum / 1024 / 1024}'`
echo $df of non-RAID storage \($freedisk free\)
fi
echo -------------------------------------------------
# echo ========
debver=`cat /etc/debian_version`
debverc=`lsb_release -c`
kerver=`uname -r`
echo debian version $debver
echo debian $debverc
echo kernel version $kerver
echo
df -h
========= End ==========