Advertisement
Guest User

Untitled

a guest
Jun 19th, 2018
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1. CHANGE THESE: Username and password for Zerto Analytics
  2. $zaUsername = "username"
  3. $zaPassword = "password"
  4.  
  5. [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12 -bor [System.Net.SecurityProtocolType]::Tls11
  6.  
  7. #Getting Zerto Analytics Token
  8. $body = '{"username": "' + $zaUsername + '","password":"' + $zaPassword + '"}'
  9. $contentType = "application/json"
  10. $xZertoAnalyticsToken = Invoke-RestMethod -Uri "https://analytics.api.zerto.com/v2/auth/token" -Method POST -Body $body -ContentType $contentType
  11.  
  12. #Build authorization header
  13. $authHeaders = @{"Authorization" = "Bearer " + $xZertoAnalyticsToken.token}
  14.  
  15. #Set the vpgIdentifier of the VPG you want to pull statistics for
  16. $vpgIdentifier = "xxxxxxxxxxxxxx"
  17.  
  18. #Get the current time
  19. $CurrentDateTime = Get-Date
  20.  
  21. #Get current time -5 minutes to pull statistics from last 5 minutes
  22. $ts = New-TimeSpan -Minutes 5
  23. $FiveMinutseAgo = Get-Date($CurrentDateTime-$ts) -Format O
  24.  
  25. #URL Encode time
  26. $FiveMinutesAgo = [System.Web.HttpUtility]::UrlEncode($FiveMinutesAgo)
  27.  
  28. #Get RPO statistics for VPG
  29. $getRpoStatsUrl = "https://analytics.api.zerto.com/v2/reports/stats-rpo?startDate=" + $FiveMinutesAgo + "&vpgIdentifier=" + $vpgIdentifier
  30. $vpgRpoStats = Invoke-RestMethod -Uri $getRpoStatsUrl -Headers $authHeaders
  31.  
  32. $avg = $vpgRpoStats.avg
  33. $max = $vpgRpoStats.max
  34. $min = $vpgRpoStats.min
  35.  
  36. Write-Host @"
  37. <prtg>
  38. <result>
  39. <channel>AvgRPO</channel>
  40. <unit>TimeSeconds</unit>
  41. <value>$avg</value>
  42. <float>1</float>
  43. </result>
  44. <result>
  45. <channel>MaxRPO</channel>
  46. <unit>TimeSeconds</unit>
  47. <value>$max</value>
  48. <float>1</float>
  49. </result>
  50. <result>
  51. <channel>MinRPO</channel>
  52. <unit>TimeSeconds</unit>
  53. <value>$min</value>
  54. <float>1</float>
  55. </result>
  56. </prtg>
  57. "@
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement