I have a website that runs internally on a windows IIS server. Sometimes the site stops responding. I have an HTTP full page load sensor and I have a wmi w3svc service sensor. Is there a way to have a failure on the HTTP sensor trigger a w3svc service restart?


Article Comments

How about having a .bat file as a notification?

Create a new .bat file in the "\Notifications\EXE" folder of your PRTG installation and paste the content below.

@echo off
rem stop service
sc <server> stop <service name>
rem start service again
sc <server> start <service name>

Replace <server> and <service name> with the actual names of the server running the service and the service name. Next create a new notification, set this notification to execute a program and select the .bat file you created.


Jun, 2014 - Permalink

Ok, I have to admit that although my previous answer in theory will work, there are some point left for improvement:

  • Check if the service really stops and starts.
  • Timeout between stopping and starting the service.
  • Error handling.
  • As the PRTG service by default runs under the local system account, it cannot rerstart services on a remote computer.

The above has been integrated into Custom Notification PTF.ServiceRestart

PTF.ServiceRestart allows you to (re)start a service on a (remote) computer and takes the following parameters:

-c= The hostname or IP of the computer running the service.
-s= The name of the service to restart.
-u= Optional the domain\username of an account that is allowed to restart the service.
-p= Optional the password or PassHash(*) of an account that is allowed to restart the service.
-t= Optional the number of seconds for the service to stop and start.
 (Default = 15 sec)

PTF.Servicerestart can be downloaded from http://PRTGToolsFamily.com/?page=downloads_notifications


Jun, 2014 - Permalink

Thanks so much for your help. I believe this is exactly what I need. I have downloaded the notification, however, I do not see any instructions for implementing. I understand that I need to place the exe in the correct folder on my PRTG server, but what then how is the notification configured?


Jun, 2014 - Permalink

The .exe needs to be copied to the '\Notifications\EXE' folder of your PRTG installation.

Next, setup a new notification and choose to 'Execute Program'. Select the ServiceRestart.exe and provide the parameters as explained above.

You can also double click the .exe for a listing of parameters supported.

Tip: before implementing the notification, run to .exe from the command line (including its parameters) to make sure you go the parameters correct.


Jun, 2014 - Permalink