Skip to main content

Unix Script 1- to find the Zombee process and send email

####################################################################################################
# Script  - CATCHZ.ksh
# Author  - Amol P Ingle
# Date    - 5/24/2018
# Version - 1.0
#
# Purpose - when stack trace with infected 11 hits ASE dataserver it will check
#           1. Check Zombie process
#              -if Zombie process came in then will send alert message to DBA Team
#               with DBA Page to On-call DBA
#              - even if zombie process not in server and infected message comes in errorlog then-
#           2. Will check health of the ASE dataserver and send an email to DBA team
#           3. Will check message with shutdown as well and if comes then will
#              Alert email message to DBA Team and On-call DBA
#
#####################################################################################################

cd /dir

if test -f lerr1.txt
then
rm lerr1.txt
fi
rm tail.log
touch tail.log
touch /dir/SERVER_NAME.log_old
cp /SERVER_NAME/ASE_LOG/ASE-*/install/ /ASE-*/install/SERVER_NAME.log /dir/SERVER_NAME.log
diff /dir/SERVER_NAME.log /dir/SERVER_NAME.log_old | grep "<" > tail.log

#####################################################################################
# PART 1 - Check the zombie process if there or not
#
#####################################################################################

EMAILTEAM="abc@abc.com"

EMAILONCALL="xyz@abc.com"



for i in tail.log
do
grep infected $i >> lerr1.txt
done
file="lerr1.txt"

if [ -s "$file" ]
then
isql -UUser_Namedb_name.table_list -PXXXXXXXXX -Dmaster -w2000 << EOF!>catchzmb.log

IF EXISTS  (select spid from master..syslogshold slh where slh.spid <> 0 and slh.spid not in(select spid from master..sysprocesses))
PRINT 'Zombie Caught'
ELSE
PRINT 'NONE'
go
IF EXISTS (select spid from master..syslocks where spid not in (select spid from master..sysprocesses))
PRINT 'Zombie Caught'
ELSE
PRINT 'NONE'
go
exit
EOF!
fi

echo $(wc -l < lerr1.txt)> inftcount.txt
inft=`cat inftcount.txt`
grep Zombie catchzmb.log > rowsout.txt

grep Zombie catchzmb.log > rowsout.txt

if [ -s rowsout.txt ]
then

cat catchzmb.log > ZOMBIE.txt
  echo " Zombie Process Found, Please check SERVER_NAME" > ZOMBIE.txt
  echo " Infected Message count : $inft " > ZOMBIE.txt

 /usr/bin/mail -s "Zombie ALERT : Zombie Process Found on SERVER_NAME Server, Please check immediately" $EMAILONCALL < ZOMBIE.txt
else
echo "No Zombie Process"

fi
cp /dir/SERVER_NAME.log /dir/SERVER_NAME.log_old
rm rowsout.txt catchzmb.log ZOMBIE.txt




##########################################################################
## PART 2 - check infected 11 appears the check server health and email ##
##########################################################################

logfile="tail.log"


isql -UUser_Namedb_name.table_list -PXXXXXXXXX -Dmaster -w2000 <> health.log

print "<< StackTrace Message Appears on the Server Errolog, Checking server Health >>"
go
select @@servername,getdate()
go
print "<>"
go
select * from syslogshold where name not like '%replication_truncation_point%'
go
print "<< Blokcing on server>>"
go
select spid,cmd,blocked from sysprocesses where blocked >0
go
print "<<  SPID which is in syslogshold but not in sysprocesses >>"
go
select * from syslogshold where spid not in (select spid from master..sysprocesses ) and name not like '%replication_truncation_point%'
go
select spid from master..syslogshold slh where slh.spid <> 0 and slh.spid not in(select spid from master..sysprocesses)
go
print "<< SPID which is in syslocks but not in sysprocesses >>"
go
select spid from syslocks where spid not in (select spid from sysprocesses)
go
print "<< Below Database marked as Suspect / Offline Status >> "
go
select name from sysdatabases where status in (-32768,64,256,32)
go

exit
EOF1!
fi
/usr/bin/mail -s "StackTrace Message Appears on SERVER_NAME Server, See below details: Infected Message Count:$inft" $EMAILTEAM < health.log

rm health.log
#exit

#####################################################################################
# PART 3 - Check for the shutdown message
#
#####################################################################################

critical="tail.log"


cat $critical | grep "shutdown"
        if [ $? = 0 ]
        then

echo " shutdown message apprears in SERVER_NAME errorlog, Please check  server Health !!" > srvdown.txt

/usr/bin/mail -s "StackTrace made SERVER_NAME server down " $EMAILONCALL < srvdown.txt
/usr/bin/mail -s "StackTrace made SERVER_NAME server down " $EMAILTEAM < tail.log
fi
rm srvdown.txt inftcount.txt
exit

Comments

Popular posts from this blog

Replication Server Quick Ref Guide

Replication Server Guide : • Replication Server Commands • ASE commands and system stored procedures • ASE RSSD stored procedures • RSSD tables • Replication Server System Functions • Troubleshooting Tips Abbreviations Some abbreviations which are used in this Quick Reference Guide: ASE Adaptive Server Enterprise DSI DataServer Interface - RS thread for a connection to a replicate database DIST Distributor - RS thread per primary database LTM Log Transfer Manager; synonym for RepAgent RS, RepServer Replication Server RepAgent Replication Agent (in primary dataserver) RepDef Replication Definition RSI Replication Server Interface - RS thread related to a route to another RepServer RSM Replication Server Manager (a DBA tool normally used in combination with Sybase Central) RSSD Replication Server System Database SQM Stable Queue Manager - RS thread managing a queue SQT Stable Queue Manager - RS thread assembling transactions Replication Server Commands The following commands can only be ...

Sybase IQ material - Quick Ref

Contents IQ 12.6 Commands IQ 12.6 Datatypes IQ 12.6 Functions IQ 12.6 System Procedures IQ 12.6 Catalogue Procedures IQ 12.6 Multiplex System Procedures IQ 12.6 ASE Compatibility System Procedures IQ 12.6 ASE Compatibility Catalogue Procedures IQ 12.6 Extended Procedures IQ 12.6 General Database Options IQ 12.6 T-SQL Compatibility Options IQ 12.6 DBISL Options IQ 12.6 Server Properties IQ 12.6 Database Properties IQ 12.6 Commands Two styles of commenting; the same as in ASE :- /* a comment between delimiters on one or more lines */ -- a comment until the end of this line ALLOCATE DESCRIPTOR descriptor-name [ WITH MAX { integer | host-variable } ] ^ALTER DBSPACE dbspace-name { READWRITE | READONLY | RELOCATE | SIZE dbspace-size [ KB | MB | GB | TB | PAGES ] | ADD dbspace-size [ KB | MB | GB | TB | PAGES ] } ALTER EVENT event-name [ DELETE TYPE | TYPE event-type ] { WHERE { trigger-condition | NULL } | { ADD | [ MODIFY ] | DELETE } SCHEDULE schedule-spec } [ ENABLE | DISABLE ] [ [ MODIFY...

Interesting Notes on ASE

Some hidden things about ASE Different States of SLEEP When all processes are shown as SLEEPING by sp_who except the one, which issued the sp_who command, how can a user tell the difference between hangings versus running processes? Definitions In pre-4.9.2 SQL Servers, the output of sp_who could be difficult to interpret. Processes showed only one type of SLEEP status, "sleeping". In System 10, and 4.9.2 Rollup 2115 and above, sp_who shows four types of sleep along with the other possible statuses: Value Meaning Infected The server erred with a stack trace, and the process got an error that would normally kill it. The process is infected instead of killed. Background This process is in the background recv sleep The process is waiting for input from the client Send sleep The process is waiting for a write to the client to complete alarm sleep The process is waiting for an alarm (usually means the process is waiting for a wait for command to complete). Lock sleep The process i...