Setup nagios core

Setup nagios core on ubuntu 12.04 (precise 32) with root user.

Instal LAMP

$ apt-get update
$ apt-get install apache2
$ apt-get install mysql-server php5-mysql
$ mysql_install_db
$ mysql_secure_installation
$ apt-get install php5 libapache2-mod-php5 php5-mcrypt

Create nagios user and group

$ useradd nagios
$ groupadd nagcmd
$ usermod -a -G nagcmd nagios

Install dependencies

$ apt-get update
$ apt-get install build-essential libgd2-xpm-dev openssl libssl-dev xinetd apache2-utils unzip

Download and install nagios core

$ cd ~
$ wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.1.1.tar.gz
$ tar xvf nagios-*.tar.gz
$ cd nagios-*
$ ./configure --with-nagios-group=nagios --with-command-group=nagcmd
$ make all
$ make install
$ make install-commandmode
$ make install-init
$ make install-config
$ /usr/bin/install -c -m 644 sample-config/httpd.conf /etc/apache2/sites-available/nagios.conf
$ usermod -G nagcmd www-data

Download and install nagios plugins

$ cd ~
$ wget http://www.nagios-plugins.org/download/nagios-plugins-2.1.1.tar.gz
$ tar xvf nagios-plugins-*.tar.gz
$ cd nagios-plugins-*
$ ./configure --with-nagios-user=nagios --with-nagios-group=nagios --with-openssl
$ make
$ make install

Config nagios

$ vi /usr/local/nagios/etc/nagios.cfg
$ => find "cfg_dir" and uncomment below line:
$ cfg_dir=/usr/local/nagios/etc/servers
$ => then create the directory
$ mkdir /usr/local/nagios/etc/servers
$ => ensure below lines are uncommented:
$ resource_file=/usr/local/nagios/etc/resource.cfg
$ check_external_commands=1

Config nagios contacts

$ vi /usr/local/nagios/etc/objects/contacts.cfg
$ => find email directive and replace its value with a real one
$ email    nagios@localhost  ;

Config nagios web interface access

$ a2enmod rewrite
$ a2enmod cgi
$ a2enmod version
$ htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
$ ln -s /etc/apache2/sites-available/nagios.conf /etc/apache2/sites-enabled/
$ service nagios start
$ service apache2 restart
$ ln -s /etc/init.d/nagios /etc/rcS.d/S99nagios
$ service nagios restart
$ service apache2 restart

Open nagios in web browser

$ => now access nagios web
$ open http://nagios_server_public_ip/nagios
$ => user/password: nagiosadmin/[your-password-set-above]

devops service assurance service monitoring nagios