Advertisement
stephanlinke

[PRTG] Read Apache Sessions

Nov 3rd, 2016
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. param($url = "")
  2.  
  3. $channel = @"
  4. <result>
  5.       <channel>{0}</channel>
  6.       <value>{1}</value>
  7. </result>
  8. "@
  9.  
  10. $Sessions = ((Invoke-WebRequest -UseBasicParsing $url))
  11. $Sessions = "Instance,State,Sessions,Path`r`n" + $Sessions  -replace ":",","
  12. $Sessions = $Sessions -creplace "C,","C:"
  13. $Sessions = $Sessions -creplace "D,","D:"
  14. $Sessions = $Sessions -creplace "E,","E:"
  15.  
  16. Write-Host "<prtg>";
  17.  
  18. Foreach($Session in ($Sessions | ConvertFrom-Csv))
  19. { Write-Host ($channel -f $Session.Instance,$Session.Sessions); }
  20.  
  21. Write-Host "</prtg>"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement