Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/ksh
- hos=$(hostname)
- curr_Dt=$(date +"%Y-%m-%d %H:%M:%S")
- var=$(ps -ef | grep -i '[/]MSTRSvr')
- if [ -z "$var" ]
- then
- echo "ALERT TIME : $curr_Dt" >>wa.txt
- echo "SERVER NAME : $hos" >>wa.txt
- echo "n n" >>wa.txt
- echo " MSTRSvr is not running on $hos Please check for possible impact " >>wa.txt
- echo "n n" >>wa.txt
- mail -s "MSTRSvr process ALERT" abc@aaa.com <wa.txt
- else
- echo "MSTRSvr is running" >>mi.txt
- mail -s "MSTRSvr process ALERT" abc@aaa.com <mi.txt
- fi
- rm wa.txt 2>ni.txt
- rm mi.txt 2>ni.txt
- #-----------------------------------------------------------------------
- #!/bin/ksh
- hos=$(hostname)
- curr_Dt=$(date +"%Y-%m-%d %H:%M:%S")
- # I am going to get the process ID for the MSTRSvr.
- ProcessPID=$(ps -ef | grep -i '[/]MSTRSvr' | grep -v grep | awk '{print $2}')
- if [[ -z ${ProcessPID} ]]; then
- # There is no PID, Not running!
- echo "ALERT TIME : $curr_Dt" >>wa.txt
- echo "SERVER NAME : $hos" >>wa.txt
- echo "n n" >>wa.txt
- echo " MSTRSvr is not running on $hos Please check for possible impact " >>wa.txt
- echo "n n" >>wa.txt
- mail -s "MSTRSvr process ALERT" abc@aaa.com <wa.txt
- else
- # The process is running check it against the last recorded PID.
- # You can also compare /tmp/MSTRSvr.pid with ${ProcessPID}.
- kill -0 `cat /tmp/MSTRSvr.pid` > /dev/null 2>&1
- if [[ $? -ne 0 ]]; then
- # The current PID does not match.
- echo "MSTRSvr was restarted." >>mi.txt
- # Update the tempfile with current running PID.
- echo ${ProcessPID}>/tmp/MSTRSvr.pid
- mail -s "MSTRSvr process ALERT" abc@aaa.com <mi.txt
- fi
- fi
- rm wa.txt 2>ni.txt
- rm mi.txt 2>ni.txt
- #---------------------------------------------------------------------
- #!/bin/ksh
- hos=$(hostname)
- curr_Dt=$(date +"%Y-%m-%d %H:%M:%S")
- var=$(ps -ef | grep -i '[/]MSTRSvr')
- if [ -z "$var" ]
- then
- echo "ALERT TIME : $curr_Dt" >>wa.txt
- echo "SERVER NAME : $hos" >>wa.txt
- echo "n n" >>wa.txt
- echo " MSTRSvr is not running on $hos Please check for possible impact " >>wa.txt
- echo "n n" >>wa.txt
- echo "stopped" > "filewithlaststate.txt"
- mail -s "MSTRSvr process ALERT" abc@aaa.com <wa.txt
- else
- if [ "$(cat "filewithlaststate.txt")" != "running" ]
- then
- echo "MSTRSvr is running" >>mi.txt
- echo "running" > "filewithlaststate.txt"
- mail -s "MSTRSvr process ALERT" abc@aaa.com <mi.txt
- fi
- fi
- rm wa.txt 2>ni.txt
- rm mi.txt 2>ni.txt
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement