The following is LINUX/HP Unix/aix daily patrol script, you can refer to the rewrite, for their own server.
#!/usr/bin/ksh
Syserrdate= ' date + '%m/%d '
Errcount=0
status=
Hosts= ' hostname '
Script= ' basename
Report= "/tmp/report.txt"
#FS percent
Filesystem_check () {
fs= ' df-k|sed ' 1d ' |awk ' sub ("%", "", $4) {if ($4 >) print $7} ' |xargs '
For I in $FS
Do
echo "The $i filesystem percent more than%80 n"
Done
}
#Active VG
Vg_check () {
echo "****************************active vg****************************n"
acvg= ' Lsvg-o|xargs '
echo "Active VG is: $ACVGn"
#LV_CHECK
echo "***************************problem lv****************************n"
blv= ' lsvg-l rootvg|grep-e "Jfs|jfs2|raw" |grep-v ' n/a ' |awk ' {if ($6~/closed/| | $6~/stale/) print $ ' |xargs '
For I in $BLV
Do
echo "The $i filesystem has a problem!!! N
Done
}
#Problem disk
Disk_check () {
echo "***************************problem disk***************************n"
disk= ' Lsvg-o|lsvg-ip|awk ' $1~/hdisk/&& $2!~/active/{print $} ' |xargs '
If ["$disk"! = ""]
Then
For I in $disk
Do
echo "The $disk in $i have a problem!!! N
Done
Fi
}
#error report
Error_check () {
echo "***************************error report***************************n"
Errdate= ' errpt |grep-v IDENTIFIER |awk ' {print $} ' |cut-c 1-4 |xargs '
For SyserrFor1 in $errdate
Do
If ["$syserrFor 1" = "$syserrdate"]
Then
Newerrcount= ' expr $errcount + 1 '
Errcount= $newerrcount
Fi
Done
If ["$errcount"-eq 0]
Then
echo "Today error is add $errcount Yesterdayn"
Else
echo "Today Errors is add $errcount than Yesterdayn"
Fi
#error Detail
errors= ' Errpt-dh-tperm '
If [-Z "$errors"]
Then
echo "The Hardware is ${STATUS:-NORMAL}.N"
Else
echo "The permanent error of Hardware as Fllow:n ' Errpt-dh-tperm '"
Fi
}
#Check Database
Db_check () {
Su-oracle-c "lsnrctl status" |grep-i "no listener"
if [$? = 1]
then
EC Ho "The Listener status is ${status:-normal}n"
Else
Echoes "The listener has a problem!!! N "
Fi
#echo" The Listener status is: ' Su-oracle-c "lsnrctl status" ' N "
#echo" Database status is: "
#su-ora Cle-c "Sqlplus-s/nolog" <<eof|sed '/^$/d '
#conn/as sysdba
#select log_mode,name,open_mode from V$database ;
#quit
#EOF
su-oracle-c "sqlplus-s/nolog" <<eof|sed '/^$/d ' 2>/dev/null|grep-i "Oracle not AVAIL
able "
Conn/as sysdba
Select Log_mode,name,open_mode from V$database;
Quit
EOF
If [$ = 0]
Then
Echo ' the database not available!!! N "
Else
Echo" The database is Normaln "
Fi
}
#HBA Card Link
Hardware_check () {
Fget_config-av|grep-i Dacnone>>/dev/null
If [$?-eq 0]
Then
echo "The storage link has problem!!!"
Else
echo "The storage link normal!"
Fi
}
#HACMP CHECK
Ha_check () {
echo "The HACMP status is: ' Lssrc-g cluster|sed ' 1d '"
}
#CHECK SNA
Sna_check () {
echo "The SNA LINK STATUS is: ' sna-d l '"
echo "The SNA SESSION has problem as fllows:n"
sna-d sl|tail +4|awk ' BEGIN {ofs= "T"; print "name", "Tactsess", "Actconw"}{if ($7 = = 0 && $8 = 0) print $, $7,$8 }‘
}
#CHECK CICS
Cics_check () {
echo "The not active CICS is as Fllows:n"
Lssrc-a|grep Cics|awk ' $3!~/active/{print $} '
}
echo $SCRIPT > $REPORT
echo $HOSTS >> $REPORT
echo "IP address: ' ifconfig-a|grep-w inet|grep-v 127.0.0.1|awk ' {print $} '" >> $REPORT
Netstat-v|grep-e "stat| Link ">> $REPORT
Oslevel >> $REPORT
Filesystem_check >> $REPORT 2>&1
Vg_check >> $REPORT 2>&1
Disk_check >> $REPORT 2>&1
Error_check >> $REPORT 2>&1
Db_check >> $REPORT 2>&1
Hardware_check >> $REPORT 2>&1
Lslpp-l|grep Cluster >/dev/null
If [$?-eq 0]
Then
Ha_check >> $REPORT 2>&1
Else
echo "This machine is not install HACMP" >> $REPORT
Fi
Lslpp-l|grep "Sna.rte" >/dev/null
If [$?-eq 0]
Then
Sna_check >> $REPORT 2>&1
Else
echo "This machine is not install SNA" >> $REPORT
Fi
Lslpp-l|grep-i CICS >/dev/null
If [$?-eq 0]
Then
Cics_check >> $REPORT 2>&1
Else
echo "This machine is not install CICS" >> $REPORT
Fi
========================================================
#! /bin/sh
Cd/home/check
Logname=check. ' hostname '. ' Date + '%y%m%d%h%m ' '. txt
echo "System log starting ..." > $logname
echo "Filesystem disk use checking started" >> $logname
echo "#df-H" >> $logname
Df-h >> $logname 2>&1
echo "FileSystem disk Ustage checking completed" >> $logname
echo "VG checking started." >> $logname
echo "Check VG status" >> $logname
echo "# vgdisplay-v" >> $logname
Vgdisplay-v >> $logname
echo "VG checking completed." >> $logname
echo "System log checking started ..." >> $logname
echo "# tail-n 50/var/log/messages" >> $logname
Tail-n 50/var/log/messages >> $logname
echo "showing root ' mail" >> $logname
Cat/var/spool/mail/root >mail.now
Diff-e mail.ref mail.now |awk ' nr>1 {print $} ' >> $logname
MV Mail.now Mail.ref
echo "showing user login since last day" >> $logname
Last >last.now
Diff-e last.ref last.now |awk ' nr>1 {print $} ' >> $logname
MV Last.now Last.ref >> $logname
echo "Crontab using and error log starting ..." >> $logname
Crontab-l >> $logname
Tail-n 30/var/log/cron >> $logname
echo "#########################" >> $logname
echo "System process checking started" >> $logname
echo "#dmesg" >> $logname
DMESG >> $logname
echo "#ps-ef |grep defunc" >> $logname
Ps-ef |grep Defunc >> $logname
echo "#service named status" >> $logname
Service named status >> $logname
echo "#uptime" >> $logname
Uptime >> $logname
echo "System process checking completed" >> $logname
echo "#########################" >> $logname
echo "Networking checking Start." >> $logname
echo "#service network status" >> $logname
Service Network Status >> $logname
echo "#netstat-in" >> $logname
Netstat-in >> $logname
echo "#netstat-rn" >> $logname
Netstat-rn >> $logname
echo "#netstat-NTAPL" >> $logname
NETSTAT-NTAPL >> $logname
echo "Networking checking completed" >> $logname
#echo "#########################" >> $logname
#echo "Performance and paging space checking start ..." >> $logname
#top >top.now
#cat top.now>> $logname
echo "Performance and paging space checking started" >> $logname
echo "#vmstat 1" >> $logname
Vmstat 1 >> $logname
echo "#free-L" >> $logname
Free-l >> $logname
echo "Performance and paging space checking completed" >> $logname
echo "showing command used history since" >> $logname
Cat/.sh_history >sh_history.now
Diff-e sh_history.ref sh_history.now |awk ' nr>1 {print $} ' >> $logname
MV Sh_history.now Sh_history.ref
echo "System logging completed" >> $logname
# now FTP to the log server
Ftp-i-N <<eof
Open 10.0.99.5
User root VMware
Lcd/home/check
Put $logname
Bye
Eof
Cd/home/check
MV $logname/home/check/syslog/
LINUX/HP Unix/aix daily Patrol script (RPM)