How to create the 'dockercontainer' sensor?
See original GitHub issueHey.
I’m trying to add the sensor for dockercontainers via the Powershell CLI
My code so far:
$Device = Get-Device -Id 1754
$Key = "-----BEGIN PRIVATE KEY-----
...
-----END PRIVATE KEY-----"
$Cert = "-----BEGIN CERTIFICATE-----
...
-----END CERTIFICATE-----"
$Params = $Device | New-SensorParameters -Verbose -RawType "dockercontainer" -QueryParameters @{
dockerport_ = 2376
key_ = "$Key"
cert_ = "$Cert"
}
$Params
And I get the following error
New-SensorParameters : An unspecified error occurred while trying to resolve sensor targets. Specified sensor type may not be valid on this device, or sensor query target parameters may be incorrect. Check the Device 'Host' is still valid or try adding sensor with the PRTG UI.
I tried some variations and debugging the script and the creation process via the PRTG UI and noticed that the UI sends a POST
request to addsensor3.htm
but with my code a GET
request will be sent.
Does anyone have any idea what I’m doing wrong or has a hint? I feel like I’m missing something.
Thanks for your Help.
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (6 by maintainers)
Top Results From Across the Web
PRTG Manual: Docker Container Status Sensor
The Docker Container Status sensor monitors the status of a Docker container. ... For a detailed list and descriptions of the channels that...
Read more >Docker: Install a sensor
Go to the sensor installation directory (for example, install_dir ) and run the docker-compose -f digicert_sensor_docker-compose.yml up -d command to create and ......
Read more >Docker Host sensor
The Docker Host Sensor uses REST APIs to retrieve the discovery related information from the Docker host machine running the 'dockerd' daemon process/ ......
Read more >Container Security Sensor Deployment Guide
download the sensor tar file from Qualys Cloud Platform and then install it on the host. - install the sensor from Docker Hub....
Read more >Docker Container Monitoring using PRTG
The last and final step is to install the docker sensor inside of PRTG. This should be fairly easy to accomplish by following...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I think I may have solved it!
Are you doing this in PowerShell or the PowerShell ISE? If PowerShell, can you try using the ISE instead?
I noticed when I type everything up in the ISE and hit F5 it runs without issue. When I save that script, open a regular PowerShell and then run the script, I get the same error as you! How can the same script generate different results in different circumstances?
The answer is that the response URI returned in PowerShell contains newlines (
\n
) whereas in the ISE the URI is all a single line. This appears to trip up our attempt to extract the tmpid from the response, resulting in a tmpid of<number>\n<certificate>
. PrtgAPI later tries to convert this string to a number, fails, and assumes it didn’t get a tmpid.The solution to this is to simply modify the tmpid extraction regex to treat the input string as a single line. I’m not sure whether you need to be running your code in a script automatically all the time or whether this is just a one time thing, however are you able to advise if using the ISE resolves the issue?
Regards, lordmilko
I tested your code on my own Docker instance and it worked fine. Are you sure the ID your Docker server’s PRTG device is 1754? I only get the error you get when I target a server that is not running the Docker Daemon
My Docker Daemon runs on Windows; the contents of my
daemon.json
are as follows