Hey,
I used a Windows Shell script (saved in PRTG custom sensor folder) for downloading the HTTP-Content to local disc and then searched for trigger words to extract the following values and returned them as XML channel. This way you can use the xmlexe-sensor, so you get each of your values back as individual channels.
Here is my vbs (provided "as is" without warrenty and so on, of course):
Option Explicit
Dim wshshell
Dim source, target, text, value, name, output, entry, entries
Set wshshell = CreateObject("WScript.Shell")
target = "C:\PRTGScripts\PRTG_custom_http.html"
source = "http://yoursourceurl"
text = DownloadHTTP(source, target)
entries = split (text, " ")
output = ""
output = output & "<prtg>" & vbcrlf
for each entry in entries
'here to do some code dividing the channel name and value
name = mid(text, 1, 5)
value = mid(text, 5, 4)
output = output & " <result>" & vbcrlf
output = output & " <channel>" & name & "</channel>" & vbcrlf
output = output & " <float>1</float>" & vbcrlf
output = output & " <unit></unit>" & vbcrlf
output = output & " <value>" & value & "</value>" & vbcrlf
output = output & " </result>" & vbcrlf
'wscript.echo entry
next
output = output & "</prtg>" & vbcrlf
wscript.echo output
function DownloadHTTP(source, target)
Dim HTTP, fs, datei, x, binary, file
Set http = CreateObject("WinHttp.WinHttpRequest.5.1")
If http Is Nothing Then Set http = CreateObject("WinHttp.WinHttpRequest")
If http Is Nothing Then Set http = CreateObject("MSXML2.ServerXMLHTTP")
If http Is Nothing Then Set http = CreateObject("Microsoft.XMLHTTP")
Set fs = WScript.CreateObject("Scripting.FileSystemObject")
'for using proxy, if nessesary
http.SetProxy 2, "yourproxyurl:8080"
HTTP.open "GET", source, False
HTTP.send
datei = HTTP.responseBody
For x = 0 to UBound(datei)
binary = binary & ChrW(AscW(Chr(AscB(MidB(datei,x+1,1)))))
Next
Set file = fs.CreateTextFile(target, True)
file.Write binary
file.Close
'DownloadHTTP = HTTP.StatusText
DownloadHTTP = binary
End function
Add comment