I have wrote a PowerShell script to use the "HTTP Push Data Advanced" sensor:

$prtgresult = '<prtg>
            <result>
            <channel>Message</channel>
            <value>1</value>
            </result>
            <Text>This_is_the_error</Text>
            </prtg> '

Add-Type -AssemblyName system.web
$Answer = Invoke-WebRequest `
   -method "POST" `
   -URI ("http://***IPof PRTG_Server***:5050/***Token***") `
   -ContentType "text/xml" `
   -Body ([System.Web.HttpUtility]:: UrlEncode.($prtgresult)) `
   -usebasicparsing
if ($answer.statuscode -ne 200) {
   write-warning "Request to PRTG failed"
   exit 1
}
else {
   $answer.content
}

I get back a message saying it matched 1 sensor but the sensor is saying "No Data" (I tried adding the HTTP Push Count with the same Token and to matched 2 sensors and I could see it in the Push Count log as picking it up) so I'm now completely stuck and I'm sure I've missed something but I can't figure out what :(

The end result should be that whenever the sensor receives the push message it triggers a "Change Notification" to alert our out of hours support team with the contents on the Text Tag.


Article Comments

Hi there,

Do you run multiple Push Data sensors all under the same Port?

Please create an entirely new Push Data Advanced Sensor with a different port and Identification Token, does the script work properly then?

Best regards.


Nov, 2018 - Permalink

Still not working I'm afraid:

I get the response that its matched the Sensor but on the sensor I get "There was no value provided"

the log file shows:

Command: POST ContentType: text/xml Uri: /Token Remote IP: .*.. Form Params: Query Params: Version: HTTP/1.1


Dec, 2018 - Permalink

Hi there,

Found the issue. You are just transmitting the result in the POST-Body, but you are missing the parameter that this result belongs to. So change this:

-Body ([System.Web.HttpUtility]:: UrlEncode.($prtgresult)) `

To this:

-Body ("content="+[System.Web.HttpUtility]:: UrlEncode.($prtgresult)) `

Basically you need to transmit the result in the "content"-Parameter.

Best regards.


Dec, 2018 - Permalink