概述:

  操作系统版本:CentOS release 6.3 (Final) 64位

  nagios版本:Nagios Core 4.0.6

  pnp4nagios版本:pnp4nagios-0.6.22

  mk-livestatus版本:mk-livestatus-1.2.5i5p2

  check_mk版本:check_mk-1.2.5i5p2

  python版本:Python-2.7.8

  httpd是rpm安装的,版本为:

  httpd-2.2.15-30.el6.centos.x86_64

  httpd-devel-2.2.15-30.el6.centos.x86_64

一、安装python模块

tar xzvf Python-2.7.8.tgz

首先需要安装python,在源码安装python时,需要加上参数

CFLAGS="-O3 -fPIC" ./configure --prefix=/usr/local/python

否则,在后续安装mod_python模块的时候会报错:

libpython2.7.a: could not read symbols: Bad value

类似这样的问题,都可以采用在编译的时候,加上CFLAGS="-O3 -fPIC" 参数

make

make install

添加python软连接:ln -s /usr/local/python/bin/python2.7 /usr/bin/python

安装mod_python,版本为:mod_python-3.3.1

tar zxf mod_python-3.3.1.tgz

安装:

./configure --with-apxs=/usr/sbin/apxs --with-python=/usr/bin/python

make

make install

注意:

1.在执行make的时候,可能会报错,提示connobject.c:142出错:

vi src/connobject.c

修改

!(b == APR_BRIGADE_SENTINEL(b) ||

!(b == APR_BRIGADE_SENTINEL(bb) ||

make

make install

执行完成之后,可以找到mod_python.so模块

[root@cdn18 mod_python-3.3.1]# find / -name "mod_python.so"

/usr/lib64/httpd/modules/mod_python.so

在httpd.conf中增加

LoadModule python_module modules/mod_python.so

重启apache,重新访问正常。

二、安装mk-livestatus

tar xzvf mk-livestatus-1.2.5i5p2.tar.gz

cd mk-livestatus-1.2.5i5p2

./configure --help

./configure  --with-nagios4

此处一定要指定with-nagios4,否则,nagios4版本会安装不上,报错如下,说库文件未定义,nagios也无法重启

[1407810436] Error: Could not load module '/usr/local/lib/mk-livestatus/livestatus.o' -> /usr/local/lib/mk-livestatus/livestatus.o: undefined symbol: last_command_check

[1407810436] Error: Failed to load module '/usr/local/lib/mk-livestatus/livestatus.o'.

[1407810436] Error: Module loading failed. Aborting.

make

make install

三、安装check_mk

tar xzvf check_mk-1.2.5i5p2.tar.gz

cd check_mk-1.2.5i5p2

./setup.sh

[root@cdn18 check_mk-1.2.5i5p2]# ./setup.sh

____ _               _        __  __ _  __

/ ___| |__   ___  ___| | __   |  \/  | |/ /

| |   | '_ \ / _ \/ __| |/ /   | |\/| | ' /

| |___| | | |  __/ (__|   <    | |  | | . \

\____|_| |_|\___|\___|_|\_\___|_|  |_|_|\_\

|_____|

Check_MK setup                                Version: 1.2.5i5p2

Welcome to Check_MK. This setup will install Check_MK into user defined

directories. If you run this script as root, installation paths below

/usr will be suggested. If you run this script as non-root user paths

in your home directory will be suggested. You may override the default

values or just hit enter to accept them.

Your answers will be saved to /root/.check_mk_setup.conf and will be

reused when you run the setup of this or a later version again. Please

delete that file if you want to delete your previous answers.

* Found running Nagios process, autodetected 20 settings.

* Read 32 settings from previous setup from /root/.check_mk_setup.conf.

1) Installation directories of check_mk

Executable programs

Directory where to install executable programs such as check_mk itself.

This directory should be in your search path ($PATH). Otherwise you

always have to specify the installation path when calling check_mk:

( previous  --> /usr/bin):

Check_MK configuration

Directory where check_mk looks for its main configuration file main.mk.

An example configuration file will be installed there if no main.mk is

present from a previous version:

( previous  --> /etc/check_mk):

Check_MK software

The base directory for the software installation of Check_MK. This

directory will get the subdirectories checks, modules, web, locale and

agents. Note: in previous versions it was possible to specify each of

those directories separately. This is no longer possible:

( previous  --> /usr/share/check_mk):

documentation

Some documentation about check_mk will be installed here. Please note,

however, that most of check_mk's documentation is available only online at

http://mathias-kettner.de/check_mk.html:

( previous  --> /usr/share/doc/check_mk):

check manuals

Directory for manuals for the various checks. The manuals can be viewed

with check_mk -M <CHECKNAME>:

( previous  --> /usr/share/doc/check_mk/checks):

working directory of Check_MK

Check_MK will create log files, automatically created checks and

other files into this directory. The setup will create several subdirectories

and makes them writable by the Nagios process:

( previous  --> /var/lib/check_mk):

2) Configuration of Linux/UNIX Agents

extensions for agents

This directory will not be created on the server. It will be hardcoded

into the Linux and UNIX agents. The agent will look for extensions in the

subdirectories plugins/ and local/ of that directory:

( previous  --> /usr/lib/check_mk_agent):

configuration dir for agents

This directory will not be created on the server. It will be hardcoded

into the Linux and UNIX agents. The agent will look for its configuration

files here (currently only the logwatch extension needs a configuration file):

( previous  --> /etc/check_mk):

3) Integration with Nagios

