# mrscounter # # Script to collect and merge Exchange MRS Performance Counters about migrations and post them to PRTG # # Pending: Parallel execution to # Pending: Grab Exchange Servers automatically # param ( $serverlist = @("EX01", "ex02", "ex03"), $prtgurl = "http://prtg.msxfaq.net:5050/mrsdatatoken?content=" ) Set-PSDebug -Strict write-host "PRTG-MRSPerformance: Start" $totalcpu=0 $totalread=0 $totalwrite=0 $totaltransmission=0 $prtgresult = ' ' foreach ($server in $serverlist) { write-host "PRTG-MRSPerformance: Server $server" $mrscpu = [math]::round((Get-Counter "\\$($server)\processor(_total)\% processor time").countersamples[0].cookedvalue) $mrsread = [math]::round((Get-Counter "\\$($server)\MSExchange Mailbox Replication Service\Transfer Rate: Read (KB/sec)").countersamples[0].cookedvalue) $mrstransmission= [math]::round((Get-Counter "\\$($server)\MSExchange Mailbox Replication Service\Transfer Rate: Transmission (KB/sec)").countersamples[0].cookedvalue) $mrswrite = [math]::round((Get-Counter "\\$($server)\MSExchange Mailbox Replication Service\Transfer Rate: Write (KB/sec)").countersamples[0].cookedvalue) write-host " CPU = $($mrscpu)" write-host " Read = $($mrsread)" write-host " Write = $($mrswrite)" write-host " Transfer = $($mrstransmission)" $totalcpu+= $mrscpu $totalread+= $mrsread $totalwrite+= $mrswrite $totaltransmission+=$mrstransmission $prtgresult+= ' '+$server+'-CPU '+$mrscpu+' 1 Prozent '+$server+'-MRSRead '+$mrsread+' 1 KB '+$server+'-MRSWrite '+$mrswrite+' 1 KB '+$server+'-MRSTransmission '+$mrstransmission+' 1 KB ' } write-host " Avg CPU = $([math]::round($totalcpu / ($serverlist.count)))" write-host " Avg Read = $($totalread)" write-host " Avg Write = $($totalwrite)" write-host " Avg Transfer = $($totaltransmission)" $prtgresult+= ' Total MRSCPU Load '+[math]::round($totalcpu/($serverlist.count))+' 1 Total MRSRead KB '+$totalread+' 1 KB Total MRSWrite KB '+$totalwrite+' 1 KB Total MRSTransmission KB '+$totaltransmission+' 1 KB ' # ' + [math]::round($outsize/1024) + ' # $prtgresult write-host "PRTG-MRSPerformance: Sending Data to $prtgurl" $httprequest=[system.Net.HttpWebRequest]::Create($prtgurl+$prtgresult); $data = $httprequest.getresponse(); $stat = $data.statuscode; $data.Close(); # no errorhandling here write-host "PRTG-MRSPerformance: End"