开发者

How can I monitor the Exchange 2003 Event Service from my application?

开发者 https://www.devze.com 2022-12-18 11:26 出处:网络
We had our server guys set up something on Exchange so t开发者_如何学Gohat for a particular email address, any attachments sent to it will be dumped to a location on the file server.

We had our server guys set up something on Exchange so t开发者_如何学Gohat for a particular email address, any attachments sent to it will be dumped to a location on the file server.

The Exchange Event Service controls this behaviour, but it seems that this particular service fails fairly often. I dont know why - I dont have access to the Exchange server and it is run by a team in a different country.

Is it possible to monitor this exchange service programatically so I can warn the users if it goes down? I know that the 'right' solution is to have this handled by the Exchange team, but because of the timezone differences (and their massive workload) I really need to handle it from my end.

Could you do something like this with WebDav?


You could use the following powerShell script:

# Getting status of Exchange Services and look for anything that's "stopped"
$ServiceStatus = get-service MSExch* | where-object {$_.Status -eq "stopped"}

# Convert Result to String
$ServiceStatusText = $ServiceStatus | fl | Out-String

# If $ServiceStatus <> $null then send notification
If ($ServiceStatus -ne $null)
 {
 ###Exchange Server Values
 $FromAddress = "Exchange-Alert@YOUR_DOMAIN.local"
 $ToAddress = "your_address@YOUR_DOMAIN.com"
 $MessageSubject = "CRITICAL: An exchange service is has stopped"
 $MessageBody = "One or more Exchange services has stopped running or crashed. Please check the server ASAP for possible issues`n"
 $MessageBody = $MessageBody + $ServiceStatusText

 $SendingServer = "msexch02.pnlab.local"

 ###Create the mail message and add the statistics text file as an attachment
 $SMTPMessage = New-Object System.Net.Mail.MailMessage $FromAddress, $ToAddress, $MessageSubject, $MessageBody

 ###Send the message
 $SMTPClient = New-Object System.Net.Mail.SMTPClient $SendingServer
 $SMTPClient.Send($SMTPMessage)
}

# Else don't do anything and exit
Else
  {
  $null
  }
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号