Name of Nagios user

The working directory for check_mk contains several subdirectories

that need to be writable by the Nagios user (which is running check_mk

in check mode). Please specify the user that should own those

directories:

( previous  --> nagios):

User of Apache process

Check_MK WATO (Web Administration Tool) needs a sudo configuration,

such that Apache can run certain commands as root. If you specify

the correct user of the apache process here, then we can create a valid

sudo configuration for you later::

( previous  --> apache):

Common group of Nagios+Apache

Check_mk creates files and directories while running as nagios.

Some of those need to be writable by the user that is running the webserver.

Therefore a group is needed in which both Nagios and the webserver are

members (every valid Nagios installation uses such a group to allow

the web server access to Nagios' command pipe)::

( previous  --> nagcmd):

Nagios binary

The complete path to the Nagios executable. This is needed by the

option -R/--restart in order to do a configuration check.:

( previous  --> /usr/local/nagios/bin/nagios):

Nagios main configuration file

Path to the main configuration file of Nagios. That file is always

named 'nagios.cfg'. The default path when compiling Nagios yourself

is /usr/local/nagios/etc/nagios.cfg. The path to this file is needed

for the check_mk option -R/--restart:

( previous  --> /usr/local/nagios/etc/nagios.cfg):

Nagios object directory

Nagios' object definitions for hosts, services and contacts are

usually stored in various files with the extension .cfg. These files

are located in a directory that is configured in nagios.cfg with the

directive 'cfg_dir'. Please specify the path to that directory

(If the autodetection can find your configuration

file but does not find at least one cfg_dir directive, then it will

add one to your configuration file for your conveniance):

( previous  --> /usr/local/nagios/etc/check_mk.d):

Nagios startskript

The complete path to the Nagios startskript is used by the option

-R/--restart to restart Nagios.:

( previous  --> /etc/init.d/nagios):

Nagios command pipe

Complete path to the Nagios command pipe. check_mk needs write access

to this pipe in order to operate:

( previous  --> /usr/local/nagios/var/rw/nagios.cmd):

Check results directory

Complete path to the directory where Nagios stores its check results.

Using that directory instead of the command pipe is faster.:

( previous  --> /usr/local/nagios/var/spool/checkresults):

Nagios status file

The web pages of check_mk need to read the file 'status.dat', which is

regularily created by Nagios. The path to that status file is usually

configured in nagios.cfg with the parameter 'status_file'. If

that parameter is missing, a compiled-in default value is used. On

FHS-conforming installations, that file usually is in /var/lib/nagios

or /var/log/nagios. If you've compiled Nagios yourself, that file

might be found below /usr/local/nagios:

( previous  --> /usr/local/nagios/var/status.dat):

Path to check_icmp

check_mk ships a Nagios configuration file with several host and

service templates. Some host templates need check_icmp as host check.

That check plugin is contained in the standard Nagios plugins.

Please specify the complete path (dir + filename) of check_icmp:

( previous  --> /usr/local/nagios/libexec/check_icmp):

4) Integration with Apache

