Advertisement
stephanlinke

[PRTG] Get Temperatures

Sep 8th, 2015
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #############
  2. # ___ ___ _____ ___
  3. #| _ \ _ \_  _/ __|
  4. #|  _/  / | || (_ |
  5. #|_| |_|_\ |_| \___|
  6. #    NETWORK MONITOR
  7. #-------------------
  8. # Description: This
  9. # Parameters:
  10. # -URL: The URL of the temperature probe
  11. # ------------------
  12. # (c) 2015 Stephan Linke | Paessler AG
  13. param($url)
  14. $regex = [regex]'(\d+\D\d+)\D+(\d+\D\d+)\D+(\d+\D\d+)'
  15. (Invoke-Webrequest -URI $URL) -match $regex
  16. Write-Host @"
  17. <PRTG>
  18.  <result>
  19.    <channel>Temperature</channel>
  20.    <value>$($matches[1])</value>
  21.    <showChart>1</showChart>
  22.    <showTable>1</showTable>
  23.    <Float>1</Float>
  24.    <DecimalMode>All</DecimalMode>
  25.    <unit>Temperature</unit>
  26.    <mode>Absolute</mode>
  27.  </result>
  28.  <result>
  29.    <channel>Humidity</channel>
  30.    <value>$($matches[2])</value>
  31.    <showChart>1</showChart>
  32.    <showTable>1</showTable>
  33.    <Float>1</Float>
  34.    <DecimalMode>All</DecimalMode>
  35.    <unit>Percent</unit>
  36.    <mode>Absolute</mode>
  37.  </result>
  38.  <result>
  39.    <channel>Brightness</channel>
  40.    <value>$($matches[3])</value>
  41.    <showChart>1</showChart>
  42.    <showTable>1</showTable>
  43.    <Float>1</Float>
  44.    <unit>CustomUnit</unit>
  45.    <customunit>Lux</customunit>
  46.    <mode>Absolute</mode>
  47.    <DecimalMode>All</DecimalMode>
  48.  </result>
  49. </PRTG>
  50. "@;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement