{"id":403,"date":"2013-04-24T11:54:32","date_gmt":"2013-04-24T09:54:32","guid":{"rendered":"http:\/\/dety.net.ua\/?p=403"},"modified":"2015-05-26T16:52:03","modified_gmt":"2015-05-26T14:52:03","slug":"exchange-2010-queue-monitoring","status":"publish","type":"post","link":"https:\/\/dety.net.ua\/?p=403","title":{"rendered":"Exchange 2010 + queue monitoring"},"content":{"rendered":"<p>Sometimes the network or other issues happen and cause queues growing.<\/p>\n<p>So I need to monitor this incident.<\/p>\n<p>This powershell script helps me:<\/p>\n<blockquote><p>$FromAddress = &#8220;postmaster@domain.com&#8221;<br \/>\n$ToAddress = &#8220;postmaster@domain.com&#8221;<br \/>\n$MessageSubject = &#8220;Queues Report&#8221;<br \/>\n$MessageBody = &#8220;Attached is the current queues.&#8221;<br \/>\n$SendingServer = &#8220;mail-server&#8221;<\/p>\n<p>$queue = Get-Queue -Filter {MessageCount -gt 5} | fl<br \/>\nif ($queue)<br \/>\n{<br \/>\nwrite-output $queue<\/p>\n<p>$MessageBody = echo $queue | Out-String<br \/>\n$SMTPMessage = New-Object System.Net.Mail.MailMessage $FromAddress,$ToAddress,$MessageSubject,$MessageBody<\/p>\n<p>$SMTPClient = New-Object System.Net.Mail.SMTPClient $SendingServer<br \/>\n$SMTPClient.Send($SMTPMessage)<br \/>\nc:\\plink -ssh -batch -l user -pw password user@192.168.0.200 sendsms 380501000000 &#8216;Exchange-queue-problem&#8217;<br \/>\n}<\/p><\/blockquote>\n<p>It&#8217;s scheduled to start and repeat every 5 minutes.<\/p>\n<p>If queue length is over 5 letters it sends message to e-mail and sms-gate(see my previous article) with command via\u00a0 plink.<\/p>\n<p>P.S.: command string to add this to scheduler:<\/p>\n<blockquote><p>C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe -command &#8220;. &#8216;C:\\Program Files\\Microsoft\\Exchange Server\\V14\\bin\\RemoteExchange.ps1&#8217;; Connect-ExchangeServer -auto; c:\\Scripts\\QueueCheck.ps1<\/p><\/blockquote>\n<p>P.P.S.:\u00a0new version of the script with ShadowRedundancy filtering:<\/p>\n<blockquote><p>$FromAddress = &#8220;reporter@domain.com&#8221;<br \/>\n$ToAddress = &#8220;admin@domain.com&#8221;<br \/>\n$MessageSubject = &#8220;Queues Report&#8221;<br \/>\n$MessageSubject2 = &#8220;Shadow Queues Report&#8221;<\/p>\n<p>$MessageSubject3 = &#8220;Retry Queues Report&#8221;<br \/>\n$MessageBody = &#8220;Attached is the current queues.&#8221;<br \/>\n$SendingServer = &#8220;SERVER&#8221;<\/p>\n<p># Checking only current flow<br \/>\n$queue = Get-Queue -Filter {messagecount -gt 20 -and DeliveryType -ne &#8220;ShadowRedundancy&#8221;} | fl<br \/>\nif ($queue)<br \/>\n{<br \/>\nwrite-output $queue<\/p>\n<p>$MessageBody = echo $queue | Out-String<br \/>\n$SMTPMessage = New-Object System.Net.Mail.MailMessage $FromAddress,$ToAddress,$MessageSubject,$MessageBody<\/p>\n<p>$SMTPClient = New-Object System.Net.Mail.SMTPClient $SendingServer<br \/>\n$SMTPClient.Send($SMTPMessage)<br \/>\nc:\\backup\\plink -ssh -batch -l user -pw pass user@192.168.0.200 sendsms 38050000000 &#8216;Exchange-queue-problem&#8217;<br \/>\n}<\/p>\n<p># Checking ShadowRedundancy only<br \/>\n$queue = Get-Queue -Filter {messagecount -gt 50 -and DeliveryType -eq &#8220;ShadowRedundancy&#8221;} | fl<br \/>\nif ($queue)<br \/>\n{<br \/>\nwrite-output $queue<\/p>\n<p>$MessageBody = echo $queue | Out-String<br \/>\n$SMTPMessage = New-Object System.Net.Mail.MailMessage $FromAddress,$ToAddress,$MessageSubject2,$MessageBody<\/p>\n<p>$SMTPClient = New-Object System.Net.Mail.SMTPClient $SendingServer<br \/>\n$SMTPClient.Send($SMTPMessage)<br \/>\nc:\\backup\\plink -ssh -batch -l user -pw pass user@192.168.0.200 sendsms 38050000000 &#8216;Exchange-Shadowqueue-problem&#8217;<br \/>\n}<\/p>\n<p># Checking Retries<br \/>\n$queue = get-transportserver | get-queue -Filter { Status -eq &#8220;Retry&#8221; }<br \/>\nif ($queue)<br \/>\n{<br \/>\nwrite-output $queue<\/p>\n<p>$MessageBody = echo $queue | Out-String<br \/>\n$SMTPMessage = New-Object System.Net.Mail.MailMessage $FromAddress,$ToAddress,$MessageSubject3,$MessageBody<\/p>\n<p>$SMTPClient = New-Object System.Net.Mail.SMTPClient $SendingServer<br \/>\n$SMTPClient.Send($SMTPMessage)<br \/>\n}<\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>Sometimes the network or other issues happen and cause queues growing. So I need to monitor this incident. This powershell script helps me: $FromAddress = &#8220;postmaster@domain.com&#8221; $ToAddress = &#8220;postmaster@domain.com&#8221; $MessageSubject = &#8220;Queues Report&#8221; $MessageBody = &#8220;Attached is the current queues.&#8221; $SendingServer = &#8220;mail-server&#8221; $queue = Get-Queue -Filter {MessageCount -gt 5} | fl if ($queue) { [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,13],"tags":[],"class_list":["post-403","post","type-post","status-publish","format-standard","hentry","category-exchange","category-novosti"],"_links":{"self":[{"href":"https:\/\/dety.net.ua\/index.php?rest_route=\/wp\/v2\/posts\/403","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dety.net.ua\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dety.net.ua\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dety.net.ua\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dety.net.ua\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=403"}],"version-history":[{"count":7,"href":"https:\/\/dety.net.ua\/index.php?rest_route=\/wp\/v2\/posts\/403\/revisions"}],"predecessor-version":[{"id":712,"href":"https:\/\/dety.net.ua\/index.php?rest_route=\/wp\/v2\/posts\/403\/revisions\/712"}],"wp:attachment":[{"href":"https:\/\/dety.net.ua\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=403"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dety.net.ua\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=403"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dety.net.ua\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=403"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}