Zuerst Nagios 3 Packages auf Ubuntu installieren:

$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt-get install nagios3 nagios3-doc

Die Konfigurationsdateien befinden sich in /etc/nagios3 und /etc/nagios3/conf.d. Die Contacts und Hosts sind auf die eigenen Bedürfnisse anzupassen.

Was mich sehr viel Zeit gekostet hat war das Aktivieren der “external commands”. Diese werden gebraucht wenn man über das Webinterface Alarme auslösen will oder sonstige Aspekte von Nagios konfigurieren will.

/etc/nagios3/nagios.cfg editieren:

# EXTERNAL COMMAND OPTION
# Values: 0 = disable commands, 1 = enable commands

check_external_commands=1

# EXTERNAL COMMAND CHECK INTERVAL
# NOTE: Setting this value to -1 causes Nagios to check the external
# command file as often as possible.

command_check_interval=15s
#command_check_interval=-1

Um den Error: Could not stat() command file ‘/var/lib/nagios3/rw/nagios.cmd’ loszuwerden, musste ich folgendes tun:

$ sudo /etc/init.d/nagios3 stop
$ sudo dpkg-statoverride --update --add nagios www-data 2710 /var/lib/nagios3/rw
$ sudo dpkg-statoverride --update --add nagios nagios 751 /var/lib/nagios3
$ sudo /etc/init.d/nagios3 start

Um Benachrichtigungen mittels SMTP Server mit Authentifikation zu versenden:

http://exchange.nagios.org/directory/Addons/Notifications/Notifications-using-ISP-SMTP-server-with-Authentication/details

$ sudo apt-get install sendemail

/etc/nagios3/resource.cfg:

$USER5$=your_isp_email_username
$USER6$=your_isp_email_password
$USER7$=your_isp_outgoing_mail_server

/etc/nagios3/commands.cfg

Ändere “notify-host-by-email” command line zu:

command_line /usr/bin/sendemail -o tls=yes -s $USER7$ -xu $USER5$ -xp $USER6$ -t $CONTACTEMAIL$ -f $CONTACTEMAIL$ -l /var/log/sendEmail -u "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" -m "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n"

Ändere die “notify-service-by-email” command line zu:

command_line /usr/bin/sendemail -o tls=yes -s $USER7$ -xu $USER5$ -xp $USER6$ -t $CONTACTEMAIL$ -f $CONTACTEMAIL$ -l /var/log/sendEmail -u "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" -m "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$"

Nun noch folgendes:

$ sudo touch /var/log/sendEmail
$ sudo chown nagios:nagios /var/log/sendEmail
$ sudo /etc/init.d/nagios3 restart

install nagios3 packages:

$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt-get install nagios3 nagios3-doc

config files are located in /etc/nagios3 and /etc/nagios3/conf.d configure your contacts and hosts accordingly.

what got me crazy was enabling external commands (needed to perform actions in the webinterface like sending alerts or enabling/disabling things).

edit /etc/nagios3/nagios.cfg:

# EXTERNAL COMMAND OPTION
# Values: 0 = disable commands, 1 = enable commands

check_external_commands=1

# EXTERNAL COMMAND CHECK INTERVAL
# NOTE: Setting this value to -1 causes Nagios to check the external
# command file as often as possible.

command_check_interval=15s
#command_check_interval=-1

to get rid of Error: Could not stat() command file ‘/var/lib/nagios3/rw/nagios.cmd’, i had to do this:

$ sudo /etc/init.d/nagios3 stop
$ sudo dpkg-statoverride --update --add nagios www-data 2710 /var/lib/nagios3/rw
$ sudo dpkg-statoverride --update --add nagios nagios 751 /var/lib/nagios3
$ sudo /etc/init.d/nagios3 start

to send notification mails using the corporate smtp host i had to do this:

http://exchange.nagios.org/directory/Addons/Notifications/Notifications-using-ISP-SMTP-server-with-Authentication/details

$ sudo apt-get install sendemail

Edit /etc/nagios3/resource.cfg:

$USER5$=your_isp_email_username
$USER6$=your_isp_email_password
$USER7$=your_isp_outgoing_mail_server

Edit /etc/nagios3/commands.cfg

Change command_line for command_name notify-host-by-email:

command_line /usr/bin/sendemail -o tls=yes -s $USER7$ -xu $USER5$ -xp $USER6$ -t $CONTACTEMAIL$ -f $CONTACTEMAIL$ -l /var/log/sendEmail -u "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" -m "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n"

and the notify-service-by-email command line to

command_line /usr/bin/sendemail -o tls=yes -s $USER7$ -xu $USER5$ -xp $USER6$ -t $CONTACTEMAIL$ -f $CONTACTEMAIL$ -l /var/log/sendEmail -u "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" -m "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$"
$ sudo touch /var/log/sendEmail
$ sudo chown nagios:nagios /var/log/sendEmail
$ sudo /etc/init.d/nagios3 restart