Initialer Commit
This commit is contained in:
parent
23bd8b3f0a
commit
61a3a377e3
14
README.md
14
README.md
@ -1,3 +1,15 @@
|
|||||||
# prtg-linux-service-monitor
|
# prtg-linux-service-monitor
|
||||||
|
|
||||||
Ein kleines Bash Script um Linux Services mit dem PRTG Monitor zu überwachen
|
Ein kleines Bash Script um Linux Services mit dem PRTG Monitor zu überwachen
|
||||||
|
|
||||||
|
# Script herunterladen
|
||||||
|
|
||||||
|
git clone https://git.media-techport.de/scriptos/prtg-linux-service-monitor.git
|
||||||
|
|
||||||
|
# Cronjob setzen:
|
||||||
|
|
||||||
|
*/5 * * * * /home/scripts/default/prtg-service-mon.sh <service> <monitoring-server:5050> <guid> > /dev/null 2>&1
|
||||||
|
|
||||||
|
# Folgenden Sensor in PRTG anlegen:
|
||||||
|
|
||||||
|
HTTP Push Data Advanced sensor
|
||||||
|
8
cronjob.txt
Normal file
8
cronjob.txt
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
#Cronjob hinzufügen
|
||||||
|
#Vorher anpassen:
|
||||||
|
|
||||||
|
*/5 * * * * /home/scripts/default/prtg-service-mon.sh <service> <monitoring-server:5050> <guid> > /dev/null 2>&1
|
||||||
|
|
||||||
|
#Koennte dann folgendermaßen aussehen:
|
||||||
|
|
||||||
|
*/5 * * * * /home/scripts/default/prtg-service-mon.sh subsonic deinmonitoringserver.de:5050 8bae8b35-7fc4-4503-ab45-115b18e47d51 > /dev/null 2>&1
|
42
prtg-service-mon.sh
Normal file
42
prtg-service-mon.sh
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# ____ ____ ____________
|
||||||
|
# / __ \/ __ \/_ __/ ____/
|
||||||
|
# / /_/ / /_/ / / / / / __
|
||||||
|
# / ____/ _, _/ / / / /_/ /
|
||||||
|
#/_/ /_/ |_| /_/ \____/
|
||||||
|
# NETWORK MONITOR
|
||||||
|
#-------------------
|
||||||
|
#(c) 2016 Dariusz Gorka, Paessler AG
|
||||||
|
#
|
||||||
|
#This script checks if a certain service is running.
|
||||||
|
#The script also tries to restart the service if it is not started.
|
||||||
|
#
|
||||||
|
|
||||||
|
#Enter the correct process name. (ps -e)
|
||||||
|
service=$1
|
||||||
|
#Enter the server address of your PRTG, including HTTPS/HTTP and the sensor port.
|
||||||
|
prtghost=$2
|
||||||
|
#Enter the Identification Token of the HTTP Push Data Advanced sensor.
|
||||||
|
identtoken=$3
|
||||||
|
|
||||||
|
#Check if process is running
|
||||||
|
if (( $(pgrep -x $service | wc -l) > 0 ))
|
||||||
|
then
|
||||||
|
#Send response to PRTG that the service is running.
|
||||||
|
wget -O/dev/null "$prtghost/$identtoken?content=<prtg><result><channel>$service status</channel><value>1</value></result><text>Service: $service is running!</text></prtg>"
|
||||||
|
else
|
||||||
|
#Send response to PRTG that the service is not started.
|
||||||
|
wget -O/dev/null "$prtghost/$identtoken?content=<prtg><result><channel>$service status</channel><value>0</value></result><text>Service: $service is down, but will restart!</text></prtg>"
|
||||||
|
#Try to restart the service
|
||||||
|
/etc/init.d/$service start
|
||||||
|
|
||||||
|
#Check if restart was successfully
|
||||||
|
if (( $(ps -ef | grep -v grep | grep $service | wc -l) > 0 ))
|
||||||
|
then
|
||||||
|
#Send response to PRTG that the restart was successfully
|
||||||
|
wget -O/dev/null "$prtghost/$identtoken?content=<prtg><result><channel>$service status</channel><value>1</value></result><text>Service: $service restarted properly!</text></prtg>"
|
||||||
|
else
|
||||||
|
#Send response to PRTG that the restart was not successful
|
||||||
|
wget -O/dev/null "$prtghost/$identtoken?content=<prtg><result><channel>$service status</channel><value>0</value></result><text>Service: $service can't restart properly! Please take action!</text></prtg>"
|
||||||
|
fi
|
||||||
|
fi
|
Loading…
Reference in New Issue
Block a user