Nagios Linux Host SSH: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
| (9 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt) | |||
| Zeile 12: | Zeile 12: | ||
*mkdir .ssh | *mkdir .ssh | ||
*nano .ssh/authorized_keys | *nano .ssh/authorized_keys | ||
| + | ;Nun den Inhalt der Datei /opt/nagios/etc/id_rsa.pub an .ssh/authorized_keys anfügen und abspeichern | ||
| + | =Nagios Server= | ||
| + | ;Nun vom Server aus die Vebindung testen | ||
| + | ==per ssh== | ||
| + | root@2a778a71f039:/# ssh -i /opt/nagios/etc/id_rsa nagios@10.0.10.202 | ||
| + | ==per check_by_ssh Plugin== | ||
| + | *root@2a778a71f039:/# /opt/nagios/libexec/check_by_ssh -H 10.0.10.202 -C "/usr/lib/nagios/plugins/check_disk -w 10% -c 5% -p /" | ||
| + | DISK OK - free space: / 19078 MB (80% inode=94%);| /=4692MB;22560;23813;0;2506 | ||
| + | ;Raus aus dem Container | ||
| + | *exit | ||
| + | *exit | ||
| + | =Konfiguration= | ||
| + | <pre> | ||
| + | define command { | ||
| + | command_name check_ssh_disk | ||
| + | command_line /opt/nagios/libexec/check_by_ssh -H $HOSTADDRESS$ -o -o StrictHostKeyChecking=no -i /opt/nagios/etc/id_rsa -C "/usr/lib/nagios/plugins/check_disk -w $ARG1$ -c $ARG2$ -p $ARG3$" | ||
| + | } | ||
| + | |||
| + | define service{ | ||
| + | host_name ubuntu20-2 | ||
| + | service_description check-FS | ||
| + | check_command check_ssh_disk!10%!5%!/ | ||
| + | use generic-service | ||
| + | } | ||
| + | |||
| + | define host{ | ||
| + | use linux-server | ||
| + | host_name ubuntu20-2 | ||
| + | alias ubuntu20-2 | ||
| + | address 10.0.10.202 | ||
| + | } | ||
| + | </pre> | ||
| + | =Neu starten= | ||
| + | *docker-compose down ; docker-compose up -d | ||
Aktuelle Version vom 11. November 2021, 12:53 Uhr
Nagios Server
SSH Key Paar erstellen
- docker exec -it nagios_nagios_1 /bin/bash
root@2a778a71f039:/# su -s /bin/bash nagios root@2a778a71f039:/# ssh-keygen -N -f /opt/nagios/etc/id_rsa
Nagios Client
Nagios Plugins installieren
- apt install nagios-plugins
User anlegen und andere Dinge
- useradd -m -s /bin/bash nagios
- su - nagios
- mkdir .ssh
- nano .ssh/authorized_keys
- Nun den Inhalt der Datei /opt/nagios/etc/id_rsa.pub an .ssh/authorized_keys anfügen und abspeichern
Nagios Server
- Nun vom Server aus die Vebindung testen
per ssh
root@2a778a71f039:/# ssh -i /opt/nagios/etc/id_rsa nagios@10.0.10.202
per check_by_ssh Plugin
- root@2a778a71f039:/# /opt/nagios/libexec/check_by_ssh -H 10.0.10.202 -C "/usr/lib/nagios/plugins/check_disk -w 10% -c 5% -p /"
DISK OK - free space: / 19078 MB (80% inode=94%);| /=4692MB;22560;23813;0;2506
- Raus aus dem Container
- exit
- exit
Konfiguration
define command {
command_name check_ssh_disk
command_line /opt/nagios/libexec/check_by_ssh -H $HOSTADDRESS$ -o -o StrictHostKeyChecking=no -i /opt/nagios/etc/id_rsa -C "/usr/lib/nagios/plugins/check_disk -w $ARG1$ -c $ARG2$ -p $ARG3$"
}
define service{
host_name ubuntu20-2
service_description check-FS
check_command check_ssh_disk!10%!5%!/
use generic-service
}
define host{
use linux-server
host_name ubuntu20-2
alias ubuntu20-2
address 10.0.10.202
}
Neu starten
- docker-compose down ; docker-compose up -d