I want to set a sensor on our Probes that will show the local IP address of the device. How can I accomplish this?
Probe IP address sensor
Votes:
0
Best Answer
Votes:
0
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
Created on Mar 14, 2012 1:58:37 PM
Last change on Mar 23, 2012 3:29:23 PM by
Torsten Lindner [Paessler Support]
6 Replies
Votes:
0
Hello,
that should be possible using a Custom Exe Sensor parsing the output of an ipconfig /all command.
best regards.
Votes:
0
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
Created on Mar 14, 2012 1:58:37 PM
Last change on Mar 23, 2012 3:29:23 PM by
Torsten Lindner [Paessler Support]
Votes:
0
How do I set the EXE sensor to pull that information that is dumped to the file?
Votes:
0
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,
Votes:
0
Thanks for the response. When I created the sensor it immediately went down and I could not get it to respond.
Votes:
0
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,
Created on Mar 22, 2012 10:01:07 AM
Last change on Jun 2, 2015 12:31:18 PM by
Luciano Lingnau [Paessler]
Add comment