search by tags

for the user

adventures into the land of the command line

installing nagios

nagios is a funky open source monitoring tool that you can use to monitor your computer systems and networks. you have to create all your own rules and alerts, so you have to remember when something changes in your system, to reflect it in your nagios rules, otherwise you may get fake errors. this post is just about installing nagios, not configuring it

install nagios core

install nagios’ dependant packages

$ sudo -u root yum install -y httpd php gcc glibc glibc-common gd gd-devel

create a nagios user & setup nagios groups

$ sudo -u root useradd -m nagios
$ sudo -u root passwd nagios
$ sudo -u root groupadd nagcmd
$ sudo -u root usermod -a -G nagcmd nagios
$ sudo -u root usermod -a -G nagcmd apache

download nagios

$ sudo -u root wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-4.0.2.tar.gz
$ sudo -u root wget https://www.nagios-plugins.org/download/nagios-plugins-1.5.tar.gz

extract the Nagios core tarball to /opt

$ sudo -u root tar -zxvf nagios-4.0.2.tar.gz -C /opt/

run the Nagios configure script, passing the name of the group you created earlier like so

$ sudo -u root /opt/nagios-4.0.2.tar.gz/configure --with-command-group=nagcmd

then compile the Nagios source code, do not do any steps inbetween as it will break the install flow

$ sudo -u root make all

if the main program and CGIs compiled without any errors, you can continue with installing Nagios as follows. type ‘make’ without any arguments for a list of all possible options

$ sudo -u root make

install the main program, CGIs, and HTML files

$ make sudo -u root install

install the init script into /etc/rc.d/init.d/nagios

$ sudo -u root make install-init

install and configure permissions on the directory for holding the external command file in /usr/local/nagios/var/rw

$ sudo -u root make install-commandmode

install SAMPLE config files in /usr/local/nagios/etc You’ll have to modify these sample files before you can use Nagios

$ sudo -u root make install-config

edit this config file and add your email address under contacts associated with nagiosadmin

$ sudo -u root vim /usr/local/nagios/etc/objects/contacts.cfg

install the Apache config file for the Nagios web interface

$ sudo -u root make install-webconf

install the Exfoliation theme for the Nagios web interface

$ sudo -u root make install-exfoliation

install the classic theme for the Nagios web interface

$ sudo -u root make install-classicui

create a nagiosadmin account for logging into the Nagios web interface

$ sudo -u root htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
password: nagios

restart apache to make the new settings take effect

$ sudo -u root /etc/init.d/httpd restart

install nagios plugins

extract the Nagios plugins tarball to /opt

$ sudo -u root tar zxvf nagios-plugins-1.5.tar.gz -C /opt/

compile and install the plugins

$ sudo -u root /opt/nagios-plugins-1.5/configure --with-nagios-user=nagios --with-nagios-group=nagios
$ sudo -u root make
$ sudo -u root make install

add Nagios to the list of system services and have it automatically start when the system boots

$ sudo -u root chkconfig --add nagios
$ sudo -u root chkconfig nagios on

verify the sample Nagios configuration files

$ sudo -u root /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

if there are no errors, start nagios

$ sudo -u root /etc/init.d/nagios start

log into the nagios web interface at http://myhostipaddress/nagios/

nagiosadmin/nagios

fix “internal server error” messages caused by SElinux

instead of disabling SELinux or setting it to permissive mode, you can use the following command to run the CGIs under SELinux enforcing/targeted mode:

$ sudo -u root chcon -R -t httpd_sys_content_t /usr/local/nagios/sbin/
$ sudo -u root chcon -R -t httpd_sys_content_t /usr/local/nagios/share/

or if you want to just do away with SELinux, edit the selinux config file and set SELINUX=permissive

$ sudo -u root vim /etc/selinux/config

then reboot for it to take permanent effect

$ sudo -u root init 6