Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
==========================================================
====================Install Nagios Core===================
==========================================================
----------------------------------------------------------
1. Install LAMP Environment (Linux, Apache, MySQL, PHP)
----------------------------------------------------------
# yum -y install httpd mysql mysql-server php php-mysql postgresql postgresql-
server php-postgresql php-pgsql php-devel
----------------------------------------------------------
2. Create users and user groups for Nagios Core
----------------------------------------------------------
# useradd nagios
# passwd nagios
# groupadd nagcmd
# usermod -a -G nagcmd nagios
# usermod -a -G nagcmd apache
----------------------------------------------------------
3. Install Nagios core
----------------------------------------------------------
# cd /opt/
# wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-
4.1.1.tar.gz
# tar xzf nagios-4.1.1.tar.gz
# cd nagios-4.1.1
# ./configure --with-command-group=nagcmd(If the gcc is not installed, please
use ‘yum install gcc’ to install gcc first).
# make all
# make install
# make install-init
# make install-config
# make install-commandmode
# make install-webconf
----------------------------------------------------------
4. Configure Apache Authentication
----------------------------------------------------------
# htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
----------------------------------------------------------
5. Restart the Apache Service so that configurations can be applied
----------------------------------------------------------
# service httpd restart
If you meet the problem that apache cannot be started, you could try
‘/bin/systemctl restart httpd.service’ instead.
----------------------------------------------------------
6. Install General Plugins for Nagios
----------------------------------------------------------
Download:
# cd /opt
# wget http://nagios-plugins.org/download/nagios-plugins-2.1.1.tar.gz
# tar xzf nagios-plugins-2.1.1.tar.gz
# cd nagios-plugins-2.1.1
Install:
# ./configure --with-nagios-user=nagios --with-nagios-group=nagios
# make
# make install
----------------------------------------------------------
7. Check the Nagios installation and start the Nagios Core
----------------------------------------------------------
# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
# service nagios start
----------------------------------------------------------
8. Access Nagios Core by http://IP_ADDRESS/nagios/
----------------------------------------------------------
==========================================================
====================Install pnp4nagios====================
==========================================================
----------------------------------------------------------
1. Install rrdtool
----------------------------------------------------------
# yum -y install gcc cairo-devel libxml2-devel pango-devel pango libpng-devel
freetype freetype-devel libart_lgpl-devel
# yum install -y rrdtool perl-rrdtool perl-Time-HiRes
----------------------------------------------------------
2. Download pnp4nagio installation package
----------------------------------------------------------
# cd /opt
# wget http://jaist.dl.sourceforge.net/project/pnp4nagios/PNP-0.6/pnp4nagios-
0.6.25.tar.gz
# tar -zxvf pnp4nagios-0.6.25.tar.gz
# cd pnp4nagios-0.6.25
----------------------------------------------------------
3. Install pnp4nagios
----------------------------------------------------------
# ./configure --prefix=/usr/local/pnp4nagios --with-nagios-user=nagios --with-
rrdtool=/usr/bin/rrdtool
# make all
# make fullinstall
----------------------------------------------------------
4. Configure pnp4nagios
----------------------------------------------------------
# cd /usr/local/pnp4nagios/etc/
# mv misccommands.cfg-sample misccommands.cfg
# mv nagios.cfg-sample nagios.cfg
# mv rra.cfg-sample rra.cfg
# cd /usr/local/pnp4nagios/etc/pages/
# mv web_traffic.cfg-sample web_traffic.cfg
# cd /usr/local/pnp4nagios/etc/check_commands/
# mv check_all_local_disks.cfg-sample check_all_local_disks.cfg
# mv check_nrpe.cfg-sample check_nrpe.cfg
# mv check_nwstat.cfg-sample check_nwstat.cfg
----------------------------------------------------------
5. Start pnp4nagios
----------------------------------------------------------
# /etc/init.d/npcd start
Restart Apache
#service httpd restart
You can try the URL: http://IP_ADDRESS/pnp4nagios/ . If you see the page with
no error message, it means that pnp4nagios has been correctly configured.
==========================================================
=====================Configure Nagios=====================
==========================================================
----------------------------------------------------------
1. Configure /usr/local/nagios/etc/nagios.cfg
----------------------------------------------------------
1). Change the process_performance_data to 1:
process_performance_data = 1, this will enable the Nagios performance data
output.
----------------------------------------------------------
2. Create file hosts.cfg and service.cfg
----------------------------------------------------------
1). Create file hosts.cfg under /usr/local/nagios/etc/objects/ directory. You
can take hosts.cfg.sample for reference or just rename and edit it. Below is an
example of the content:
define host{
use generic-test,host-pnp
host_name HOST_NAME_1
address IP_ADDRESS_1
}
define host{
use generic-test,host-pnp
host_name HOST_NAME_2
address IP_ADDRESS_2
}
define hostgroup{
hostgroup_name group1(mapping with the host group name in services.cfg)
alias group1
members HOST_NAME_1, HOST_NAME_2
}
----------------------------------------------------------
3. Configure /usr/local/nagios/etc/objects/commands.cfg
----------------------------------------------------------
Add below lines into the file:
define command{
command_name process-service-perfdata-file
command_line /bin/mv /usr/local/pnp4nagios/var/service-perfdata
/usr/local/pnp4nagios/var/spool/service-perfdata.$TIMET$
}
define command{
command_name process-host-perfdata-file
command_line /bin/mv /usr/local/pnp4nagios/var/host-perfdata
/usr/local/pnp4nagios/var/spool/host-perfdata.$TIMET$
}
In the mean time, you need to comment out the original defined ‘process-host-
perfdata’ and ‘process-service-perfdata’.
----------------------------------------------------------
4. Configure /usr/local/nagios/etc/objects/templates.cfg
----------------------------------------------------------
Add below content into the file:
define host {
name host-pnp
action_url /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=_HOST_’
class=’tips’ rel=’/pnp4nagios/index.php/popup?host=$HOSTNAME$&srv=_HOST_
register 0
}
define service {
name srv-pnp
action_url /pnp4nagios/index.php/graph?
host=$HOSTNAME$&srv=$SERVICEDESC$’ class=’tips’ rel=’/pnp4nagios/index.php/popup?
host=$HOSTNAME$&srv=$SERVICEDESC$
register 0
}
define host {
name srv-pnp
action_url /pnp4nagios/graph?host=$HOSTNAME$&srv=_HOST_
register 0
}
define service {
name services-pnp
action_url /pnp4nagios/graph?host=$HOSTNAME$&srv=$SERVICEDESC$
register 0
}
PS: If you use the hosts.cfg.sample, the template of generic-test should be
added. You can take templates.cfg.sample for reference.
----------------------------------------------------------
5. Restart Nagios Service
----------------------------------------------------------
# service nagios restart