Hi,

I'm writing scripts to add devices (servers, specifically) in PRTG. We monitor CPU,memory, and disk drives as a baseline. I can create a C drive just fine, using an example similar to this. https://kb.paessler.com/en/topic/79033-adding-new-sensors-using-prtg-api

The issue is when I need to add a 'D' or 'F' or any other drive letter than C. Me and the Powershell genius of our department can't figure this out. The parameter set for the snmpdiskfree sensor type will only give you C drives.

This is the most common error we get Add-Sensor : PRTG was unable to complete the request. The server responded with the following error: 'The validation of at least one of the new objects failed because of the following: Disk: Required field, not defined. The object was not created.'.

Here's another one Add-Sensor : PRTG was unable to complete the request. The server responded with the following error: Nothing was selected, no sensors could be created.

Do we have to make a raw set of parameters, like so? This hasn't worked. $raw = @{name_ = "Disk L" sensortype = "snmpdiskfree"; priority = "3"; disk_ = "1"; tags_ = 'snmpdiskfreesensor'; disk__check_ = 'L'; }

Thanks


Article Comments

Hi jbowser,

This is more so a question about PrtgAPI than a question about PRTG itself. As PrtgAPI is a third party product, questions regarding it should generally be raised as issues on GitHub rather than in the Paessler forums.

Looking at your code, I can see why this is not working. First of all, you have labelled your disk check property as "disk__check_" - I feel fairly confident that this should in fact be "disk__check" without the trailing underscore. Secondly, the value you are specifying to this property is simple "L" - usually the value of a sensor target encodes several properties, separated by pipes.

To construct raw sensor parameters it is important you follow the instructions on doing so very carefully, however generally speaking I would recommend *not* using raw sensor parameters, and rather using dynamic sensor parameters instead, which do all the hard work of specifying parameters and providing sensor targets for you.

You should be able to create an snmpdiskfree sensor easily by using code similar to the following

Get-Device -Id 1001 | New-SensorParameters -RawType snmpdiskfree -Target * | Add-Sensor

Please let me know how you go

Regards,

lordmilko


Dec, 2019 - Permalink

Thanks, the -Target parameter worked!


Dec, 2019 - Permalink