Jan 21, 2017 - We will see how to install all the essential pack in Centos 7 (Redhat 7), Nagios Core 4 + Checkmk + pnp4nagios + Nagvis.
Learning has never been so easy!
Nagios,Pnp4Nagios & Nagvis installation on centos
20 Steps total
Step 1: Installation of apache
sudo yum install httpd
sudo service httpd start
sudo yum install php php-mysql
sudo service httpd start
sudo yum install php php-mysql
Step 2: Download packages & extract
wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.3.2.tar.gz
wget https://nagios-plugins.org/download/nagios-plugins-2.2.1.tar.gz
wget https://nagios-plugins.org/download/nagios-plugins-2.2.1.tar.gz
tar -xzf nagios-4.3.2.tar.gz
tar -xzf nagios-plugins-2.2.1.tar.gz
rm -rf *.tar.gz
tar -xzf nagios-plugins-2.2.1.tar.gz
rm -rf *.tar.gz
Step 3: install required packages
yum install httpd php gcc glibc glibc-common gd gd-devel perl unzip -y
Step 4: add users and give rights
/usr/sbin/useradd -m nagios
passwd nagios
/usr/sbin/groupadd nagcmd # Used for Web Interface
/usr/sbin/usermod -a -G nagcmd nagios
/usr/sbin/usermod -a -G nagcmd apache
passwd nagios
/usr/sbin/groupadd nagcmd # Used for Web Interface
/usr/sbin/usermod -a -G nagcmd nagios
/usr/sbin/usermod -a -G nagcmd apache
Step 5: compile the extracted code
./configure --with-command-group=nagcmd
make all
make install
make install-init
make install-config
make install-commandmode
make install-webconf
make all
make install
make install-init
make install-config
make install-commandmode
make install-webconf
now setup security for the front end
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
systemctl restart nagios && systemctl restart httpd
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
systemctl restart nagios && systemctl restart httpd
Step 6: Install nagios plugins
tar xzf nagios-plugins-2.1.1.tar.gz
cd nagios-plugins-2.1.1
cd nagios-plugins-2.1.1
./configure --with-nagios-user=nagios --with-nagios-group=nagios
make
make install
make
make install
Add Nagios services
chkconfig --add nagios
chkconfig nagios on
chkconfig --add nagios
chkconfig nagios on
Verify the sample Nagios configuration files.
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
service nagios start
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
service nagios start
Step 7: Disable selinux
nano /etc/sysconfig/selinux
and set SELINUX=disabled
reboot the machine
reboot the machine
Step 8: Add firewall rules
firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --zone=public --add-port=444/tcp --permanent
firewall-cmd --zone=public --add-port=25/tcp --permanent
firewall-cmd --reload
firewall-cmd --zone=public --add-port=444/tcp --permanent
firewall-cmd --zone=public --add-port=25/tcp --permanent
firewall-cmd --reload
systemctl restart nagios
systemctl restart httpd
systemctl restart httpd
Step 9: Installation NRPE
yum groupinstall 'Development Tools'
download http://downloads.sourceforge.net/project/nagios/nrpe-2.x/nrpe-2.15/nrpe-2.15.tar.gz
tar -xzf nrpe
cd nrpe
yum install -y gcc glibc glibc-common openssl openssl-devel perl wget
./configure --enable-command-args --with-nagios-user=nagios --with-nagios-group=nagios --with-ssl=/usr/bin/openssl --with-ssl-lib=/usr/lib/x86_64-linux-gnu
make all
make install
make install-xinetd
make install-daemon-config
download http://downloads.sourceforge.net/project/nagios/nrpe-2.x/nrpe-2.15/nrpe-2.15.tar.gz
tar -xzf nrpe
cd nrpe
yum install -y gcc glibc glibc-common openssl openssl-devel perl wget
./configure --enable-command-args --with-nagios-user=nagios --with-nagios-group=nagios --with-ssl=/usr/bin/openssl --with-ssl-lib=/usr/lib/x86_64-linux-gnu
make all
make install
make install-xinetd
make install-daemon-config
nano /etc/xinetd.d/nrpe
and add only_from = your interal ip
service xinetd restart
and add only_from = your interal ip
service xinetd restart
Step 10: Installation pnp4nagios
yum install rrdtool perl-Time-HiRes rrdtool-perl php-gd
download pnp4 nagios
extract
cd
download pnp4 nagios
extract
cd
(https://downloads.sourceforge.net/project/pnp4nagios/PNP-0.6/pnp4nagios-0.6.26.tar.gz)
./configure
make
make all
make fullinstall
chkconfig --add npcd && chkconfig --level 35 npcd on
systemctl reload httpd
mv /usr/local/pnp4nagios/share/install.php /usr/local/pnp4nagios/share/install.php-ori
./configure
make
make all
make fullinstall
chkconfig --add npcd && chkconfig --level 35 npcd on
systemctl reload httpd
mv /usr/local/pnp4nagios/share/install.php /usr/local/pnp4nagios/share/install.php-ori
Step 11: edit nagios.cfg
usr/local/nagios/etc/nagios/.cfg
add / edit
# Bulk / NPCD mode
process_performance_data=1
service_perfdata_file=/usr/local/pnp4nagios/var/service-perfdata
service_perfdata_file_template=DATATYPE::SERVICEPERFDATAtTIMET::$TIMET$tHOSTNAME::$HOSTNAME$tSERVICEDESC::$SERVICEDESC$tSERVICEPERFDATA::$SERVICEPERFDATA$tSERVICECH$
service_perfdata_file_mode=a
service_perfdata_file_processing_interval=15
service_perfdata_file_processing_command=process-service-perfdata-file
# Bulk / NPCD mode
process_performance_data=1
service_perfdata_file=/usr/local/pnp4nagios/var/service-perfdata
service_perfdata_file_template=DATATYPE::SERVICEPERFDATAtTIMET::$TIMET$tHOSTNAME::$HOSTNAME$tSERVICEDESC::$SERVICEDESC$tSERVICEPERFDATA::$SERVICEPERFDATA$tSERVICECH$
service_perfdata_file_mode=a
service_perfdata_file_processing_interval=15
service_perfdata_file_processing_command=process-service-perfdata-file
host_perfdata_file=/usr/local/pnp4nagios/var/host-perfdata
host_perfdata_file_template=DATATYPE::HOSTPERFDATAtTIMET::$TIMET$tHOSTNAME::$HOSTNAME$tHOSTPERFDATA::$HOSTPERFDATA$tHOSTCHECKCOMMAND::$HOSTCHECKCOMMAND$tHOSTSTATE::$
host_perfdata_file_mode=a
host_perfdata_file_processing_interval=15
host_perfdata_file_processing_command=process-host-perfdata-file
host_perfdata_file_template=DATATYPE::HOSTPERFDATAtTIMET::$TIMET$tHOSTNAME::$HOSTNAME$tHOSTPERFDATA::$HOSTPERFDATA$tHOSTCHECKCOMMAND::$HOSTCHECKCOMMAND$tHOSTSTATE::$
host_perfdata_file_mode=a
host_perfdata_file_processing_interval=15
host_perfdata_file_processing_command=process-host-perfdata-file
Step 12: edit commands.cfg
# 'process-host-perfdata' command definition
define command{
command_name process-host-perfdata
command_line /usr/bin/printf '%b' '$LASTHOSTCHECK$t$HOSTNAME$t$HOSTSTATE$t$HOSTATTEMPT$t$HOSTSTATETYPE$t$HOSTEXECUTIONTIME$t$HOSTOUTPUT$t$HOSTPERFDATA$$
}
define command{
command_name process-host-perfdata
command_line /usr/bin/printf '%b' '$LASTHOSTCHECK$t$HOSTNAME$t$HOSTSTATE$t$HOSTATTEMPT$t$HOSTSTATETYPE$t$HOSTEXECUTIONTIME$t$HOSTOUTPUT$t$HOSTPERFDATA$$
}
# 'process-service-perfdata' command definition
define command{
command_name process-service-perfdata
command_line /usr/bin/printf '%b' '$LASTSERVICECHECK$t$HOSTNAME$t$SERVICEDESC$t$SERVICESTATE$t$SERVICEATTEMPT$t$SERVICESTATETYPE$t$SERVICEEXECUTIONTIME$$
}
define command{
command_name process-service-perfdata
command_line /usr/bin/printf '%b' '$LASTSERVICECHECK$t$HOSTNAME$t$SERVICEDESC$t$SERVICESTATE$t$SERVICEATTEMPT$t$SERVICESTATETYPE$t$SERVICEEXECUTIONTIME$$
}
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$
}
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$
}
command_name process-host-perfdata-file
command_line /bin/mv /usr/local/pnp4nagios/var/host-perfdata /usr/local/pnp4nagios/var/spool/host-perfdata.$TIMET$
}
Step 13: edit templates.cfg
define host {
name host-pnp
action_url /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=_HOST_'s domain
my $opt_token = 'yoursecret'; # The token from your Nagios services page
name host-pnp
action_url /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=_HOST_'s domain
my $opt_token = 'yoursecret'; # The token from your Nagios services page
Step 19: edit contacts
define contact {
contact_name slack
alias Slack
service_notification_period 24x7
host_notification_period 24x7
service_notification_options w,u,c,r
host_notification_options d,r
service_notification_commands notify-service-by-slack
host_notification_commands notify-host-by-slack
}
contact_name slack
alias Slack
service_notification_period 24x7
host_notification_period 24x7
service_notification_options w,u,c,r
host_notification_options d,r
service_notification_commands notify-service-by-slack
host_notification_commands notify-host-by-slack
}
Step 20: additional packages
for some script you need these packages
yum install cpan
cpan : install Net::DNS
yum install php-gd
yum install gd-progs
cpan : install Net::DNS
yum install php-gd
yum install gd-progs
1 Comment
- Sonoradmle Feb 27, 2019 at 10:33pmFirst thank you for great how-to, second, this tutorial will work with CentOS 7 (lastest)?