..\\
..\\
..\\
**If you found this page via Google, I would recommend to use [[check_mk_raw_centos]] instead. Using the 1.4 stable branch.**\\
..\\
..\\
..\\
====== Check_MK monitoring (from source) - CentOS7 ======
Use this guide to install the latest version of Check_MK and Nagios.
Prerequisites
* EPEL repository
* Disable SELinux. Normally i would let SELinux be enabled, but with a monitoring system it is one of the few exceptions I make. This service does too many things SELinux doesn't like.
====Install packages====
* Install rrdtool: yum install rrdtool perl-rrdtool
* Install development tools: yum groupinstall development tools
* Install apache & php. yum install httpd php
* Install other requirements. yum install gd gd-devel php-gd openssl-devel net-snmp net-snmp-utils policycoreutils-python dejavu-fonts-common dejavu-sans-mono-fonts dejavu-lgc-sans-mono-fonts
====Install Nagios 4====
* Create user and group.useradd nagios
groupadd nagcmd
usermod -a -G nagcmd nagios
usermod -G nagcmd apache
* Download latest version.
* Extract. tar zxvf nagios-4.0.8.tar.gz
* Compile Nagios 4. cd nagios-4.0.8
./configure --with-command-group=nagcmd --prefix=/opt/nagios --exec-prefix=/opt/nagios
make all
make install
make install-init
make install-config
make install-commandmode
make install-webconf
cp -R contrib/eventhandlers/ /opt/nagios/libexec/
chown -R nagios:nagios /opt/nagios/libexec/eventhandlers
* Test and start Nagios, it still uses legacy init:/opt/nagios/bin/nagios -v /opt/nagios/etc/nagios.cfg
service nagios start
* Edit **/opt/nagios/etc/resource.cfg** $USER1$=/opt/nagios-plugins/libexec
* Add a default user for Web Interface Access htpasswd -c /opt/nagios/etc/htpasswd.users nagiosadmin
* Download latest Nagios plugins.
* Install Nagios Plugins: cd
tar zxvf nagios-plugins-2.0.3.tar.gz
cd /tmp/nagios-plugins-2.0.3
./configure --with-nagios-user=nagios --with-nagios-group=nagios --prefix=/opt/nagios-plugins --exec-prefix=/opt/nagios-plugins
make
make install
====Configure services and firewall====
* Service setup. chkconfig --add nagios
chkconfig --level 35 nagios on
systemctl enable httpd
* Open port 80 / 443: firewall-cmd --permanent --zone public --add-service=http
firewall-cmd --permanent --zone public --add-service=https
firewall-cmd --reload
* Give the Nagios localhost http check something. touch /var/www/html/index.html
* Start Apache, restart Nagios, it should be running on your webserver /nagios service nagios restart
systemctl start httpd
====Install PNP4Nagios====
* Download the latest PNP4nagios.
* Extract. tar zxvf pnp4nagios.tgz
* Compile.cd pnp4nagios-0.6.25
./configure --prefix=/opt/pnp4nagios --exec-prefix=/opt/pnp4nagios
make all
make fullinstall
* Configure apache, edit **/etc/httpd/conf.d/pnp4nagios.conf** AuthUserFile /opt/nagios/etc/htpasswd.users
* Restart apache. systemctl restart httpd
* Configure Nagios to use PNP4nagios. Edit **/opt/nagios/etc/nagios.cfg**. #
# Bulk / NPCD mode
#
process_performance_data=1
# *** the template definition differs from the one in the original nagios.cfg
#
service_perfdata_file=/opt/pnp4nagios/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
# *** the template definition differs from the one in the original nagios.cfg
#
host_perfdata_file=/opt/pnp4nagios/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
* Edit **/opt/nagios/etc/objects/commands.cfg** Disable sample performance data commands, add: #
# Bulk mode
#
define command {
command_name process-service-perfdata-file
command_line /opt/pnp4nagios/libexec/process_perfdata.pl --bulk /opt/pnp4nagios/var/service-perfdata
}
define command {
command_name process-host-perfdata-file
command_line /opt/pnp4nagios/libexec/process_perfdata.pl --bulk /opt/pnp4nagios/var/host-perfdata
}
* Remove install file. rm /opt/pnp4nagios/share/install.php
* Restart nagios. service nagios restart
* Open /pnp4nagios on your webserver, it might take a while before data has been processed and images are shown.
====Install Check_MK====
* Install xinetd. yum install xinetd
service xinetd start
chkconfig xinetd on
* Download latest Check_MK version.
* Extract. tar zxvf check_mk-1.2.6p1.tar.gz
* Compile. cd check_mk-1.2.6p1
./setup.sh
You have chosen the following directories:
Executable programs /opt/check_mk/bin
Check_MK configuration /opt/check_mk/etc
Check_MK software /opt/check_mk/share
documentation /opt/check_mk/share/doc
check manuals /opt/check_mk/share/doc/check_mk/checks
working directory of Check_MK /opt/check_mk/var/lib
extensions for agents /usr/lib/check_mk_agent
configuration dir for agents /etc/check_mk
Name of Nagios user nagios
User of Apache process apache
Common group of Nagios+Apache nagcmd
Nagios binary /opt/nagios/bin/nagios
Nagios main configuration file /opt/nagios/etc/nagios.cfg
Nagios object directory /opt/nagios/etc/check_mk.d
Nagios startskript /etc/init.d/nagios
Nagios command pipe /opt/nagios/var/rw/nagios.cmd
Check results directory /opt/nagios/var/spool/checkresults
Nagios status file /opt/nagios/var/status.dat
Path to check_icmp /opt/nagios-plugins/libexec/check_icmp
URL Prefix for Web addons /
Apache config dir /etc/httpd/conf.modules.d
HTTP authentication file /opt/nagios/etc/htpasswd.users
HTTP AuthName Nagios Access
PNP4Nagios templates /opt/pnp4nagios/share/templates
RRD files /opt/pnp4nagios/var/perfdata
rrdcached socket /tmp/rrdcached.sock
compile livestatus module yes
Nagios / Icinga version 4.0.8
check_mk's binary modules /opt/check_mk/lib
Unix socket for Livestatus /opt/nagios/var/rw/live
Backends for other systems /opt/check_mk/share/livestatus
Install Event Console yes
working directory of mkeventd /opt/mkeventd/lib
Proceed with installation (y/n)? y
(Compiling MK Livestatus....................................................)
Installation completed successfully.
Please restart Nagios and Apache in order to update/active check_mk's web pages.
You can access the new Multisite GUI at http://localhost/check_mk/
====mod_python====
The current version (1.2.6x) of Check_MK still needs the old mod_python.
* Install development tools:yum install python-devel httpd-devel
* Download latest modpython source code.
* Extract:tar zxvf mod_python-3.5.0.tgz
* Install:cd mod_python-3.5.0
./configure
make
make install
# Edit /usr/lib64/python2.7/site-packages/mod_python/version.py
# Change version line to: version = "3.5.0"
vi /usr/lib64/python2.7/site-packages/mod_python/version.py
* Configure and Apache:# in /etc/httpd/conf.modules.d, create 00-python.conf with the following LoadModule line inside it
LoadModule python_module modules/mod_python.so
systemctl restart httpd
====Check_MK Config====
* Enable and Start mkeventd:chkconfig --add mkeventd
chkconfig --level 35 mkeventd on
service mkeventd start
* Install Check_MK client on host. yum install xinetd
cd check_mk-1.2.6p1
mkdir agents
cd agents
tar zxvf ../agents.tar.gz
mkdir /opt/check_mk_agent
cp check_mk_agent.linux /opt/check_mk_agent/bin/check_mk_agent
cp xinetd.conf /etc/xinetd.d/check_mk_agent
# Edit path and allowed hosts
# server = /opt/check_mk_agent/bin/check_mk_agent
# only_from = 127.0.0.1
vi /etc/xinetd.d/check_mk_agent
systemctl enable xinetd
systemctl start xinetd
# Test agent
nc 127.0.0.1 6556
* Configure monitoring host in Check_MK itself, add host, IP-address 127.0.0.1.
* Remove localhost from **/opt/nagios/etc/nagios.cfg**, then restart all of Check_MK:/opt/check_mk/bin/cmk -R.
====Set rights to enable config 'discard changes'====
* Modify rights:chown -R apache.nagcmd /opt/check_mk/etc
chown -R nagios.nagcmd /opt/check_mk/var/lib/
chown -R apache.nagcmd /opt/check_mk/var/lib/wato
chgrp -R nagcmd /opt/nagios/etc/
chown -R apache.nagcmd /opt/check_mk/var/lib/wato
chmod g+w /opt/check_mk/etc
chmod g+w /opt/check_mk/var/lib/
chmod g+w /opt/nagios/etc/
====Modify template====
* Nagios warns about obsoleted feature, remove **failure_prediction_enabled** from template file **/opt/nagios/etc/check_mk.d/check_mk_templates.cfg**
====Disable Nagios logging to syslog====
* Edit **/opt/nagios/etc/nagios.cfg** use_syslog=0
* Restart nagios. service nagios restart
====Quick start agent setup====
**Note: the EPEL version is older and might have some incompatibilities, you can also install the RPM provided with the Check_MK tar.gz**
* Install check_mk agent via EPEL:yum -y install check-mk-agent
vi /etc/xinetd.d/check-mk-agent # change only_from
firewall-cmd --permanent --zone trusted --add-service=checkmkagent
firewall-cmd --reload
systemctl enable xinetd
systemctl restart xinetd
====Upgrade Check_MK====
* Download latest tar.gz
* Extract
* Run ./setup.sh
* Restart nagios and apache
* Fix notifications (see above), after run cmk -O (captital o)
{{tag>[linux monitoring check_mk centos7]}}