Advertisement
Guest User

Untitled

a guest
Jul 24th, 2017
511
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.42 KB | None | 0 0
  1. #!/bin/ksh
  2. hos=$(hostname)
  3.  
  4. curr_Dt=$(date +"%Y-%m-%d %H:%M:%S")
  5.  
  6. var=$(ps -ef | grep -i '[/]MSTRSvr')
  7.  
  8. if [ -z "$var" ]
  9. then
  10.  
  11. echo "ALERT TIME : $curr_Dt" >>wa.txt
  12. echo "SERVER NAME : $hos" >>wa.txt
  13. echo "n n" >>wa.txt
  14. echo " MSTRSvr is not running on $hos Please check for possible impact " >>wa.txt
  15. echo "n n" >>wa.txt
  16.  
  17. mail -s "MSTRSvr process ALERT" abc@aaa.com <wa.txt
  18.  
  19. else
  20.  
  21. echo "MSTRSvr is running" >>mi.txt
  22.  
  23. mail -s "MSTRSvr process ALERT" abc@aaa.com <mi.txt
  24.  
  25. fi
  26.  
  27. rm wa.txt 2>ni.txt
  28. rm mi.txt 2>ni.txt
  29.  
  30. #-----------------------------------------------------------------------
  31. #!/bin/ksh
  32.  
  33. hos=$(hostname)
  34. curr_Dt=$(date +"%Y-%m-%d %H:%M:%S")
  35.  
  36. # I am going to get the process ID for the MSTRSvr.
  37. ProcessPID=$(ps -ef | grep -i '[/]MSTRSvr' | grep -v grep | awk '{print $2}')
  38.  
  39. if [[ -z ${ProcessPID} ]]; then
  40. # There is no PID, Not running!
  41. echo "ALERT TIME : $curr_Dt" >>wa.txt
  42. echo "SERVER NAME : $hos" >>wa.txt
  43. echo "n n" >>wa.txt
  44. echo " MSTRSvr is not running on $hos Please check for possible impact " >>wa.txt
  45. echo "n n" >>wa.txt
  46. mail -s "MSTRSvr process ALERT" abc@aaa.com <wa.txt
  47. else
  48. # The process is running check it against the last recorded PID.
  49. # You can also compare /tmp/MSTRSvr.pid with ${ProcessPID}.
  50. kill -0 `cat /tmp/MSTRSvr.pid` > /dev/null 2>&1
  51. if [[ $? -ne 0 ]]; then
  52. # The current PID does not match.
  53. echo "MSTRSvr was restarted." >>mi.txt
  54. # Update the tempfile with current running PID.
  55. echo ${ProcessPID}>/tmp/MSTRSvr.pid
  56. mail -s "MSTRSvr process ALERT" abc@aaa.com <mi.txt
  57. fi
  58. fi
  59.  
  60. rm wa.txt 2>ni.txt
  61. rm mi.txt 2>ni.txt
  62. #---------------------------------------------------------------------
  63.  
  64. #!/bin/ksh
  65. hos=$(hostname)
  66.  
  67. curr_Dt=$(date +"%Y-%m-%d %H:%M:%S")
  68.  
  69. var=$(ps -ef | grep -i '[/]MSTRSvr')
  70.  
  71. if [ -z "$var" ]
  72. then
  73. echo "ALERT TIME : $curr_Dt" >>wa.txt
  74. echo "SERVER NAME : $hos" >>wa.txt
  75. echo "n n" >>wa.txt
  76. echo " MSTRSvr is not running on $hos Please check for possible impact " >>wa.txt
  77. echo "n n" >>wa.txt
  78.  
  79. echo "stopped" > "filewithlaststate.txt"
  80.  
  81. mail -s "MSTRSvr process ALERT" abc@aaa.com <wa.txt
  82.  
  83. else
  84.  
  85. if [ "$(cat "filewithlaststate.txt")" != "running" ]
  86. then
  87. echo "MSTRSvr is running" >>mi.txt
  88.  
  89. echo "running" > "filewithlaststate.txt"
  90.  
  91. mail -s "MSTRSvr process ALERT" abc@aaa.com <mi.txt
  92. fi
  93.  
  94. fi
  95.  
  96. rm wa.txt 2>ni.txt
  97. rm mi.txt 2>ni.txt
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement