Check_MK check to show some data about Ex2010 mailbox databases

A few days ago I finished to test a new check for check_mk and published it as package at Check_MK Exchange. I named the check "Ex2010_MBDB_Info". In this article I'd like to share a couple of details about the check and its functionality.

The purpose of the check is to get the size of mailbox databases and the count of the mailboxes in each of them. The check package consists of the check itself, the plugin for check_mk agent, the perf-o-meter helper file and the pnp-template.

The plugin It must run on an Exchange 2010 server that the role Mailbox server is installed and running on. The plugin is a cmd file, which calls some Powershell commands, which try to collect information from local  (!) server about the size of the mailbox databases, which are located on the same server, and about the count of the mailboxes, which belong to the mailbox databases.
The plugin for the check_mk agent must be copied in the sub-directory "plugins" of the installed check_mk agent, typically under c:\programm files(x86)\check_mk\plugins.

The check itself has the ability to find all mailbox databases, which reside on the server with the copied plugin, while you carry out an inventory of the Exchange 2010 mailbox database server. The check creates a new service for each mailbox database found. The check's status is 'OK' always and the output is the size of the mailbox database (in MBytes or GBytes) and the count of the mailboxes, which reside in the mailbox database.

Additionally a perf-o-meter and a PNP-template belong to the check. They help you to visualize the data collected during a longer time period and to recognize trends.

Below is an example screenshot of the check in the check_mk interface:












