on 12-09-2012 07:34 AM
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:
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.
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!
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!
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 !
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
And, out of curiosity, what other monitoring scripts you have? Specifically for EV...
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
Do you have the cluster name in the EVServers.txt file or just the physical server name(s)?
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.
Has anyone seen a script that can purge the msmqs?
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:
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.
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!
hello all
what do these below lines represents exactly? i didnt manage to figure out.
what do $warning = 85
$critical = 90
thanks