cancel
Showing results for 
Search instead for 
Did you mean: 
AKL
Level 6
Certified

Hello All

Today I ran into following forum about monitoring for Enterprise vault Message queue via Powershell and this post is in regard to same i.e. sharing a  script that will help you monitor enterprise vault MSMQ.

https://www-secure.symantec.com/connect/forums/powershell-retrieving-message-count-msmq-queues

The output of script will look something like below:

http://sdrv.ms/RCDQ0S

The zip file includes:
  1. MonitorMSMQ.ps1: This is the main powershell script which will monitor MSMQ for all EV servers mentioned in the text file.
  2. EVServers.txt: Contains list of all EV servers that you wish to monitor using this script.
  3. MonitorMSMQ.bat: This file is created if you wish to create scheduled job or something. It basically calls out for powershell and the ps1 script.
Variable parameters within ps1 script:
  • $MSMQFileName = "C:\HTML\EV_MSMQ.htm" - Locatio n of the HTML file
  • $serverlist = "C:\TXT\EVServers.txt" – Location of the txt file
  • $queuecountwarning = 100 – Count of messages in MSMQ that should generate warning message.
  • $queuecountcritical = 200 – Count of messages in MSMQ that should generate critical alert.
  • $queuesizewarning = 10 – Size of messages in MSMQ that should generate warning message. (in MB)
  • $queuesizecritical = 20 – Size of messages in MSMQ that should generate crtical alert. (in MB)
  • $smtphost = "10.0.0.1" - Relay server with anonymous authentication to Send email
  • $from = OperationsManager@contoso.com - From address
  • $to = Administrator@contoso.com - To address
  • $subject = "PLEASE ACTION: Enterprise Vault MSMQ Monitor" - Subject line.

Note: If you're running Enterprise vault server on a Windows 2003 machine, you might have to install the WMI class manually first using Add/remote windows components wizard.

Hope you find it helpful. Please let me know if you run into any issues with configuring same.

Comments
GertjanA
Moderator
Moderator
Partner    VIP    Accredited Certified

Hello AKL!

I just tested it on 1 machine. Really good!

I like the coloring, it immediately shows a possible issue with a queue.

As I am not a coder, a 'layout' question.

In the column Queue Name, you list the complete queuename.For example:

Servername\private$\enterprise vault storage archive

Would it be possible to remove the Servername\private$ in that column?

If not, can I adjust the width of the columns, so the report is a little more 'truncated'?

But, thumbs up!

And, is it perhaps possible (one way or the other) to filter rows? In your ps1 script, you give the possibility to enter a $queuecountwarning. If a queue is below this given value, can it be left out? I have for instance another check, which only shows queues ABOVE the threshold. Does that make sense?

I'll do some investigation myself, to see if I can figure this out, but if you have an idea, that would be great!

GertjanA
Moderator
Moderator
Partner    VIP    Accredited Certified

Additional Comment.

I changed the percentages for the rows to make the report more 'readable'

param($fileName) 
 Add-Content $fileName "<tr bgcolor=#CCCCCC>"
 Add-Content $fileName "<td width='5%' align='center'>Server Name</td>"
 Add-Content $fileName "<td width='50%' align='center'>Queue Name</td>"
 Add-Content $fileName "<td width='11%' align='center'>Message Count in Queue</td>"
 Add-Content $fileName "<td width='11%' align='center'>Message Size in Queue (MB)</td>"
 Add-Content $fileName "<td width='11%' align='center'>Message Count in Journal Queue</td>"
 Add-Content $fileName "<td width='11%' align='center'>Message Size in Journal Queue (MB)</td>"
 Add-Content $fileName "</tr>"

In addition, I commented out the lines as indicated below, and changed the ElseIf into an IF. I noticed that when running the batchfile, it pust output to the screen stating "No Action Required". As I run this via a scheduled task, there is no use to have this output to screen.

# COMMENT OUT if ($queuec -lt $queuecountwarning) {Write-Host "No Action Required"}
  If ($queuec -ge $queuecountcritical) {$email_critical += '1'}
  Else {$email_warning += '1'}
#COMMENT OUT if ($queues -lt $queuesizewarning) {Write-Host "No Action Required"}
  If ($queues -ge $queuesizecritical) {$email_critical += '1'}
  Else {$email_warning += '1'}

 

I am still looking for something to make sure the order of the queues is correct. I notice that sometimes it shows queue A5, then A7, then A1 etc. For me, it would be more practical to see the order as they are listed on the server itself. (A1/A2/A3 etc).

But, works like a charm!

AKL
Level 6
Certified

Thanks a lot Gertjan for the modifications made to make the query better and stable. I apologize for late response.

For remaining points:

To Leave out the queues that are below threshold values.

You can replace below line in original script:

writememInfo $MSMQFileName $server $queuen $queuec $queues $queuejc $queuejs

With this line:

If (($queuec -ge $queuecountwarning) -and ($queues -ge $queuesizewarning)) {writememInfo $MSMQFileName $server $queuen $queuec $queues $queuejc $queuejs}

This will make sure only queues that are above thresholds are reported in email.

I must say, this idea was BRILLIANT and it helped me update remaining of my monitoring scripts as well. The filtered results are easier to view on smartphones and we don't have to scroll through complete thing now !

To Sort the queues with their names.

Replace below line in original script

