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?


Article Comments

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


Sep, 2012 - Permalink

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.


Aug, 2020 - Permalink