Sie sind auf Seite 1von 5

Nagios Prerequisites Install the required programs: aptitude -y install build-essential apache2 php5-gd wget wibgd2-xpm libgd2-xpm-dev libapache2-modphp5

Type vi /etc/apache2/apache2.conf and add the following line: DirectoryIndex index.html index.php index.cgi Restart Apache by typing: /etc/init.d/apache2 restart Create users and groups: mkdir -p /etc/nagios /var/nagios groupadd --system --gid 9000 nagios groupadd --system --gid 9001 nagcmd adduser --system --gid 9000 --home /usr/local/nagios nagios usermod --groups nagcmd nagios usermod --append --groups nagcmd www-data chown nagios:nagios /usr/local/nagios /etc/nagios /var/nagios

Build and Install Nagios from Source Download Nagios software (NOTE: You can use newer links once new versions become available): cd /usr/local/src wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-3.4.1.tar.gz Build and install Nagios Core: tar -xzvf /usr/local/src/nagios-3.4.1.tar.gz cd /usr/local/src/nagios ./configure --sysconfdir=/etc/nagios --localstatedir=/var/nagios --prefix=/usr/local/nagios --with-nagiosuser=nagios --with-nagios-group=nagios --with-command-group=nagcmd --withmail=/usr/bin/sendemail make all make install make install-init make install-config make install-commandmode

Edit the commands by typing vi /etc/nagios/objects/commands.cfg to change both sendemail references to match the correct sendemail syntax: define command{ command_name notify-host-by-email command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /usr/bin/sendemail -s srv-mail:25 -f "admin <admin@nagios.server>" -t $CONTACTEMAIL$ -u "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" } define command{ command_name notify-service-by-email command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$" | /usr/bin/sendemail -s srv-mail:25 -f "admin <admin@nagios.server>" -t $CONTACTEMAIL$ -u "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" } Save and close commands.cfg Edit the contacts by typing vi /etc/nagios/objects/contacts.cfg and change the following: define contact{ contact_name nagiosadmin ; Short name of user use generic-contact ; Inherit default values from generic-contact template (defined above) alias John Doe ; Full name of user email John.Doe@mydomain.com ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ****** } Save and close contacts.cfg Type the following: cd /usr/local/src/nagios make install-webconf Set the nagiosadmin password to mynagiospassword by typing the following: htpasswd -c /etc/nagios/htpasswd.users nagiosadmin /etc/init.d/apache2 reload

Ensure Nagios can execute by typing chmod +x /etc/init.d/nagios (NOTE: On this version of Ubuntu and Nagios, it is already set correctly) Type the following to avoid startup problems: (NOTE: This is not documented anywhere, it is just my trial, error and observation) mkdir -p /usr/local/nagios/var/spool/checkresults chown nagios:nagios /var/nagios/spool/checkresults chown nagios:nagios /var/nagios/spool chown nagios:nagios /var/nagios Ensure Nagios is started whenever the system boots up: /usr/sbin/update-rc.d -f nagios defaults 99 ln -s /etc/init.d/nagios /etc/rcS.d/S99nagios Check your Nagios configuration file for errors. Look for errors in red. /usr/local/nagios/bin/nagios -v /etc/nagios/nagios.cfg NOTE TO SELF: I need to generate (and document) an SSL certificate to enable SSL to protect the password during authentication. Self-Signed Certs (http://library.linode.com/security/sslcertificates/self-signed) Start Nagios for the 1st time. /etc/init.d/nagios start Access the web-based administration utility at http://192.168.107.21/nagios/ (use nagiosadmin for the ID and mynagiospassword for the password) NOTE: The Nagios server is now up-and-running but doing absolutely nothing. ;) We need plugins to actually make it do something so we will install a base plugin pack. However, we will eventually need to get other plugins and maybe write our own in order to monitor everything we want.

Nagios Plugin Prerequisites Nagios Plugin Requirements for check_snmp: perl -MCPAN -e 'install Net::SNMP' Configure as much as possible automatically? yes aptitude -y install snmp Requirements for check_mysql: (NOTE: For my site, this is not necessary because I will run it locally on MySQL server) aptitude -y install libmysqlclient-dev Requirements for check_nrpe:

aptitude -y install libssl-dev Nagios Plugins Download, build and install Nagios plugins (NOTE: You can use newer links once new versions become available): cd /usr/local/src wget http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.15.tar.gz tar xzf /usr/local/src/nagios-plugins-1.4.15.tar.gz cd /usr/local/src/nagios-plugins-1.4.15 ./configure --sysconfdir=/etc/nagios --localstatedir=/var/nagios --with-nagios-user=nagios --with-nagiosgroup=nagios make make install

Download, build and install NRPE plugin cd /usr/local/src wget http://prdownloads.sourceforge.net/sourceforge/nagios/nrpe-2.13.tar.gz tar xzf /usr/local/src/nrpe-2.13.tar.gz cd /usr/local/src/nrpe-2.13 ./configure --sysconfdir=/etc/nagios --libexecdir=/usr/local/nagios/libexec --prefix=/usr/local/nagios -localstatedir=/var/nagios --with-nagios-user=nagios --with-nagios-group=nagios --with-nrpe-user=nagios --with-nrpe-group=nagios --enable-ssl=yes --with-ssl=/usr/bin/openssl --with-ssl-lib=/usr/lib/x86_64linux-gnu make all make install-plugin Verify that Plugins are Working! For all the plugins we intend on using, we need to verify they are working before trying to integrate them into Nagios. However, not all plugins will work without first configuring the target to be monitored. Ping an IP address you know to be active: /usr/local/nagios/libexec/check_icmp -H 192.168.107.20 Check for an HTTP reply from a web server: /usr/local/nagios/libexec/check_http -H 192.168.107.20

Check for a response from an HP LaserJet printer: /usr/local/nagios/libexec/check_hpjd -H 192.168.107.51 -C public Check the uptime of a router via SNMP: /usr/local/nagios/libexec/check_snmp -H 192.168.107.1 -C public -o sysUpTime.0 NOTE: For whatever reason, this command hangs on me. Not sure what I did wrong this time but I'll track it down, fix it and update these dox. Check a MySQL server (if on local host): /usr/local/nagios/libexec/check_mysql -H 192.168.107.20 -P 3306 -u mysqlid -p mysqlpassword NOTE: This will fail if you do not configure the MySQL server 1st. However, you might want to run the MySQL command remotely via NRPE instead.

http://ubuntuforums.org/archive/index.php/t-1986743.html http://www.ubuntugeek.com/tag/install-nagios-ubuntu http://sudeepkodavati.com/blog/installing-nagios-on-ubuntu-12-04/ http://constey.de/?p=349 https://ideasnet.wordpress.com/category/ubuntu-12-04lts-nagios-core-server/

Das könnte Ihnen auch gefallen