Shell scripts (for the CentOS and Debian series)
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/6E/89/wKiom1V-5EHy3r1hAAUOL0mNyT4610.jpg "title=" Aaa.jpg "alt=" Wkiom1v-5ehy3r1haauol0mnyt4610.jpg "/>
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/6E/85/wKioL1V-5uKzpQ1MAAWu8b3jp0Y084.jpg "title=" Bbb.jpg "alt=" Wkiol1v-5ukzpq1maawu8b3jp0y084.jpg "/>
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/6E/85/wKioL1V-5kPAt93mAANRmxUEZ3k697.jpg "title=" Ccc.png "alt=" Wkiol1v-5kpat93maanrmxuez3k697.jpg "/>
cat check.sh #!/bin/bash #--------------------------------------------------#Date: June 15 2015#author:jimmygong#mail:[email protected] #Function: #Version:1.0#apt-get -y Install dmidecode --force-yes or yum -y install dmidecode#apt-get -y install pciutils --force-yes or yum -y install pciutils#apt-get -y install curl --force-yes or yum -y install curl#------------------- -------------------------------set -o nounsetline= ' ================================================= ===================== ' bluecolor= ' \e[1;32m ' if [[ ' id -u ' -ne 0 ]]then echo "Sctipts need root" exit 0fifunction os () { manufacturer=$ (dmidecode -s system-manufacturer) product=$ (Dmidecode -s system-product-name) sn=$ (Dmidecode -s system-serial-number) nu=$ (dmidecode|grep "Height") kernel=$ (Uname -r) if [[ -e /etc/debian_version ]] then release1=$ (cat /etc/debian_version) echo -e "${bluecolor}" Os: "Debian${release1}\n${line}" elif [[ -e /etc/redhat-release ]] then release2=$ (cat /etc/redhat-release) echo -e "${bluecolor}" Os: "${release2}\n${line}" else echo "Unkown release" fi if [[ -e /boot/grub/menu.lst ]] then grub1=$ (cat /boot/grub/menu.lst|egrep -v "^#|^$") echo -e "Grub:${grub1}\n${line}" else grub2=$ (cat /etc/default/grub|egrep -v "^#|^$") echo -e "Grub:${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 "&NBSP;MB" &NBSP;} ') echo -e "Memslot:${memoryslot}" echo -e "Number of mem:${memory} " echo -e " TOTAL&NBSP;OF&NBSP;MEM:${MEM}MB " echo -e "TotaL&NBSP;OF&NBSP;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) echo -e "Disktotal:${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 "Innerip:${inneriP} " echo -e " Outerip:${outerip} " echo -e " ${ Namecmd} " echo -e " Hostname:${hostnamecmd}\n${line} "}function ipmi () { lsmodipmi=$ (LSMOD|GREP&NBSP;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<= $processnum; i++) do pid= ' ss -pl|awk -f: ' {print $4} ' |awk -f ', ' ' {print $2} ' |sed '/^$/d ' |sed -n $i ' P ' process= ' pmap $pid | Head -n 2 ' echo -e ' process:${process} ' done echo -e ${line}}function swap () { echo -e&nbSP; " Pid\tswap\tprogame " num=0 for pid in " ls -1 /proc|egrep "^[0-9]" ' do if [[ $pid -le ' + ' ]] then continue fi program=$ (ps -eo pid,command|grep -w $pid |grep -v grep|awk ' {print $2} ') for swap in ' grep swap /proc/$pid/smaps 2>/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<= $num; i++)) do user=$ (cat /etc/passwd|grep "/bin/bash" |awk -F: ' {print $1} ' |sed -n $i ' P ') effeday=$ (cat /etc/shadow|grep $user |awk -f: ' {print $1,$5} ') echo -e "Shadow:${effeday}" done if [ [ -e /etc/sudoers ]] then sudoers=$ (cat /etc/sudoers|egrep -v "^#|^$") echo -e "Sudoers:${sudoers}" fi chag=$ (Chage -l root) echo -e "Chageroot:\n${chag}\n${line}"}function lastlogin () { if [[ -e /var/log/wtmp ]] then last=$ (last|head -n 10) echo -e "Last:\n${last}\n${line}" fi}function limit () { limitcmd=$ (cat /etc/security/limits.conf|egrep -v ' ^#|^$ ') if [[ $? -eq 0 ]] then echo -e "Limitconf:\n${limitcmd}\n${line}" fi} function diskcheck () {if [[ -e /usr/local/sbin/megacli64 ]]then cmd= "/usr/local/sbin/MegaCli64" raid= ' $cmd -cfgdsply -aALL|grep "Raid level" |tail -1|awk -F: ' {print $1 ' : "$ $} ' disknum= ' $cmd -cfgdsply -aALL|grep "number of drives" |awk -f: ' {print $ ' onlinedisk= ' $cmd -cfgdsply -aALL|grep -c Online ' faileddisk= ' $cmd -AdpAllInfo -aALL -NoLog|awk '/failed disks/ {print $4} ' criticaldisk= ' $cmd -AdpAllInfo -aALL -NoLog|awk ' /critical disks/ {print $4} " case $raid" in "raid level : Primary-1, secondary-0,&nBsp Raid level qualifier-0 ") echo "Raid level:1";; "raid level : primary-0, secondary-0, raid level qualifier-0 ") echo "raid level:0";; "raid level : primary-5, secondary-0, raid level qualifier-3 ") echo "Raid level:5";; "raid level : primary-6, secondary-0, raid level qualifier-3 ") echo "raid Level:6 ";; "raid level : primary-1, secondary-3, raid level qualifier-0 ") echo "Raid level:10";; esac echo "Total diak number: $disknum" echo "Online disk number: $onlinedisk" echo " Failed disk number: $faileddisk " echo " critical disk number:$ Criticaldisk " $cmd -PDList -aALL|grep " Firmware state " echo -e ${line}fi}function localea () { if [[ -e /etc/default/locale ]] then locale1=$ (cat /etc/default/locale|egrep -v "^#|^$") echo -e "Currlocale:${locale1}" elif [[ -e /etc/sysconfig/i18n ]] then locale2=$ (cat /etc/sysconfig/i18n|egrep -v "^#| ^$ ") echo -e " Currlocale:${locale2} " else echo $LANG fi locale= ' locale -a|wc -l ' echo -e ' localenum : ${locale}\n${line} "}function cron () { user=$ (ps aux|grep -v user|awk ' {print $1} ' |sort -r|uniq) echo -e ' Runuser:\n${user} \n${line} " path1="/var/spool/cron/crontabs " path2="/var/spool/ Cron " if  [[ -d $path 1 ]] then for user in $ (ls -1 $path 1) do echo -e "$user:" crontab -l -u $user done else for user in $ (ls -1 $path 2) do echo -e "$user:" crontab -l -u $user &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;DONE&NBSP;&NBSP;&NBSP;&NBSP;FI} OscpumemdisktimezonenetworkipmiprocessidswapmimalastloginlImitdiskchecklocaleacronexit 0
This article is from the "7928217" blog, please be sure to keep this source http://7938217.blog.51cto.com/7928217/1662177
Quick access to server basic information (Debian CentOS) shell scripts