I want to set a sensor on our Probes that will show the local IP address of the device. How can I accomplish this?


Article Comments

Hello,

that should be possible using a Custom Exe Sensor parsing the output of an ipconfig /all command.

best regards.


Mar, 2012 - Permalink

Something like this will do in a batch file sensor:

@echo off
IPCONFIG |FIND "IPv4 Address" > %temp%\TEMPIP.txt
FOR /F "tokens=2 delims=:" %%a in (%temp%\TEMPIP.txt) do (
set ip=%%a
goto end
)
:end
del %temp%\TEMPIP.txt

set "space= "
for /f "tokens=* delims=%space%" %%a in ("%ip%") do set "ip=%%a"
echo 0:%ip%

Depending on the localized output if the ipconfig command, "IPv4 Address" must be replaced by "IP Address", "IP-adres", "IP-Adresse" or something simular


Mar, 2012 - Permalink

How do I set the EXE sensor to pull that information that is dumped to the file?


Mar, 2012 - Permalink

Hi Will,

There is no need to pull information from a file. Simply create a new .bat file in the "Custom Sensor/EXE" folder of your PRTG installation, paste the code above and that's the complete sensor.

Regards,


Mar, 2012 - Permalink

Thanks for the response. When I created the sensor it immediately went down and I could not get it to respond.


Mar, 2012 - Permalink

Hi Will,

You are right, PRTG does not like the white space at the beginning of the response. The script returned something like

0: 192.168.1.1

what needed to be

0:192.168.1.1

I modified the script to remove the white space.

Regards,


Mar, 2012 - Permalink