Closed Z3nto closed 5 years ago
Hi @Z3nto,
So to confirm you're saying the XML returned from the request contains expected data but Get-Sensor
doesn't actually output anything?
Can you please advise what the exact code you're typing is - i.e. whether you're specifying a wildcard (Get-Sensor -Tag wmi*
) or a full tag name (Get-Sensor -Tag wmicpuloadsensor
)
If you do (Get-Sensor -Tag *a*).count
, what is the response?
Hi @lordmilko thats right, the XML that I get with a browser using the URL from verbose output contains 1684 Sensors, but get-sensor doesn't output anything.
I'm using the full tag name without wildcard. I've just tried it with wildcard and this one works.
Here is the respone with and without wildcard
(Get-Sensor -Tag tableau).Count
0
(Get-Sensor -Tag *tableau*).Count
1684
Also here is the "tags" line from from one Item in the XML:
<tags>pingsensor,tableau</tags>
BR Z3nto
Thanks @Z3nto,
I am currently trying to setup a PRTG server with 1600 sensors that look like this and will see whether I can replicate the issue
Are you able to advise what the output of the following is?
get-sensor -tag *tableau*|select -first 1 -expand tags
I definitely think I may have stumbled upon the issue; tags added within the PRTG UI are normally delimited via spaces, not commas
<tags>pingsensor tableau first second third C_OS_VMware TestGroup TestProbe</tags>
When you type a comma in when adding tags in the PRTG UI, PRTG will finalize the previous tag you were entering, but the tags will still be delineated via spaces in the XML response
If you directly manipulate the tags of an object using the API however and delimit your tags using a comma instead of a space, PRTG will happily accept this, however this will result in your tags
value being technically malformed. Paessler appear to have anticipated this to some extent however, as your string will properly appear in the PRTG as two separate tags.
Are you able to advise whether your tableau tag was added to all these objects programmatically?
Given it appears to be illegal to contain commas in tags I would recommend either using a wildcard for now, or correcting the tags of all these objects to be "correct". You can see how you might do this with the following code (untested)
$sensors = Get-Sensor -Tag *tableau*
foreach($sensor in $sensors)
{
$tags = $sensor | Get-ObjectProperty tags
$fixed = $tags -split "," -join " "
Write-Host "Changing $sensor $($sensor.Id) tags from '$tags' to '$fixed'"
$sensor | Set-ObjectProperty tags $fixed
}
I will look into having Set-ObjectProperty
automatically replace any commas you specify as well as having the Tags
and ParentTags
properties in general understand that they should deserialize either splitting by spaces or by commas
Regards, lordmilko
Hi, wasn;t sure where to address this question, but I have some issues finding if there is a possibility to specify the token while you creating new sensor(http push) . Sorry if this is wrong place to ask this question, I will be very glad for the answer. Thanks in advance! BR Michal
Hi @MichalZadoroznyBanqsoft,
I am not sure what you mean by "token", however as this does not appear to be relevant to this issue please open a new issue to discuss this further
Hi @Z3nto,
Please be advised that PrtgAPI 0.9.9 has now been released, which includes a fix for this issue. To update PrtgAPI simply run
Update-Module PrtgAPI
and reopen PowerShell
Regards, lordmilko
Hi @lordmilko ,
it seems that get-sensor not working properly when using the -tag or -tags parameter. It returns less or nothing sensors while there are over 1000 with the specified tag. I've already checked the xml that is return from prtg (with the url in -verbose), it contains all Sensors.
Do you have an idea?
BR Z3nto