Wget -O/dev/null "$prtghost/$identtoken?content=$service status0Service: $service can't restart properly! Please take action!"Ĭreate the CRONTAB below on your Linux server to use the script. #Send response to PRTG that the restart was not successful Wget -O/dev/null "$prtghost/$identtoken?content=$service status1Service: $service restarted properly!" #Send response to PRTG that the restart was successfully If (( $(ps -ef | grep -v grep | grep $service | wc -l) > 0 )) Wget -O/dev/null "$prtghost/$identtoken?content=$service status0Service: $service is down, but will restart!" #Send response to PRTG that the service is not started. Wget -O/dev/null "$prtghost/$identtoken?content=$service status1Service: $service is running!" #Send response to PRTG that the service is running. If (( $(pgrep -x $service | wc -l) > 0 )) #Enter the Identification Token of the HTTP Push Data Advanced sensor. #Enter the server address of your PRTG, including HTTPS/HTTP and the sensor port. #The script also tries to restart the service if it is not started. #This script checks if a certain service is running. Save the following script on the target system, where it can be executed by CRON. The script also sends sensor messages like $service is running, $service is down, $service restarted properly, and $service can't restart properly.Value "1" means that the service is up and value "0" means that the service is down or could not properly restart.If the service is up, the script sends a report to the PRTG core server with the value "1".The script basically checks if the desired service is available or not.To monitor a service, restart it automatically, and push the current status to PRTG with HTTP, use the script below. This article applies as of PRTG 22 How to monitor, automatically restart, and report the current status of a Linux service
0 Comments
Leave a Reply. |