lordmilko / PrtgAPI

C#/PowerShell interface for PRTG Network Monitor
MIT License
301 stars 38 forks source link

$param = Get-Device -id 127399 | New-SensorParameters -RawType exexml -Target PSx64.exe #341

Open carsten0407 opened 1 year ago

carsten0407 commented 1 year ago

What's going on?

Im trying to add a sensor (exexml) with $param = Get-Device -id 127399 | New-SensorParameters -RawType exexml -Target PSx64.exe get-device -id 127399 | Add-Sensor $params

I get the param, but nothing happens no sensor will added.

scriptplaceholdergroup : 1 scriptplaceholder1description : scriptplaceholder1 : scriptplaceholder2description : scriptplaceholder2 : scriptplaceholder3description : scriptplaceholder3 : scriptplaceholder4description : scriptplaceholder4 : scriptplaceholder5description : scriptplaceholder5 : exefilelabel : exeparams : environment : 0 usewindowsauthentication : 0 mutexname : timeout : 60 writeresult : 0 anti-csrf-token : ZWJmNTc4MjZiZDJjMTY2ZmY2NmJjMThlMzcwMmQ5NGFjZTQ3OTg4OQ== exefile : PSx64.exe Targets : {[exefile, PrtgAPI.Targets.GenericSensorTarget[]]} Source : server.lan.local QueryParameters : SensorType : exexml Priority : Three InheritTriggers : True InheritInterval : True Interval : 00:01:00 IntervalErrorMode : OneWarningThenDown DynamicType : False Name : XML-Programm-/Skriptsensor Tags : {xmlexesensor} Cookie : False

If I try without -target $param = Get-Device -id 127399 | New-SensorParameters -RawType exexml ((((-Target PSx64.)))) the sensor will added but the wrong one with a wrong exefile

Due Dilligance

carsten0407 commented 1 year ago

PSVersion : 5.1.22621.1778 PSEdition : Desktop OS : Microsoft Windows 11 Enterprise PrtgAPIVersion : 0.9.18 Culture : de-DE CLRVersion : 533320 PrtgVersion : 23.2.83.1760 PrtgLanguage : german.lng

lordmilko commented 1 year ago

After executing this line

$param = Get-Device -id 127399 | New-SensorParameters -RawType exexml -Target PSx64.exe

Can you provide the output of $param

$param

In addition, what is the output of

get-device -id 127399 | Add-Sensor $params -Verbose

Please remove any sensitive information (such as your server address, username and passhash) in the verbose output

carsten0407 commented 1 year ago

Here the output

PS C:\Users\BID00422\OneDrive - KME\PRTG_Go_Dropbox\Scripts> $param = Get-Device -id 127399 | New-SensorParameters -RawType exexml -Target PSx64.exe PS C:\Users\BID00422\OneDrive - KME\PRTG_Go_Dropbox\Scripts> $param

scriptplaceholdergroup : 1 scriptplaceholder1description : scriptplaceholder1 : scriptplaceholder2description : scriptplaceholder2 : scriptplaceholder3description : scriptplaceholder3 : scriptplaceholder4description : scriptplaceholder4 : scriptplaceholder5description : scriptplaceholder5 : exefilelabel : exeparams : environment : 0 usewindowsauthentication : 0 mutexname : timeout : 60 writeresult : 0 anti-csrf-token : MzBjMWY1YmU4OGE3NjI0OWMwY2E2MWIwZWE2OTM2ZDk5MWIxYWQzYTdiNzVkZTgwZTdiYTJjZjAyN2VlYzUxYw== exefile : PSx64.exe Targets : {[exefile, PrtgAPI.Targets.GenericSensorTarget[]]} Source : SR.intern.local QueryParameters : SensorType : exexml Priority : Three InheritTriggers : True InheritInterval : True Interval : 00:01:00 IntervalErrorMode : OneWarningThenDown DynamicType : False Name : XML Custom EXE/Script Sensor Tags : {xmlexesensor} Cookie : False

After executing this line

$param = Get-Device -id 127399 | New-SensorParameters -RawType exexml -Target PSx64.exe

Can you provide the output of $param

$param

In addition, what is the output of

get-device -id 127399 | Add-Sensor $params -Verbose

Please remove any sensitive information (such as your server address, username and passhash) in the verbose output

— Reply to this email directly, view it on GitHubhttps://github.com/lordmilko/PrtgAPI/issues/341#issuecomment-1615527332, or unsubscribehttps://github.com/notifications/unsubscribe-auth/APIS7JBKOFA6WXME7IXG4T3XN63QVANCNFSM6AAAAAAZ2SFAHY. You are receiving this because you authored the thread.Message ID: @.**@.>>

carsten0407 commented 1 year ago

