cd /tmp
> chk1985.out
> chk1985.out1
> chk1985.out9v_df=85
v_swap=65
v_cpu=70
v_ts=85v_df1=90
v_swap1=80
v_cpu1=80
v_ts1=90############os######################################################################
export LC_ALL=C  //去除所有本地话设置,让以下命令能正确执行case `uname` in  //定义名称
AIX)
df -g|sed 1d|grep -v -|awk '{print $4$7}'|awk -F"%" '{if($1>'$v_df')print "os df:"$2" "$1"%"}' >> chk1985.out //文件以g为单位显示|删除1行|排除多个关键字|打印文件第4和第7字段|当1字段>$v_df变量时,打印OS DF :2字段和1字段 %作分隔符 并将结果保存给  chk1985.out 文件中
df -g|sed 1d|grep -v -|awk '{print $4$7}'|awk -F"%" '{if($1>'$v_df1')print "os df:"$2" "$1"%"}' >> chk1985.out1
df -k|sed 1d|grep -v -|awk '{print $7" "$2" "$2-$3" "$4}'|awk -F% '{print "os df:"$1}' >> chk1985.out9lsps -s|sed 1d|awk '{print $2}'|awk -F"%" '{if($1>'$v_swap')print "os swap:"$1"%"}' >> chk1985.out //交换区的使用信息显示|删除1行|打印第二个字段
lsps -s|sed 1d|awk '{print $2}'|awk -F"%" '{if($1>'$v_swap1')print "os swap:"$1"%"}' >> chk1985.out1
lsps -s|sed 1d|awk '{print $2}'|awk -F"%" '{print "os swap:"$1}' >> chk1985.out9
#errpt
v_err=`errpt -T PERM|grep \`date +%m%d\`'....'\`date +%y\`|grep -vE "largest|SOFTWARE"|tr -s ' '|head -2|sed 's/$/;/g'`
if [ `echo $v_err|grep -v ^$|wc -l` -gt 0 ]
then
echo "errpt:"$v_err >> chk1985.out
echo "errpt:"$v_err >> chk1985.out9
fiv_pcpu=`ps aux|grep -v aux|sort -rnk3|head -1|awk '{if($3>90) print "process id "$2" use "$3"% cpu"}'`
v_pmem=`ps aux|grep -v aux|sort -rnk4|head -1|awk '{if($4>80) print "process id "$2" use "$4"% memory"}'`
v_vmstat=`vmstat 1 10 |tail -n 10|awk '{a+=$16}END{print 100-a/10}'|awk -F"." '{print $1}'`;;
Linux)
v_pcpu=`ps aux|grep -vE "aux|migration"|sort -rnk3|head -1|awk '{if($3>90) print "process id "$2" use "$3"% cpu"}'`
v_pmem=`ps aux|grep -vE "aux|migration"|sort -rnk4|head -1|awk '{if($4>80) print "process id "$2" use "$4"% memory"}'`
v_vmstat=`vmstat 1 10 |tail -n 10|awk '{a+=$15}END{print 100-a/10}'|awk -F"." '{print $1}'`if [ $ipaddr'x' = '10.10.11.207x' ]
then
df -P|grep -v backup|sed 1d|awk '{print $5$6}'|awk -F% '{if($1>'$v_df') print "os df:"$2" "$1"%"}' >> chk1985.out
df -P|grep -v backup|sed 1d|awk '{print $5$6}'|awk -F% '{if($1>'$v_df1') print "os df:"$2" "$1"%"}' >> chk1985.out1
df -P|grep -v backup|sed 1d|awk '{print $6" "$2" "$3" "$5}'|awk -F% '{print "os df:"$1}' >> chk1985.out9
else
df -P|sed 1d|awk '{print $5$6}'|awk -F% '{if($1>'$v_df') print "os df:"$2" "$1"%"}' >> chk1985.out
df -P|sed 1d|awk '{print $5$6}'|awk -F% '{if($1>'$v_df1') print "os df:"$2" "$1"%"}' >> chk1985.out1
df -P|sed 1d|awk '{print $6" "$2" "$3" "$5}'|awk -F% '{print "os df:"$1}' >> chk1985.out9
fifree|grep Swap|awk '{printf "%.0f\n",$3/$2*100}'|awk '{if($1>='$v_swap') print "os swap:"$1"%"}' >> chk1985.out
free|grep Swap|awk '{printf "%.0f\n",$3/$2*100}'|awk '{if($1>='$v_swap1') print "os swap:"$1"%"}' >> chk1985.out1
free|grep Swap|awk '{printf "%.0f\n",$3/$2*100}'|awk '{print "os swap:"$1}' >> chk1985.out9#network adapter bonding
if [ -f /proc/net/bonding/bond0 ] && [ -f /proc/net/bonding/bond1 ]
then
v_bond0=`cat /proc/net/bonding/bond0|grep -i Status|grep down|wc -l`
v_bond1=`cat /proc/net/bonding/bond1|grep -i Status|grep down|wc -l`
if [ $v_bond0 -gt 0 ] || [ $v_bond1 -gt 0 ]
then
echo "network adapter down" >> chk1985.out
echo "network adapter down" >> chk1985.out9
fi
fi;;
HP-UX)if [ `hostname`'x' = 'reportx' ]
then
v_df=95
v_df1=95
fibdf|sed 1d|grep %|awk '{if($1>0)print $4$5;else print $5$6}'|awk -F"%" '{if($1>'$v_df')print "os df:"$2" "$1"%"}' >> chk1985.out
bdf|sed 1d|grep %|awk '{if($1>0)print $4$5;else print $5$6}'|awk -F"%" '{if($1>'$v_df1')print "os df:"$2" "$1"%"}' >> chk1985.out1
bdf|sed 1d|grep %|awk '{if($1>0)print "os df:"$5" "$1" "$2" "$4;else print "os df:"$6" "$2" "$3" "$5}'|sed 's/%//g' >> chk1985.out9
m1=`swapinfo -mt|grep dev|awk '{print $2}'|awk '{sum+=$1}END{print sum}'`
m2=`swapinfo -mt|grep dev|awk '{print $3}'|awk '{sum+=$1}END{print sum}'`
let i=m2*100/m1
if [ $i -ge $v_swap ]
then
echo "os swap:"$i"%" >> chk1985.out
fi
if [ $i -ge $v_swap1 ]
then
echo "os swap:"$i"%" >> chk1985.out1
fiecho "os swap:"$i >> chk1985.out9v_vmstat=`vmstat 1 10 |tail -n 10|awk '{a+=$18}END{print (100-a/10)}'|awk -F"." '{print $1}'`;;
esacif [ $v_vmstat -gt $v_cpu ]
then
echo "os cpu:"$v_vmstat"%" >> chk1985.out
fiif [ $v_vmstat -gt $v_cpu1 ]
then
echo "os cpu:"$v_vmstat"%" >> chk1985.out1
fi
echo "os cpu:"$v_vmstat >> chk1985.out9if [ $v_pcpu'x' != 'x' ]
then
echo $v_pcpu >> chk1985.out
echo $v_pcpu >> chk1985.out9
fiif [ $v_pmem'x' != 'x' ]
then
echo $v_pmem >> chk1985.out
echo $v_pmem >> chk1985.out9
fi
############os######################################################################
############informix################################################################
if [ `ps -ef|grep oninit|grep -v grep|wc -l` -gt 2 ]
thenif [ `whoami` = 'vlog' ]
then
. /home/vlog/chkprofile
elif [ `whoami` = 'vlogcd' ]
then
. /home/vlogcd/chkprofile
fi
if [ `uname` = 'AIX' ] && [ `whoami` != 'root' ]
then
cd /tmp
dbaccess <<!
database sysmaster;unload to /tmp/com1985.txt
select * from sysprofile
where name = 'iscommits';unload to /tmp/rol1985.txt
select * from sysprofile
where name ='isrollbacks';unload to /tmp/tablespace1985.txt
select name dbspace, round(sum(chksize)*4/1024/1024,2) allocated, round(sum(nfree)*4/1024/1024,2) free,
round(((sum(chksize) - sum(nfree))/sum(chksize))*100) pcused
from sysdbspaces d, syschunks c
where d.dbsnum = c.dbsnum and name <> 'cbsviewtmpdbs'
group by name
order by name;unload to "seqscans1985.txt" 
select  * from (
select pp.tabname,pt.nrows,sum(seqscans) total_scans
from sysptprof pp,sysptnhdr pt where pp.partnum=pt.partnum and seqscans >0 and pp.dbsname
not like "sys%" and pp.tabname not like "sys%"
group by 1,2 order by 3 desc
)where (nrows > 100000 and total_scans > 100) or nrows > 1000000;
!
tt1=`onstat -l|awk '{print $3}'|grep "U-"|wc -l`
bb1=`onstat -l|awk '{print $3}'|grep "U-B"|wc -l`
rr1=`echo $bb1 $tt1|awk '{print $1/$2*100}'`
if [ $rr1 -lt 80 ]
then
echo "informix logical log backup failed" >> chk1985.out
echo "informix logical log backup failed" >> chk1985.out1
echo "informix logical log backup failed" >> chk1985.out9
fi
fiif [ `whoami` = 'root' ]
then
su - informix -c "dbaccess <<!
database sysmaster;unload to /tmp/com1985.txt
select * from sysprofile
where name = 'iscommits';unload to /tmp/rol1985.txt
select * from sysprofile
where name ='isrollbacks';unload to /tmp/tablespace1985.txt
select name dbspace, round(sum(chksize)*4/1024/1024,2) allocated, round(sum(nfree)*4/1024/1024,2) free,
round(((sum(chksize) - sum(nfree))/sum(chksize))*100) pcused
from sysdbspaces d, syschunks c
where d.dbsnum = c.dbsnum and name <> 'cbsviewtmpdbs'
group by name
order by name;
!"
ficd /tmp
cat tablespace1985.txt|grep -v physdbs|grep -v logdbs|grep -v phydbs|awk -F"|" '{if($4>'$v_ts')print "db ts:"$1" "$4"%"}' >> chk1985.out
cat tablespace1985.txt|grep -v physdbs|grep -v logdbs|grep -v phydbs|awk -F"|" '{if($4>'$v_ts1')print "db ts:"$1" "$4"%"}' >> chk1985.out1
cat tablespace1985.txt|grep -v physdbs|grep -v logdbs|grep -v phydbs|awk -F'|' '{print "db ts:"$1" "$2" "$2-$3" "$4}' >> chk1985.out9
fi
############informix################################################################
#v_date=`date +%Y%m%d%H%M%S`
#echo "os date:"$v_date >> chk1985.out