Chinaunix首页 | 论坛 | 博客
  • 博客访问: 3386100
  • 博文数量: 631
  • 博客积分: 10716
  • 博客等级: 上将
  • 技术积分: 8397
  • 用 户 组: 普通用户
  • 注册时间: 2008-04-01 22:35
文章分类

全部博文(631)

文章存档

2020年(2)

2019年(22)

2018年(4)

2017年(37)

2016年(22)

2015年(1)

2013年(12)

2012年(20)

2011年(19)

2010年(20)

2009年(282)

2008年(190)

分类:

2009-12-09 10:42:13


#!/sbin/sh

# AUTHOR: yongfeng li
# mail
# DATE: 11/28/2009
#PURPOSE:  This shell script is used to get  the hp-UX system information
# PLATFORM: HP-UX Only
######################################################
############### DEFINE VARIABLES HERE ################
######################################################
文件: hp_check.sh.pdf
大小: 19KB
下载: 下载

syserrdate=`date +"%m/%d"`
errcount=0
HOSTS=`hostname` # Hostname of this machine
SCRIPT=`basename $0`
PMANI=0 # do not use print_manifest by default
TEMPDIR="/tmp/hp_report"
#ls -d $TEMPDIR||mkdir -p $TEMPDIR >/dev/null
if [ -d $TEMPDIR ] ; then
echo "$TEMPDIR exist"
rm -f $TEMPDIR/*
else mkdir -p $TEMPDIR
fi
REPORT="$TEMPDIR/report.txt"
CONFIG="$TEMPDIR/config.txt"
FSFILE="$TEMPDIR/fsfile.txt"
OUTFILE="$TEMPDIR/bdfout.txt"
LOGFILE="$TEMPDIR/log.gile.txt"
FSMAX="85"  # Max. FS percentage value
SWLIST="$TEMPDIR/swlist.txt"
PERFORMANCE="$TEMPDIR/performance.txt"
>$REPORT    # Initialize to empty
>$CONFIG    # Initialize to empty
>$FSFILE    # Initialize to empty
>$OUTFILE   # Initialize to empty
>$LOGFILE  # Initialize to empty
>$SWLIST
>$PERFORMANCE
######################################################
############### DEFINE FUNCTIONS HERE ################
######################################################

#FS percent
FILESYSTEM_CHECK() {
bdf|sed '1d'|egrep -v '/cdrom' \
   | awk '{print $1, $5, $6}' | \
while read FSDEVICE FSVALUE FSMOUNT
do
      FSVALUE=$(echo $FSVALUE | sed s/\%//g) # Remove the % sign
      if [ $FSVALUE -gt $FSMAX ]
      then
          echo "$FSDEVICE mounted on $FSMOUNT is ${FSVALUE}%" \
                >> $OUTFILE
      fi
done
if [ -s  $OUTFILE ]
then
      echo "\nFull Filesystem(s) on $THISHOST\n"
      cat $OUTFILE
      print
fi
}
#Active VG
VG_CHECK() {
echo "****************************ACTIVE VG****************************\n"
ACVG=`vgdisplay -v|egrep -i "vg name|vg status"|awk '{print $NF}'|xargs`
echo "Active VG is: $ACVG\n"
}
LV_CHECK() {
vgdisplay -v |egrep -i "lv name|lv status"|awk '{print $NF}'|grep -i stale
if [ $? -eq 0 ] ; then
vgdisplay -v|egrep -i "lv name|lv status"|grep -i stale
fi
}
#Disk_check
hw_disk_check()
{
DEVICES=`ioscan -fknCdisk | grep -e /rdsk/ | cut -d "/" -f4`
printf "\n%-24s%-10s%-22s%-8s%-8s%-3s%-3s\n" Hardwarepath Device \
Vendor/Product Cap/GB Firm. QD IR
echo "-----------------------------------------------------------------------\
-------"
for device in $DEVICES
   do
      scsi=`/usr/sbin/scsictl -akq /dev/rdsk/$device 2>/dev/null`
      sir=`echo $scsi|awk -F";" '{ print $1; }{}'`
      sqd=`echo $scsi|awk -F";" '{ print $2; }{}'`
      hw_pfad=` lssf /dev/dsk/$device  | awk '{ print $(NF-1) }'`
      printf "%-24s%-10s" $hw_pfad $device
      (diskinfo -v /dev/rdsk/$device 2> /dev/null \
| grep -e product -e rev -e vendor -e size) |\
awk '{if(match($1,"vendor:")) {vendor=$2}} \
{if (match($1,"product")) {product=$3}} \
{if (match($1,"size:")) {size=$2}} \
{if (match($1,"rev")) {vend_p=vendor"/"product;printf "%-22s%-8.1f%-8s",\
vend_p,(size+0.01)/1024/1024,$3}} '
printf "%-3s%-3s\n" $sqd $sir
done
}
ex_log()
{ #executes and logs a command
echo $1 ; ( echo "### $1 ###" ; $1 ) >> $2
}
get_system_info() {
echo "-----------------------------------------------------------------------"
uname -a
echo "-----------------------------------------------------------------------"
uptime
echo "-----------------------------------------------------------------------"
if [ -x /usr/contrib/bin/machinfo ] ; then
/usr/contrib/bin/machinfo
fi
echo "----------------------------------------------------------------------"
if [ -x /opt/ignite/bin/print_manifest ] ; then
 echo "print_manifest ..."
 /opt/ignite/bin/print_manifest
fi
}
vx_vm_check()
 { if [ -x /usr/sbin/vxdctl ] ; then
TM=`/usr/sbin/vxdctl mode | awk ' { print $2 } '`
if [ "$TM" != "disabled" -a "$TM" != "not-running" ] ; then
ex_log "/usr/sbin/vxdctl -c mode" vxvm.txt
ex_log "/usr/sbin/vxdctl license" vxvm.txt
ex_log "/usr/sbin/vxprint -ht" vxvm.txt
ex_log "/usr/sbin/vxdisk list" vxvm.txt
/usr/sbin/vxdisk -e list > /dev/null 2>&1
if [ $? -eq 0 ] ; then
ex_log "/usr/sbin/vxdisk -e list" vxvm.txt
fi
ex_log "/usr/sbin/vxdisk -o alldgs list" vxvm.txt
ex_log "/usr/sbin/vxdisk -s list" vxvm.txt
ex_log "/usr/sbin/vxdg list" vxvm.txt
# the "bootdg" option is new in 4.0
/usr/sbin/vxdg help 2>&1 | grep "bootdg" >> /dev/null
if [ $? -eq 0 ] ; then
ex_log "/usr/sbin/vxdg bootdg" vxvm.txt
fi
for i in `/usr/sbin/vxdg -q list | awk ' { print $1 } '`
do
ex_log "/usr/sbin/vxdg list $i" vxvm.txt
ex_log "/usr/sbin/vxstat -g $i -ffc -d" vxvm.txt
done
fi
fi
 
}
######################################################
################ BEGINNING OF MAIN ###################
######################################################

FILESYSTEM_CHECK>>$REPORT 2>&1
VG_CHECK>>$REPORT 2>&1
LV_CHECK>>$REPORT 2>&1
hw_disk_check|tee $TEMPDIR/diskinfo.txt
get_system_info>>$CONFIG  2>&1
vx_vm_check>>$REPORT 2>&1
 
#######################################################
################ performance_check#####################
#######################################################
ex_log "/usr/bin/vmstat 3 6" $PERFORMANCE
ex_log "/usr/bin/sar 3 6"  $PERFORMANCE 
ex_log "/usr/bin/iostat 3 6"  $PERFORMANCE
#######################################################
################ log_check#############################
#######################################################

ex_log " dmesg" $LOGFILE
ex_log "grep -E 'warn|error|fail'  /var/adm/syslog/syslog.log"   $LOGFILE
ex_log "cat /etc/rc.log"  $LOGFILE
ex_log "cat /etc/shutdownlog"  $LOGFILE
#######################################################
################swlist_check###########################
#######################################################
 
#ex_log "swlist -l bundle" swlist.txt
#echo "_______________________________________" >> $SWLIST
#ex_log "swlist -l product -a date -a title -a revision" swlist.txt
#echo "checking for unconfigured patches ..."
#swlist -l fileset -a state | grep -E -v '^#|conf' >>$SWLIST
echo "getting lan  lvm information"
ex_log lanscan  $REPORT
ex_log "strings /etc/lvmtab" $REPORT
ex_log "vgdisplay -v"  $REPORT
ex_log "uname -a" $CONFIG
ex_log  "crashconf" $CONFIG
ex_log "lvlnboot -v" $CONFIG
ex_log "swapinfo -atm" $CONFIG
ex_log "swlist -l bundle" $SWLIST
ex_log "swlist -l product -a date -a title -a revision" $SWLIST
echo "checking for unconfigured patches ...">>$SWLIST
swlist -l fileset -a state | grep -E -v '^#|conf' >>$SWLIST
 
 
阅读(4356) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~