get-device -id 127399 | Add-Sensor $param -Verbose

Add-Sensor : PRTG was unable to complete the request. The server responded with the following error: Nothing was selected, no sensors could be created. In Zeile:1 Zeichen:25

[EXTERNAL E-MAIL] Use caution when following links or opening attachments.

After executing this line

$param = Get-Device -id 127399 | New-SensorParameters -RawType exexml -Target PSx64.exe

Can you provide the output of $param

$param

In addition, what is the output of

get-device -id 127399 | Add-Sensor $params -Verbose

Please remove any sensitive information (such as your server address, username and passhash) in the verbose output

— Reply to this email directly, view it on GitHubhttps://github.com/lordmilko/PrtgAPI/issues/341#issuecomment-1615527332, or unsubscribehttps://github.com/notifications/unsubscribe-auth/APIS7JBKOFA6WXME7IXG4T3XN63QVANCNFSM6AAAAAAZ2SFAHY. You are receiving this because you authored the thread.Message ID: @.**@.>>

lordmilko commented 1 year ago

Hi @carsten0407,

When you do get-device -id 127399 | Add-Sensor $param -Verbose it displays the raw HTTP request PrtgAPI attempted to execute. It appears you have completely omitted this text. Can you please provide the verbose output with just the server, username and password redacted

carsten0407 commented 1 year ago
AUSFÜHRLICH: Ausführen des Vorgangs "Add-Sensor" für das Ziel "XML Custom EXE/Script Sensor (Destination: SRV-BACKUP01-19.thuemlein.local (ID: 127399))".
AUSFÜHRLICH: Add-Sensor: Synchronously executing request
https://monserver.intern.de/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,sc 
hedule,basetype,baselink,notifiesx,intervalx,access,dependency,position,status,comments,priority,message,parentid,tags,type,active&count=*&filter_parentid=127399&filter_type=exexml&username=AA_monserver-PowershellUser&passhash=xxxxxxxxxx
AUSFÜHRLICH: Add-Sensor: Synchronously executing request https://monserver.intern.de/controls/addsensor2.htm?id=127399&sensortype=exexml&username=AA_monserver-PowershellUser&passhash=xxxxxxxxxx
AUSFÜHRLICH: Add-Sensor: Synchronously executing request 
https://monserver.intern.de/addsensor5.htm?name_=XML+Custom+EXE%2FScript+Sensor&priority_=3&inherittriggers=1&intervalgroup=1&interval_=60%7C60+seconds&errorintervalsdown_=1&tags_=xmlexesensor&scriptplaceholdergroup=1&scriptplaceholder1de 
scription_=&scriptplaceholder1_=&scriptplaceholder2description_=&scriptplaceholder2_=&scriptplaceholder3description_=&scriptplaceholder3_=&scriptplaceholder4description_=&scriptplaceholder4_=&scriptplaceholder5description_=&scriptplaceholder5_=&exefil 
elabel=&exeparams_=&environment_=0&usewindowsauthentication_=0&mutexname_=&timeout_=60&writeresult_=0&anti-csrf-token=Nzc5MDJkNzE1OTAxMjdjY2U3ZTg0NzFkNmJhMWU3YzY5MjI4ODJiMzExMDI5MzFmNGY2OWE5ZTc3ZmEzZDdjNg%3D%3D&exefile=PSx64.exe%7CPSx64.exe%7C%7C&sens 
ortype=exexml&id=127399&tmpid=62
Add-Sensor : PRTG was unable to complete the request. The server responded with the following error: Nothing was selected, no sensors could be created.
In Zeile:1 Zeichen:25
+ get-device -id 127399 | Add-Sensor $param -Verbose
+                         ~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Add-Sensor], PrtgRequestException
    + FullyQualifiedErrorId : PrtgRequestException,PrtgAPI.PowerShell.Cmdlets.AddSensor
carsten0407 commented 1 year ago

Any updates?

carsten0407 commented 1 year ago

Strange, if I rename my wanted exefile to 1st place in alphabetical order it works. If not he always uses arcserve.exe Any ideas? 2023-07-07 08_33_22-Window

lordmilko commented 1 year ago

Hi @carsten0407,

Please be advised I have managed to reproduce this error and am investigating

lordmilko commented 1 year ago

I couldn't see anything immediately obvious in my investigation aside from the fact PRTG uses POST to execute addsensor5.htm (PrtgAPI uses GET). This has always been the case and worked without issue; it's possible PRTG have changed things in a recent version such that GET no longer works on this endpoint. A bit of investigation/work would need to be done to try and resolve this; I am currently having medical issues so don't have the time to investigate this at the moment. I'm unable to give any ETA as to when this might be resolved

carsten0407 commented 1 year ago

Hi lordmilko,

take your time