Cheshire Cat Computing

Software support and information
It is currently Tue May 21, 2013 7:11 pm

All times are UTC + 12 hours [ DST ]




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Wed May 23, 2012 12:07 pm 
Offline
Silver User

Joined: Tue Nov 03, 2009 9:27 pm
Posts: 21
As i figured it out and found it not via google, here a perl script to Montor the SMTP MAIL IO of an Exchange 2010 Server.
If anyone interested in something like this (WMI Based queries like Disk IO, Diskload) post a reply
But this will only work on an Windows Host...
Code:
use strict;
use Win32::OLE('in');

use constant wbemFlagReturnImmediately => 0x10;
use constant wbemFlagForwardOnly => 0x20;

my $computer = "$ARGV[0]";
my $MessagesReceivedTotal;
my $MessagesSentTotal;


my $objWMIService = Win32::OLE->GetObject("winmgmts:\\\\$computer\\root\\CIMV2") or die "WMI connection failed.\n";

my $colItems = $objWMIService->ExecQuery(
   "SELECT * FROM Win32_PerfRawData_MSExchangeTransportSMTPReceive_MSExchangeTransportSMTPReceive where Name = '_Total'", "WQL",
   wbemFlagReturnImmediately | wbemFlagForwardOnly
);

foreach my $objItem (in $colItems) {
      #print "Name: $objItem->{Name}\n";
      #print "MessagesReceivedTotal: $objItem->{MessagesReceivedTotal}\n";
     $MessagesReceivedTotal=$objItem->{MessagesReceivedTotal};
}


my $colItems = $objWMIService->ExecQuery(
   "SELECT * FROM Win32_PerfRawData_MSExchangeTransportSmtpSend_MSExchangeTransportSmtpSend where Name = '_Total'", "WQL",
   wbemFlagReturnImmediately | wbemFlagForwardOnly
);

foreach my $objItem (in $colItems) {
     #print "Name: $objItem->{Name}\n";
     #print "MessagesSentTotal: $objItem->{MessagesSentTotal}\n";
      $MessagesSentTotal=$objItem->{MessagesSentTotal};

}


print "$MessagesReceivedTotal\n";
print "$MessagesSentTotal\n";
print "not used\n";
print "MessagesReceivedTotal\n";
print "MessagesSentTotal\n";

cfg:
Code:
##################################################################################
# Exchange Messages Load
########################################################
Title[MAILServer.wmi.Exchange_Messages]:                        MAILServer: Exchange Messages Load
Target[MAILServer.wmi.Exchange_Messages]:                       `Scripts\Exchange_Messages.pl MAILServer`
MaxBytes[MAILServer.wmi.Exchange_Messages]:                     100
YLegend[MAILServer.wmi.Exchange_Messages]:                      Mail IO
Options[MAILServer.wmi.Exchange_Messages]:                      growright
ShortLegend[MAILServer.wmi.Exchange_Messages]:                  Mails/s
Legend1[MAILServer.wmi.Exchange_Messages]:                      MessagesReceived
Legend2[MAILServer.wmi.Exchange_Messages]:                      MessagesSent
Legend3[MAILServer.wmi.Exchange_Messages]:                      Maximal 2 Minute C:
Legend4[MAILServer.wmi.Exchange_Messages]:                      Maximal 2 Minute D:
LegendI[MAILServer.wmi.Exchange_Messages]:                       MessagesReceived:
LegendO[MAILServer.wmi.Exchange_Messages]:                       MessagesSent:
PageTop[MAILServer.wmi.Exchange_Messages]:                      <HR>
    <H1>MAILServer: Exchange Mails pro Sekunde</H1>
    <TABLE>
        <TR>    <TD>System:</TD>                        <TD>MAILServer</TD></TR>
        <TR>    <TD>Script:</TD>                        <TD><i>`Scripts\Exchange_Messages.pl MAILServer`</i></TD></TR>
    </TABLE>
    <HR>



Top
 Profile  
 
PostPosted: Thu May 31, 2012 1:01 pm 
Offline
Site Admin

Joined: Tue Jul 29, 2003 11:42 am
Posts: 2921
Location: Auckland, New Zealand
Thanks for this!

To make it work on a UNIX host, you could always use the NRPE agent and run it remotely (you'd need to change the output format to be a single line, and then use the mrtgnrpe.pl script to remotely run it and parse the output.

_________________
Steve Shipway
UNIX Systems, ITSS, University of Auckland, NZ
Woe unto them that rise up early in the morning... -- Isaiah 5:11


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC + 12 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group