Advertisement
stephanlinke

PRTG-BulkSMSCredits

Apr 26th, 2016
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #require --version 4.0
  2. <#
  3.  ___ ___ _____ ___
  4. | _ \ _ \_   _/ __|
  5. |  _/   / | || (_ |
  6. |_| |_|_\ |_| \___|
  7.  BulkSMSCreditCheck
  8.  
  9.  Description:   Simply pass the get credits API URL in the sensor and it will show the remaining credits.
  10.  
  11.  Author:        Stephan Linke
  12.  
  13.  Version History
  14.  ----------------------------
  15.  1.0        Initial Release
  16. #>
  17.  
  18. param([string]$url,[switch]$use_comma = $FALSE)
  19.  
  20. $remaining_credits = (Invoke-WebRequest -UseBasicParsing -Uri $url).Content.Split("|")[1];
  21.  
  22. if($use_comma)
  23. { $remaining_credits =  $remaining_credits.Replace(".",",") }
  24.  
  25. Write-Host (@"
  26. <prtg>
  27. <result>
  28. <channel>Remaining Credits</channel>
  29. <float>1</float>
  30. <value>{0}</value>
  31. </result>
  32. <text>{0} remaining SMS credits</text>
  33. </prtg>
  34. "@ -f $remaining_credits)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement