Hey I'm using nvsmi to get the gpu utilization on my clientmachine. I created a .bat script with following code and added it via Advanced EXE/XML Sensor

@echo off echo ^<?xml version="1.0" encoding="Windows-1252" ?^> echo ^<prtg^> echo ^<result^> echo ^<channel^>GPU0 Power Draw^</channel^> echo ^<float^>1^</float^> echo ^<value^> echo "C:\Program files\NVIDIA Corporation\NVSMI\nvidia-smi.exe" --query-gpu=utilization.gpu --format="csv,nounits,noheader" echo ^</value^> echo ^</result^> echo ^</prtg^>

The Command "C:\Program files\NVIDIA Corporation\NVSMI\nvidia-smi.exe" --query-gpu=power.draw --format="csv,nounits,noheader" returns a float value, like 86.3 if I paste it in cmd. But in PRTG in returns 0# as a value. It happens if I use --query-gpu=power.draw, or --query-gpu=temperature.gpu as a parameter for nvsmi too. so I guess there's a formatting error in my sensor code.


Article Comments

Hello,

please enable the "Result to disk" option in the sensor in order to check what the sensor reads from the console.

It could be that the executable does not run unless you change the security context in the sensor in order to run with user impersonation using the device object's Windows credentials.

It could also be that the output has to be changed, using comma instead of dot.


Sep, 2020 - Permalink

The results of this Sensor: <?xml version="1.0" encoding="Windows-1252" ?> <prtg> <result> <channel>GPU Utilization</channel> <float>1</float> <value> "C:\Program files\NVIDIA Corporation\NVSMI\nvidia-smi.exe" --query-gpu=utilization.gpu --format="csv,nounits,noheader" </value> </result> </prtg>

I guess the problem is that I can't connect to the target device. Maybe I need to integrate winrs in this script ?


Oct, 2020 - Permalink

Hello,

it seems that the smi tool is not executed, because the command itself is written as output value. Please make sure that the command is executed and its output somewhere stored so that you can use it for the script.


Oct, 2020 - Permalink

Hello,

indeed, the script is run on the probe, not on the target device. This leaves you two options:

  • Use remote-powershell in the script. You can pass login credential from the PRTG device either with parameters, or with environment variables
  • Run the script via Windows Scheduler directly on the target, have it perform an HTTP POST to communicate with a HTTP Push Data Advanced sensor setup on a PRTG probe.

Oct, 2020 - Permalink

Im not that well with PS or HTTP Push Data Syntax, so I found another way by writing the value of nvsmi to a file and access via .bat script.

@echo off
FOR /F "tokens=* delims=" %%x in (\\pcname\logs\gpu_temp.csv) DO echo %%x

The script is working so far, but I need to create a script for each machine I want to monitor. Is there a way to import "%host" parameter in the batch file? Then I could replace "pcname" in the file path.


Oct, 2020 - Permalink

Hello,

you can pass parameters to the script. Inside the script, parameters are normally processed as if the script was started via the command line.


Oct, 2020 - Permalink

Hello. A full guide here https://www.pennyitsupport.eu/drupal/node/15


Jun, 2021 - Permalink