URL Prefix for Web addons

Usually the Multisite GUI is available at /check_mk/ and PNP4Nagios

is located at /pnp4nagios/. In some cases you might want to define some

prefix in order to be able to run more instances of Nagios on one host.

If you say /test/ here, for example, then Multisite will be located

at /test/check_mk/. Please do not forget the trailing slash.:

( previous  --> /):

Apache config dir

Check_mk ships several web pages implemented in Python with Apache

mod_python. That module needs an apache configuration section which

will be installed by this setup. Please specify the path to a directory

where Apache reads in configuration files.:

( previous  --> /etc/httpd/conf.d):

HTTP authentication file

Check_mk's web pages should be secured from unauthorized access via

HTTP authenticaion - just as Nagios. The configuration file for Apache

that will be installed contains a valid configuration for HTTP basic

auth. The most conveniant way for you is to use the same user file as

for Nagios. Please enter your htpasswd file to use here:

( previous  --> /usr/local/nagios/etc/htpasswd.users):

HTTP AuthName

Check_mk's Apache configuration file will need an AuthName. That

string will be displayed to the user when asking for the password.

You should use the same AuthName as for Nagios. Otherwise the user will

have to log in twice:

( previous  --> Nagios Access):

5) Integration with PNP4Nagios 0.6

PNP4Nagios templates

Check_MK ships templates for PNP4Nagios for most of its checks.

Those templates make the history graphs look nice. PNP4Nagios

expects such templates in the directory pnp/templates in your

document root for static web pages:

( previous  --> /usr/local/pnp4nagios/share/templates):

RRD files

Configure the directory PNP4Nagios stores the RRD database files in:

( previous  --> /usr/local/pnp4nagios/var/perfdata):

rrdcached socket

If you use the rrdcached to process performance data from Nagios,

you can configure the socket of the rrdcached here to make the prediction

feature use it:

( previous  --> /tmp/rrdcached.sock):

6) Check_MK Livestatus Module

compile livestatus module

The well known MK Livestatus broker module is part of Check_MK.

It provides direct access to Nagios internal data structures. It aims to

supersede status.dat and also NDO. The Livestatus Module does not only

allow extremely fast access to the status of your services and hosts, it

does also provide live data (which status.dat does not). Also - unlike NDO -

Livestatus does not cost you even measurable CPU performance, does not need

any disk space and also needs no configuration.

Livestatus is neccessary when you want to use Multisite. It is also

the preferred backend for NagVis.

Please answer 'yes', if you want to compile and integrate the

Livestatus module into your Nagios. You need 'make' and the GNU

C++ compiler installed in order to do this:

( previous  --> yes):

Nagios / Icinga version

The version is required for the compilation of the livestatus module.

Depending on the major version (3 or 4) different nagios headers are included:

( previous  --> 4.0.6):

check_mk's binary modules

Directory for architecture dependent binary libraries and plugins

of check_mk:

( previous  --> /usr/lib/check_mk):

Unix socket for Livestatus

The Livestatus Module provides Nagios status data via a unix

socket. This is similar to the Nagios command pipe, but allows

bidirectional communication. Please enter the path to that pipe.

