Setup Nagios 4.02 in Ubuntu 12.04 LTS

Install Ubuntu 12.04, dist-update, install openssh-server. Then as root:

apt-get install -y vim apache2 libapache2-mod-php5 build-essential libgd2-xpm-dev libssl-dev sendmail-bin sendmail heirloom-mailx wget curl daemon apt-file libnet-snmp-perl libperl5.14 libpq5 libradius1 libsensors4 libsnmp-base libsnmp15 libtalloc2 libtdb1 libwbclient0 samba-common samba-common-bin smbclient snmp whois libmysqlclient15-dev && groupadd -g 3000 nagios && groupadd -g 3001 nagcmd && useradd -u 3000 -g nagios -G nagcmd -d /usr/local/nagios -c 'Nagios Admin' nagios && adduser www-data nagcmd && mkdir -p /var/www/nagios && cd /opt && wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-4.0.2.tar.gz && tar xf nagios-4.0.2.tar.gz && cd nagios-4.0.2 && mkdir -p /usr/local/nagios/share/{stylesheets,images} && ./configure --prefix=/usr/local/nagios --with-nagios-user=nagios --with-nagios-group=nagios --with-command-user=nagios --with-command-group=nagcmd && make all && make install && make install-init && make install-config && make install-commandmode && make install-webconf && make install-exfoliation && mkdir -p /usr/local/nagios/nagios-plugins && cd /usr/local/nagios/nagios-plugins && wget https://www.nagios-plugins.org/download/nagios-plugins-1.5.tar.gz && tar -xf nagios-plugins-1.5.tar.gz && cd nagios-plugins-1.5 && ./configure --with-nagios-user=nagios --with-nagios-group=nagios --with-openssl=/usr/bin/openssl --enable-perl-modules --enable-libtap && make && make install && mkdir -p /usr/local/nagios/nrpe && cd /usr/local/nagios/nrpe && wget http://kent.dl.sourceforge.net/project/nagios/nrpe-2.x/nrpe-2.15/nrpe-2.15.tar.gz && tar -xf nrpe-2.15.tar.gz && cd nrpe-2.15 && ./configure --with-ssl=/usr/bin/openssl --with-ssl-lib=/usr/lib/x86_64-linux-gnu && make all && make install && cd && rm /etc/init.d/nagios && vim /etc/init/nagios.conf

# Nagios 4.02
# by Remy Van Elst at https://raymii.org/s/tutorials/Nagios_Core_4_Installation_on_Ubuntu_12.04.html
description "nagios monitoring system"
start on virtual-filesystems
stop on runlevel [06]
respawn
respawn limit 5 30
limit nofile 65550 65550
chdir /usr/local/nagios/
setuid nagios
setgid nagios
console log
script
exec bin/nagios etc/nagios.cfg
end script

sudo initctl reload-configuration && vim /etc/apache2/httpd.conf

ScriptAlias /nagios/cgi-bin /usr/local/nagios/sbin
<Directory "/usr/local/nagios/sbin">
AllowOverride None
Options ExecCGI
Order allow,deny
Allow from all
Alias /nagios /usr/local/nagios/share
<Directory "/usr/local/nagios/share">
AllowOverride None
Options None
Order allow,deny
Allow from all

htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
chown nagios:nagcmd /usr/local/nagios/etc/htpasswd.users && service apache2 restart && start nagios

Very special thank yous:

Advertisements