Guest User

Untitled

a guest
Feb 24th, 2018
296
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.91 KB | None | 0 0
  1. Clear-Host
  2. #$repeat="Y"
  3. $count = 0
  4. $last_restart = 0
  5. $restart = 0
  6. do {
  7. if((get-date).hour -eq 0 -and (get-date).minute -eq 0)
  8. {$count = 0 #reset the restart counter at midnight every day
  9. write-host "________________________"}
  10.  
  11. if((get-process jrun|select -exp workingset64) -gt 3900MB)
  12. {get-process jrun | stop-process
  13. $count++
  14. write-host "Jrun restarted: " -nonewline; Get-Date | write-host
  15. write-host "count: " $count
  16. $last_restart = $restart
  17. $restart = get-date
  18. $a= (Get-Content E:\server\path\test_log.txt)[-1].Split("`t")
  19. write-host $a[1].Trim() "broke the page!" #for testing
  20. $smtpServer = "192.168.0.1"
  21. $MailFrom_ = "iwebmaster@domain.com"
  22. $msg_ = new-object Net.Mail.MailMessage
  23. $smtp_ = new-object Net.Mail.SmtpClient($smtpServer)
  24. $msg_.From = $MailFrom_
  25. #$msg_.To.Add("it@domain.com")
  26. $msg_.To.Add($a[0].Trim())
  27. $msg_.Subject = "Problem with submission"
  28. $MailTextT_ = $a[1].Trim() + ", the process needed to be restarted on the web server. If your pages did not download completely, please reduce the number of pages to process in this batch. You may need to download them individually and OCR with eCopy. If you received all of your pages, then you may disregard this message."
  29. $msg_.Body = $MailTextT_
  30. $smtp_.Send($msg_)
  31. Start-Sleep -s 30
  32. }
  33. else
  34. {Start-Sleep -s 30}
  35. if(($count -eq 10) -and ($last_restart.month -eq (get-date).month -and $last_restart.day -eq (get-date).day))
  36. {
  37. $smtpServer = "192.168.0.1"
  38. $MailFrom = "iwebmaster@domain.com"
  39. $msg = new-object Net.Mail.MailMessage
  40. $smtp = new-object Net.Mail.SmtpClient($smtpServer)
  41. $msg.From = $MailFrom
  42. $msg.To.Add("it@domain.com")
  43. $msg.Subject = "Potential issue on web"
  44. $MailTextT = "PS script has killed jrun 10 times on web in the last 24 hours!"
  45. $msg.Body = $MailTextT
  46. $smtp.Send($msg)
  47. $count = 0
  48. write-host "________________________"
  49. $last_restart = $restart
  50. $restart = get-date
  51. }
  52. }
  53. while (1 -eq 1)
Add Comment
Please, Sign In to add comment