It is recommended to put it into the same directory as Nagios'

command pipe:

( previous  --> /usr/local/nagios/var/rw/live):

Backends for other systems

Directory where to put backends and configuration examples for

other systems. Currently this is only Nagvis, but other might follow

later.:

( previous  --> /usr/share/check_mk/livestatus):

7) Check_MK Event Console

Install Event Console

The Check_MK Event Console is a full featured event processing

module that integrates with Multisite. It has an own daemon and

several methods for retrieving events. It even has an integrated

syslog daemon.  Please answer 'yes', if you want to enable the

Event Console.:

( previous  --> no):

----------------------------------------------------------------------

You have chosen the following directories:

Executable programs             /usr/bin

Check_MK configuration          /etc/check_mk

Check_MK software               /usr/share/check_mk

documentation                   /usr/share/doc/check_mk

check manuals                   /usr/share/doc/check_mk/checks

working directory of Check_MK   /var/lib/check_mk

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                   /usr/local/nagios/bin/nagios

Nagios main configuration file  /usr/local/nagios/etc/nagios.cfg

Nagios object directory         /usr/local/nagios/etc/check_mk.d

Nagios startskript              /etc/init.d/nagios

Nagios command pipe             /usr/local/nagios/var/rw/nagios.cmd

Check results directory         /usr/local/nagios/var/spool/checkresults

Nagios status file              /usr/local/nagios/var/status.dat

Path to check_icmp              /usr/local/nagios/libexec/check_icmp

URL Prefix for Web addons       /

Apache config dir               /etc/httpd/conf.d

HTTP authentication file        /usr/local/nagios/etc/htpasswd.users

HTTP AuthName                   Nagios Access

PNP4Nagios templates            /usr/local/pnp4nagios/share/templates

RRD files                       /usr/local/pnp4nagios/var/perfdata

rrdcached socket                /tmp/rrdcached.sock

compile livestatus module       yes

Nagios / Icinga version         4.0.6

check_mk's binary modules       /usr/lib/check_mk

Unix socket for Livestatus      /usr/local/nagios/var/rw/live

Backends for other systems      /usr/share/check_mk/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安装完成

打开check_mk的web页面,报错如下:

Livestatus problem:Cannot connect to 'unix:/usr/local/nagios/var/rw/live':[Error 13]Permission denied

解决方法:

check_mk,安装完成之后,web报错:

Cannot connect to 'unix:/usr/local/nagios/var/rw/live': [Errno 13] Permission denied

Livestatus problem: Cannot connect to 'unix:/usr/local/nagios/var/rw/live': [Errno 13] Permission denied

这个文件,nagios用户本身是有权限的,而且,文件是自动生成,权限是nagios:nagios的,但是因为这个socket文件是apache用户操作的,所以apache需要写权限。

默认的live文件权限是:srw-rw---- 1 nagios nagios 0 Aug 12 16:30 live

#vim /usr/local/nagios/etc/nagios.cfg

添加如下内容:

broker_module=/usr/lib/check_mk/livestatus.o /usr/local//nagios/var/rw/live

#usermod -G apache,nagios,nagcmd nagios

#usermod -G apache,nagios,nagcmd apache

#service nagios restart

#tail /usr/local//nagios/var/nagios.log

本身,执行chmod 777 live文件就可以解决,或者是chown -R nagios:apache live,因为这个socket文件是apache用户组写的,或者直接将apache用户加入到nagios和nagcmd用户组,但是,最好的方法是将apache用户加到nagios用户组。

如果是采用的赋权修改live的方式,因为每次重启nagios,都会重新生成这个live文件,所以最好在nagios的启动脚本里面加入chown -R nagios:apache live命令

四、安装check_mk客户端:

Linux主机

#rpm -ivh check_mk-agent-1.2.5i5p2-1.noarch.rpm

指定被监控端的IP

