一个用于查看内存槽位的脚本

     2015年01月12日       江南兔子哥       运维笔记->系统管理       ram 

#!/bin/bash -
PATH=/usr/bin:/bin:/usr/sbin
d=`mktemp /tmp/d.XXXXXXXXXX`||d=/tmp/d.$$
s=`mktemp /tmp/s.XXXXXXXXXX`||s=/tmp/s.$$
l=`mktemp /tmp/l.XXXXXXXXXX`||l=/tmp/l.$$
lb=`mktemp /tmp/l.XXXXXXXXXX`||l=/tmp/lb.$$
t=`mktemp /tmp/t.XXXXXXXXXX`||t=/tmp/t.$$
dmidecode > $d
cat $d | grep -i 'size' |grep -Evi '(rom|maximum|runtime|installed size|enabled size|range|page)' > $s
cat $d | grep -i 'locator' | grep -i 'dimm' > $l
cat $d | grep 'Bank Locator'| grep -Ev '(BAD INDEX)|(Not Specified)' > $lb
n=`cat $l | wc -l`
cat $d | grep -i 'speed:' | grep -Evi '(max|current|rpm|nominal)' | tail -$n > $t
lbcheck=`cat $lb|wc -l`
if [ $lbcheck -eq 0 ];then
        paste $l $s $t| sed -e 's/^[[:space:]]*//g' -e 's/No Module Installed/No Module/g' > $d
else
        paste $l $lb $s $t| sed -e 's/^[[:space:]]*//g' -e 's/No Module Installed/No Module/g' > $d
fi
IFS=""
while read line
do
        echo $line | grep "No Module" 1>/dev/null 2>&1
        if [ $? -ne 0 ];then
                echo -ne '\033[32m'
                echo $line
        else
                echo -ne '\033[0m'
                echo $line
        fi
done< <(cat $d)
echo -ne '\033[0m'
rm -f $d $s $l $lb  $t