These steps were performed on a Nagios Core 4.0.x host running on CentOS 6.5 as per this guide. This will install PNP4Nagios 0.4.14 configured as "Bulk Mode with NPCD". - Establish an ssh session as the user root
- NOTE: Copy and paste the commands as it makes it easier and prevents typing mistakes
- Everything between "Type" the command in bold "and press Enter" is one entire line
- Type yum -y install rrdtool perl-rrdtool perl-Time-HiRes php-gd and press Enter
- Wait while the components are downloaded and installed
- Type service httpd restart and press Enter
- Type cd /usr/local/src and press Enter
- Type wget http://downloads.sourceforge.net/pnp4nagios/pnp-0.4.14.tar.gz and press Enter
- Type tar -xzf pnp-0.4.14.tar.gz and press Enter
- Type cd pnp-0.4.14
and press Enter
- Type wget -O scripts/rc.npcd.in http://sourceforge.net/p/pnp4nagios/code/ci/master/tree/scripts/rc.npcd.in?format=raw
and press Enter
- Type ./configure
and press Enter
- Wait for the configure command to complete
- Type make all
and press Enter
- Wait for the make all command to complete
- Type make install
and press Enter
- Wait for the make install command to complete
- Type make install-config
and press Enter
- Wait for the make install-config command to complete
- Type make install-init
and press Enter
- Wait for the make install-init command to complete
- The following adds the commands for processing the performance data
- Type echo '' >> /usr/local/nagios/etc/objects/commands.cfg
and press Enter
- Type echo 'define command {' >> /usr/local/nagios/etc/objects/commands.cfg
and press Enter
- Type echo ' command_name process-service-perfdata-file-bulk-npcd' >> /usr/local/nagios/etc/objects/commands.cfg
and press Enter
- Type echo ' command_line /bin/mv /usr/local/nagios/var/service-perfdata /usr/local/nagios/var/spool/perfdata/service-perfdata.$TIMET$' >> /usr/local/nagios/etc/objects/commands.cfg
and press Enter
- Type echo ' }' >> /usr/local/nagios/etc/objects/commands.cfg
and press Enter
- Type echo '' >> /usr/local/nagios/etc/objects/commands.cfg
and press Enter
- Type echo 'define command {' >> /usr/local/nagios/etc/objects/commands.cfg
and press Enter
- Type echo ' command_name process-host-perfdata-file-bulk-npcd' >> /usr/local/nagios/etc/objects/commands.cfg
and press Enter
- Type echo ' command_line /bin/mv /usr/local/nagios/var/host-perfdata /usr/local/nagios/var/spool/perfdata/host-perfdata.$TIMET$' >> /usr/local/nagios/etc/objects/commands.cfg
and press Enter
- Type echo ' }' >> /usr/local/nagios/etc/objects/commands.cfg
and press Enter
- Type echo '' >> /usr/local/nagios/etc/objects/commands.cfg
and press Enter
- The following adds the required configuration to nagios.cfg
- Type sed -i 's/process_performance_data=0/process_performance_data=1/g' /usr/local/nagios/etc/nagios.cfg
and press Enter
- Type sed -i 's/#service_perfdata_file=/service_perfdata_file=/g' /usr/local/nagios/etc/nagios.cfg
and press Enter
- Type sed -i 's/^#service_perfdata_file_template=.*/service_perfdata_file_template=DATATYPE::SERVICEPERFDATA\\tTIMET::$TIMET$\\tHOSTNAME::$HOSTNAME$\\tSERVICEDESC::$SERVICEDESC$\\tSERVICEPERFDATA::$SERVICEPERFDATA$\\tSERVICECHECKCOMMAND::$SERVICECHECKCOMMAND$\\tHOSTSTATE::$HOSTSTATE$\\tHOSTSTATETYPE::$HOSTSTATETYPE$\\tSERVICESTATE::$SERVICESTATE$\\tSERVICESTATETYPE::$SERVICESTATETYPE$/g' /usr/local/nagios/etc/nagios.cfg
and press Enter
- Type sed -i 's/#service_perfdata_file_mode=/service_perfdata_file_mode=/g' /usr/local/nagios/etc/nagios.cfg
and press Enter
- Type sed -i 's/^#service_perfdata_file_processing_interval=.*/service_perfdata_file_processing_interval=15/g' /usr/local/nagios/etc/nagios.cfg
and press Enter
- Type sed -i 's/^#service_perfdata_file_processing_command=.*/service_perfdata_file_processing_command=process-service-perfdata-file-bulk-npcd/g' /usr/local/nagios/etc/nagios.cfg
and press Enter
- Type sed -i 's/#host_perfdata_file=/host_perfdata_file=/g' /usr/local/nagios/etc/nagios.cfg
and press Enter
- Type sed -i 's/^#host_perfdata_file_template=.*/host_perfdata_file_template=DATATYPE::HOSTPERFDATA\\tTIMET::$TIMET$\\tHOSTNAME::$HOSTNAME$\\tHOSTPERFDATA::$HOSTPERFDATA$\\tHOSTCHECKCOMMAND::$HOSTCHECKCOMMAND$\\tHOSTSTATE::$HOSTSTATE$\\tHOSTSTATETYPE::$HOSTSTATETYPE$/g' /usr/local/nagios/etc/nagios.cfg
and press Enter
- Type sed -i 's/#host_perfdata_file_mode=/host_perfdata_file_mode=/g' /usr/local/nagios/etc/nagios.cfg
and press Enter
- Type sed -i 's/^#host_perfdata_file_processing_interval=.*/host_perfdata_file_processing_interval=15/g' /usr/local/nagios/etc/nagios.cfg
and press Enter
- Type sed -i 's/^#host_perfdata_file_processing_command=.*/host_perfdata_file_processing_command=process-host-perfdata-file-bulk-npcd/g' /usr/local/nagios/etc/nagios.cfg
and press Enter
- We need to validate the nagios.cfg file
- Type /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
and press Enter
- If you don't get any errors then everything is ok
- Type service nagios restart
and press Enter
- Type cp /usr/local/nagios/etc/pnp/npcd.cfg-sample /usr/local/nagios/etc/pnp/npcd.cfg
and press Enter
- Type /usr/local/nagios/bin/npcd -d -f /usr/local/nagios/etc/pnp/npcd.cfg
and press Enter
- Type chkconfig --add npcd and press Enter
- Type chkconfig npcd on
and press Enter
- Type service npcd start
and press Enter
- At this point you should be able to open a web browser to:
- http://nagios_host_address/nagios/pnp/index.php
What Happened Above ExplainedAfter installing PNP4Nagios we added some commands and configured the nagios.cfg file. The above commands were making changes to the files in a default install of Nagios. As a reference, here is what was done: In the file /usr/local/nagios/etc/objects/commands.cfg we added the following commands: define command { command_name process-service-perfdata-file-bulk-npcd command_line /bin/mv /usr/local/nagios/var/service-perfdata /usr/local/nagios/var/spool/perfdata/service-perfdata.$TIMET$ }
define command { command_name process-host-perfdata-file-bulk-npcd command_line /bin/mv /usr/local/nagios/var/host-perfdata /usr/local/nagios/var/spool/perfdata/host-perfdata.$TIMET$ }
In the file /usr/local/nagios/etc/nagios.cfg the following settings were defined: process_performance_data=1
service_perfdata_file=/usr/local/nagios/var/service-perfdata service_perfdata_file_template=DATATYPE::SERVICEPERFDATA\tTIMET::$TIMET$\tHOSTNAME::$HOSTNAME$\tSERVICEDESC::$SERVICEDESC$\tSERVICEPERFDATA::$SERVICEPERFDATA$\tSERVICECHECKCOMMAND::$SERVICECHECKCOMMAND$\tHOSTSTATE::$HOSTSTATE$\tHOSTSTATETYPE::$HOSTSTATETYPE$\tSERVICESTATE::$SERVICESTATE$\tSERVICESTATETYPE::$SERVICESTATETYPE$ service_perfdata_file_mode=a service_perfdata_file_processing_interval=15 service_perfdata_file_processing_command=process-service-perfdata-file-bulk-npcd
host_perfdata_file=/usr/local/nagios/var/host-perfdata host_perfdata_file_template=DATATYPE::HOSTPERFDATA\tTIMET::$TIMET$\tHOSTNAME::$HOSTNAME$\tHOSTPERFDATA::$HOSTPERFDATA$\tHOSTCHECKCOMMAND::$HOSTCHECKCOMMAND$\tHOSTSTATE::$HOSTSTATE$\tHOSTSTATETYPE::$HOSTSTATETYPE$ host_perfdata_file_mode=a host_perfdata_file_processing_interval=15 host_perfdata_file_processing_command=process-host-perfdata-file-bulk-npcd
|