|
#!/bin/bash
#--------------------------------------------------
#Date:June 15 2015
#Author:jimmygong
#Mail:jimmygong@taomee.com
#Function:
#Version:1.0
#--------------------------------------------------
set -o nounset
line='======================================================================'
greencolor='\E[1;32m'
if [[ `id -u` -ne 0 ]]
then
echo "sctipts need root"
exit 0
fi
function os ()
{
manufacturer=$(dmidecode -s system-manufacturer)
product=$(dmidecode -s system-product-name)
sn=$(dmidecode -s system-serial-number)
nu=$(dmidecode|grep "Height")
if [[ -e /etc/debian_version ]]
then
unamev=$(uname -r)
unamem=$(uname -m)
echo -e "${greencolor}"Os:"debian ${unamev} ${unamem}\n${line}"
apt-get -y install lsscsi curl pciutils dmidecode --force-yes > /dev/null 2>&1
elif [[ -e /etc/redhat-release ]]
then
release=$(cat /etc/redhat-release)
echo -e "${greencolor}"Os:"${release}\n${line}"
yum -y install lsscsi curl pciutils dmidecode > /dev/null 2>&1
else
echo "unkown release"
fi
if [[ -e /boot/grub/menu.lst ]]
then
grub1=$(cat /boot/grub/menu.lst|egrep -v "^#|^$")
echo -e "Grub:\n${grub1}\n${line}"
else
grub2=$(cat /etc/default/grub|egrep -v "^#|^$")
echo -e "Grub:\n${grub2}\n${line}"
fi
echo -e "Manufacturer:${manufacturer}"
echo -e "Product:${product}"
echo -e "Sn:${sn}"
echo -e "U:${nu}\n${line}"
}
function cpu ()
{
mode=$(getconf LONG_BIT)
counts=$(cat /proc/cpuinfo|grep "physical id"|sort|uniq -c|wc -l)
cores=$(grep 'cpu cores' /proc/cpuinfo|uniq|awk -F : '{print $2}' |sed 's/^[ \t]*//g')
processor=$(cat /proc/cpuinfo|grep "processor"|wc -l)
cpu=$(grep 'model name' /proc/cpuinfo|uniq|awk -F : '{print $2}' |sed 's/^[ \t]*//g' |sed 's/ \+/ /g')
echo -e "Total Of Physical Cpu:${counts}"
echo -e "Number Of Cpu Cores:${cores}"
echo -e "Number Of Cpu Processor:${processor}"
echo -e "Present Mode Of Cpu:${mode}"
echo -e "Cpu Model:${cpu}\n${line}"
}
function mem ()
{
swap=$(cat /proc/meminfo|grep SwapTotal|awk -F: '{print $2}'|awk -F" " '{print $1}')
swap=$(expr $swap / 1024)
mem=$(cat /proc/meminfo|grep MemTotal|awk -F: '{print $2}'|awk -F" " '{print $1}')
memory=$(dmidecode|grep -i -C5 'Memory Device'|grep -v "No Module Installed"|grep -i size|grep -v "Range")
memoryslot=$(dmidecode|grep -i -C5 'Memory Device'|grep "No Module Installed"|wc -l)
mem=$(expr $mem / 1024)
remem=$(free -m|grep cache|awk '/[0-9]/{ print $4" MB" }')
echo -e "Memslot:${memoryslot}"
echo -e "Number Of Mem:\n${memory}"
echo -e "Total Of Mem:${mem}MB"
echo -e "Total Of Swap:${swap}MB"
echo -e "RemainMem:${remem}\n${line}"
}
function disk ()
{
disk=$(fdisk -l|grep 'Disk'|awk -F , '{print $1}' | sed 's/Disk identifier.*//g' | sed '/^$/d')
dftotal=$(df -h|grep "^/dev"|grep -v Filesystem)
dfinode=$(df -i|grep "^/dev"|grep -v Filesystem)
fstab=$(cat /etc/fstab|egrep -v "^#|^$"'|media|proc'|awk '{print $1,$2,$3,$4}')
blkid=$(blkid)
lsscsicmd=$(lsscsi)
lspcicmd=$(lspci|egrep -i "sas|raid")
echo -e "Scsi:\n${lsscsicmd}"
echo -e "Raid:\n${lspcicmd}"
echo -e "Disktotal:\n${disk}"
echo -e "Dftotal:\n${dftotal}"
echo -e "Dfinode:\n${dfinode}"
echo -e "Fstab:\n${fstab}"
echo -e "Blkid:\n${blkid}\n${line}"
}
function timezone ()
{
if [[ -e /etc/timezone ]]
then
timezone1=$(cat /etc/timezone)
echo -e "Timezone:${timezone1}\n${line}"
else
timezone2=$(cat /etc/sysconfig/clock|grep -v "^#"|grep -v "^$"|awk -F"=" '{print $2}')
echo -e "Timezone:${timezone2}\n${line}"
fi
}
function network ()
{
hostnamecmd=$(cat /proc/sys/kernel/hostname)
namecmd=$(cat /etc/resolv.conf|grep "nameserver"|egrep -v "^#|^$")
innerip=$(hostname -i)
outerip=$(curl -s ip.cip.cc)
echo -e "${namecmd}"
echo -e "Hostname:${hostnamecmd}"
echo -e "Innerip:${innerip}"
echo -e "Outerip:${outerip}\n${line}"
}
function ipmi ()
{
lsmodipmi=$(lsmod|grep ipmi)
if [[ $? -eq 0 ]]
then
ipmi=$(ipmitool lan print|grep "IP Address"|sed 's/IP Address Source.*//g'| sed '/^$/d')
echo -e "Ipmi:${ipmi}"
fi
tty=$(ps aux|grep -w "ttyS1"|grep -v grep||ps aux|grep -w "ttyS0"|grep -v grep)
if [[ $? -eq 0 ]]
then
echo -e "TtyS:${tty}\n${line}"
fi
}
function processid ()
{
ss -s|head -2
net=`netstat -tpnl|grep LISTEN|awk '{print $4,$7}'`
echo -e "Netstattpnl:\n${net}"
processnum=`ss -pl|awk -F: '{print $4}'|awk -F"," '{print $2}'|sed '/^$/d'|wc -l`
for ((i=1;i/dev/null|awk '{print $2}'`
do
let num=$num+$swap
done
echo -e "${pid}\t${num}\t${program}"
num=0
done|sort -nrk2|head
echo -e ${line}
}
function mima ()
{
num=$(cat /etc/passwd|grep "/bin/bash"|awk -F: '{print $1}'|wc -l)
for ((i=1;i |
|
|