#vim /etc/xinetd.d/check_mk

修改only_from = “监控端IP”(服务端IP)

重启xinetd

#service xinedt restart

windows主机

下载http://mathias-kettner.de/download/check-mk-agent-1.2.5i5p2.exe

安装即可

编辑安装目录下的check_mk.example.ini

修改only_from = “监控端IP”(服务端IP)

重启Check_MK_Agent服务即可。

五、监控Linux主机

#vim /etc/check_mk/main.mk

修改all_hosts,填写每一个被监控机的IP地址,中间用,隔开,这里的IP地址如果在nagios中你作为hostname使用的话,请修改nagios中的hostname或者将其注释掉,否则两者将会冲突报错。

all_hosts = [ '192.168.203.10','192.168.203.20' ]

保存退出后:

执行以下命令:

#check_mk -I

检查所有可检测的项目

df                8 new checks

logwatch          14 new checks

mem.win           2 new checks

systemtime        2 new checks

uptime            2 new checks

winperf_phydisk   2 new checks

winperf_processor.util 2 new checks

#check_mk -O

创建或更新Nagios配置,并且重新加载Nagios

Generating Nagios configuration...OK

Validating Nagios configuration...OK

Precompiling host checks...OK

Reloading Nagios...OK

六、访问http://localhost/check_mk

发现并未出现定义的那些主机

#vim /etc/check_mk/multisite.mk

将admin_users = [ "nagiosadmin" ]   修改为登陆到nagios的用户名,即htpasswd定义的用户名,我这里是admin

admin_users = [ "nagios" ]

保存退出,重新刷新,即可看到刚才定义的主机了

在长时间的观察发现,这些定义的主机的服务器基本上已正常,但是主机确实down的状态

错误提示:

Waring:This plugin must be either run as root or setuid root"

解决方法:

找到当初安装check_mk时附带的check_icmp命令

#chown root:nagios check_icmp

#chmod u+s check_icmp

稍等下,主机马上就处于up状态。

如果是少量机器,个人更推荐是从web界面配置主机,web配置主机之后,也需要执行check_mk -I,check_mk -O,但是,不需要收到修改客户端的配置文件的only_from

对于从web界面直接添加主机的方法,点击左下角的一个Hosts & Folders按钮,点击New host即可,如下:

http://www.newsmth.net/nForum/#!article/Python/101637

http://grass51.blog.51cto.com/4356355/994819

解决问题参考以上链接

