What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general.

Learn more

PRTG Network Monitor

Intuitive to Use. Easy to manage.
More than 500,000 users rely on Paessler PRTG every day. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free Download

Top Tags


View all Tags

Can I create a sensor to regularly test my notifications?

Votes:

0

I would like to have a sensor which is always green, but turns to a red "Error" status for a short while, twice a day.

I want to use this kind of sensor to intentionally trigger my SMS text message notifications to make sure they work when they're needed.

How can I achieve this?

custom-exe custom-script-exe exe-script-sensor notifications powershell prtg ps1 test

Created on Sep 5, 2012 9:24:24 AM by  Daniel Zobel [Product Manager]

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



2 Replies

Accepted Answer

Votes:

1

This article applies to PRTG Network Monitor 12 or later

Powershell Script for EXE/Script Sensor

Using the following script you can create an EXE/Script Sensor which is usually green, but shows an error twice a day. Attach a notification trigger to this sensor in order to test your notifications, e.g. by intentionally sending out an SMS text messages for testing.

PowerShell Script

We provide the following script without any warranty or support. Please adapt it to your needs. Thanks to Raffaele for sharing this idea with our support team!

$Time = date -f hhmm
if ($args[0] -eq $Time -or $args[1] -eq $Time) {
                $msg="2:Error"
                $exit=2

}else {
                $msg="0:ok"
                $exit=0
}
write-host $msg
exit $exit

Start Parameters

The script accepts two start parameters in which you can define the times when the sensor will show a Down status. Define them when adding your EXE/Script sensor to PRTG.

  • Provide the times in hhmm 24 hours format (without a colon symbol).
  • The first parameter is mandatory, the second is optional.

In the example below we provided the parameters

0700 1900

which will switch the sensor to show an error every day at 7 a.m. and 7 p.m.


Example Start Parameters

See Also

Created on Sep 5, 2012 9:33:09 AM by  Daniel Zobel [Product Manager]

Last change on Sep 6, 2012 7:26:59 AM by  Daniel Zobel [Product Manager]



Votes:

0

Thank you for this script. Helps me a lot.

Just as a addtion: I had to change hhmm to HHmm to get 24-hour format into the $Time variable.

Created on Aug 2, 2020 4:22:09 PM




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.