spuder

influxdb powershell array

May 5th, 2015
360
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. C:\Windows\system32> Function ReportToInfluxDB($duration, $name, $cpu, $memory, $hypervisor, $exitcode)
  2. {
  3. $username = "foo"
  4. $password = "union-share-itself-aid" | ConvertTo-SecureString -asPlainText -Force
  5. $credential = New-Object System.Management.Automation.PSCredential($username,$password)
  6. $influxdatabase = 'foobar'
  7. $influxtable = 'bar'
  8. $influxserver = "http://influxdb.example.com:8086/db/$influxdatabase/series"
  9. $influxdata = [ordered]@{}
  10. $influxdata.name = $influxtable
  11. $influxdata.columns = @("duration","name","cpu","memory","hypervisor","exitcode")
  12. $influxdata.points = @()
  13. $influxdata.points += ,@("$duration", "$name", "$cpu", "$memory", "$hypervisor", "$exitcode")
  14. $influxdatajson = $influxdata | ConvertTo-Json -Depth 2
  15. $influxdatajson
  16. }
  17.  
  18.  
  19. $sw.elapsed.seconds = 28
  20. $GUESTCPUS = 2
  21. $GUESTMEMORY = 2147483648
  22.  
  23.  
  24. C:\Windows\system32> ReportToInfluxDB $sw.elapsed.seconds, $GUESTNAME, $GUESTCPUS, $GUESTMEMORY, $HVCOMPUTERNAME
  25.  
  26. "name": "foobar",
  27. "columns": [
  28. "duration",
  29. "name",
  30. "cpu",
  31. "memory",
  32. "hypervisor",
  33. "exitcode"
  34. ],
  35. "points": [
  36. [
  37. "28 2 2147483648 ",
  38. "",
  39. "",
  40. "",
  41. "",
  42. ""
  43. ]
  44. ]
Advertisement
Add Comment
Please, Sign In to add comment