Update Readme.md
This commit is contained in:
157
README.md
157
README.md
@@ -1,53 +1,104 @@
|
||||
<p># prtg-linux-service-monitor Ein kleines Bash Script um Linux Services mit dem PRTG Monitor zu überwachen</p>
|
||||
<div style="direction: ltr; border-width: 100%;">
|
||||
<div style="direction: ltr; margin-top: 0in; margin-left: 0in; width: 7.4361in;">
|
||||
<div style="direction: ltr; margin-top: 0in; margin-left: 0in; width: 7.4361in;">
|
||||
<ol style="direction: ltr; unicode-bidi: embed; margin-top: 0in; margin-bottom: 0in; font-family: Calibri; font-size: 11.0pt; font-weight: normal; font-style: normal;" type="1">
|
||||
<li style="margin-top: 0; margin-bottom: 0; vertical-align: middle;" value="1"><span style="font-family: Calibri; font-size: 11.0pt; font-weight: normal; font-style: normal;">Script installieren</span></li>
|
||||
</ol>
|
||||
<p style="margin: 0in; margin-left: .75in; font-family: Calibri; font-size: 11.0pt;">mkdir -p /temp && cd /temp</p>
|
||||
<p style="margin: 0in; margin-left: .75in; font-family: Calibri; font-size: 11.0pt;">git clone <a href="https://git.media-techport.de/scriptos/prtg-linux-service-monitor.git">https://git.media-techport.de/scriptos/prtg-linux-service-monitor.git</a></p>
|
||||
<p style="margin: 0in; margin-left: .75in; font-family: Calibri; font-size: 11.0pt;">cd prtg-linux-service-monitor</p>
|
||||
<p style="margin: 0in; margin-left: .75in; font-family: Calibri; font-size: 11.0pt;">cp prtg-service-mon.sh /home/scripts/default/prtg-service-mon.sh</p>
|
||||
<p style="margin: 0in; margin-left: .75in; font-family: Calibri; font-size: 11.0pt;">chmod 711 /home/scripts/default/prtg-service-mon.sh</p>
|
||||
<p style="margin: 0in; font-family: Calibri; font-size: 11.0pt;"> </p>
|
||||
<ol style="direction: ltr; unicode-bidi: embed; margin-top: 0in; margin-bottom: 0in; font-family: Calibri; font-size: 11.0pt; font-weight: normal; font-style: normal;" type="1">
|
||||
<li style="margin-top: 0; margin-bottom: 0; vertical-align: middle;" value="2"><span style="font-family: Calibri; font-size: 11.0pt; font-weight: normal; font-style: normal;">Cronjob einrichten</span></li>
|
||||
</ol>
|
||||
<p style="margin: 0in; margin-left: .75in; font-family: Calibri; font-size: 11.0pt;">cat <(crontab -l) <(echo "*/5 * * * * /home/scripts/default/prtg-service-mon.sh mariadb push.mon01.media-techport.de:5050 b2949934-1f05-40b0-afd8-856ac7e534cd > /dev/null 2>&1") | crontab -</p>
|
||||
<p style="margin: 0in; margin-left: 1.125in; font-family: Calibri; font-size: 11.0pt;">Beschreibung für die Parameter hinter dem Befehl:</p>
|
||||
<p style="margin: 0in; margin-left: 1.125in; font-family: Calibri; font-size: 11.0pt;"><span style="font-size: 11pt;">1. ist der Service, welcher überwacht werden soll</span></p>
|
||||
<p style="margin: 0in; margin-left: 1.125in; font-family: Calibri; font-size: 11.0pt;"><span style="font-family: Calibri; font-size: 11.0pt;">2. ist der Server, an dem die Push gesendet wird</span></p>
|
||||
<p style="margin: 0in; margin-left: 1.125in; font-family: Calibri; font-size: 11.0pt;"><span style="font-family: Calibri; font-size: 11.0pt;">3. ist die GUID zur Identifizierung (der sogenannte Ident, dieser muss für jeden Sensor anders sein)</span></p>
|
||||
<p style="margin: 0in; margin-left: 1.125in; font-family: Calibri; font-size: 11.0pt;">Kann hier generiert werden: <a href="https://guidgenerator.com/">https://guidgenerator.com/</a></p>
|
||||
<p style="margin: 0in; margin-left: .75in; font-family: Calibri; font-size: 11.0pt;"> </p>
|
||||
<ol style="direction: ltr; unicode-bidi: embed; margin-top: 0in; margin-bottom: 0in; font-family: Calibri; font-size: 11.0pt; font-weight: normal; font-style: normal;" type="1">
|
||||
<li style="margin-top: 0; margin-bottom: 0; vertical-align: middle;" value="3"><span style="font-family: Calibri; font-size: 11.0pt; font-weight: normal; font-style: normal;">Sensor einrichten</span></li>
|
||||
<ol style="direction: ltr; unicode-bidi: embed; margin-top: 0in; margin-bottom: 0in; font-family: Calibri; font-size: 11.0pt; font-weight: normal; font-style: normal;" type="a">
|
||||
<li style="margin-top: 0; margin-bottom: 0; vertical-align: middle;" value="1"><span style="font-family: Calibri; font-size: 11.0pt; font-weight: normal; font-style: normal;">in PRTG anmelden</span></li>
|
||||
<li style="margin-top: 0; margin-bottom: 0; vertical-align: middle;"><span style="font-family: Calibri; font-size: 11.0pt;">Server, dessen Service überwacht werden soll, aufrufen</span></li>
|
||||
<li style="margin-top: 0; margin-bottom: 0; vertical-align: middle;"><span style="font-family: Calibri; font-size: 11.0pt;">Neuen Sensor hinzufügen</span></li>
|
||||
</ol>
|
||||
</ol>
|
||||
<p style="margin: 0in; margin-left: .75in;"><img src="https://assets.media-techport.de/f1/git/scriptos/prtg-linux-service-monitor/prtg1.png" alt="" /></p>
|
||||
<ol style="direction: ltr; unicode-bidi: embed; margin-top: 0in; margin-bottom: 0in; font-family: Calibri; font-size: 11.0pt; font-weight: normal; font-style: normal;" type="a">
|
||||
<li style="margin-top: 0; margin-bottom: 0; vertical-align: middle;" value="4"><span style="font-family: Calibri; font-size: 11.0pt; font-weight: normal; font-style: normal;">Folgende Felder ausfüllen:</span></li>
|
||||
<ol style="direction: ltr; unicode-bidi: embed; margin-top: 0in; margin-bottom: 0in; font-family: Calibri; font-size: 11.0pt; font-weight: normal; font-style: normal;" type="1">
|
||||
<li style="margin-top: 0; margin-bottom: 0; vertical-align: middle;" value="1"><span style="font-family: Calibri; font-size: 11.0pt; font-weight: normal; font-style: normal;">Name des Sensors: "Service: MariaDB"</span></li>
|
||||
<li style="margin-top: 0; margin-bottom: 0; vertical-align: middle;"><span style="font-family: Calibri; font-size: 11.0pt;">Einstellungen für SSL: unsicher</span></li>
|
||||
<li style="margin-top: 0; margin-bottom: 0; vertical-align: middle;"><span style="font-family: Calibri; font-size: 11.0pt;">Port: "5050"</span></li>
|
||||
<li style="margin-top: 0; margin-bottom: 0; vertical-align: middle;"><span style="font-family: Calibri; font-size: 11.0pt;">Token für Identifikation: Dieser wird aus dem Cronjob übernommen</span></li>
|
||||
<li style="margin-top: 0; margin-bottom: 0; vertical-align: middle;"><span style="font-family: Calibri; font-size: 11.0pt;">Keine hereinkommenden Daten: Auf "Nach x Minuten auf "Fehler" wechseln" setzen</span></li>
|
||||
<li style="margin-top: 0; margin-bottom: 0; vertical-align: middle;"><span style="font-family: Calibri; font-size: 11.0pt;">Schwellenwert für Zeit (Minuten): "10"</span></li>
|
||||
</ol>
|
||||
</ol>
|
||||
<p style="margin: 0in; font-family: Calibri; font-size: 11.0pt;"> </p>
|
||||
<p style="margin: 0in; margin-left: .75in; font-family: Calibri; font-size: 11.0pt;">Das ganze könnte dann so aussehen:</p>
|
||||
<p style="margin: 0in; margin-left: .75in;"><img src="https://assets.media-techport.de/f1/git/scriptos/prtg-linux-service-monitor/prtg2.png" alt="" /></p>
|
||||
<p style="margin: 0in; margin-left: .75in;"><img src="https://assets.media-techport.de/f1/git/scriptos/prtg-linux-service-monitor/prtg3.png" alt="" /></p>
|
||||
<p style="margin: 0in; margin-left: .75in; font-family: Calibri; font-size: 11.0pt;"> </p>
|
||||
Quellen:
|
||||
<p style="margin: 0in; font-family: Calibri; font-size: 11.0pt;"><a href="https://kb.paessler.com/en/topic/70771-how-can-i-monitor-and-automatically-restart-a-service-on-a-linux-host">https://kb.paessler.com/en/topic/70771-how-can-i-monitor-and-automatically-restart-a-service-on-a-linux-host</a> <a href="https://www.paessler.com/manuals/prtg/http_push_data_advanced_sensor">https://www.paessler.com/manuals/prtg/http_push_data_advanced_sensor</a></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<p align="center">
|
||||
<a href="https://techniverse.net">
|
||||
<img src="https://assets.techniverse.net/f1/git/graphics/repo-techniverse-logo.png" alt="Techniverse Community" height="70" />
|
||||
</a>
|
||||
</p>
|
||||
|
||||
<h1 align="center">PRTG Linux Service Monitor</h1>
|
||||
|
||||
<h4 align="center">
|
||||
Ein Bash-Script zur automatischen Überwachung und Neustart von Linux-Diensten mit PRTG Network Monitor
|
||||
</h4>
|
||||
|
||||
<h6 align="center">
|
||||
<a href="https://www.cleveradmin.de">🏰 Website</a>
|
||||
·
|
||||
<a href="https://techniverse.net">📰 Community</a>
|
||||
·
|
||||
<a href="https://social.techniverse.net/@donnerwolke">🐘 Mastodon</a>
|
||||
·
|
||||
<a href="https://matrix.to/#/#support:techniverse.net">💬 Support</a>
|
||||
</h6>
|
||||
<br><br>
|
||||
|
||||
**prtg-linux-service-monitor** ist ein leichtgewichtiges Bash-Script, das Linux-Dienste mit dem [PRTG Network Monitor](https://www.paessler.com/prtg) überwacht. Es prüft kontinuierlich, ob ein definierter Service läuft, startet ihn bei Ausfall automatisch neu und sendet den Status per HTTP-Push an PRTG.
|
||||
|
||||
### ✨ Features
|
||||
|
||||
- ✅ **Automatische Dienstprüfung** – Prüft in regelmäßigen Intervallen, ob ein Service läuft
|
||||
- 🔄 **Auto-Restart** – Startet ausgefallene Dienste automatisch neu
|
||||
- 📡 **PRTG Integration** – Sendet Statusmeldungen per HTTP-Push an PRTG
|
||||
- ⚡ **Leichtgewichtig** – Kein zusätzlicher Aufwand, nur ein einfaches Bash-Script
|
||||
|
||||
## 📦 Script installieren
|
||||
|
||||
```bash
|
||||
mkdir -p /temp && cd /temp
|
||||
git clone https://git.media-techport.de/scriptos/prtg-linux-service-monitor.git
|
||||
cd prtg-linux-service-monitor
|
||||
cp prtg-service-mon.sh /home/scripts/default/prtg-service-mon.sh
|
||||
chmod 711 /home/scripts/default/prtg-service-mon.sh
|
||||
```
|
||||
|
||||
## ⏰ Cronjob einrichten
|
||||
|
||||
Füge folgenden Eintrag zur Crontabelle hinzu (z. B. alle 5 Minuten):
|
||||
|
||||
```bash
|
||||
cat <(crontab -l) <(echo "*/5 * * * * /home/scripts/default/prtg-service-mon.sh mariadb push.mon01.media-techport.de:5050 b2949934-1f05-40b0-afd8-856ac7e534cd > /dev/null 2>&1") | crontab -
|
||||
```
|
||||
|
||||
### 🛠 Parameter des Scripts
|
||||
|
||||
| # | Beschreibung |
|
||||
|---|------|
|
||||
| 1 | Der Service, welcher überwacht werden soll |
|
||||
| 2 | Der Server, an dem die Push-Nachricht gesendet wird |
|
||||
| 3 | Die GUID zur Identifizierung (der sogenannte *Ident*, muss für jeden Sensor eindeutig sein) |
|
||||
|
||||
> 💡 GUIDs können hier generiert werden: https://guidgenerator.com/
|
||||
|
||||
## 🔧 Sensor einrichten
|
||||
|
||||
### 1️⃣ PRTG Sensor erstellen
|
||||
|
||||
1. In PRTG anmelden
|
||||
2. Den Server aufrufen, dessen Service überwacht werden soll
|
||||
3. **Neuen Sensor hinzufügen**
|
||||
|
||||

|
||||
|
||||
### 2️⃣ Felder ausfüllen
|
||||
|
||||
| Feld | Wert |
|
||||
|------|------|
|
||||
| Name des Sensors | `Service: MariaDB` |
|
||||
| Einstellungen für SSL | **Unsicher** |
|
||||
| Port | `5050` |
|
||||
| Token für Identifikation | Wird aus dem Cronjob übernommen |
|
||||
| Keine hereinkommenden Daten | **Nach x Minuten auf "Fehler" wechseln** |
|
||||
| Schwellenwert für Zeit (Minuten) | `10` |
|
||||
|
||||
### 3️⃣ Beispiel
|
||||
|
||||
Das ganze könnte dann so aussehen:
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
## 📚 Quellen
|
||||
|
||||
- [KB: How can I monitor and automatically restart a service on a Linux host](https://kb.paessler.com/en/topic/70771-how-can-i-monitor-and-automatically-restart-a-service-on-a-linux-host)
|
||||
- [PRTG: HTTP Push Data Advanced Sensor](https://www.paessler.com/manuals/prtg/http_push_data_advanced_sensor)
|
||||
|
||||
<br><br>
|
||||
<p align="center">
|
||||
<img src="https://assets.techniverse.net/f1/git/graphics/gray0-catonline.svg" alt="">
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<sub>
|
||||
© Patrick Asmus · Techniverse Network · <a href="./LICENSE">Lizenz</a>
|
||||
</sub>
|
||||
</p>
|
||||
|
||||
BIN
assets/img/prtg1.png
Normal file
BIN
assets/img/prtg1.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 23 KiB |
BIN
assets/img/prtg2.png
Normal file
BIN
assets/img/prtg2.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 87 KiB |
BIN
assets/img/prtg3.png
Normal file
BIN
assets/img/prtg3.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 40 KiB |
Reference in New Issue
Block a user