lordmilko / PrtgAPI

C#/PowerShell interface for PRTG Network Monitor
MIT License
301 stars 37 forks source link

HTTP Advanced sensor and custom configuration #284

Closed r0m1CH closed 2 years ago

r0m1CH commented 2 years ago

Describe the bug

Hello,

I'm not sure this is a bug but I'm trying to create a new HTTP Advanced sensor with content verification. I want the sensor to be in error if a text is not found into the web pages displayed.

I figure that I need to configure includemust and includemusttype properties to make it works. However I cannot find any value that suit PRTG Server to check the option "Set sensor to down status if keyword is missing"

I saw that the default value is 0. So I tried multiple integer to select the right option without any success. Whatever I put, it ends with first option check "Do not check for keyword (default)"

Any idea on how to fill this one or maybe find what PRTG Server is waiting as possible values ?

Steps to reproduce

$HttpSensorParams = $PRTGDevice | New-SensorParameters -RawType httpadvanced 
$HttpSensorParams.httpurl = "http://"+$IPAddress
$HttpSensorParams.includemust = "text to check"
$HttpSensorParams.includemusttype = 1
$HttpSensor = $HttpSensorParams | Add-Sensor

What is the output of 'Get-PrtgClient -Diagnostic'?

I'm using powershell version.

Additional context

Thanks !

lordmilko commented 2 years ago

If you inspect the HTML of the HTTP Advanced sensor creation page you will find what properties correspond with what settings

In this instance, we have

<input type="radio" class="hidden radio  GroupShowHide" name="httpmustneeded_" value="1" id="httpmustneeded1">

<label for="httpmustneeded1" class="radio-control-label">
<i class="icon-gray icon-radio-on"></i>
Set sensor to down status if keyword is missing
</label>

Therefore httpmustneeded (which you'll see is a property on the DynamicSensorParameters object) should be set to 1

r0m1CH commented 2 years ago

You killed it. Thanks a lot. I tried to look into the source in the first play but I don't know why I missed it.

Thanks a again !