New Question
 
 
PRTG Network Monitor

Intuitive to Use.
Easy to manage.

200.000 administrators have chosen PRTG to monitor their network. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free PRTG
Download >>

 

What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general. You are invited to get involved by asking and answering questions!

Learn more

 

Top Tags


View all Tags


Can I create an inverse Ping sensor?

Votes:

0

Your Vote:

Up

Down

In our network, we monitor devices that usually should not be reachable. If they go online, something is wrong. A typical example for this would be a scenario of a backup ISDN router going online only if the usual broadband Internet connection fails.

I want to set up a Ping sensor that acts in an inverse / reverse way: It shows a green OK status if a device is not reachable, and a red Error status when a device answers to a Ping.

How can I do that?

custom-script-exe custom-sensor exe exe-sensor inverse ping prtg reverse

Created on Oct 13, 2010 12:40:21 PM by  Daniel Zobel [Paessler Support]

Last change on Mar 19, 2015 3:44:48 PM by  Martina Wittmann [Paessler Support]



2 Replies

Accepted Answer

Votes:

0

Your Vote:

Up

Down

This article applies to PRTG Network Monitor 16 or later

Inverse Ping with a Windows Script File

With an EXE/Script sensor, you can use a Windows command script (.cmd/.bat) to send a Ping request to a device and return an error when it is actually reachable.

We've tested the following script successfully:

@echo off
PING %1 > nul
if errorlevel 1 (echo 0:OK - Ping to %1 failed && EXIT /B 0) else (echo 1:Error - Ping to %1 successful && EXIT /B 2)

For Windows 2008 and Windows 7, use this script (see answer below):

@echo off

ping -n 2 %1|Findstr /I /C:"timed out" /C:"host unreachable" /C:"could not find host" > nul
if %errorlevel%==0 (echo 0:OK - Ping to %1 failed && EXIT /B 0) else (echo 1:Error - Ping to %1 successful && EXIT /B 2)

Steps to take

  1. In the \PRTG Network Monitor\Custom Sensors\EXE sub-directory of your PRTG installation, create a BAT or CMD file inverse_ping.cmd containing the script shown above. In a cluster installation, copy this file to every cluster node.
  2. In PRTG, add a new EXE/Script sensor.
    • In the sensor settings, choose inverse_ping.cmd from the EXE/Script drop down menu.
    • In the Parameters field, enter the DNS name or IP address of the device you want to Ping.
    • Save your settings.
  3. The sensor will start monitoring immediately.
    • If the configured device does not answer to a Ping, the sensor will show a green OK status, the last message OK - Ping to xyz failed, and the last result 0.
    • If the configured device does actually answer to a Ping, the sensor will show a red Down status, the last message Error - Ping to xzy successful, and the last result 1.

Notes

  • The values returned by the script do not correspond to the measured Ping times, but are merely to indicate the status. To additionally measure Ping times, you can add another sensor. Please see How to create/customize statistical PING sensor? for more information.
  • As usual, you can set up notification triggers to be notified when the EXE/Script sensor's state changes.
  • Issues related to custom sensors are not covered by Paessler's 24-hours support offer.

Created on Oct 13, 2010 1:04:06 PM by  Daniel Zobel [Paessler Support]

Last change on Apr 20, 2018 9:14:52 AM by  Dariusz Gorka [Paessler Support]



Votes:

1

Your Vote:

Up

Down

This doesn't work on Windows 2008 R2

Looks like this issue - http://superuser.com/questions/403905/ping-from-windows-7-get-no-reply-but-sets-errorlevel-to-0

I used this instead as per the URL above

@echo off

ping -n 2 %1|Findstr /I /C:"timed out" /C:"host unreachable" > nul
if %errorlevel%==0 (echo 0:OK - Ping to %1 failed && EXIT /B 0) else (echo 1:Error - Ping to %1 successful && EXIT /B 2)

Created on Jan 14, 2013 1:49:09 AM by  incog (10)

Last change on Jan 14, 2013 9:51:39 AM by  Daniel Zobel [Paessler Support]



Please log in or register to enter your reply.


Disclaimer: The information in the Paessler Knowledge Base comes without warranty of any kind. Use at your own risk. Before applying any instructions please exercise proper system administrator housekeeping. You must make sure that a proper backup of all your data is available.