Ben's notes

Linux, Unix, network, radio...

User Tools

Site Tools


check_mk_monitoring

Check_MK monitoring - CentOS6

Using this guide, you can install the latest Check_MK and Nagios version.

Prerequisites

  • RepoForge repository
  • EPEL repository
  • Disable SELinux. Normally i would SELinux be enabled, but a monitoring system is one of the few exceptions i make. The server does too many things SELinux doesn't like.

Install packages

  • Install rrdtool 1.4
    yum --enablerepo=repoforge install rrdtool
    
    # or install manually
    
    yum localinstall rrdtool-1.4.7-1.el6.rfx.x86_64.rpm  perl-rrdtool-1.4.7-1.el6.rfx.x86_64.rpm
  • 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
    wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-4.0.7.tar.gz
  • Extract.
    tar zxvf nagios-4.0.7.tar.gz
  • Compile Nagios 4.
    cd nagios-4.0.7
    ./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
    /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 Nagios plugins
    cd
    wget http://nagios-plugins.org/download/nagios-plugins-2.0.2.tar.gz
  • Nagios Plugin Installation.
    tar zxvf nagios-plugins-2.0.2.tar.gz
    cd /tmp/nagios-plugins-2.0.2
    ./configure --with-nagios-user=nagios --with-nagios-group=nagios --prefix=/opt/nagios-plugins --exec-prefix=/opt/nagios-plugins
    make
    make install

Configure CentOS

  • Service setup.
    chkconfig --add nagios
    chkconfig --level 35 nagios on
    chkconfig --add httpd
    chkconfig --level 35 httpd on
  • Open port 80. Edit /etc/sysconfig/iptables add:
    -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
  • Restart iptables
    service iptables restart
  • Give the Nagios localhost http check something.
    touch /var/www/html/index.html
  • Start Apache, Nagios should be running on your webserver /nagios
    service httpd start

Install PNP4Nagios

  • Download PNP4nagios.
    wget https://sourceforge.net/projects/pnp4nagios/files/latest
  • Extract.
    tar zxvf pnp4nagios.tgz
  • Compile.
    cd pnp4nagios-0.6.22
    ./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.
    service httpd restart
  • 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.

Install Check_MK

  • Install xinetd.
    yum install xinetd
    service xinetd start
    chkconfig xinetd on
  • Install mod_python.
    yum install mod_python
  • Download latest Check_MK version.
    wget http://mathias-kettner.de/download/check_mk-1.2.4p3.tar.gz
  • Extract.
    tar zxvf check_mk-1.2.4p3.tar.gz
  • Compile.
    cd check_mk-1.2.4p3
    ./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.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.7                                   
     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           no    
    
      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/
                           

Check_MK Config

  • Remove localhost from /opt/nagios/etc/nagios.cfg
  • Install Check_MK client on host.
  • Configure monitoring host in Check_MK itself.

Disable Nagios logging to syslog

  • Edit /opt/nagios/etc/nagios.cfg
    use_syslog=0
  • Restart nagios.
    service nagios restart

Fix notification problem with Check_MK & Nagios 4

  • Edit /opt/check_mk/share/check_mk_templates.cfg
    #change the command to force an explicit /bin/sh
    
    define command {
      command_name check-mk-notify
      command_line \
           /bin/sh -c "NOTIFY_CONTACTNAME='$CONTACTNAME$' \
           NOTIFY_CONTACTEMAIL='$CONTACTEMAIL$' \
           NOTIFY_CONTACTPAGER='$CONTACTPAGER$' \
           NOTIFY_NOTIFICATIONTYPE='$NOTIFICATIONTYPE$' \
           NOTIFY_HOSTNOTIFICATIONNUMBER='$HOSTNOTIFICATIONNUMBER$' \
           NOTIFY_SERVICENOTIFICATIONNUMBER='$SERVICENOTIFICATIONNUMBER$' \
           NOTIFY_HOSTPROBLEMID='$HOSTPROBLEMID$' \
           NOTIFY_SERVICEPROBLEMID='$SERVICEPROBLEMID$' \
           NOTIFY_HOSTNAME='$HOSTNAME$' \
           NOTIFY_HOSTALIAS='$HOSTALIAS$' \
           NOTIFY_HOSTADDRESS='$HOSTADDRESS$' \
           NOTIFY_LASTHOSTSTATE='$LASTHOSTSTATE$' \
           NOTIFY_LASTHOSTSTATECHANGE='$LASTHOSTSTATECHANGE$' \
           NOTIFY_HOSTSTATE='$HOSTSTATE$' \
           NOTIFY_HOSTSTATEID='$HOSTSTATEID$' \
           NOTIFY_HOSTCHECKCOMMAND='$HOSTCHECKCOMMAND$' \
           NOTIFY_HOSTOUTPUT='$HOSTOUTPUT$' \
           NOTIFY_HOSTPERFDATA='$HOSTPERFDATA$' \
           NOTIFY_LONGHOSTOUTPUT='$LONGHOSTOUTPUT$' \
           NOTIFY_SERVICEDESC='$SERVICEDESC$' \
           NOTIFY_LASTSERVICESTATE='$LASTSERVICESTATE$' \
           NOTIFY_LASTSERVICESTATECHANGE='$LASTSERVICESTATECHANGE$' \
           NOTIFY_SERVICESTATE='$SERVICESTATE$' \
           NOTIFY_SERVICESTATEID='$SERVICESTATEID$' \
           NOTIFY_SERVICEOUTPUT='$SERVICEOUTPUT$' \
           NOTIFY_LONGSERVICEOUTPUT='$LONGSERVICEOUTPUT$' \
           NOTIFY_SERVICEPERFDATA='$SERVICEPERFDATA$' \
           NOTIFY_SERVICECHECKCOMMAND='$SERVICECHECKCOMMAND$' \
           NOTIFY_DATE='$DATE$' \
           NOTIFY_SHORTDATETIME='$SHORTDATETIME$' \
           NOTIFY_LONGDATETIME='$LONGDATETIME$' \
           NOTIFY_HOSTDOWNTIME='$HOSTDOWNTIME$' \
           NOTIFY_NOTIFICATIONCOMMENT='$NOTIFICATIONCOMMENT$' \
           NOTIFY_NOTIFICATIONAUTHOR='$NOTIFICATIONAUTHOR$' \
           NOTIFY_NOTIFICATIONAUTHORNAME='$NOTIFICATIONAUTHORNAME$' \
           NOTIFY_NOTIFICATIONAUTHORALIAS='$NOTIFICATIONAUTHORALIAS$' \
           NOTIFY_HOSTTAGS='$_HOSTTAGS$' \
           NOTIFY_HOST_SL='$_HOSTEC_SL$' \
           NOTIFY_SVC_SL='$_SERVICEEC_SL$' \
           NOTIFY_SERVICE_SL='$_SERVICEEC_SL$' \
           NOTIFY_HOST_EC_CONTACT='$_HOSTEC_CONTACT$' \
           NOTIFY_SERVICE_EC_CONTACT='$_SERVICEEC_CONTACT$' \
           /usr/bin/check_mk --notify"
    }

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)
check_mk_monitoring.txt · Last modified: 2021/10/09 15:14 by 127.0.0.1