check_MK安装部署(nagios4版本)的更多相关文章

  1. 通过跳板机建立信任,对多个tomcat服务统一安装部署(shell编写)

    unifyDeploy 自动化统一安装部署 系统版本: unifyDeploy0.1 文件编号: 0.1 发布日期: 2014-06-26 编    制: WangYong 版权所有 内部资料注意保密 ...

  2. Zstack的安装部署

    ZStack是下一代开源的云计算IaaS(基础架构即服务)软件. 它主要面向的是未来的智能数据中心,通过提供全完善的API来管理包括计算.存储和网络在内的数据中心的各种资源.跟OpenStack相比, ...

  3. (转)linux下weblogic12c集群的安装部署

    本文介绍linux下weblogic12c集群的安装部署,版本12c,其他版本操作会有所不同,但其大体操作基本都是一样的 关于weblogic的集群,在此就不多做介绍了,如果有不了解的朋友可以百度搜索 ...

  4. 比Ansible更吊的自动化运维工具,自动化统一安装部署自动化部署udeploy 1.0 版本发布

    新增功能: 逻辑与业务分离,完美实现逻辑与业务分离,业务实现统一shell脚本开发,由框架统一调用. 并发多线程部署,不管多少台服务器,多少个服务,同时发起线程进行更新.部署.启动. 提高list规则 ...

  5. OEMCC 13.2 集群版本安装部署

    之前测试部署过OEMCC 13.2单机,具体可参考之前随笔: OEMCC 13.2 安装部署 当时环境:两台主机,系统RHEL 6.5,分别部署OMS和OMR: OMS,也就是OEMCC的服务端 IP ...

  6. Hive环境的安装部署(完美安装)(集群内或集群外都适用)(含卸载自带mysql安装指定版本)

    Hive环境的安装部署(完美安装)(集群内或集群外都适用)(含卸载自带mysql安装指定版本) Hive 安装依赖 Hadoop 的集群,它是运行在 Hadoop 的基础上. 所以在安装 Hive 之 ...

  7. ELK 安装部署实战 (最新6.4.0版本)

    一.实战背景 根据公司平台的发展速度,对于ELK日志分析日益迫切.主要的需求有: 1.用户行为分析 2.运营活动点击率分析 作为上述2点需求,安装最新版本6.4.0是非常有必要的,大家可根据本人之前博 ...

  8. 基于HDP版本的YDB安装部署(转)

    第三章 YDB依赖环境准备 一.硬件环境 硬件如何搭配,能做到比较高的性价比,不存在短板.合理的硬件搭配,对系统的稳定性也很关键. 1.CPU不是核数越高越好,性价比才是关键. 经常遇到很多的企业级客 ...

  9. JBoss、Tomcat、JBoss EAP、JBoss AS、wildfly,JBoss EAP安装部署,JBoss各个版本下载,JBoss允许远程访问

    感谢: https://www.cnblogs.com/invlong/p/5983334.html https://blog.csdn.net/mooncarp/article/details/78 ...

随机推荐

  1. null的比较问题

    select count(*) from table_a WHERE  status=1 and end_time<now(); 写这个sql的时候有点纠结,万一end_time是null怎么办 ...

  2. 【puppeteer+Node.js】学习

    总结了一下有关puppeteer的学习的网站,以后还会继续更新 puppeteer 介绍 Puppeteer是一个通过DevTools Protocol控制headless chromium的高级no ...

  3. 删除rabbitmq的队列和队列中的数据

      访问http://{rabbitmq安装IP}:15672,帐号guest,密码guest(也可以使用自己创建的帐号). 登录后访问http://{rabbitmq安装IP}:15672/#/qu ...

  4. python 基础 3.1 打开文件 a a+ r+ w+ 详解

      一.python 访问文件   1.在python中要访问文件,首先要打开文件,也就是open ---open   r:  只读   w:  只写 ,文件已存在则清空,不存在则创建   a:追加 ...

  5. TP框架---thinkphp使用ajax

    thinkphp使用ajax和之前使用ajax的方法一样,不同点在于之前的ajax中的url指向了一个页面,而thinkphp里面的url需要指向一个操作方法. 一.thinkphp使用ajax返回数 ...

  6. Java 学习 day04

    17-数组(概述-内存结构) 概念:同一种类型数据的集合,其实数组就是一个容器. 可以自动给数组中的元素从0开始编号,方便操作这些元素. int[] x = new int[3]; 01-数组(静态初 ...

  7. JavaScript中实现继承

    今天即兴研究了下JS,查阅了相关资料 ,发现Js中没有"子类"和"父类"的概念,也没有"类"(class)和"实例"(i ...

  8. ArcGIS api for js OverviewMap(鹰眼/概览图)

    说明.本篇博客中主要介绍 地图显示在某个div情况 1.运行效果 2.HTML <!DOCTYPE html> <html> <head> <meta htt ...

  9. Cocos2d-js官方完整项目教程翻译:六、添加Chipmunk物理引擎在我们的游戏世界里

    添加Chipmunk物理引擎在我们的游戏世界里         一.简介                   cocos2d JS能给我们力量来创造令人印象深刻的游戏世界.但缺乏某种现实.       ...

  10. CF148D. Bag of mice(概率DP)

    D. Bag of mice time limit per test 2 seconds memory limit per test 256 megabytes input standard inpu ...