Closed bvanbavel closed 5 years ago
Hi @bvanbavel,
Can you please confirm whether the sensor is created and resolved properly if you set the name of the sensor to be Base Sensor
instead?
If you have a look at the fields available when you attempt to create a SNMP Library sensor in the PRTG UI, there is no "name" field available. This indicates the name will be dynamically generated from the parameters you specify; it's possible PRTG is creating the wrong sensor type because you specified a name.
If you had tried to create these parameters via dynamic sensor parameters you would see the default name is "Base Sensor", however because we have to select an oidlib think that's why we have to use custom parameters for this sensor type.
I managed to test your code against some of my own PRTG servers; on PRTG 17.3 the sensors are successfully created as snmplibrary sensors. On PRTG 18.4 I can see snmpcustomtable sensors are created. Changing the name to Base Sensor
did not help
As I don't have any SNMP Linux devices on my 18.4 instance, can you please add one of these sensors using the PRTG UI and confirm whether it creates snmpcustomtable sensors as well?
Hi @bvanbavel ,
I have been able to confirm it is now normal behavior for snmplibrary sensors to have dynamic types once they have been created.
As such, I have now compiled a release candidate for PrtgAPI 0.9.3 which should include a fix for this issue. New-SensorParameters
now includes a new -DynamicType
parameter. When specified, the new DynamicType
property of NewSensorParameters
objects will be automatically set to true
. This will cause Add-Sensor
to relax its sensor resolution algorithm to ensure all created sensors are retrieved
$params = New-SensorParameters $table -DynamicType
$device | Add-Sensor $params
Can you please perform the following steps and confirm whether the issue has been resolved?
-DynamicType
to New-SensorParameters
Regards, lordmilko
Hi @lordmilko , I can confirm that this fixes the issue! Many thanks for this. Kind regards, Bart
Thanks @bvanbavel,
Barring any other issues, once I have confirmed #45 is also fixed I will release this update to NuGet
Regards, lordmilko
Hi @bvanbavel,
PrtgAPI 0.9.3 has now been released. To update to the latest version, please run Update-Module PrtgAPI
and reopen PowerShell
Regards, lordmilko
When I try to create a sensor with custom parameters below the state keeps giving: WARNING: 'Add-Sensor' failed to resolve sensor: object is still being created. Retries remaining: 3 Finally it times out with: Add-Sensor : Could not resolve object: PRTG is taking too long to create the object. Confirm the object has been created in the Web UI and then attempt resolution again manually
What i can see is that the sensortype is snmplibrary, but when the sensor is created and the type is determined with the command Get-Sensor the sensortype created is snmpcustomtable. I tried with fiddler filters to modify the sensortype in the get status request from snmplibrary to snmpcustomtable the issue is resolved and I can see the ID of the sensor created. When I modify the sensortype in the powershell script it does not create my sensor.
Can you fix the code so it can use a different type in the status get request that in the script or is there another alternative to this problem?
GET request modified with fiddler: GET /api/table.xml?content=sensors&columns=objid,name,probe,group,favorite,lastvalue,device,downtime,downtimetime,downtimesince,uptime,uptimetime,uptimesince,knowntime,cumsince,lastcheck,lastup,lastdown,minigraph,schedule,basetype,baselink,parentid,notifiesx,intervalx,access,dependency,position,status,comments,priority,message,tags,type,active&count=*&filter_name=@sub(KEA+DHCP)&filter_parentid=46820&username=bvanbavel&passhash=<> HTTP/1.1
Powershell code: $table = @{ name = "BLA" sensortype = "snmplibrary" library="C:\Program Files (x86)\PRTG Network Monitor\snmplibs\Basic Linux Library (UCD-SNMP-MIB).oidlib" interfacenumber_ = 1 interfacenumber__check = "1.3.6.1.4.1.2021.2.1.100.1|Basic Linux Library (UCD-SNMP-MIB)|Processes: 1|Processes Error Flag|#|0|0|Processes Error Flag|2|1|0|1|A Error flag to indicate trouble with a process. It goes to 1 if there is an error, 0 if no error.|0|0|0|0||1.3.6.1.4.1.2021.2.1.100|prErrorFlag|1.3.6.1.4.1.2021.2||ASN_INTEGER|0|ASN_INTEGER||Basic Linux Library (UCD-SNMP-MIB)|Processes: #[1.3.6.1.4.1.2021.2.1.1]|100|||||||||||||||||||||||||||||||||||","1.3.6.1.4.1.2021.2.1.5.1|Basic Linux Library (UCD-SNMP-MIB)|Processes: 1|Processes Count|#|0|0|Processes Count|2|1|0|1|The number of current processes running with the name in question.|0|0|0|0||1.3.6.1.4.1.2021.2.1.5|prCount|1.3.6.1.4.1.2021.2||ASN_INTEGER|0|ASN_INTEGER||Basic Linux Library (UCD-SNMP-MIB)|Processes: #[1.3.6.1.4.1.2021.2.1.1]|5|||||||||||||||||||||||||||||||||||","1.3.6.1.4.1.2021.2.1.1.1|Basic Linux Library (UCD-SNMP-MIB)|Processes: 1|Processes Index|#|0|0|Processes Index|2|1|0|1|Reference Index for each observed process.|0|0|0|0||1.3.6.1.4.1.2021.2.1.1|prIndex|1.3.6.1.4.1.2021.2||ASN_INTEGER|0|ASN_INTEGER||Basic Linux Library (UCD-SNMP-MIB)|Processes: #[1.3.6.1.4.1.2021.2.1.1]|1|||||||||||||||||||||||||||||||||||" } $params = New-SensorParameters $table $device | Add-Sensor $params -verbose