#!/usr/bin/perl
$CheckNTPath='/usr/lib/nagios/plugins';

$ActiveUserCount  = `$CheckNTPath/check_nt -H $ARGV[0] -p 12489 -v COUNTER -l "\\MSExchange RpcClientAccess\\Active User Count"`;
chomp $ActiveUserCount;
$ConnectionCount      = `$CheckNTPath/check_nt -H $ARGV[0] -p 12489 -v COUNTER -l "\\MSExchange RpcClientAccess\\Connection Count"`;
chomp $ConnectionCount;
$RPCOperationssec      = `$CheckNTPath/check_nt -H $ARGV[0] -p 12489 -v COUNTER -l "\\MSExchange RpcClientAccess\\RPC Operations/sec"`;
chomp $RPCOperationssec;
$UserCount      = `$CheckNTPath/check_nt -H $ARGV[0] -p 12489 -v COUNTER -l "\\MSExchange RpcClientAccess\\User Count"`;
chomp $UserCount;
$RPCAveragedLatency      = `$CheckNTPath/check_nt -H $ARGV[0] -p 12489 -v COUNTER -l "\\MSExchange RpcClientAccess\\RPC Averaged Latency"`;
chomp $RPCAveragedLatency;
$RPCRequests      = `$CheckNTPath/check_nt -H $ARGV[0] -p 12489 -v COUNTER -l "\\MSExchange RpcClientAccess\\RPC Requests"`;
chomp $RPCRequests;
$AverageSearchTime      = `$CheckNTPath/check_nt -H $ARGV[0] -p 12489 -v COUNTER -l "\\MSExchange OWA\\Average Search Time"`;
chomp $AverageSearchTime;
$AverageTimetoProcessaFreeBusyRequest      = `$CheckNTPath/check_nt -H $ARGV[0] -p 12489 -v COUNTER -l "\\MSExchange Availability Service\\Average Time to Process a Free Busy Request"`;
chomp $AverageTimetoProcessaFreeBusyRequest;

print "ActiveUserCount:"    						  . $ActiveUserCount .
     " ConnectionCount:"							  . $ConnectionCount .
     " RPCOperationssec:"    						  . $RPCOperationssec .
     " UserCount:"          						  . $UserCount .
     " RPCAveragedLatency:"  						  . $RPCAveragedLatency .
     " RPCRequests:"         						  . $RPCRequests .
	 " AverageSearchTime:"   						  . $AverageSearchTime .
     " AverageTimetoProcessaFreeBusyRequest:"         . $AverageTimetoProcessaFreeBusyRequest .
	 "\n";

