Nagios3 unter Debian Linux: Unterschied zwischen den Versionen
Keine Bearbeitungszusammenfassung |
|||
| Zeile 60: | Zeile 60: | ||
==NRPE - Der Linux Nagios Client== | ==NRPE - Der Linux Nagios Client== | ||
==NSClient - Der Windows Nagios Client== | ==NSClient - Der Windows Nagios Client== | ||
==SMS Benachrichtigungen verschicken mit Nagios & Gnokii== | |||
===Handy Verbindung mit dem Server überwachen=== | |||
Da ich ab und an das Problem hatte das die USB Verbindung vom Handy zum Server unterbrochen wurde oder gar ganz weg war, hab ich hier ein kleines Nagios Plugin geschrieben, welches überwacht ob das Handy für gnokii auslesbar ist.<br> | |||
''check_phone.sh'' | |||
<pre> | |||
#!/bin/sh | |||
######################################################################################### | |||
#check_phone.sh | |||
#by A. Laub andreas@laub-home.de | |||
#this Script reads a Backup Logfile which contains one line in this format: | |||
# 201005131629 ERROR: Backup has Problems | |||
# or | |||
# 201005131629 SUCCESS: Backup runs well | |||
#date Format is: date +%Y%m%d%H%M | |||
# | |||
#run script: | |||
# check_phone.sh [LOGFILE] [TIME] | |||
# | |||
#License: | |||
#This program is free software: you can redistribute it and/or modify it | |||
#under the terms of the GNU General Public License as published by the | |||
#Free Software Foundation, either version 3 of the License, or (at your option) | |||
#any later version. | |||
#This program is distributed in the hope that it will be useful, | |||
#but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY | |||
#or FITNESS FOR A PARTICULAR PURPOSE. | |||
######################################################################################## | |||
#Load the Pathes | |||
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin | |||
export PATH | |||
/usr/bin/gnokii --config /etc/gnokiirc --monitor once > /dev/null 2>&1 | |||
ERRORCODE=$? | |||
if [ $ERRORCODE = 5 ]; then | |||
echo "OK - Mobile Phone is connected" | |||
exit 0 | |||
fi | |||
if [ $ERRORCODE = 2 ]; then | |||
echo "CRITICAL - Mobile Phone is not connected" | |||
exit 2 | |||
fi | |||
echo "CRITICAL - other Error" | |||
exit 2 | |||
</pre> | |||
Dieses Script sollte am besten nach ''/usr/lib/nagios/plugins/'' kopiert werden und das Ausführecht bekommen.<br> | |||
Nun die Plugin Konfigurationsdatei unter ''/etc/nagios-plugins/config'' anlegen:<br> | |||
''check_mobile.cfg'' | |||
<pre> | |||
# 'check_mobile' command definition | |||
define command{ | |||
command_name check_mobile | |||
command_line /usr/lib/nagios/plugins/check_mobile.sh | |||
} | |||
</pre> | |||
Und nun das ganze in die Nagios Konfiguration des Hostes:<br> | |||
zum Beispiel: | |||
<pre> | |||
# check mobile phone | |||
define service { | |||
host_name nagios-server | |||
service_description Mobile Phone | |||
check_command check_mobile | |||
use longtime-service | |||
notification_interval 0 ; set > 0 if you want to be renotified | |||
} | |||
</pre> | |||
==Quellen== | ==Quellen== | ||
* http://blog.netways.de/2009/06/30/installation-von-nconf-unter-debian/ | * http://blog.netways.de/2009/06/30/installation-von-nconf-unter-debian/ | ||
Version vom 12. Oktober 2010, 10:19 Uhr
Work in Progress
Diese Seite wird erst noch aufgebaut. Bitte noch keine Änderungen vornehmen, ohne mit dem ursprünglichen Author zu sprechen!
Vielen Dank
Nagios 3 - Der Monitoring Server
Installation Nagios3
Konfiguration Nagios3
NConf Installation
Webseite des Herstellers: http://www.nconf.org
Abhängigkeiten installieren
Folgende Pakete müssen vor der Installation auf dem System vorhanden sein:
- Apache Webserver
- PHP4.4 oder höher mit php-mysql (bei LDAP Auth auch php-ldap)
- MySQL 5.0.2 inkl. InnoDB
- Perl 5.6 oder höher mit perl-DBI und perl-dbd-mysql
- ein Nagios Binary
Diese können mittels aptitude ggf. nachinstalliert werden.
Datenbank vorbereiten
am Datenbankserver anmelden:
mysql -u root -p
Und nun die Datenbank anlegen:
create database nconf; grant select, insert, update, delete, create, drop, alter ON `nconf`.* to 'nconf'@'hostname' identified by 'nconfpass';
Nconf Installieren
Zuerst von der Downloadpage des Herstellers auf den Server laden und entpacken:
cd /usr/src/ wget http://sourceforge.net/projects/nconf/files/nconf/1.2.6-0/nconf-1.2.6-0.tgz/download tar -xzvf nconf-1.2.6-0.tgz
Nun in den Apache vhost kopieren und die richtigen Rechte setzten:
mv nconf /var/www/ cd /var/www/ chown www-data:www-data ./config ./output ./temp
Nun kann die Datenbank gefüttert werden:
mysql -u root -p -D nconf < /var/www/INSTALL/create_database.sql
Nconf Konfigurieren
Zum konfigurieren kann nun folgender Pfad in einem Browser geöffnet werden:
http://<HOSTNAME>/nconf/INSTALL.php
Hier werden dann die Abhängigkeiten geprüft und bei einem Klick auf next kommt man zur Datenbankeinrichtung. Bei einem weiteren Klick auf next prüft er die Datenbankverbindung. Ist diese erfolgreich gelangt man weiter zur General configuration. Diese habe ich auf den Default Werten stehen gelassen. Genau wie die nächste Seite Authentication configuration, hier brauche ich nichts einstellen, da der ganze vhost eh Passwortgeschützt ist. Nachdem nochmals alles geprüft wird und die Configfiles angelegt wurden sollten folgende Dateien gelöscht werden:
cd /var/www/nconf rm INSTALL.php rm UPDATE.php rm -rf INSTALL rm -rf UPDATE
Nun noch das Nagios Binary in den richtigen Ordner kopieren:
/var/www/nconf/bin/nagios
Dieses sollte bei einem nagios3 unter /usr/sbin/nagios3 zu finden sein.
Nconf starten
Beim folgendem Aufruf begrüßt einen die NCONF Startpage:
http://<HOSTNAME>/nconf/
NRPE - Der Linux Nagios Client
NSClient - Der Windows Nagios Client
SMS Benachrichtigungen verschicken mit Nagios & Gnokii
Handy Verbindung mit dem Server überwachen
Da ich ab und an das Problem hatte das die USB Verbindung vom Handy zum Server unterbrochen wurde oder gar ganz weg war, hab ich hier ein kleines Nagios Plugin geschrieben, welches überwacht ob das Handy für gnokii auslesbar ist.
check_phone.sh
#!/bin/sh
#########################################################################################
#check_phone.sh
#by A. Laub andreas@laub-home.de
#this Script reads a Backup Logfile which contains one line in this format:
# 201005131629 ERROR: Backup has Problems
# or
# 201005131629 SUCCESS: Backup runs well
#date Format is: date +%Y%m%d%H%M
#
#run script:
# check_phone.sh [LOGFILE] [TIME]
#
#License:
#This program is free software: you can redistribute it and/or modify it
#under the terms of the GNU General Public License as published by the
#Free Software Foundation, either version 3 of the License, or (at your option)
#any later version.
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
#or FITNESS FOR A PARTICULAR PURPOSE.
########################################################################################
#Load the Pathes
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
export PATH
/usr/bin/gnokii --config /etc/gnokiirc --monitor once > /dev/null 2>&1
ERRORCODE=$?
if [ $ERRORCODE = 5 ]; then
echo "OK - Mobile Phone is connected"
exit 0
fi
if [ $ERRORCODE = 2 ]; then
echo "CRITICAL - Mobile Phone is not connected"
exit 2
fi
echo "CRITICAL - other Error"
exit 2
Dieses Script sollte am besten nach /usr/lib/nagios/plugins/ kopiert werden und das Ausführecht bekommen.
Nun die Plugin Konfigurationsdatei unter /etc/nagios-plugins/config anlegen:
check_mobile.cfg
# 'check_mobile' command definition
define command{
command_name check_mobile
command_line /usr/lib/nagios/plugins/check_mobile.sh
}
Und nun das ganze in die Nagios Konfiguration des Hostes:
zum Beispiel:
# check mobile phone
define service {
host_name nagios-server
service_description Mobile Phone
check_command check_mobile
use longtime-service
notification_interval 0 ; set > 0 if you want to be renotified
}