PRTG - VMware datastore latency monitoring

Here is an example how to monitor individual ESXi datastores read/write latency through vCenter and PRTG. Tested with PRTG V16.4.28.7421 and ESXi 5.1. "VMware vSphere PowerCLI" is required on Probe server.

# "DataStoreName - totalWriteLatency.ps1" file
Add-PSSnapin VMware.VimAutomation.Core
$a=Connect-VIServer vCenterServer -User "Domain\User" -Password "UserPassword" -WarningAction SilentlyContinue
$p=@()
$p=Get-Datastore DataStoreName | foreach {$dsName = $_.Name; $uuid = $_.ExtensionData.Info.Url.Split('/')[-2]; Get-VMHost -Datastore $_ | Get-Stat -Stat "datastore.totalWriteLatency.average" -Realtime | where {$_.Instance -eq $uuid} | sort Timestamp -descending | select -first 1 | select -expand Value}
echo $p':ok'

# "DataStoreName - totalReadLatency.ps1" file.
Add-PSSnapin VMware.VimAutomation.Core
$a=Connect-VIServer vCenterServer -User "Domain\User" -Password "UserPassword" -WarningAction SilentlyContinue
$p=@()
$p=Get-Datastore DataStoreName | foreach {$dsName = $_.Name; $uuid = $_.ExtensionData.Info.Url.Split('/')[-2]; Get-VMHost -Datastore $_ | Get-Stat -Stat "datastore.totalReadLatency.average" -Realtime | where {$_.Instance -eq $uuid} | sort Timestamp -descending | select -first 1 | select -expand Value}
echo $p':ok' 

Put both files into "PRTG Installation folder\Custom Sensors\EXE" and create EXE/Script sensors.

2 comments:

  1. Hi Vyacheslav, i found your script and created a new one to use with exe/xml and with an for each loop for the DatastoreName

    https://github.com/pbraxmeier/nexpert_prtg/blob/master/Powershell%20Script%20-%20VMware%20-%20Datastore%20Latency.ps1

    regards

    ReplyDelete

(c) 2014-2017 www.fedenko.info - Vyacheslav Fedenko