Check_mboxsize.ws
Another Nagios plugin. One of my hardest to write.
Note that this will require the Nagios Plugin Service to run as a Administrator Account (local system account) will
not work!
Script example:
…nagios/libexec# ./check_nrpe -H SERVER114 -t 90 -u -c get_top_mbox -a SERVER114 3 2000 4000
WARNING – Full Name, Mona , 2.517,00 MB – San Pil, Eric , 1.175,00 MB – Cabo Boiola, Manul , 991,00 MB
Always run the command localy to test if it works, then from nagios cmd line then define it.
The arguments of the command are:
c:cscript check_mboxsize.wsg -h -t -w -c
ex:
c:cscript check_mboxsize.wsg -h SERVER10 -t 5 -w 900 -c 2000
will report the top 5 largest mailboxes and will trhow a warn if over 900mbs and critical if over 2gb.
More information on how to configure NRPE commands and Nagios commands here
get_top_mbox is defined inside nrpe.cfg to point and pass arguments to the script.

Download code

Tags: , , , , , , ,

15 thoughts on “Check Exchange Mailbox Size

  1. Hey, could you give me more informations regarding this check ?
    you give the check_mboxsize script but in your command I cannot see that name … ??? Could you help me ?

  2. @Luc
    I don’t mind helping. I appreciate being able to use this script (Thanks to Mr. Ferreira for writing it) and want others to be able to enjoy it.
    In order to use it, you need to have several things configured:
    1. The NRPE client on the exchange server
    2. The command defined in Nagios
    3. The service check set up for the host
    Examples:
    1. I use NSClient++, so my NSC.ini file contains this
    ;# Checks largest mailboxes in Exchange
    command[check_mboxsize]=c:winntsystem32cscript.exe //NoLogo //T:40 “C:Program FilesNSClient++scriptscheck_mboxsize.wsf” -t $ARG1$ -w $ARG2$ -c $ARG3$ -h
    Check that the path is right for your setup. You might have windows instead of winnt.
    2. Your Nagios config should include this with your other commands:
    define command{
    command_name check_mboxsize
    command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -t 60 -u -c check_mboxsize -a $ARG1$ $ARG2$ $ARG3$
    }
    3.
    define service{
    use email-service
    host_name
    service_description largest_mailboxes
    display_name Largest Mailboxes
    check_command check_mboxsize!6!450!500
    }
    Note that if you don’t have an email-service template, you should either make one or use something else. Use the arguments in the check_command line that make the most sense for your situation.
    Enjoy.

  3. @kaeves
    Edit:
    The following line should read
    “C:Program FilesNSClient++scriptscheck_mboxsize.wsf” -t $ARG1$ -w $ARG2$ -c $ARG3$ -h

  4. @kaeves
    Ok. I see why it took that out. HTML is disabled so it didn’t like my > and <
    After the -h it should have the hostname of your exchange server.
    Also in part 3, after host_name it should have the same.

  5. I just wanted to thank you very much for this indepth article. I have already bookmarked your site, when I have more free time I am going to have to do some further browsing. Well back to my dreaming of Panama or back to the books – I wonder which one is going to win out. 🙂

  6. Hi,
    First I want to Thank you for this great script, I’m dying to put it to good use. This brings me to my issue. I have copied the script over to the server which I obtained from the link above. When I run the following from the command prompt:
    cscript check_mboxsize.wsf -t 5 -w 900 -c 2000 -h server1
    I get the following error:
    check_mboxsize.wsf(120, 4) ClogQueryClass: Error parsing query: Syntax Error: : expecting FROM keyword instead of token ‘FilesNSClient++scriptslog_.txt’ [SQL query syntax invalid or unsupported.]
    NSClient++ is running as a user with Administrator privileges. Am I suppose to edit something in the script or did I miss anything?
    Thanks for any help you provide 🙂

    1. Vicort,
      Its hard for me to tell exaclty where is the problem but I recommend u go inside the script and
      change it do debug mode and run locally on the exchange server
      Dim Verbose : Verbose = 1 ‘########### SET 1 FOR DEBUG MODE #####
      Check the Query, maybe its malformed or u have some non-standard location of ur storages….

  7. @admin
    Hi, it has been a while 🙂 .. I left this on the backburner and I recently remembered..I changed the verbose to 1 as you suggested and I get the following returned:
    cscript check_mboxsize.wsf -t 5 -w 900 -c 2000 -h server1
    Microsoft (R) Windows Script Host Version 5.6
    Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.
    0 – -t
    1 – 5
    2 – -w
    3 – 900
    4 – -c
    5 – 2000
    6 – -h
    7 – server1
    Querying : , SMTP LogFile : 20100301.log , for over 1 emails sent
    C:Program FilesNSClient++scriptscheck_mboxsize.wsf(120, 4) CLogQueryClass: Error
    parsing query: Syntax Error: : expecting FROM keyword instead
    of token ‘FilesNSClient++scriptslog_.txt’ [SQL query syntax invalid or unsupported.]

  8. Victor :
    Hi,
    First I want to Thank you for this great script, I’m dying to put it to good use. This brings me to my issue. I have copied the script over to the server which I obtained from the link above. When I run the following from the command prompt:
    cscript check_mboxsize.wsf -t 5 -w 900 -c 2000 -h server1
    I get the following error:
    check_mboxsize.wsf(120, 4) ClogQueryClass: Error parsing query: Syntax Error: : expecting FROM keyword instead of token ‘FilesNSClient++scriptslog_.txt’ [SQL query syntax invalid or unsupported.]
    NSClient++ is running as a user with Administrator privileges. Am I suppose to edit something in the script or did I miss anything?
    Thanks for any help you provide
    UN:F [1.7.5_995]

    please wait…
    Rating: 0.0/5 (0 votes cast)

    Did you ever fix this issue?
    I am runnign into same issue and have CLogQueryClass. installed

    1. have u tried running it localy? did it work?
      read inside the script you may need to create a folder or set some variables.
      cheers,
      Felipe

  9. Not long ago, I was searching about the related subject but could not truly find it out. In all appreciation for this one.

  10. I have everything working with this script as far as connectivity to nagios. However when launching localy or even though nagios I get the following error.
    Querying : , SMTP LogFile : 20101125.log , for over 1 emails sent
    Can anyone shed some light on this one for me?

  11. Hi,
    I’m facing the same problem as Victor and eugene.
    My command looks like this:
    cscript check_emailers.wsf -t 5 -w 1000 -c 3000 -h winexch01
    As output I receive
    0 – -t
    1 – 5
    2 – -w
    3 – 1000
    4 – -c
    5 – 3000
    6 – -h
    7 – winexch01
    Querying : , SMTP LogFile : 20101200.log , for over 1 emails sent
    C:Program FilesNSClient++scriptscheck_emailers.wsf(121, 4) CLogQueryClass: Error parsing query: Syntax Error: : expecting FROM keyword instead of token ‘FilesNSClient++scriptslog_.txt’ [Syntaxe de requête SQL non valide ou non prise en charge.]
    If I look at this line:
    Querying : , SMTP LogFile : 20101200.log , for over 1 emails sent
    and then look into the code:
    DisplayMsg( “Querying : ” & serverOUT & ” , SMTP LogFile : ” & nomelog & “.log , for over ” & intSpamMin & ” emails sent” )
    It appears to me that serverOUT is empty and nomelog 20101200.log
    Instead of these value should it be winexch01 for serverOUT and 20101201.log for nomelog as I run it the first december 2010?
    Did someone managed to get rid of this error?

Comments are closed.