Closed Thib261 closed 4 years ago
Hi @Thib261,
To answer this question we need to figure out how the measurements field actually works. If you press Ctrl+Shift+J in Chrome this will open the Chrome Developer Tools. If you click the little square with a mouse pointer on it up the top left of the tools you can click on the checkbox of each measurement type to view the underlying HTML in the inspector. For each checkbox there is an input tag <input ... />
. We want to know what the value is of each measurement type.
Based on previous sensor types I've seen, I imagine the values for all 4 of these are 1, 2, 3, 4. Therefore, I would wager you can select all four of them by doing the following
$snmp.measurement = 1,2,3,4
Although maybe 1 represents the "none" selection, so it should be 2,3,4,5
or something like that
I managed to locate a Cisco device I could try creating this sensor type myself on, and have concluded this is in fact a bug in PrtgAPI.
After inspecting the underlying HTML I discovered that PRTG actually defines several OID values over the course of several lines. This completely messes up PrtgAPI's analytics, resulting in a DynamicSensorParameters
object that does not contain the measurement__check
property.
Fortunately, for now we can work around this by adding in the required values ourselves.
In my system, I only have the CPU and Memory measurements. The HTML for each of these is as follows (note: on your system it might be slightly different)
<input type="checkbox" data-rule-required="true" class="checkbox notconnectedAll validateme validateerror" name="measurement__check" id="measurement_-0" value="1.3.6.1.4.1.9.9.109.1.1.1.1.4.1
|CPU|1|" style="display: none;" aria-required="true" aria-describedby="measurement__check-error">
<input type="checkbox" data-rule-required="true" class="checkbox notconnectedAll validateme" name="measurement__check" id="measurement_-1" value="1.3.6.1.4.1.9.9.48.1.1.1.6.1
1.3.6.1.4.1.9.9.48.1.1.1.5.1
1.3.6.1.4.1.9.9.48.1.1.1.6.2
1.3.6.1.4.1.9.9.48.1.1.1.5.2
|Memory|2|" style="display: none;" aria-required="true">
To include these measurements in our request, we do the following
$cpu = "1.3.6.1.4.1.9.9.109.1.1.1.1.4.1`n|CPU|1|"
$memory = "1.3.6.1.4.1.9.9.48.1.1.1.6.1`n1.3.6.1.4.1.9.9.48.1.1.1.5.1`n1.3.6.1.4.1.9.9.48.1.1.1.6.2`n1.3.6.1.4.1.9.9.48.1.1.1.5.2`n|Memory|2|"
$snmp = Get-Device Switch1 | New-SensorParameters -RawType snmpciscosystemhealth
$snmp.Unlock()
$snmp.measurement__check = $cpu,$memory
$snmp | Add-Sensor
First we take all of the lines from the value
of the measurement's <input>
field, merging the lines together into a single physical line with a `n newline characters to mark where a newline should be.
Then, we retrieve our sensor parameters as normal, unlock the parameters to allow adding parameters that PrtgAPI failed to retrieve, then set a value for the measurement__check
property that was missing from the response. Finally, we add the sensor!
Please let me know how you go with this
Thanks alot for the quick and elaborated answers, currently I cannot investigate it further because I don't have acces to the switch and prtg right now. I will update you on Monday.
This seems to work perfectly thank you, the only question I have with this is that the measurements available are dependent on the model of the switch that is being monitored, for example one switch can give the temperature values and another one can't. PRTG automatically knows this, but is there a way to find out which measurements can be selected or if it is possible to just check everything.
I found out that the checkbox for "select all" in the prtg is described as follows:
But when trying to add the sensor with
$snmp.measurement_ = 1
I am getting this error:
Hi @Thib261,
Each option is represented as a value to the property measurement__check
. The hidden measurement_
property you are seeing represents something else.
With the bug fix to this issue applied it is easy to tell PrtgAPI to simply select all of the measurements, whatever they may be, however unfortunately until this version is released the only way to do this would be to manually emulate the sensor creation process in order to scrape the contents of this page, which is a non-trivial thing to do.
How many different device models are you targeting? If you had a number of devices of a single model I would imagine they should all support the same measurements
Currently I am only using two different models so this is not an issue, it was just to be sure to be able to make it work in the future when the models would change.
But currently everything is working perfect with the method described earlier.
Thank you very much
Hi @Thib261,
Please be advised PrtgAPI 0.9.10 has been released, which includes a fix for this issue. To update to the latest version of PrtgAPI run the command
Update-Module PrtgAPI
and then close and reopen PowerShell.
Regards, lordmilko
Hello,
I have a question about the "snmpciscosystemhealth" raw-sensor. When I create this sensor via
$snmp = Get-Device Switch1 | New-SensorParameters -RawType snmpciscosystemhealth
and add this sensor to my device it gives an error that I haven't selected anything.
I understand that i need to select the measurements I want to monitor but whatever value i put into the "measurement" parameter it does not change. It also doesn't give me the measurement table.
My main question is how i could select any of the properties, and as a second question is there a possibility to select "All"?
In PRTG it looks like this: