check_MK安装部署(nagios4版本)

概述:

  操作系统版本: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模块

[[email protected] 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

[[email protected] 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版本)

时间: 2024-10-12 12:36:18

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

基于centos7.3安装部署jewel版本ceph集群实战演练

一.环境准备 安装centos7.3虚拟机三台 由于官网源与网盘下载速度都非常的慢,所以给大家提供了国内的搜狐镜像源:http://mirrors.sohu.com/centos/7.3.1611/isos/x86_64/CentOS-7-x86_64-DVD-1611.iso 在三台装好的虚拟机上分别加三块100G的硬盘.如图所示: 3.配置ip ceph-1 ceph-2 ceph-3 192.168.42.200 192.168.42.201 192.168.42.203 修改可参照下面的

tomcat8 安装部署--一键版本

wget http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html  ##需要进去,点介绍协议,下载jdk8 tar zxvf jdk-8u144-linux-x64.tar.gz mv jdk1.8.0_144/   /usr/local/jdk8.0 echo "JAVA_HOME=/usr/local/jdk8.0 JAVA_BIN=/usr/local/jdk8.0/bin PA

etcd安装部署及数据同步MySQL

一.etcd说明及原理 二.etcd安装部署说明 三.etcd操作说明 四.python安装etcd 五.python-etcd使用说明 六.通过脚本获取本地的信息上传到etcd 七.通过脚本将etc的数据同步到mysql 一.etcd 简介 etcd是用于共享配置和服务发现的分布式,一致的键值存储,重点是: 简单:定义明确,面向用户的API(gRPC) 安全:使用可选的客户端证书认证的自动TLS 快速:基准测试10,000写/秒 可靠:使用Raft协议来进行合理的分布式 etcd是在Go中编写

一次在CentOS7上安装部署Zabbix3.0版本及快速进行基本配置的实例

Zabbix3.0的安装.部署.配置,必须基于LAMP环境或是是LNMP环境. 关于LAMP环境的简单快速搭建,见博客:http://afterdawn.blog.51cto.com/7503144/1923139 注意:以下步骤都是在LAMP配置之后进行的. 本文不会再对zabbix-server和zabbix-agent理论知识再进行介绍,建议看完http://afterdawn.blog.51cto.com/7503144/1922502再进行zabbix实战. Zabbix3.0对软硬件

Linux:多Tomcat服务, 统一安装部署 unifyDeploy0.2版本发布

下载地址:  unifyDeploy0.1版本  unifyDeploy0.2版本 1       引言 基于JAVA开发项目,随着服务的越来越多,配置文件更是眼花缭乱,每次不知道因为配置问题浪费多少时间,更不知道因为配置问题出过多少问题.多台服务器来回切换,如果服务需要依赖,启动更是问题. 1.1 目的 一次修改,统一安装:操作简单,实用高效. 1.2 范围 本项目使用范围包括: 基于JAVA开发项目 项目相关服务繁多 服务启动有依赖关系 1.3 读者 本需求规格说明书的阅读者或其他文档干系人

Eclipse(非J2EE版本)配置Extjs环境以及安装部署Tomcat

Eclipse(非J2EE版本)配置Extjs环境(Spket) 1. 安装spket插件,帮助->安装新软件->http://www.agpad.com/update. 2. 设置Spket使得编写代码时有提示,首先:window--preferences--Spket--Javascript Profiles,点击右侧的按钮New,随便输入一个名字,如Ext.点击ExtJS--Add Library,在下拉框中选择ExtJS:点击ExtJS--Add Filewindow--prefere

Openstack安装部署指南翻译系列 之 说明(Pike版本官网翻译)

从部署实践来看,部署工作有两大困难,一个是架构设计,一个是排查错误.其中,当部署过程中出现错误,需要排查的时候,如果不了解基础的系统结构原理和基础的安装步骤,是很难定位和解决问题的. 现在Openstack的部署有很多可选项,主要有: 1)根据社区官网最基础的安装文档根据设计对每一个service组件进行安装,这种安装方式最基础,全手工: 2)使用Mirantis公司的Fuel工具进行部署.这种部署方式非常高效,界面友好,Fuel工具真正实现了一键部署,只要设计好网络和功能节点分布,一键部署完成

OEMCC 13.2 集群版本安装部署

之前测试部署过OEMCC 13.2单机,具体可参考之前随笔: OEMCC 13.2 安装部署 当时环境:两台主机,系统RHEL 6.5,分别部署OMS和OMR: OMS,也就是OEMCC的服务端 IP:192.168.1.88 内存:12G+ 硬盘:100G+ OMR,也就是OEM底层的资料库 IP:192.168.1.89 内存:8G+ 硬盘:100G+ 相当于OMS和OMR都是单机版,然后有些客户对监控系统的要求也很高,这就需要集群来提升高可用性. 对于OMR来说,可以搭建对应版本的RAC来

Nagios服务器端安装部署详解(1)

下载地址如下: http://sourceforge.net/projects/nagios/files/ 具体详细下载地址:http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-4.0.6.tar.gz 1 开始下载: wget http://sourceforge.net/projects/nagios/files/nagios-4.x/nagios-4.0.6/nagios-4.0.6.tar.gz/download?us