Installing Nagios in CentOS 6
by Alpha01
Make sure you’ve installed the following packages on your CentOS installation before continuing.
- Apache
- PHP
- GCC compiler
- GD development libraries
yum install httpd php gcc glibc glibc-common gd gd-devel make autoconf
Create nagios
user and give it a password.
/usr/sbin/useradd -m nagios
passwd nagios
Create a new nagcmd
group for allowing external commands to be submitted through the web interface. Add both the nagios
user and the apache
user to the group.
/usr/sbin/groupadd nagcmd
/usr/sbin/usermod -a -G nagcmd nagios
/usr/sbin/usermod -a -G nagcmd apache
Download and extract the latest stable Nagios Core from http://www.nagios.org/download/core/ Run the Nagios configure script, passing the name of the group you created earlier:
./configure --with-command-group=nagcmd
Compile Nagios
make all
Install Nagios
make install
Update the email address associated with the nagiosadmin
contact definition in /usr/local/nagios/etc/objects/contacts.cfg
. Install the Nagios web config file in the Apache conf.d
directory.
make install-webconf
Install Nagios init config
make install-init
Create htaccess user to access the Nagios web interface.
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
Restart Apache to make the new settings take effect.
service httpd restart
Add Nagios to the list of system services and have it automatically start when the system boots.
chkconfig --add nagios
chkconfig nagios on
Download and extract the latest stable Nagios Plugins from http://www.nagios.org/download/plugins. Configure, compile and install the Nagios plugins.
./configure --with-nagios-user=nagios --with-nagios-group=nagios
make
make install
Update permissions
chown nagios.nagios /usr/local/nagios
chown -R nagios.nagios /usr/local/nagios/libexec
Verify the sample Nagios configuration files.
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
If there are no errors, start Nagios.
service nagios start
Post Installation
To make things easier to myself, the ncheck
and nrestart
aliases were created in /root/.bashrc
to check the nagios configuration and restart the service respectively.
alias ncheck='/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg'
alias nrestart='service nagios restart'
Reference
Tags: [nagios
centos
]