Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when I try to add a sensor #365

Open
2 tasks done
BragaGuilherme opened this issue Nov 6, 2023 · 11 comments
Open
2 tasks done

Error when I try to add a sensor #365

BragaGuilherme opened this issue Nov 6, 2023 · 11 comments
Labels
question Questions raised by people who don't know how to program or read the wiki :P

Comments

@BragaGuilherme
Copy link

What's going on?

Hello Lord Milko, how are you?

I was trying to run this command:

$table = @{ "name_" = "PCT_CROMATOGRAFIA_NITROGENIO"; "pythonscript_" = "Modbus Python.py";"params_" ="registro=17231,nome=PCT_CROMATOGRAFIA_NITROGENIO,tipo=32float";"sensortype" = "pythonscript";"comments_"="teste"};$params = New-SensorParameters $table; Get-Device -Id 39273 | Add-sensor $params;

It was working fine earlier, but now it keeps giving me this error:

Add-sensor : Could not authenticate to PRTG; the specified username and password were invalid.
No linha:1 caractere:280

  • ... w-SensorParameters $table; Get-Device -Id 39273 | Add-sensor $params;
  •                                                   ~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : NotSpecified: (:) [Add-Sensor], HttpRequestException
    • FullyQualifiedErrorId : System.Net.Http.HttpRequestException,PrtgAPI.PowerShell.Cmdlets.AddSensor

Can you help me with this?

Captura de tela 2023-11-06 155200

Due Dilligance

  • It wasn't covered by the wiki, I swear!
  • I have tried doing some basic research on this issue but haven't been able to come up with anything. Please help!
@BragaGuilherme BragaGuilherme added the question Questions raised by people who don't know how to program or read the wiki :P label Nov 6, 2023
@lordmilko
Copy link
Owner

Please provide the output of Get-PrtgClient -Diagnostic

@BragaGuilherme
Copy link
Author

Here lord,
image

@BragaGuilherme
Copy link
Author

I have another question: how can I create sensors that remain paused? The situation is that there are sensors that are not needed at the moment, but I would like to have them created but in a paused state. Is there a way to achieve this? Would it involve using the Pause-Object/Suspend-Object cmdlets? If so, could you provide an example? I tried using these cmdlets, but I wasn't successful.

@xasz
Copy link

xasz commented Nov 9, 2023

What Sensor are you trying to add ?
I have never added a phytonscript sensor, but i think here are some basic problems.
At least on my instance the New-SensorParameters Cmdlet have not -Type phytonscript

Furthermore if you want to build hashmap for the parameters, which i see no point in that szenario, you need to use @
like New-SensorParameters @table

@BragaGuilherme This should be possible with basic powershell piping:

Get-Device -Id 148376 | Get-Sensor -Name Ping | Pause-Object -Forever -Message "You are not needed"

@BragaGuilherme
Copy link
Author

BragaGuilherme commented Nov 13, 2023

Here lord, image

This issue has reappeared. What could I do to work around it?

One point, the address of this PRTG has a certificate error, and I have to use -IgnoreSSL when logging in. Could this interfere?

@xasz
Copy link

xasz commented Nov 13, 2023

What issue? You should add sime information... ?

@nickhoksbergen
Copy link

nickhoksbergen commented Nov 14, 2023

I have the same issue when adding sensors with either the New-Sensor or Add-Sensor cmdlets.

This is the code I run:

$device = $newgroup | get-device | select -first 1
$device | new-sensor -ExeFile "NonDefaultServicesV2.ps1" -Name "Non Default Services" -ExeXml

$params = New-SensorParameters ExeXml "Non Default Services"
$params.ExeFile = "NonDefaultServicesV2.ps1"
$params.ExeParameters = "-FQDN %host"
$device | Add-Sensor $params

This is the result

Schermafbeelding 2023-11-14 125048

Result of 'Get-PrtgClient -Diagnostic'
PSVersion : 5.1.22621.2428
PSEdition : Desktop
OS : Microsoft Windows 11 Enterprise
PrtgAPIVersion : 0.9.18
Culture : nl-NL
CLRVersion : 533320
PrtgVersion : 23.4.88.1429
PrtgLanguage : english.lng

@xasz
Copy link

xasz commented Nov 14, 2023

Your prtgapi Version ist Not Up2date.

@BragaGuilherme
Copy link
Author

What issue? You should add sime information... ?

Yes, I am trying to add a PythonScript sensor, which has worked before. The issue is that when I try to execute it, accessing another PRTG that is only accessible via IP and does not have a security certificate, this happens.

@xasz
Copy link

xasz commented Nov 14, 2023

Does IT Work any other Sensors. I think you should Test one oneliner on which command IT Is failing. I cannot See that from you informations posted.

@lordmilko
Copy link
Owner

lordmilko commented Nov 16, 2023

I tested PrtgAPI 0.9.19 on PRTG 23.4.90.1299

$params = New-SensorParameters ExeXml "Non Default Services"
$params.ExeFile = "NonDefaultServicesV2.ps1"
$params.ExeParameters = "-FQDN %host"
$device | Add-Sensor $params

I was able to run this code

Are you able to update to PRTG 23.4.90.1299 and advise if you're still having the issue? I didn't test on an earlier version of PRTG

If you're still having issues are you potentially able to try a ping sensor as well?

$device | New-SensorParameters -rt ping | Add-Sensor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Questions raised by people who don't know how to program or read the wiki :P
Projects
None yet
Development

No branches or pull requests

4 participants