21 Kommentare :: Check_MK check to show some data about Ex2010 mailbox databases

  1. Hi,
    I attempted to run this with check_mk, ran into a problem however and manually running the command threw up this error " <<>>
    The term '%%' is not recognized as the name of a cmdlet, function, script file,
    or operable program. Check the spelling of the name, or if a path was included
    , verify that the path is correct and try again.
    At line:1 char:179"

  2. Hm... please make sure, the cmd-file consists only of one line of code. Hier is the line:

    "C:\Windows\Sysnative\WindowsPowerShell\v1.0\powershell.exe" -Command "& { Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010 ; Write-Host '<<>>' ; $DBS = Get-MailboxDatabase -Status -Server (hostname) ; $DBS | %% { '{0,-10} {1,-20} {2, -6}' -f $_.name, ($_.Databasesize -replace ',', ''-replace '^.*\((.*) bytes\)', '$1'), (Get-MailboxStatistics -Database $_.name|where { $_.DisconnectReason -ne 'SoftDeleted' }).count }; }"

    To run the command file local to verify it, copy the file outside of the plugin directory and change the code from "C:\Windows\Sysnative" to "C:\Windows\system32".

  3. Thanks for your plugin, is very good. I have a little problem. When I get the mailbox check_mk, appears a service called MailBoxDB Mailbox with status: UNKNOWN - invalid output from agent, invalid check parameters or error in implementation of check Ex2010_MBDB_Info. Please set debug_log to a filename in main.mk for enabling exception logging.

    In the debug file appears:
    /var/log/nagios/check_mk_debug.log

    Host: XXXXX
    Service: MailBoxDB Mailbox
    Check type: Ex2010_MBDB_Info
    Item: 'Mailbox'
    Parameters: None
    Traceback (most recent call last):
    File "/var/lib/check_mk/precompiled/XXXXX", line 675, in do_all_checks_on_host
    ^A^N^B^P^A ^A ^A^F^A
    File "/var/lib/check_mk/precompiled/XXXXXX", line 1025, in check_Ex2010_MBDB_Info
    ValueError: invalid literal for int() with base 10: 'Database'

    Agent info: [['Mailbox', 'Database', '2146388325', '142671872', '4'],
    ['ex_level1', '142671872'],
    ['ex_level1', '8454144'],
    ['ex_level2', '8454144'],




  4. Hi Anonymous,
    please try to execute the plugin on the mail server and post the output here. Consider my comment above yours.
    BR

  5. Hi

    great plugin....

    How can the Exchange Server Load minimized (which is caused by this plugin)? If the script runs every 60sec on the Exchange Server, the Server average CPU Usage is rised by ca. 10%. Kind regards
    Michael

  6. thank you, glad to hear this :-)
    yes, I know the issue, but I have no idea, how the requests in the powershell script can be done more smoothly. If you've found a solution, please share it.

  7. at the Moment i did change the Interval for Service Check in the Check_MK WATO Config. I set it now to 900 s instead of 60 s. But i am not sure, if this is realy live now. I will inform you. The second this we are testing now is how should we monitor with this script a DAG Environment. I will also update all of you

    Michael Bänteli

    21 January, 2013 13:10

  8. Hi

    I created a rule in WATO for "Normal check interval for service checks" for the Service "MailBoxDB" with 15 Minutes inteval. Now the load is only a Little bit higher than without this script.

    Actually we are on the way to figure out the modifcations for a DAG.

    Michael

  9. Script with Modification for DAG

    "C:\Windows\Sysnative\WindowsPowerShell\v1.0\powershell.exe" -Command "& { Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010 ; Write-Host '<<>>' ; $DAG = (Get-MailboxServer (hostname)).DatabaseAvailabilityGroup.ToString() ;$DBS = Get-MailboxDatabase -Status $DAG* ;$DBS | %% { '{0,-10} {1,-20} {2, -6}' -f $_.name, ($_.Databasesize -replace ',', ''-replace '^.*\((.*) bytes\)', '$1'), (Get-MailboxStatistics -Database $_.name).count }; }"

    With this script the hole DAG can be monitored, without the Need to run this script on any DAG Member Server.

    A specail thanks to me work collegue in UK.

    Michael

  10. Michael, thank you very much for sharing your changes regarding the checking of a DAG! I can imagine it could be possible to unite the both checks in one only.

  11. Hi, I have the same problem as Andrew Bootsma, the proposed solution did not work (its only one line of code, I also tried the line you provided in your answer - same error). Here is a copy of my commandline and the result:

    C:\>"C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe" -Command "& { Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010 ; Write-Host '<<>>' ; $DBS = Get-MailboxDatabase -Status -Server sbstx200 ; $DBS | %% { '{0,-10} {1,-20} {2, -6}' -f $_.name, ($_.Databasesize -repl
    ace ',', ''-replace '^.*\((.*) bytes\)', '$1'), (Get-MailboxStatistics -Database $_.name).count }; }"
    <<>>
    Die Benennung "%%" wurde nicht als Name eines Cmdlet, einer Funktion, einer Skriptdatei oder eines ausführbaren Programms erkannt. Überprüfen Sie die Schreibweise des Namens, oder ob der Pfad korrekt ist (sofern enthalten), und wiederholen Sie den Vorgang.
    Bei Zeile:1 Zeichen:168
    + & { Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010 ; Write-Host '<<>>' ; $DBS = Get-MailboxDatabase -Status -Server sbstx200 ;
    $DBS | %% <<<< { '{0,-10} {1,-20} {2, -6}' -f $_.name, ($_.Databasesize -replace ',', ''-replace '^.*\((.*) bytes\)', '$1'), (Get-MailboxStatistics -Database
    $_.name).count }; }
    + CategoryInfo : ObjectNotFound: (%%:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

    Do you have any suggestion? Thank you!
    Manfred

  12. OK, I've released a new version of the plugin. Please look at a new article in blog.

  13. I've tried the same solution for the high server load as Michael Bänteli (I need this check only once a day), the rule is working (no checks since, next check in 16 hours), but on the server the script runs every minute (25% CPU), the agent check needs ca. 10 sec (without this script 0,2). Maybe this is the way check_mk works (execute any script in the plugins-folder every time the agent-check runs)? Or have I missed something?

    Manfred

  14. Thank you for your Plugin. I have the same problem with the "UNKNOWN - invalid output from agent, invalid check parameters or error in implementation of check Ex2010_MBDB_Info. Please set debug_log to a filename in main.mk for enabling exception logging" at the Webfrontend.
    cmk -d Exchange2010: shows the correct info.
    <<>>
    Mailbox Database 1965957315 786839040 9

    The plugin on the Exchange-Server run fine.
    Can anyone help me?

    Matthias

  15. I've released a new corrected version, which should be robuster and not stumble upon spaces in mailbox database names. Please look at the newest article for more details.

  16. This comment has been removed by the author.
  17. I'm running version 1.32 and after removing an extra } character from the powershell command that sits in the plugins directory, it looks like it should work. However i get this error in the debug log:

    Invalid output from plugin or error in check:
    Check_MK Version: 1.2.0p2
    Date: 2013-25-10 16:58:58
    Host: pnexch01.pn.local
    Service: MailBoxDB DB04
    Check type: Ex2010_MBDB_Info
    Item: 'DB04'
    Parameters: None
    Traceback (most recent call last):
    File "/omd/sites/pn/var/check_mk/precompiled/pnexch01.pn.local", line 675, in do_all_checks_on_host

    File "/omd/sites/pn/var/check_mk/precompiled/pnexch01.pn.local", line 1030, in check_Ex2010_MBDB_Info
    AttributeError: 'str' object has no attribute 'format'

    Agent info: [['DB02', '214354165760', '55'],
    ['DB01', '58795819008', '16'],
    ['DB03', '140534415360', '117'],
    ['DB04', '192745635840', '51']]


    I checked though, the problem is version of python < 2.6. My OMD box is still on centos 5.8. I'm rebuilding as we speak.

  18. Everybody, please note that I created this check for the version 1.1.12 of Check_MK. I neither have tried the check under the version 1.2 of Check_MK or above nor I have any experiences with the current version of Check_MK.

  19. Hi Hermann,

    is there an new version of your script available that works with works with cmk 1.2.6?

  20. Hello,

    I'm a newbie working with OMD check_mk. The cmk -P install of the MPK does not seems to work on OMD. SO i put the files manually in the paths needed.

    Now my question is, how can i make it work on OMD check_mk?

  21. Thank You and that i have a dandy give: Whole House Renovation Checklist Pdf home addition contractors

Post a Comment