$queues = Get-WmiObject -Class Win32_PerfRawData_MSMQ_MSMQQueue -ComputerName $server | Where-Object {$_.Name -like "*Enterprise Vault*"}

With this line

$queues = Get-WmiObject -Class Win32_PerfRawData_MSMQ_MSMQQueue -ComputerName $server | Where-Object {$_.Name -like "*Enterprise Vault*"} | Sort-Object -Property Name

I should've thought that in first place, it's a good learning point.

Lastly, Truncating name of queue is something I didn't spend much time on yet as it is tricky to truncate the strings and I haven't played with string values a lot so far. I'll try to update that as well, but however I hope that it is just tailoring correction and it doesn't reduces script's ability for monitoring.

Thanks again for the ideas - They helped a lot !

GertjanA
Moderator
Moderator
Partner    VIP    Accredited Certified

Hello AKL,

Fantastic! I am not (yet) a Powershell Guru, so thanks for looking into this.

Last (I think question/remark).

The report now indeed shows only queues larger than the value as given. However, when there is a server where all queues are less than the value, it only shows a greybar with the headings. See JPG for example.

Would it be possible to add the servername to the header "ServerName"? and/or

Would it be possible to add a line like: "no queues over threshold on "servername" " when a server has no queues below the threshold?

I assume you uploaded the edited PS1 to your initial post?

Thanks again!

Gertjan

 

 

 

GertjanA
Moderator
Moderator
Partner    VIP    Accredited Certified

And, out of curiosity, what other monitoring scripts you have? Specifically for EV...

Victor_Geyyer_2
Level 3

Hello,

I have a quick question: the script is using the following WMI query:

Get-WmiObject -Class Win32_PerfRawData_MSMQ_MSMQQueue -ComputerName $server | Where-Object {$_.Name -like "*Enterprise Vault*"}

Which seems to be working only for stand alone MSMQ.

Does anybody have a success to have this work in the clustered MSMQ?

Thank you in advance,

Victor

jgorman
Level 2
Certified

Do you have the cluster name in the EVServers.txt file or just the physical server name(s)?

Victor_Geyyer_2
Level 3

Get-WmiObject -Class Win32_PerfRawData_MSMQ_MSMQQueue -ComputerName $server | Where-Object {$_.Name -like "*Enterprise Vault*"}

will not return any results if MSMQ is clustered.  It works only for standalone MSMQ.

 

 

VictorK
Not applicable

Has anyone seen a script that can purge the msmqs?

AKL
Level 6
Certified

Hello All

Sorry for "long" delay in response but I was swarmed up in recent few weeks, either way, I've updated the main zip file attached with the original post.

Updates Made:

  1. Remove initial common characters like "\server\private" from name: I've added a line in script (mentioned below) which strips off first 20 characters from queue name for making it look more compact. The figure 20 was for my environment, you'll have to edit it based on your organization requirement: $queuen = $queuen.Substring(20)
  2. Added server name to header: As requested earlier, if no queue to report, script will still add server name in header for ease of read (cosmetic change)
  3. All other updates which've been discussed originally have been incoroporated into main file.

Apart from same, though I couldn't make to blog but I was still reading updates via email. Unfortunately I haven't been able to figure out WMI class for clustered MSMQ yet, as soon as I get some information on same, I'll update here accordingly.

For purging MSMQ, we can add the code in script but I won't recommend purging of MSMQ to be automated task because it is very rare occassion when you've to purge EV MSMQ or any other application queues. If you're facing that issue frequently due to which you've a need to automate it, I'll recommend troubleshooting why issue has been happening frequently and remediate accordingly.

Please let me know if any further changes required in script - cosmetic or functionality.

GertjanA
Moderator
Moderator
Partner    VIP    Accredited Certified

Hello AKL,

I found that it is needed to also add the $freeSpaceFileName variable as follow:

$MSMQFileName = "D:\gertjan\MSMQCheck\LastVersion\Result\EV_MSMQ.htm"
$freeSpaceFileName = "D:\gertjan\MSMQCheck\LastVersion\Result\EV_MSMQ.htm"
$serverlist = "D:\gertjan\MSMQCheck\LastVersion\EVServers.txt"
$queuecountwarning = 100
$queuecountcritical = 200
$queuesizewarning = 10
$queuesizecritical = 20
$email_warning = 0
$email_critical = 0

If not, you get an error about a path.

I also re-adjusted the percentages in section: Function writeTableMemHeader to improve the layout (as below)

param($fileName) 
 Add-Content $fileName "<tr bgcolor=#CCCCCC>"
 Add-Content $fileName "<td width='5%' align='center'>Server Name</td>"
 Add-Content $fileName "<td width='50%' align='center'>Queue Name</td>"
 Add-Content $fileName "<td width='11%' align='center'>Message Count in Queue</td>"
 Add-Content $fileName "<td width='11%' align='center'>Message Size in QUeue (MB)</td>"
 Add-Content $fileName "<td width='11%' align='center'>Message Count in Journal Queue</td>"
 Add-Content $fileName "<td width='11%' align='center'>Message Size in Journal QUeue (MB)</td>"
 Add-Content $fileName "</tr>"

For the rest A+OK!

Danyro
Level 1

hello all 

what do these below lines represents exactly? i didnt manage to figure out.

what do $warning = 85
$critical = 90

thanks

 

Version history
Last update:
‎12-09-2012 07:34 AM
Updated by: