AIX巡检脚本.docx
- 文档编号:30294679
- 上传时间:2023-08-13
- 格式:DOCX
- 页数:20
- 大小:19.51KB
AIX巡检脚本.docx
《AIX巡检脚本.docx》由会员分享,可在线阅读,更多相关《AIX巡检脚本.docx(20页珍藏版)》请在冰豆网上搜索。
AIX巡检脚本
#!
/bin/ksh
####################################################################
#Script:
health_check.ksh#
#pSerieshealth_check#
####################################################################
#
#Thisprogramwillcheck:
#Filesystemsizes
#LVMmapping/characteristics
#Thestateofspecificdaemons
#Performanceinformationforpaging,memoryandI/O
#Networkadapters&statistics
#Networkrouting
#Networkparms
#LVMdiskmapping
#errpts
#
######################################################################
#datestampforoutputfilename.
STAMP=$(date+"%Y%m%d")#用日期命令生成时间戳
#DirectoryandFilenamevariablesfortheoutput
HCDIR=/var/aixcheck#临时文件所在目录
HCFILE=${HCDIR}/checklog${STAMP}
SERRFILE=${HCDIR}/errpts_${STAMP}#简要错误输出
LERRFILE=${HCDIR}/errptl_${STAMP}#完整错误输出
#Createtheoutputdirectoryandfile
mkdir-p${HCDIR}#创建输出文件目录
rm-f${HCFILE}#清除重名的输出文件
touch${HCFILE}#生成空的输出文件
OSLEVEL=$(oslevel|sed-e's/\.//g'|cut-c1-3)#取版本号
exportOSLEVEL
###########################################################
#functionpSeries_network
#
#GathersthefollowingnetworkinformationontheServer:
#hostname
#networkadapters
#networkroutes
#networkinterfaces
#networkmemorydenials
#networkstatistics
#nfsstatistics
#/etc/hosts
###########################################################
functionpseries_network{
printf"------------NetworkInformation------------\n">>${HCFILE}2>&1
print-n"network,"
print\\n"Listthenetworkconfigurationfor$HOST...">>${HCFILE}
print\\n"hostname">>${HCFILE}
hostname>>${HCFILE}2>&1
#输出服务器名
print\\n"networkadapters">>${HCFILE}
lsdev-Ccadapter|grep-i-E"Ether|fdd|atm"\
>>${HCFILE}2>&1
#输出网络通信卡信息
print\\n"networkrouting">>${HCFILE}
netstat-rn>>${HCFILE}2>&1
print\\n>>${HCFILE}2>&1
#输出网络路由
print\\n"networkinterfaces">>${HCFILE}
netstat-in>>${HCFILE}2>&1
print\\n>>${HCFILE}2>&1
#输出网络IP地址设置
print\\n"networkmemory(onlyifdenied)">>${HCFILE}
if((${OSLEVEL}>=432));then
extnetstats=$(no-a|grepextendednetstats|sed-e's/[^01]//g')
if[[$debug=1]];then
print\\n"exdendednetstats=$extnetstats">>${HCFILE}
if[[$extnetstats=1]];then
netstat-m2>&1|grepdenied>>${HCFILE}2>&1
else
print\\n"AIX4.3.2+andextendednetstatsNOTenabled!
">>${HCFILE}2>&1
fi
else
netstat-m2>&1|grepdenied>>${HCFILE}2>&1
fi
fi
print\\n"networkstats">>${HCFILE}2>&1
netstat-v2>&1|grep-E"STAT|S/WTransmit">>${HCFILE}2>&1
print\\n>>${HCFILE}2>&1
#输出网络通信内存不足信息(如果存在)
print\\n"Checkingfor/.rhostsfilefor$HOST">>${HCFILE}
home=${HOME}
if[[-f"${HOME}/.rhosts"]];then
print\\n"${HOME}/.rhostsfilepermissions">>${HCFILE}
ls-al/.rhosts>>${HCFILE}2>&1
else
print\\n"No${HOME}/.rhostsfile.">>${HCFILE}2>&1
fi
print\\n>>${HCFILE}2>&1
#输出/.rhosts文件,HACMP某些版本需要此文件,但也可能导致安全问题,所以要特别注意
print\\n"Checking/etc/hostsfor$HOST...">>${HCFILE}
ls-al/etc/hosts>>${HCFILE}2>&1
print\\n>>${HCFILE}2>&1
#检查host文件表(用处不大,仅供参考)
#NetworkoptionsontheServer
#Thisshouldcatchthewall,sb_max,ipforwarding,tcp_sendspace,
#tcp_recvspace,udp_sendspace,udp_recvspace,tcp_mssdflt,
#rfc1323
print-n"networkoptions,"
print\\n"no-aonthe$HOST...">>${HCFILE}
no-a|grep-E"extend|thewall|sb|ipfo|sends|recvs|mssd|1323|arp|tcp_
pmt|ipqmax|arelocal">>${HCFILE}2>&1
print\\n>>${HCFILE}2>&1
#检查重要的网络参数,这些参数对网络性能有影响
print-n"arpbucket,"
print\\n"arp-aon$HOST...">>${HCFILE}
arp-a>>${HCFILE}2>&1
print\\n>>${HCFILE}2>&1
print\\n>>${HCFILE}2>&1
#检查arp表状况
}
#############################################################
#functionpSeries_software
#
#GathersthefollowingsoftwareinformationontheServer:
#AIXlevel
#AIXlppchk
#############################################################
functionpseries_software{
#AIXlevelontheServer
printf"------------SoftwareInformation----------\n">>${HCFILE}2>&1
print-n"AIXLevel,"
print\\n"CheckingAIXlevelon$HOST...">>${HCFILE}
oslevel>>${HCFILE}2>&1
print\\n>>${HCFILE}2>&1
lslpp-L>>${HCFILE}2>&1
#检查操作系统版本
#AIXMaintenanceLevels-checkforlevelofAIX
print-n"AIXMLs,"
print\\nCheckingMaintenanceLevel:
>>${HCFILE}2>&1
if((${OSLEVEL}>510));then
#print\\n>>${HCFILE}2>&1
oslevel-r>>${HCFILE}2>&1
else
print\\nThe-rflagforoslevelnotavailableinyourAIXlevel>>${HCFILE}2>&1
print\\nCheckingMLusinginstfixcommand:
>>${HCFILE}2>&1
instfix-i|grepAIX_ML>>${HCFILE}2>&1
fi
print\\n>>${HCFILE}2>&1
#检查补丁版本
#LPPCheckontheServer
print-n"lppchk,"
print\\n"CheckingLPPswithlppchkon$HOST...">>${HCFILE}
lppchk-v>>${HCFILE}2>&1
#检查安装的程序是否有错误
#CheckAIXenvironment
print-n"environment,"
print\\n"CheckingAIXenvironmenton$HOST...">>${HCFILE}
lsattr-Elsys0>>${HCFILE}2>&1
#检查操作系统基础参数
#LinuxToolboxRPMs(SoftwarePackages)installedonsystem
print-n"RPM,"
print\\n"CheckingforLinuxToolboxSoftware...">>${HCFILE}
rpm-qa>>${HCFILE}2>&1
print\\n>>${HCFILE}2>&1
}
#检查Linux程序包
##############################################################
#functionpSeries_hardware
#
#GathersthefollowinghardwareinformationontheServer
#lscfg
#lsattr
#ttydefinition
#
##############################################################
functionpseries_hardware{
#ListconfigurationontheServer
printf"------------HardwareInformation-----------\n">>${HCFILE}2>&1
print-n"lscfg,"
print\\n"Listthesystemconfigurationfor$HOST...">>${HCFILE}
lscfg-vp>>${HCFILE}2>&1
print\\n>>${HCFILE}2>&1
lsdev-C>>${HCFILE}2>&1
print\\n>>${HCFILE}2>&1
#显示系统配置信息
#Determinethevalueofcpuguard
print-n"lsattr,"
print\\n"DeterminethevalueofCPUguardfor$HOST...">>${HCFILE}
hascpu=$(lsattr-Elsys0|grep-icpuguard)>>${HCFILE}2>&1
if["$hascpu"=""]
then
print\\nCPUGuardnotapplicableonthisarchitecture>>${HCFILE}2>&1
else
print\\nCPUGuardisapplicableonthisarchitecture>>${HCFILE}2>&1
fi
print\\n>>${HCFILE}2>&1
#系统是否有CPU健康跟踪功能,此功能可以随时监视CPU,一旦发现问题,可以做单CPU隔离而不是停机
#ListTTYdefinitions
print-n"ttys,"
print\\n"Listingthetty'sontheServer">>${HCFILE}
lsdev-Cctty>>${HCFILE}2>&1
print\\n>>${HCFILE}2>&1
print\\n>>${HCFILE}2>&1
#查看串口终端设置
}
#####################################################
#functionpSeries_processes
#
#GathersthefollowinginformationontheServer:
#subsystemstatus
#
#####################################################
functionpseries_processes{
#ListthestatusofthesubsystemontheServer
printf"-----------SubsystemInformation------------\n">>${HCFILE}2>&1
print-n"daemons,"
print\\n"lssrc-aoutput">>${HCFILE}
lssrc-a>>${HCFILE}2>&1
print\\n>>${HCFILE}2>&1
print\\n>>${HCFILE}2>&1
#检查网络守护进程情况
}
##################################################
#functionpSeries_users
#
#GathersthefollowinginformationontheServer:
#Userdefinition
#Groupdefinition
#Passworddefinition
#
#################################################
functionpseries_users{
#Verifiesthecorrectnessofuserdefinition
printf"------------UserInformation--------------\n">>${HCFILE}2>&1
print-n"users,"
print\\n"Userdefinition">>${HCFILE}
usrck-nALL>>${HCFILE}2>&1
print\\n>>${HCFILE}2>&1
#检查用户状态
#Verifiesthecorrectnessofgroupdefinition
print-n"groups,"
print\\n"Groupdefinition">>${HCFILE}
grpck-nALL>>${HCFILE}2>&1
print\\n>>${HCFILE}2>&1
#检查用户组状态
#Verifiesthecorrectnessofpassworddefinition
print-n"passwords,"
print\\n"Passworddefinition">>${HCFILE}
pwdck-nALL>>${HCFILE}2>&1
print\\n>>${HCFILE}2>&1
#检查用户密码状态
}
##################################################
#functionpSeries_lvmfs
#
#GathersthefollowinginformationontheServer:
#lspv
#lsvg
#lsfs
#df
#Also,checkdiskutilization.
##################################################
functionpseries_lvmfs{
#ListLVMinformationontheServe
printf"----------LogicalVolumeInformation---------\n">>${HCFILE}2>&1
print-n"LVM,"
print\\n"ListingtheLVMandFSinfoon$HOST...">>${HCFILE}
print\\n"lspvoutput">>${HCFILE}
lspv>>${HCFILE}2>&1
print\\n>>${HCFILE}2>&1
#检查磁盘定义信息
print\\n"lsdevfordiskslookingforUnavail">>${HCFILE}
hasdisk=$(lsdev-C|grepdisk|grep-v"Avail")>>${HCFILE}2>&1
if["$hasdisk"=""]
then
print\\nNoUnavailabledisk>>${HCFILE}2>&1
else
print\\nYouhaveUnavailabedisk>>${HCFILE}2>&1
fi
print\\n>>${HCFILE}2>&1
#检查是否有不可用的磁盘定义
print\\n"VolumeGroupOutput">>${HCFILE}
lsvg-o>>${HCFILE}2>&1
print\\n>>${HCFILE}2>&1
#显示被激活的卷组
#ListVolumeGroupSummaryInformation"
print\\n"VolumeGroupSummaryoutput">>${HCFILE}
forvgin`lsvg`
do
lsvg$vg>>${HCFILE}2>&1
print\\n>>${HCFILE}2>&1
lsvg-l$vg>>${HCFILE}2>&1
print\\n>>${HCFILE}2>&1
done
#显示每个被激活的卷组的详细信息
print\\n"dfoutput">>${HCFILE}
df-k>>${HCFILE}2>&1
print\\n>>${HCFILE}2>&1
#显示文件系统使用
print\\n"lsfsoutput">>${HCFILE}
lsfs>>${HCFILE}2>&1
print\\n>>${HCFILE}2>&1
#显示每个文件系统的详细情况
print\\n"DiskUtilizationoutput">>${HCFILE}
lsvg-o|lsvg-i-p>>${HCFILE}2>&1
print\\n>>${HCFILE}2>&1
print\\n>>${HCFILE}2>&1
#显示每个卷组的磁盘使用情况
}
##########################################################
#functionpSeries_dump
#
#Gathersinformati
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- AIX 巡检 脚本