Icinga: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
Die Seite wurde neu angelegt: „=== Beschreibung === === Download === === Installation === ==== Master Server ==== ==== Agent/Client ==== <syntaxhighlight lang="bash" line="1"> curl -sSL https://packages.icinga.com/icinga.key | apt-key add - apt-add-repository "deb https://packages.icinga.com/$(lsb_release -cs) icinga-$(lsb_release -cs) main" apt-get update apt-get install icinga2 </syntaxhighlight> === Konfiguration === ==== Master Server ==== ==== Agent/Client ==== <syntaxhighlight…“ |
|||
| (15 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt) | |||
| Zeile 5: | Zeile 5: | ||
=== Installation === | === Installation === | ||
==== Master Server ==== | ==== Master Server ==== | ||
==== Agent/Client ==== | ==== Agent/Client Installation ==== | ||
Am Agent/Client: | |||
<syntaxhighlight lang="bash" line="1"> | <syntaxhighlight lang="bash" line="1"> | ||
curl -sSL https://packages.icinga.com/icinga.key | apt-key add - | curl -sSL https://packages.icinga.com/icinga.key | apt-key add - | ||
apt-add-repository "deb https://packages.icinga.com/$(lsb_release -cs) icinga-$(lsb_release -cs) main" | apt-add-repository "deb https://packages.icinga.com/$(lsb_release -cs) icinga-$(lsb_release -cs) main" | ||
apt-get update | apt-get update | ||
apt- | apt install monitoring-plugins -y | ||
adduser icinga | |||
sudo sed -i 's/^#\?\s*PasswordAuthentication\s\+no/PasswordAuthentication yes/' /etc/ssh/sshd_config && service ssh restart | |||
</syntaxhighlight> | </syntaxhighlight> | ||
=== | Vom Icinga-Server aus: | ||
==== | <syntaxhighlight lang="bash" line="1"> | ||
sudo -u nagios ssh-copy-id icinga@<remote-server> | |||
</syntaxhighlight> | |||
Am Agent/Client: | |||
<syntaxhighlight lang="bash" line="1"> | |||
sudo sed -i 's/^#\?\s*PasswordAuthentication\s\+yes/PasswordAuthentication no/' /etc/ssh/sshd_config && service ssh restart | |||
</syntaxhighlight> | |||
Vom Icinga-Server aus: | |||
<syntaxhighlight lang="bash" line="1"> | |||
sudo -u nagios /usr/bin/ssh -i /var/lib/nagios/.ssh/id_rsa icinga@<remote-server> "/usr/lib/nagios/plugins/check_disk -w 20% -c 10% -p /" #testen | |||
</syntaxhighlight> | |||
===== Emailversand ===== | |||
Siehe [[Postfix#Via_SMTP_Relay_Host|Postfix]] | |||
==== Agent/Client ==== | ==== Agent/Client ==== | ||
<syntaxhighlight lang="bash" line="1"> | <syntaxhighlight lang="bash" line="1"> | ||
| Zeile 20: | Zeile 36: | ||
Während der Konfiguration: | Während der Konfiguration: | ||
Typ des Setups: Wähle agent. | *Typ des Setups: Wähle agent. | ||
Master-Verbindung: Gib die IP/Hostname des Masters ein. | *Master-Verbindung: Gib die IP/Hostname des Masters ein. | ||
Port: 5665 (Standardport für den Agent). | *Port: 5665 (Standardport für den Agent). | ||
Zertifikatsanforderung: Bestätige, dass der Agent ein Zertifikat vom Master anfordert. | *Zertifikatsanforderung: Bestätige, dass der Agent ein Zertifikat vom Master anfordert. | ||
Zone: Stelle sicher, dass die Zone des Agents korrekt benannt ist. | *Zone: Stelle sicher, dass die Zone des Agents korrekt benannt ist. | ||
Endpunkt: Füge den Endpunkt des Masters hinzu. | *Endpunkt: Füge den Endpunkt des Masters hinzu. | ||
Am Master, neuen Client hinzufügen: | |||
<syntaxhighlight lang="bash" line="1"> | |||
Am Master: | icinga2 pki ticket --cn '<client hostname>' --salt '<salt>' #die Ausgabe dann beim Client eintragen | ||
icinga2 ca list | icinga2 ca list | ||
</syntaxhighlight> | |||
Client: | Client: | ||
<syntaxhighlight lang="bash" line="1"> | |||
sudo systemctl restart icinga2 | sudo systemctl restart icinga2 | ||
sudo systemctl enable icinga2 | sudo systemctl enable icinga2 | ||
</syntaxhighlight> | |||
Füge den Agent in der /etc/icinga2/zones.conf hinzu: | Füge den Agent in der /etc/icinga2/zones.conf hinzu: | ||
<syntaxhighlight lang="bash" line="1"> | |||
bash | |||
object Endpoint "vps-hostname" { | object Endpoint "vps-hostname" { | ||
host = "IP-Adresse-des-VPS" | host = "IP-Adresse-des-VPS" | ||
| Zeile 46: | Zeile 60: | ||
object Zone "vps-hostname" { | object Zone "vps-hostname" { | ||
endpoints = [ "vps-hostname" ] | endpoints = [ "vps-hostname" ] | ||
parent = " | parent = "icinga" | ||
} | } | ||
</syntaxhighlight> | |||
Füge den Host in der Datei /etc/icinga2/conf.d/hosts.conf hinzu: | Füge den Host in der Datei /etc/icinga2/conf.d/hosts.conf hinzu: | ||
<syntaxhighlight lang="bash" line="1"> | |||
bash | |||
object Host "vps-hostname" { | object Host "vps-hostname" { | ||
address = "IP-Adresse-des-VPS" | address = "IP-Adresse-des-VPS" | ||
| Zeile 57: | Zeile 70: | ||
vars.os = "Linux" | vars.os = "Linux" | ||
} | } | ||
</syntaxhighlight> | |||
Konfiguration neu laden: | Konfiguration neu laden: | ||
<syntaxhighlight lang="bash" line="1"> | |||
icinga2 daemon -C && systemctl restart icinga2 | |||
</syntaxhighlight> | |||
=== Update === | === Update === | ||
| Zeile 67: | Zeile 81: | ||
=== Fehlerbehebung=== | === Fehlerbehebung=== | ||
==== | ====Remote command execution failed: @@@@@@==== | ||
===== | Bash Script auf Icinga Server erstellen: | ||
<syntaxhighlight lang="bash" line="1"> | |||
#!/bin/bash | |||
# Script zum Eintragen eines SSH-Host-Keys für den Nagios-Benutzer | |||
# Verwendung: sudo ./add_known_host.sh npuls.de | |||
HOST="$1" | |||
USER="nagios" | |||
SSH_DIR="/var/lib/$USER/.ssh" | |||
KNOWN_HOSTS="$SSH_DIR/known_hosts" | |||
if [[ -z "$HOST" ]]; then | |||
echo "Verwendung: $0 <hostname oder IP>" | |||
exit 1 | |||
fi | |||
# Erstelle das .ssh-Verzeichnis, falls nicht vorhanden | |||
if [[ ! -d "$SSH_DIR" ]]; then | |||
echo "[INFO] Erstelle $SSH_DIR ..." | |||
mkdir -p "$SSH_DIR" | |||
chown "$USER:$USER" "$SSH_DIR" | |||
chmod 700 "$SSH_DIR" | |||
fi | |||
# Stelle sicher, dass known_hosts existiert | |||
if [[ ! -f "$KNOWN_HOSTS" ]]; then | |||
echo "[INFO] Erstelle $KNOWN_HOSTS ..." | |||
touch "$KNOWN_HOSTS" | |||
chown "$USER:$USER" "$KNOWN_HOSTS" | |||
chmod 600 "$KNOWN_HOSTS" | |||
fi | |||
# Füge den Host-Key hinzu, falls noch nicht vorhanden | |||
echo "[INFO] Füge SSH-Host-Key für $HOST hinzu ..." | |||
sudo -u "$USER" ssh-keyscan -H "$HOST" >> "$KNOWN_HOSTS" | |||
echo "[OK] Host $HOST wurde zu $KNOWN_HOSTS hinzugefügt." | |||
</syntaxhighlight> | |||
Ausführen: | |||
<syntaxhighlight lang="bash" line="1"> | |||
sudo chmod +x /usr/local/bin/add_known_host.sh && sudo /usr/local/bin/add_known_host.sh <IP oder Domain> | |||
</syntaxhighlight> | |||
====Remote command execution failed: bash: line 1: /usr/lib/nagios/plugins/check_mem.pl: No such file or directory==== | |||
<syntaxhighlight lang="bash" line="1"> | <syntaxhighlight lang="bash" line="1"> | ||
wget https://raw.githubusercontent.com/justintime/nagios-plugins/master/check_mem/check_mem.pl -O /usr/lib/nagios/plugins/check_mem.pl | |||
chmod +x /usr/lib/nagios/plugins/check_mem.pl | |||
chown root:nagios /usr/lib/nagios/plugins/check_mem.pl | |||
</syntaxhighlight> | </syntaxhighlight> | ||
Aktuelle Version vom 5. Juni 2025, 10:17 Uhr
Beschreibung
Download
Installation
Master Server
Agent/Client Installation
Am Agent/Client:
curl -sSL https://packages.icinga.com/icinga.key | apt-key add -
apt-add-repository "deb https://packages.icinga.com/$(lsb_release -cs) icinga-$(lsb_release -cs) main"
apt-get update
apt install monitoring-plugins -y
adduser icinga
sudo sed -i 's/^#\?\s*PasswordAuthentication\s\+no/PasswordAuthentication yes/' /etc/ssh/sshd_config && service ssh restartVom Icinga-Server aus:
sudo -u nagios ssh-copy-id icinga@<remote-server>Am Agent/Client:
sudo sed -i 's/^#\?\s*PasswordAuthentication\s\+yes/PasswordAuthentication no/' /etc/ssh/sshd_config && service ssh restartVom Icinga-Server aus:
sudo -u nagios /usr/bin/ssh -i /var/lib/nagios/.ssh/id_rsa icinga@<remote-server> "/usr/lib/nagios/plugins/check_disk -w 20% -c 10% -p /" #testenEmailversand
Siehe Postfix
Agent/Client
icinga2 node wizardWährend der Konfiguration:
- Typ des Setups: Wähle agent.
- Master-Verbindung: Gib die IP/Hostname des Masters ein.
- Port: 5665 (Standardport für den Agent).
- Zertifikatsanforderung: Bestätige, dass der Agent ein Zertifikat vom Master anfordert.
- Zone: Stelle sicher, dass die Zone des Agents korrekt benannt ist.
- Endpunkt: Füge den Endpunkt des Masters hinzu.
Am Master, neuen Client hinzufügen:
icinga2 pki ticket --cn '<client hostname>' --salt '<salt>' #die Ausgabe dann beim Client eintragen
icinga2 ca listClient:
sudo systemctl restart icinga2
sudo systemctl enable icinga2Füge den Agent in der /etc/icinga2/zones.conf hinzu:
object Endpoint "vps-hostname" {
host = "IP-Adresse-des-VPS"
}
object Zone "vps-hostname" {
endpoints = [ "vps-hostname" ]
parent = "icinga"
}Füge den Host in der Datei /etc/icinga2/conf.d/hosts.conf hinzu:
object Host "vps-hostname" {
address = "IP-Adresse-des-VPS"
check_command = "hostalive"
vars.os = "Linux"
}Konfiguration neu laden:
icinga2 daemon -C && systemctl restart icinga2Update
Test
Fehlerbehebung
Remote command execution failed: @@@@@@
Bash Script auf Icinga Server erstellen:
#!/bin/bash
# Script zum Eintragen eines SSH-Host-Keys für den Nagios-Benutzer
# Verwendung: sudo ./add_known_host.sh npuls.de
HOST="$1"
USER="nagios"
SSH_DIR="/var/lib/$USER/.ssh"
KNOWN_HOSTS="$SSH_DIR/known_hosts"
if [[ -z "$HOST" ]]; then
echo "Verwendung: $0 <hostname oder IP>"
exit 1
fi
# Erstelle das .ssh-Verzeichnis, falls nicht vorhanden
if [[ ! -d "$SSH_DIR" ]]; then
echo "[INFO] Erstelle $SSH_DIR ..."
mkdir -p "$SSH_DIR"
chown "$USER:$USER" "$SSH_DIR"
chmod 700 "$SSH_DIR"
fi
# Stelle sicher, dass known_hosts existiert
if [[ ! -f "$KNOWN_HOSTS" ]]; then
echo "[INFO] Erstelle $KNOWN_HOSTS ..."
touch "$KNOWN_HOSTS"
chown "$USER:$USER" "$KNOWN_HOSTS"
chmod 600 "$KNOWN_HOSTS"
fi
# Füge den Host-Key hinzu, falls noch nicht vorhanden
echo "[INFO] Füge SSH-Host-Key für $HOST hinzu ..."
sudo -u "$USER" ssh-keyscan -H "$HOST" >> "$KNOWN_HOSTS"
echo "[OK] Host $HOST wurde zu $KNOWN_HOSTS hinzugefügt."Ausführen:
sudo chmod +x /usr/local/bin/add_known_host.sh && sudo /usr/local/bin/add_known_host.sh <IP oder Domain>Remote command execution failed: bash: line 1: /usr/lib/nagios/plugins/check_mem.pl: No such file or directory
wget https://raw.githubusercontent.com/justintime/nagios-plugins/master/check_mem/check_mem.pl -O /usr/lib/nagios/plugins/check_mem.pl
chmod +x /usr/lib/nagios/plugins/check_mem.pl
chown root:nagios /usr/lib/nagios/plugins/check_mem.pl