Hi,
I've been looking at a guide (https://helpdesk.paessler.com/en/support/solutions/articles/760000635110713-can-i-automatically-restart-a-windows-service-with-prtg) because I'd like to use PRTG to periodically restart a service on a destination server.
I don't want it to restart when the service is down, I just want it to restart at 03:00 each day, for example.
I was doing this with Task Scheduler but there is now a requirement to do this with PRTG so that we get notifications or get an alarm if the service doesn't successfully restart.
This guide above, however, requires the destination server to be resolved by hostname from the Core Server - in my setup, this isn't possible because the Core Server simply connects to a remote probe. The server with the remote probe installed does not have the folders that this guide tell you to put the scripts into (e.g. Notifications\EXE).
Can this be done?
Article Comments
You can use the batch script below as a Custom Sensor with a 30 min sensor interval.
The script needs to be placed in the "Custom Sensors\EXE" folder of your PRTG probe machine.
It will check if the current time is between 03:00 and 03:30 before restarting the service.
You will of cause need to replace the ServerName and ServiceName placeholders with their actual values.
@echo off For /f "tokens=1-4 delims=/:." %%a in ("%TIME%") do ( SET HH24=%%a SET MI=%%b SET SS=%%c SET FF=%%d ) :Check if hour is 03 IF NOT %HH24% == "03" GOTO ntd :Check if minute < 30 IF %MI% GTR 10 GOTO ntd :stop service SC \\ServerName stop ServiceName > nul :wait 3 seconds ping 1.1.1.1 -n 1 -w 3000 > nul :start service SC \\ServerName start ServiceName > nul GOTO restarted :ntd ECHO 0:Nothing to do GOTO end :restarted ECHO 1:Service has been restarted GOTO end :end
Nov, 2014 - Permalink
Hi,
PRTG is not designed for this kind of usage. Sorry. So there is no way to realize this.
Best regards
Nov, 2014 - Permalink