none
Exchange 2010信息统计脚本 RRS feed

  • 问题

  • Exhange 2010的PowerShell命令能否实现如下要求,如何实现,谢谢!

    要求如下:

    需要的是 每小时为单位 核算邮件系统

    收邮件数量(内部/外部)

    发邮件数量(内部/外部)

         最好可以附带出  收件人 发件人 主题 这三个新信息

    2015年10月21日 8:54

答案

全部回复

  • 不能满足所有的要求

    http://exchangeserverpro.com/calculate-hourly-email-traffic-using-message-tracking-log-parser/

    Most Exchange server environments will demonstrate a predictable volume of email traffic throughout a typical day. However from time to time some problem may arise that causes an unusual spike in email traffic.

    To be able to identify this type of problem you should first know what your normal email traffic patterns look like. You can find this information by using Log Parser to search through your Exchange server’s message tracking logs.

    There are two ways to look at this traffic.

    • As a total of the traffic per hour for all days combined
    • As the traffic per hour for each separate day

    TOTAL EMAIL TRAFFIC PER HOUR FOR ALL DAYS COMBINED

    First let’s look at the Log Parser query to calculate the total email traffic per hour for all days combined.

    SELECT QUANTIZE(TO_LOCALTIME(TO_TIMESTAMP(EXTRACT_PREFIX(TO_STRING(EXTRACT_SUFFIX([#Fields: date-time],0,'T')),0,'.'), 'hh:mm:ss')),3600) AS Hour,
    	COUNT(*) AS Messages
    FROM *.log
    WHERE (event-id='RECEIVE')
    GROUP BY Hour
    ORDER BY Hour ASC

    When run from the folder where the message tracking logs are located the full syntax is:

    "C:\Program Files (x86)\Log Parser 2.2\logparser.exe" "SELECT QUANTIZE(TO_LOCALTIME(TO_TIMESTAMP(EXTRACT_PREFIX(TO_STRING(EXTRACT_SUFFIX([#Fields: date-time],0,'T')),0,'.'), 'hh:mm:ss')),3600) AS Hour, COUNT(*) AS Messages from *.log where (event-id='RECEIVE') GROUP BY Hour ORDER BY Hour ASC" -i:CSV -nSkipLines:4 -rtp:-1

    This will return results similar to these:

    Hour     Messages
    -------- --------
    00:00:00 408
    01:00:00 415
    02:00:00 363
    03:00:00 347
    04:00:00 273
    05:00:00 327
    06:00:00 403
    07:00:00 450
    08:00:00 590
    09:00:00 574
    10:00:00 637
    11:00:00 810
    12:00:00 612
    13:00:00 597
    14:00:00 700
    15:00:00 789
    16:00:00 821
    17:00:00 448
    18:00:00 396
    19:00:00 527
    20:00:00 346
    21:00:00 476
    22:00:00 348
    23:00:00 448
    
    Statistics:
    -----------
    Elements processed: 106823
    Elements output:    24
    Execution time:     0.58 seconds

    You can also generate graphs straight from Log Parser (if you have the required Office Web Components installed) with slightly different syntax like this:

    "C:\Program Files (x86)\Log Parser 2.2\logparser.exe" "SELECT QUANTIZE(TO_LOCALTIME(TO_TIMESTAMP(EXTRACT_PREFIX(TO_STRING(EXTRACT_SUFFIX([#Fields: date-time],0,'T')),0,'.'), 'hh:mm:ss')),3600) AS Hour, COUNT(*) AS [Messages per Hour] INTO HourlyTraffic.gif from *.log where (event-id='RECEIVE') GROUP BY Hour ORDER BY Hour ASC" -i:CSV -nSkipLines:4 -chartType:Column3D

    That Log Parser query will generate a column graph for you similar to this.

    TOTAL EMAIL TRAFFIC PER HOUR FOR EACH SEPARATE DAY

    If you’d rather see the hourly traffic for each separate day you can use the following Log Parser query that handles the timestamps slightly differently.

    SELECT TO_LOCALTIME(QUANTIZE(TO_TIMESTAMP(TO_STRING(EXTRACT_PREFIX([#Fields: date-time],0,'.')), 'yyyy-MM-ddThh:mm:ss'),3600)) AS Hour,
    	COUNT(*) AS Messages
    FROM *.log
    WHERE event-id='RECEIVE'
    GROUP BY Hour
    ORDER BY Hour ASC

    The full Log Parser command when run from the folder containing the message tracking logs is as follows:

    "C:\Program Files (x86)\Log Parser 2.2\logparser.exe" "SELECT TO_LOCALTIME(QUANTIZE(TO_TIMESTAMP(TO_STRING(EXTRACT_PREFIX([#Fields: date-time],0,'.')), 'yyyy-MM-ddThh:mm:ss'),3600)) AS Hour, COUNT(*) AS Messages from *.log where event-id='RECEIVE' GROUP BY Hour ORDER BY Hour ASC" -i:CSV -nSkipLines:4 -rtp:-1

    This will generate a lot of output depending on the amount of log retention you have configured.

    Hour                Messages
    ------------------- --------
    2012-04-05 10:00:00 48
    2012-04-05 11:00:00 77
    2012-04-05 12:00:00 35
    2012-04-05 13:00:00 74
    2012-04-05 14:00:00 84
    2012-04-05 15:00:00 86
    2012-04-05 16:00:00 79
    2012-04-05 17:00:00 35
    2012-04-05 18:00:00 44
    2012-04-05 19:00:00 24
    2012-04-05 20:00:00 41
    2012-04-05 21:00:00 19
    2012-04-05 22:00:00 40
    2012-04-05 23:00:00 59
    2012-04-06 00:00:00 28
    2012-04-06 01:00:00 42
    2012-04-06 02:00:00 22
    2012-04-06 03:00:00 31
    2012-04-06 04:00:00 16
    2012-04-06 05:00:00 31
    2012-04-06 06:00:00 40
    2012-04-06 07:00:00 22
    2012-04-06 08:00:00 84
    2012-04-06 09:00:00 77
    2012-04-06 10:00:00 46
    2012-04-06 11:00:00 84
    ....

    As with other Log Parser results you can output this one to a graph as well (again, providing that you have the Office Web Components installed).

    Because of the amount of data a line graph seems more appropriate than a column graph. The default size of a graph generated by Log Parser is 640×480, but you can use the -groupsize parameter to set a custom width x height that suits the amount of data being included.

    "C:\Program Files (x86)\Log Parser 2.2\logparser.exe" "SELECT TO_LOCALTIME(QUANTIZE(TO_TIMESTAMP(TO_STRING(EXTRACT_PREFIX([#Fields: date-time],0,'.')), 'yyyy-MM-ddThh:mm:ss'),3600)) AS Hour, COUNT(*) AS Messages INTO DailyTrafficPerHour.gif from *.log where event-id='RECEIVE' GROUP BY Hour ORDER BY Hour ASC" -i:CSV -nSkipLines:4 -chartType:Line -groupsize:1024x480

     

    2015年10月22日 2:02
  • 你好!

    Exchange 2010上面没有直接的语句来实现它。不过,TechNet的代码库里有一个脚本,或许正好是你所需要的:

    https://gallery.technet.microsoft.com/office/ec7940c1-be9a-45d5-9ea1-921677fa081c#content

    可尝试下载运行。


    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact tnmff@microsoft.com.

    Winnie Liang
    TechNet Community Support

    2015年10月22日 7:16
  • 你这个是每个小时所有邮箱收发的统计吧?没法列出来每个邮箱用户的信息吗?
    2015年10月22日 7:23
  • https://gallery.technet.microsoft.com/scriptcenter/bb94b422-eb9e-4c53-a454-f7da6ddfb5d6

    这个链接里的脚本统计的比较全面,但是是统计每天的,如何在这个基础修改实现每个小时统计一次?

    2015年10月22日 7:29
  • 你好!

    请问你的问题解决了吗?

    通常关于脚本的问题,我们建议到Script Center论坛去问,那边有更多熟悉脚本编写的专业人士可以为您解答(英文版的论坛):

    https://social.technet.microsoft.com/Forums/scriptcenter/en-us/home?forum=ITCG


    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact tnmff@microsoft.com.

    Winnie Liang
    TechNet Community Support

    2015年10月28日 5:44