Back to the main page

Install and configure Nagios and Pnp4nagios on Oracle Linux 6




Apache (ver.2) main index page is /var/www/html/index.html
Go to http://<your_hostname> to see it.
Main Apache configuration file is /etc/httpd/conf
It has directive "Include conf.d/*.conf" which means that directory /etc/httpd/conf.d/ contains web configs for nagios, mrtg, pnp4nagios.


MRTG is used to graph Nagios performance. The config file to check Nagios performance is /etc/mrtg/mrtg.cfg
Checks run every 5 min via cronjob, see the file /etc/crontab
It has the line:
*/5 * * * * root LANG=C LC_ALL=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg --lock-file /var/lock/mrtg/mrtg_l --confcache-file /var/lib/mrtg/mrtg.ok
To see graphs, visit URL and click on links: http://<hostname>/mrtg/nagios-stats.html


The directory /etc/nagios/ is where Nagios is configured. Main configuration file is nagios.cfg
Use resource.cfg to define $USERx$ macros. After doing any change to Nagios configuration, including adding/removing host/service, first check configuration before commit change. Warnings can be ignored, but errors must be fixed (do not restart/reload nagios with errors).
[root@hostname]# service nagios configtest
Checking config for nagios: [ OK ]

[root@hostname]# service nagios reload
nagios (pid 888) is running...
Reloading nagios: [ OK ]

Manual check of Nagios configuration can be done with command: nagios -v /etc/nagios/nagios.cfg


This is Nagios graphing tool. There are several modes to process performance data, this is example with Bulk Mode with NPCD.

Bulk mode with NPCD reduces the load on the server because data collector is not invoked for every host/service check. Nagios writes data to a temporary file in defined format. The file is processed by at certain intervals, this is done by Nagios engine.

The NPCD daemon (Nagios Performance C Daemon) will monitor the directory for new files and will pass the names to /usr/libexec/ Processing of performance data is decoupled completely from nagios. NPCD itself is able to start multiple thread for processing the data.

Configuration (example, may be different for others):
How it works:
[root@hostname]# chkconfig --list npcd
npcd 0:off 1:off 2:on 3:on 4:on 5:on 6:off

[root@hostname]# service npcd status
npcd (pid 919) is running...

[root@hostname]# ps -ef | grep npcd
nagios 919 1 0 09:53 ? 00:00:00 /usr/bin/npcd -d -f /etc/pnp4nagios/npcd.cfg

NPCD log file is /var/log/nagios/npcd.log

The pnp4nagios uses templates to create graphs, default ones (extension .php) are located in directory /usr/share/pnp4nagios/templates.dist/
Sometimes when you create new custom Nagios plugin, it may be problem to get desired graph. In this case you can copy default template to directory /usr/share/pnp4nagios/templates and name template as service name.

Example: There is plugin to check usage of disk/share on ZFS storage, so default graph for disk check (/usr/share/pnp4nagios/templates.dist/check_disk.php) is copied to /usr/share/pnp4nagios/templates/check_zfsappliance_share_usage.php

And to verify pnp4nagios configuration, use the perl scrpt verify_pnp_config.
The example: perl verify_pnp_config -m bulk+npcd -c /etc/nagios/nagios.cfg -p /etc/pnp4nagios

Back to the main page