New Question
 
 
PRTG Network Monitor

Intuitive to Use.
Easy to manage.

200.000 administrators have chosen PRTG to monitor their network. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free PRTG
Download >>

 

What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general. You are invited to get involved by asking and answering questions!

Learn more

 

Top Tags


View all Tags


Count Exchange mailbox by day

Votes:

0

Your Vote:

Up

Down

Hello,

PRTG have not a specific sensor for count the number of received email in specific mailbox for analyse the statistics by day.

I want a total number to incoming emails on specific mailbox, by day.

(I already use the sensor for count the number of email in folder inbox but it'is different to know the number of received emails by day)

I do not expect a prtg/Paessler response because I know there is no sensor for this, but I'm looking for an answer from other PRTG users.

The need is to simply know the number of mail received per day on a specific mailbox, and to have the number 1 times a day.

thank you

count exchange-2010 statistics

Created on Dec 19, 2016 9:03:20 AM by  DIMITRI (0) 1

Last change on Dec 19, 2016 12:24:12 PM by  Sven Roggenhofer [Paessler Technical Support]



5 Replies

Accepted Answer

Votes:

7

Your Vote:

Up

Down

Dear DIMITRI,

Thank you very much for your KB-post.

My colleague Dieter wrote a script which should help you with your request. Using this script you can use PRTG´s native EXE/Script Advanced Sensor.

  • Please save this script as Get-MailcountReceivedYesterdayTodayForUser.ps1 under C:\Program Files (x86)\PRTG Network Monitor\Custom Sensors\EXE
  • Deploy a EXE/Script Advanced Sensor to your Exchange device
  • Please use the following syntax for the parameter-setting within PRTG:
    • -server <fqdn of the server> -user <loginname> -pass <password> -recipient <smtp-address to check for mails>
  • Save the settings.
    Please let us know if this works fine for you.

Kind regards,
Sven

Param(
    $server,
    $user, 
    $pass,
    $recipient
)

<# use the following syntax for the parameter-setting within PRTG:
    -server <fqdn of the server> -user <loginname> -pass <password> -recipient <smtp-address to check for mails>
or simple to use presets within the device:
    -server %host -user %windowsdomain\%windowsuser -pass %windowspassword -recipient <smtp-address to check for mails>
#>

$prtg = ‘<?xml version="1.0" encoding="utf-8" ?> 
<prtg> 
‘ 

try {
    $secPw = ConvertTo-SecureString $pass -AsPlainText -Force
    $credential = New-Object System.Management.Automation.PSCredential ($user, $secPw)

    $Session = New-PSSession -ConfigurationName Microsoft.Exchange `
        -ConnectionUri http://$server/PowerShell/ `
        -credential $credential 
    Import-PSSession $session -AllowClobber

    $msgsSinceYesterday = Get-MessageTrackingLog -ResultSize Unlimited -Start (get-date (get-date).AddDays(-1) -f ((New-Object System.Globalization.CultureInfo(“en-US”)).DateTimeFormat.ShortDatePattern)) -Recipients $recipient -EventId Receive

    $msgsSinceYesterdayGrouped = $msgsSinceYesterday | select timestamp | Group-Object {$_.timestamp.date}

    if ($msgsSinceYesterdayGrouped.count -eq 2) { 
        $mailsYesterday = $msgsSinceYesterdayGrouped[0].count
        $mailsToday = $msgsSinceYesterdayGrouped[1].count
    } elseif ($msgsSinceYesterdayGrouped.count -eq 1) { # this may happen if there is NO mail within one day for example during night or at the weekend
        if ((get-date($msgsSinceYesterday[0].name)).Date -lt (get-date).Date) {
            $mailsYesterday = $msgsSinceYesterdayGrouped[0].count
            $mailsToday = 0
        } else {
            $mailsYesterday = 0
            $mailsToday = $msgsSinceYesterdayGrouped[0].count
        }
    } else {
            $mailsYesterday = 0
            $mailsToday = 0
    }

    $prtg +="  <result> 
        <channel>Mails Today</channel> 
        <value>$mailstoday</value> 
        <unit>custom</unit>
        <customunit>emails</customunit>
        <showChart>1</showChart> 
        <showTable>1</showTable> 
    </result> 
    <result> 
        <channel>Mails Yesterday</channel> 
        <value>$mailsyesterday</value> 
        <unit>custom</unit>
        <customunit>emails</customunit>
        <showChart>1</showChart> 
        <showTable>1</showTable> 
    </result>
" 

    $prtg +="    <text>OK</text> 
</prtg>" 
    

} catch {
    $errormessage = $_.Exception.Message
    $prtg +="  <error>1</error>" 
    $prtg +="  <text>$errormessage</text> 
    </prtg>" 
    
} finally {
    if ($Session -ne $null) { Remove-PSSession $Session; }
}
$prtg

Created on Dec 19, 2016 2:14:16 PM by  Sven Roggenhofer [Paessler Technical Support]

Last change on Dec 19, 2016 2:14:40 PM by  Sven Roggenhofer [Paessler Technical Support]



Votes:

0

Your Vote:

Up

Down

Hello,

thank you for this response: This is the result of sensor

Réponse non correcte : "( ModuleType Version Name ExportedCommands ---------- ------- ---- ---------------- Script 1.0 tmp_12hib4vw.oub {Add-DistributionG... <?xml version="1.0" encoding="utf-8" ?> <prtg> <error>1</error> <text>Le terme « Get-MessageTrackingLog » n'est pas reconnu comme nom d'applet de comande, fonction, fichier de script ou programme exécutable. Vérifiez l'orthographe du nom, ou si un chemin d'accès existe, vérifiez que le chemin d'accès est correct et réessayez.</text> </prtg> )" (code : PE132)

On the Exchange Server, if I send the powershell command "get-MessageTrackingLog" the server return the informations normally

Have you an idea?

Created on Dec 19, 2016 3:43:26 PM by  DIMITRI (0) 1

Last change on Dec 30, 2016 8:01:28 AM by  Luciano Lingnau [Paessler Support]



Votes:

0

Your Vote:

Up

Down

Dear DIMITRI,

Thank you very much for your response.

Please use the same user/password in the sensor-settings of PRTG as you use when you run the command directly on the Exchange Server. This is needed because the related CMDlets won´t be available on the Probe if you are not use a suitable user.

Best regards,
Sven

Created on Dec 20, 2016 10:07:00 AM by  Sven Roggenhofer [Paessler Technical Support]



Votes:

0

Your Vote:

Up

Down

Hello In my case, the user logon is "domain\logon" I test it with parameter only "logon" but not working and test it with parameter domain\logon with backslash not working either

thank you

Created on Dec 20, 2016 3:19:32 PM by  DIMITRI (0) 1



Votes:

0

Your Vote:

Up

Down

Dear DIMITRI,

Thank you very much for your response.

Have you used the following syntax for the parameter-setting within PRTG?

-server <fqdn of the server> -user <loginname> -pass <password> -recipient <smtp-address to check for mails>
or simple to use presets within the device:
-server %host -user %windowsdomain\%windowsuser -pass %windowspassword -recipient <smtp-address to check for mails>

Please use " " before/after loginname and password and try it once again.

If this still does not work, please open a support ticket, and send us screenshots of the sensor-settings.

Thank you very much in advance.

Best regards,
Sven

Created on Dec 21, 2016 9:22:10 AM by  Sven Roggenhofer [Paessler Technical Support]

Last change on Dec 21, 2016 9:23:24 AM by  Sven Roggenhofer [Paessler Technical Support]



Please log in or register to enter your reply.


Disclaimer: The information in the Paessler Knowledge Base comes without warranty of any kind. Use at your own risk. Before applying any instructions please exercise proper system administrator housekeeping. You must make sure that a proper backup of all your data is available.