NAGIOS INSTALLATION IN CENTOS 6.7
===========================
[root@server~]# yum install httpd* php* gcc* glibc* glibc-common* gd* gd-devel*
[root@server~]# /usr/sbin/useradd -m nagios
[root@server~]# passwd nagios
[root@server~]# /usr/sbin/groupadd nagcmd
[root@server~]# /usr/sbin/usermod -a -G nagcmd nagios
[root@server~]# /usr/sbin/usermod -a -G nagcmd apache
[root@server~]# mkdir ~/downloads
[root@server~]# cd ~/downloads
[root@server~]# wget http://citylan.dl.sourceforge.net/project/nagios/nagios-3.x/nagios-3.4.4/nagios-3.4.4.tar.gz
[root@server~]# wget http://citylan.dl.sourceforge.net/project/nagiosplug/nagiosplug/1.4.16/nagios-plugins-1.4.16.tar.gz
[root@server~]# wget http://exchange.nagios.org/components/com_mtree/attachment.php?link_id=2172&cf_id=24 ---> latest packge for theme
[root@server~]# cd ~/downloads
[root@server~]# tar xzf nagios-3.3.1.tar.gz
[root@server~]# cd nagios-3.3.1
Run the Nagios configure script, passing the name of the group you created earlier like so:
[root@server~]# ./configure --with-command-group=nagcmd
Compile the Nagios source code.
[root@server~]# make all
Install binaries, init script, sample config files and set permissions on the external command directory.
[root@server~]# make install
[root@server~]# make install-init
[root@server~]# make install-config
[root@server~]# make install-commandmode
Set Permission
[root@server~]# chown nagios.nagios /usr/local/nagios
[root@server~]# chown -R nagios.nagios /usr/local/nagios/libexec/
Don't start Nagios yet - there's still more that needs to be done...
Configure the Web Interface
Install the Nagios web config file in the Apache conf.d directory.
[root@server~]# make install-webconf
Create a nagiosadmin account for logging into the Nagios web interface. Remember the password you assign to this account - you'll need it later.
[root@server~]# htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
Restart Apache to make the new settings take effect.
[root@server~]# service httpd restart
Extract the Nagios plugins source code tarball.
[root@server~]# cd ~/downloads
[root@server~]# tar xzf nagios-plugins-1.4.15.tar.gz
[root@server~]# cd nagios-plugins-1.4.15
Compile and install the plugins.
[root@server~]# ./configure --with-nagios-user=nagios --with-nagios-group=nagios
[root@server~]# make
[root@server~]# make install
Add Nagios to the list of system services and have it automatically start when the system boots.
[root@server~]# chkconfig --add nagios
[root@server~]# chkconfig nagios on
For getting alert via email to admin
[root@server~]# vi /usr/local/nagios/etc/objects/contacts.cfg
email nagios@localhost ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******
:wq
Verify the sample Nagios configuration files.
[root@server~]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
If there are no errors, start Nagios.
[root@server~]# service nagios start
8) Modify SELinux Settings
Fedora ships with SELinux (Security Enhanced Linux) installed and in Enforcing mode by default. This can result in "Internal Server Error" messages when you attempt to access the Nagios CGIs.
See if SELinux is in Enforcing mode.
[root@server~]# getenforce
Put SELinux into Permissive mode.
[root@server~]# setenforce 0
To make this change permanent, you'll have to modify the settings in /etc/selinux/config and reboot.
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:
[root@server~]# chcon -R -t httpd_sys_content_t /usr/local/nagios/sbin/
[root@server~]# chcon -R -t httpd_sys_content_t /usr/local/nagios/share/
ADD NAGIOS USER THOSE YOU ABOVE CREATED FOR ACCESS NAGIOS WEB INTERFACE
[root@server~]# /usr/local/nagios/etc/cgi.cfg
[you need to change user nagiosadmin <-- user name]
start service
[root@server~]# service httpd restart
[root@server~]# service nagios restart
cd /usr/local/nagios/etc/
vim nagios.cfg
### add below line here #####
# Definitions for monitoring the local (Linux) host
35 cfg_file=/usr/local/nagios/etc/objects/localhost.cfg
cfg_dir=/usr/local/nagios/etc/servers
:wq
cd /usr/local/nagios/etc/objects
vim commands.cfg
define command{
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$ -t 60
}
:wq
service nagios restart
TO ACCESS NAGIOS FROM BROWSER
http://hostname/nagios or http://serverip/nagios
Note : Make the changes in cgi.cfg file and put the user name created in htpasswd.users file.
FOR NEW THEME INSTALLATION
1. go to location /usr/local/nagios/share
2. download new theme
wget http://sourceforge.net/projects/arana-nagios/files/arana_style-1.0for-Nagios3x-ENG.zip/download
3. unzip new theme here [extract file here.]
Note:- first take backup already present file and remove it
unzip new theme file /usr/local/nagios/shre
4. Nagios restart
TO ACCESS NAGIOS FROM BROWSER
http://ip-addr/nagios or ip-addr/nagios
===================================================
FOR CHANGE NAGIOS HEADER
========================
# vim /usr/local/nagios/share
and edit index.html, index.php,top.html & sidebar.html file
# service nagios restart
HOW TO CHANGE NAGIOS LOGO
Replace Image designby.png from /usr/local/nagios/share/images/interface/ download any of your choices images. Name of image should be "designby.png"
# service nagios restart
=======================================================
IF YOU GET ERROR:-
==========================================================
It appears as though you do not have permission to view information for any of the hosts you requested...
If you believe this is an error, check the HTTP server authentication requirements for accessing this CGI
and check the authorization options in your CGI configuration file.
==========================================================
SOLUTION:-
EDIT BELOW CGI LINE
# vim /usr/local/nagios/etc/cgi.cfg
add user name
:wq
# service nagios restart
==========================================
Nagios Error and Solution
Error :- sudo: sorry, you must have a tty to run sudo
Solution:-
[root@server~]# vi /etc/sudoers
comment #Defaults requiretty
and add below lines at end of file
# %users localhost=/sbin/shutdown -h now
nagios ALL=(ALL) NOPASSWD: /usr/local/nagios/libexec/
nagios ALL=(ALL) NOPASSWD: /usr/sbin/vzctl
:wq
[root@server~]# service xinetd restart
Enjoy
Verifying Nagios Configuration
[root@server~]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
=====================================================
ps -aufx find /usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg and kill
and again /usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg.
=====================================================
=====================================================
1 comment:
Thanks for sharing...
Post a Comment