Ben's notes

Linux, Unix, network, radio...

User Tools

Site Tools


centos7_check_mk

Differences

This shows you the differences between two versions of the page.


Previous revision
centos7_check_mk [2021/10/09 15:14] (current) – external edit 127.0.0.1
Line 1: Line 1:
 +
 +..\\
 +..\\
 +..\\
 +**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: <code>yum install rrdtool perl-rrdtool</code>
 +  * Install development tools: <code>yum groupinstall development tools</code>
 +  * Install apache & php. <code>yum install httpd php</code>
 +  * Install other requirements. <code>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</code>
 +====Install Nagios 4====
 +  * Create user and group.<code>useradd nagios
 +groupadd nagcmd
 +usermod -a -G nagcmd nagios
 +usermod -G nagcmd apache</code>
 +  * Download latest version. 
 +  * Extract. <code>tar zxvf nagios-4.0.8.tar.gz</code>
 +  * Compile Nagios 4. <code>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</code>
 +  * Test and start Nagios, it still uses legacy init:<code>/opt/nagios/bin/nagios -v /opt/nagios/etc/nagios.cfg
 +service nagios start</code>
 +  * Edit **/opt/nagios/etc/resource.cfg** <code>$USER1$=/opt/nagios-plugins/libexec</code>
 +  * Add a default user for Web Interface Access <code>htpasswd -c /opt/nagios/etc/htpasswd.users nagiosadmin</code>
 +  * Download latest Nagios plugins.
 +  * Install Nagios Plugins: <code>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</code>
 +====Configure services and firewall====
 +  * Service setup. <code>chkconfig --add nagios
 +chkconfig --level 35 nagios on
 +systemctl enable httpd</code>
 +  * Open port 80 / 443: <code>firewall-cmd --permanent --zone public --add-service=http
 +firewall-cmd --permanent --zone public --add-service=https
 +firewall-cmd --reload</code> 
 +  * Give the Nagios localhost http check something. <code>touch /var/www/html/index.html</code>
 +  * Start Apache, restart Nagios, it should be running on your webserver /nagios <code>service nagios restart
 +systemctl start httpd</code>
 +====Install PNP4Nagios====
 +  * Download the latest PNP4nagios.
 +  * Extract. <code>tar zxvf pnp4nagios.tgz</code>
 +  * Compile.<code>cd pnp4nagios-0.6.25
 +./configure --prefix=/opt/pnp4nagios --exec-prefix=/opt/pnp4nagios
 +make all
 +make fullinstall</code>
 +  * Configure apache, edit **/etc/httpd/conf.d/pnp4nagios.conf** <code>AuthUserFile /opt/nagios/etc/htpasswd.users</code>
 +  * Restart apache. <code>systemctl restart httpd</code>
 +  * Configure Nagios to use PNP4nagios. Edit **/opt/nagios/etc/nagios.cfg**. <code>#
 +# 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</code>
 +  * Edit **/opt/nagios/etc/objects/commands.cfg** Disable sample performance data commands, add: <code>#
 +# 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
 +}</code>
 +
 +  * Remove install file. <code>rm /opt/pnp4nagios/share/install.php</code>
 +  * Restart nagios. <code>service nagios restart</code>
 +  * Open /pnp4nagios on your webserver, it might take a while before data has been processed and images are shown.
 +
 +====Install Check_MK====
 +  * Install xinetd. <code>yum install xinetd
 +service xinetd start
 +chkconfig xinetd on</code>
 +  * Download latest Check_MK version.
 +  * Extract. <code>tar zxvf check_mk-1.2.6p1.tar.gz</code>
 +  * Compile. <code>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/
 +                       
 +</code>
 +====mod_python====
 +The current version (1.2.6x) of Check_MK still needs the old mod_python. 
 +  * Install development tools:<code>yum install python-devel httpd-devel</code>
 +  * Download latest modpython source code.
 +  * Extract:<code>tar zxvf mod_python-3.5.0.tgz</code>
 +  * Install:<code>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</code>
 +  * Configure and Apache:<code># 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</code>
 +====Check_MK Config====
 +  * Enable and Start mkeventd:<code>chkconfig --add mkeventd
 +chkconfig --level 35 mkeventd on
 +service mkeventd start</code>
 +  * Install Check_MK client on host. <code>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
 +
 +</code>
 +  * 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:<code>/opt/check_mk/bin/cmk -R.</code>
 +====Set rights to enable config 'discard changes'====
 +  * Modify rights:<code>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/</code>
 +====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** <code>use_syslog=0</code>
 +  * Restart nagios. <code>service nagios restart</code>
 +
 +
 +====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:<code>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</code>
 +
 +====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]}}